Re: [PATCH 06/10] KVM: x86: Move "flush guest's TLB" logic to separate kvm_x86_ops hook

From: Paolo Bonzini
Date: Fri Feb 21 2020 - 12:31:16 EST


On 21/02/20 14:52, Vitaly Kuznetsov wrote:
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index fbabb2f06273..72f7ca4baa6d 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -2675,7 +2675,7 @@ static void record_steal_time(struct kvm_vcpu *vcpu)
>> trace_kvm_pv_tlb_flush(vcpu->vcpu_id,
>> st->preempted & KVM_VCPU_FLUSH_TLB);
>> if (xchg(&st->preempted, 0) & KVM_VCPU_FLUSH_TLB)
>> - kvm_vcpu_flush_tlb(vcpu, false);
>> + kvm_x86_ops->tlb_flush_guest(vcpu);
>>
>> vcpu->arch.st.preempted = 0;
> There is one additional place in hyperv.c where we do TLB flush on
> behalf of the guest, kvm_hv_flush_tlb(). Currently, it does
> KVM_REQ_TLB_FLUSH (resulting in kvm_x86_ops->tlb_flush()), do we need
> something like KVM_REQ_TLB_FLUSH_GUEST instead?

Yes, that would be better since INVEPT does not flush linear mappings.
So, when EPT and VPID is enabled, KVM_REQ_TLB_FLUSH would not flush the
guest's translations.

Paolo