Skip to content

Commit 4b85507

Browse files
whitebrandymatosatti
authored andcommitted
KVM: nVMX: Don't advertise single context invalidation for invept
For single context invalidation, we fall through to global invalidation in handle_invept() except for one case - when the operand supplied by L1 is different from what we have in vmcs12. However, typically hypervisors will only call invept for the currently loaded eptp, so the condition will never be true. Signed-off-by: Bandan Das <bsd@redhat.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
1 parent fd2a445 commit 4b85507

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

arch/x86/kvm/vmx.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,12 +2353,11 @@ static __init void nested_vmx_setup_ctls_msrs(void)
23532353
VMX_EPT_INVEPT_BIT;
23542354
nested_vmx_ept_caps &= vmx_capability.ept;
23552355
/*
2356-
* Since invept is completely emulated we support both global
2357-
* and context invalidation independent of what host cpu
2358-
* supports
2356+
* For nested guests, we don't do anything specific
2357+
* for single context invalidation. Hence, only advertise
2358+
* support for global context invalidation.
23592359
*/
2360-
nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT |
2361-
VMX_EPT_EXTENT_CONTEXT_BIT;
2360+
nested_vmx_ept_caps |= VMX_EPT_EXTENT_GLOBAL_BIT;
23622361
} else
23632362
nested_vmx_ept_caps = 0;
23642363

@@ -6441,7 +6440,6 @@ static int handle_invept(struct kvm_vcpu *vcpu)
64416440
struct {
64426441
u64 eptp, gpa;
64436442
} operand;
6444-
u64 eptp_mask = ((1ull << 51) - 1) & PAGE_MASK;
64456443

64466444
if (!(nested_vmx_secondary_ctls_high & SECONDARY_EXEC_ENABLE_EPT) ||
64476445
!(nested_vmx_ept_caps & VMX_EPT_INVEPT_BIT)) {
@@ -6481,16 +6479,13 @@ static int handle_invept(struct kvm_vcpu *vcpu)
64816479
}
64826480

64836481
switch (type) {
6484-
case VMX_EPT_EXTENT_CONTEXT:
6485-
if ((operand.eptp & eptp_mask) !=
6486-
(nested_ept_get_cr3(vcpu) & eptp_mask))
6487-
break;
64886482
case VMX_EPT_EXTENT_GLOBAL:
64896483
kvm_mmu_sync_roots(vcpu);
64906484
kvm_mmu_flush_tlb(vcpu);
64916485
nested_vmx_succeed(vcpu);
64926486
break;
64936487
default:
6488+
/* Trap single context invalidation invept calls */
64946489
BUG_ON(1);
64956490
break;
64966491
}

0 commit comments

Comments
 (0)