Re: [PATCH v6 05/38] KVM: x86: hyper-v: Handle HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST{,EX} calls gently

From: Vitaly Kuznetsov
Date: Mon Jun 13 2022 - 13:35:16 EST


Maxim Levitsky <mlevitsk@xxxxxxxxxx> writes:

...

>>  
>>  void kvm_hv_vcpu_flush_tlb(struct kvm_vcpu *vcpu)
>>  {
>>         struct kvm_vcpu_hv_tlb_flush_fifo *tlb_flush_fifo;
>>         struct kvm_vcpu_hv *hv_vcpu = to_hv_vcpu(vcpu);
>> +       u64 entries[KVM_HV_TLB_FLUSH_FIFO_SIZE];
>> +       int i, j, count;
>> +       gva_t gva;
>>  
>> -       kvm_vcpu_flush_tlb_guest(vcpu);
>> -
>> -       if (!hv_vcpu)
>> +       if (!tdp_enabled || !hv_vcpu) {
> I haven't noticed that in the review I did back then, but
> any reason why !tdp_enabled?

This follows the logic in kvm_vcpu_flush_tlb_guest():

if (!tdp_enabled) {
/*
* A TLB flush on behalf of the guest is equivalent to
* INVPCID(all), toggling CR4.PGE, etc., which requires
* a forced sync of the shadow page tables. Ensure all the
* roots are synced and the guest TLB in hardware is clean.
*/
kvm_mmu_sync_roots(vcpu);
kvm_mmu_sync_prev_roots(vcpu);
}

and as !tdp_enabled should be a rare debug or special case I decided to
take the shortcut and not drag any of this logic into hyperv emulation
code.

--
Vitaly