nVMX: Introduce new vmx_basic MSR feature bit for vmx tests
Introduce IA32_VMX_BASIC[bit56] support, i.e., skipping HW consistency
check for event error code if the bit is supported..
CET KVM enabling series introduces the vmx_basic_msr feature bit and it
causes some of the original test cases expecting a VM entry failure end
up with a successful result and the selftests report test failures. Now
checks the VM launch status conditionally against the bit support status
so as to make test results consistent with the change enforced by KVM.
Signed-off-by: Yang Weijiang <weijiang.yang@intel.com>
Link: https://lore.kernel.org/r/20230913235006.74172-4-weijiang.yang@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
diff --git a/x86/vmx.h b/x86/vmx.h
index 25d3895..9cd9048 100644
--- a/x86/vmx.h
+++ b/x86/vmx.h
@@ -141,7 +141,8 @@
type:4,
insouts:1,
ctrl:1,
- reserved2:8;
+ no_hw_errcode_cc:1,
+ reserved2:7;
};
};
diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 8b1c961..bec9395 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -4192,7 +4192,10 @@
ent_intr_info);
vmcs_write(GUEST_CR0, guest_cr0_save & ~X86_CR0_PE & ~X86_CR0_PG);
vmcs_write(ENT_INTR_INFO, ent_intr_info);
- test_vmx_invalid_controls();
+ if (basic_msr.no_hw_errcode_cc)
+ test_vmx_valid_controls();
+ else
+ test_vmx_invalid_controls();
report_prefix_pop();
ent_intr_info = ent_intr_info_base | INTR_INFO_DELIVER_CODE_MASK |
@@ -4225,7 +4228,10 @@
ent_intr_info);
vmcs_write(GUEST_CR0, guest_cr0_save | X86_CR0_PE);
vmcs_write(ENT_INTR_INFO, ent_intr_info);
- test_vmx_invalid_controls();
+ if (basic_msr.no_hw_errcode_cc)
+ test_vmx_valid_controls();
+ else
+ test_vmx_invalid_controls();
report_prefix_pop();
vmcs_write(CPU_EXEC_CTRL1, secondary_save);
@@ -4247,7 +4253,11 @@
report_prefix_pushf("VM-entry intr info=0x%x [-]",
ent_intr_info);
vmcs_write(ENT_INTR_INFO, ent_intr_info);
- test_vmx_invalid_controls();
+ if (exception_type_mask == INTR_TYPE_HARD_EXCEPTION &&
+ basic_msr.no_hw_errcode_cc)
+ test_vmx_valid_controls();
+ else
+ test_vmx_invalid_controls();
report_prefix_pop();
}
report_prefix_pop();
@@ -4284,7 +4294,10 @@
report_prefix_pushf("VM-entry intr info=0x%x [-]",
ent_intr_info);
vmcs_write(ENT_INTR_INFO, ent_intr_info);
- test_vmx_invalid_controls();
+ if (basic_msr.no_hw_errcode_cc)
+ test_vmx_valid_controls();
+ else
+ test_vmx_invalid_controls();
report_prefix_pop();
/* Positive case */