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