Skip to content

Commit 992edea

Browse files
Liran Alonbonzini
authored andcommitted
KVM: nVMX: Assume TLB entries of L1 and L2 are tagged differently if L0 use EPT
Since commit 1313cc2 ("kvm: mmu: Add guest_mode to kvm_mmu_page_role"), guest_mode was added to mmu-role and therefore if L0 use EPT, it will always run L1 and L2 with different EPTP. i.e. EPTP01!=EPTP02. Because TLB entries are tagged with EP4TA, KVM can assume TLB entries populated while running L2 are tagged differently than TLB entries populated while running L1. Therefore, update nested_has_guest_tlb_tag() to consider if L0 use EPT instead of if L1 use EPT. Reviewed-by: Joao Martins <[email protected]> Reviewed-by: Krish Sadhukhan <[email protected]> Signed-off-by: Liran Alon <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 5637f60 commit 992edea

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/x86/kvm/vmx/nested.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,9 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne
11261126
* populated by L2 differently than TLB entries populated
11271127
* by L1.
11281128
*
1129-
* If L1 uses EPT, then TLB entries are tagged with different EPTP.
1129+
* If L0 uses EPT, L1 and L2 run with different EPTP because
1130+
* guest_mode is part of kvm_mmu_page_role. Thus, TLB entries
1131+
* are tagged with different EPTP.
11301132
*
11311133
* If L1 uses VPID and we allocated a vpid02, TLB entries are tagged
11321134
* with different VPID (L1 entries are tagged with vmx->vpid
@@ -1136,7 +1138,7 @@ static bool nested_has_guest_tlb_tag(struct kvm_vcpu *vcpu)
11361138
{
11371139
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
11381140

1139-
return nested_cpu_has_ept(vmcs12) ||
1141+
return enable_ept ||
11401142
(nested_cpu_has_vpid(vmcs12) && to_vmx(vcpu)->nested.vpid02);
11411143
}
11421144

0 commit comments

Comments
 (0)