...so that it can be re-used by other tests. Signed-off-by: Krish Sadhukhan <krish.sadhukhan@xxxxxxxxxx> Reviewed-by: Karl Heubaum <karl.heubaum@xxxxxxxxxx> --- x86/vmx_tests.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c index ee96596..a339bb3 100644 --- a/x86/vmx_tests.c +++ b/x86/vmx_tests.c @@ -5007,13 +5007,14 @@ static void guest_state_test_main(void) asm volatile("fnop"); } -static void report_guest_pat_test(const char *test, u32 xreason, u64 guest_pat) +static void report_guest_state_test(const char *test, u32 xreason, + u64 field, const char * field_name) { u32 reason = vmcs_read(EXI_REASON); u64 guest_rip; u32 insn_len; - report("%s, GUEST_PAT %lx", reason == xreason, test, guest_pat); + report("%s, %s %lx", reason == xreason, test, field_name, field); guest_rip = vmcs_read(GUEST_RIP); insn_len = vmcs_read(EXI_INST_LEN); @@ -5112,8 +5113,9 @@ static void test_pat(u32 fld, const char * fld_name, u32 ctrl_fld, u64 ctrl_bit) } else { // GUEST_PAT __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT enabled", - VMX_VMCALL, val); + report_guest_state_test("ENT_LOAD_PAT enabled", + VMX_VMCALL, val, + "GUEST_PAT"); } } } @@ -5139,17 +5141,19 @@ static void test_pat(u32 fld, const char * fld_name, u32 ctrl_fld, u64 ctrl_bit) } else { // GUEST_PAT if (i == 0x2 || i == 0x3 || i == 0x8) { __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT " - "enabled", + report_guest_state_test("ENT_LOAD_PAT " + "enabled", VMX_FAIL_STATE | VMX_ENTRY_FAILURE, - val); + val, + "GUEST_PAT"); } else { __enter_guest(ABORT_ON_EARLY_VMENTRY_FAIL); - report_guest_pat_test("ENT_LOAD_PAT " + report_guest_state_test("ENT_LOAD_PAT " "enabled", VMX_VMCALL, - val); + val, + "GUEST_PAT"); } } -- 2.20.1