mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 1/2] KVM: VMX: Don't advertise EPT switching if EPT itself is not exposed
@ 2017-10-17  4:03 Wanpeng Li
  2017-10-17  4:03 ` [PATCH v2 2/2] KVM: VMX: Fix VPID capability detection Wanpeng Li
  2017-10-17 17:29 ` [PATCH v2 1/2] KVM: VMX: Don't advertise EPT switching if EPT itself is not exposed Jim Mattson
  0 siblings, 2 replies; 9+ messages in thread
From: Wanpeng Li @ 2017-10-17  4:03 UTC (permalink / raw)
  To: linux-kernel, kvm
  Cc: Paolo Bonzini, Radim Krčmář, Wanpeng Li, Jim Mattson

From: Wanpeng Li <wanpeng.li@hotmail.com>

I can use vmxcap tool to observe "EPTP Switching   yes" even if EPT is not 
exposed to L1.

EPT switching is advertised unconditionally since it is emulated, however, 
it can be treated as an extended feature for EPT and it should not be 
advertised if EPT itself is not exposed. This patch fixes it.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Jim Mattson <jmattson@google.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
v1 -> v2:
 * don't advertise "EPT VM Functions" in secondary processor-based VM-execution 
   controls if we don't actually support any VM Functions.

 arch/x86/kvm/vmx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c460b0b..a6861ca 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2842,8 +2842,12 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
 		 * Advertise EPTP switching unconditionally
 		 * since we emulate it
 		 */
-		vmx->nested.nested_vmx_vmfunc_controls =
-			VMX_VMFUNC_EPTP_SWITCHING;
+		if (enable_ept) {
+			vmx->nested.nested_vmx_vmfunc_controls =
+				VMX_VMFUNC_EPTP_SWITCHING;
+		} else
+			vmx->nested.nested_vmx_secondary_ctls_high &=
+				~SECONDARY_EXEC_ENABLE_VMFUNC;
 	}
 
 	/*
-- 
2.7.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-18  1:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-17  4:03 [PATCH v2 1/2] KVM: VMX: Don't advertise EPT switching if EPT itself is not exposed Wanpeng Li
2017-10-17  4:03 ` [PATCH v2 2/2] KVM: VMX: Fix VPID capability detection Wanpeng Li
2017-10-17 17:43   ` Jim Mattson
2017-10-17 17:48     ` Paolo Bonzini
2017-10-18  0:51       ` Wanpeng Li
2017-10-17 17:29 ` [PATCH v2 1/2] KVM: VMX: Don't advertise EPT switching if EPT itself is not exposed Jim Mattson
2017-10-17 17:35   ` Paolo Bonzini
2017-10-17 18:30     ` Jim Mattson
2017-10-18  1:05       ` Wanpeng Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®