kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Some code refactor surround CR4.UMIP virtualization
@ 2023-03-10 12:57 Robert Hoo
  2023-03-10 12:57 ` [PATCH 1/3] KVM: VMX: Rename vmx_umip_emulated() to cpu_has_vmx_desc() Robert Hoo
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Robert Hoo @ 2023-03-10 12:57 UTC (permalink / raw)
  To: seanjc, pbonzini, kvm; +Cc: robert.hoo.linux

This is some small code refactor/cleanup surround CR4.UMIP virtualization.

vmx_umip_emulated() is misleading, it is actually cpu_has_vmx_desc(). E.g.,
if host has both UMIP cap and VMX_FEATURE_DESC_EXITING feature,
vmx_umip_emulated() returns true, but UMIP in fact isn't emulated. Rename
it.

Also, vCPU can have UMIP feature (i.e. CR4.UMIP is valid) if and only if
host has UMIP and/or VMX_FEATURE_DESC_EXITING cap, (see vmx_set_cpu_caps());
then checking cpu_has_vmx_desc() for emulating UMIP is redundant, because
boot_cpu_has(X86_FEATURE_UMIP) and cpu_has_vmx_desc() must at least one be
true. 

===Test===
kvm-unit-test umip cases, enabled and disabled (unittests.cfg patch below),
pass. But currently I have no machine with UMIP feature, so actually only
emulation path is covered.
In January, test was carried out on Simics platform with UMIP. Passed.

diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index 08a9b20..32a3b79 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -323,6 +323,10 @@ arch = x86_64
 file = umip.flat
 extra_params = -cpu qemu64,+umip
 
+[umip-disabled]
+file = umip.flat
+extra_params = -cpu qemu64,-umip
+


Robert Hoo (3):
  KVM: VMX: Rename vmx_umip_emulated() to cpu_has_vmx_desc()
  KVM: VMX: Remove a unnecessary cpu_has_vmx_desc() check in
    vmx_set_cr4()
  KVM: VMX: Use the canonical interface to read CR4.UMIP bit

 arch/x86/kvm/vmx/capabilities.h |  2 +-
 arch/x86/kvm/vmx/nested.c       |  4 ++--
 arch/x86/kvm/vmx/vmx.c          | 12 +++++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)


base-commit: 45dd9bc75d9adc9483f0c7d662ba6e73ed698a0b
-- 
2.31.1


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

end of thread, other threads:[~2023-04-11  5:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 12:57 [PATCH 0/3] Some code refactor surround CR4.UMIP virtualization Robert Hoo
2023-03-10 12:57 ` [PATCH 1/3] KVM: VMX: Rename vmx_umip_emulated() to cpu_has_vmx_desc() Robert Hoo
2023-03-10 15:59   ` Sean Christopherson
2023-03-11  1:59     ` Robert Hoo
2023-03-15 17:50       ` Sean Christopherson
2023-03-31  9:48         ` Robert Hoo
2023-04-10 18:12           ` Sean Christopherson
2023-03-10 12:57 ` [PATCH 2/3] KVM: VMX: Remove a unnecessary cpu_has_vmx_desc() check in vmx_set_cr4() Robert Hoo
2023-03-10 16:12   ` Sean Christopherson
2023-03-11  2:36     ` Robert Hoo
2023-03-15 16:35       ` Sean Christopherson
2023-03-31  9:48         ` Robert Hoo
2023-04-10 18:35           ` Sean Christopherson
2023-04-11  5:04             ` Hoo Robert
2023-03-10 12:57 ` [PATCH 3/3] KVM: VMX: Use the canonical interface to read CR4.UMIP bit Robert Hoo
2023-03-10 16:27   ` Sean Christopherson
     [not found]     ` <CA+wubQBsiaH_==UJ-JUi7hwS8W1i5MLZ-dPuw2smVH8Z0sqXsw@mail.gmail.com>
2023-03-28  4:38       ` Sean Christopherson
2023-03-31  9:48     ` Robert Hoo
2023-04-10 18:35       ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).