Skip to content

Some code refactor surround CR4.UMIP virtualization

Robert Hoo kvm 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3KVM: VMX: Rename vmx_umip_emulated() to cpu_has_vmx_desc()arch/x86/kvm/vmx/capabilities.h arch/x86/kvm/vmx/nested.c arch/x86/kvm/vmx/vmx.c+11 -55 replies
2/3KVM: VMX: Remove a unnecessary cpu_has_vmx_desc() check in vmx_set_cr4()arch/x86/kvm/vmx/vmx.c+1 -16 replies
3/3KVM: VMX: Use the canonical interface to read CR4.UMIP bitarch/x86/kvm/vmx/vmx.c+1 -14 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Some code refactor surround CR4.UMIP virtualization

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.

x86/unittests.cfg +4 -0
index 08a9b20..32a3b79 100644
@@ -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

Signature · 1 line
2.31.1