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@xxxxxxxxx> --- x86/vmx.h | 3 ++- x86/vmx_tests.c | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/x86/vmx.h b/x86/vmx.h index d280f104..34e6b949 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -167,7 +167,8 @@ union vmx_basic_msr { 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 f598496e..96848f4f 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -4173,7 +4173,10 @@ static void test_invalid_event_injection(void) 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 | @@ -4206,7 +4209,10 @@ static void test_invalid_event_injection(void) 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); @@ -4228,7 +4234,11 @@ skip_unrestricted_guest: 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(); @@ -4265,7 +4275,10 @@ skip_unrestricted_guest: 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 */ -- 2.27.0