Add tests to verify that DEBUGCTLMSR_RTM_DEBUG state is correctly handled during VMX transitions on top of the shared helper. Signed-off-by: Chenyi Qiang --- lib/x86/msr.h | 1 + x86/unittests.cfg | 8 ++++++++ x86/vmx_tests.c | 14 ++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/lib/x86/msr.h b/lib/x86/msr.h index da75740d..8b019f7e 100644 --- a/lib/x86/msr.h +++ b/lib/x86/msr.h @@ -110,6 +110,7 @@ #define DEBUGCTLMSR_BTS_OFF_OS (1UL << 9) #define DEBUGCTLMSR_BTS_OFF_USR (1UL << 10) #define DEBUGCTLMSR_FREEZE_LBRS_ON_PMI (1UL << 11) +#define DEBUGCTLMSR_RTM_DEBUG (1UL << 15) #define MSR_LBR_NHM_FROM 0x00000680 #define MSR_LBR_NHM_TO 0x000006c0 diff --git a/x86/unittests.cfg b/x86/unittests.cfg index c8426770..78c15e2b 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -479,6 +479,14 @@ arch = x86_64 groups = vmx timeout = 240 +[vmx_rtm_test] +file = vmx.flat +test_args = "vmx_rtm_test" +qemu_params = -cpu max,+vmx +arch = x86_64 +groups = vmx +timeout = 240 + [debug] file = debug.flat arch = x86_64 diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index a3e52d3b..934d6021 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -11831,6 +11831,18 @@ static void vmx_bus_lock_detect_test(void) report_pass(__func__); } +static void vmx_rtm_test(void) +{ + if (!this_cpu_has(X86_FEATURE_RTM)) { + report_skip("%s : \"RTM\" not supported", __func__); + return; + } + + vmx_debugctl_transition_test("DEBUGCTLMSR.RTM_DEBUG", + DEBUGCTLMSR_RTM_DEBUG); + report_pass(__func__); +} + #define TEST(name) { #name, .v2 = name } /* name/init/guest_main/exit_handler/syscall_handler/guest_regs */ @@ -11954,5 +11966,7 @@ struct vmx_test vmx_tests[] = { TEST(vmx_cet_test), /* "debug controls VM-entry/exit controls tests" for DEBUGCTLMSR_BUS_LOCK_DETECT */ TEST(vmx_bus_lock_detect_test), + /* "debug controls VM-entry/exit controls tests" for DEBUGCTLMSR_RTM_DEBUG */ + TEST(vmx_rtm_test), { NULL, NULL, NULL, NULL, NULL, {0} }, }; -- 2.43.5