diff mbox

[kvm-unit-tests,1/2] x86/vmx: fix unexpected stage error in PML test

Message ID 20170703175853.1939-2-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář July 3, 2017, 5:58 p.m. UTC
Recent patches triggered an unexpected stage error.  This happened
because report() now adds one extra entry to the PML.

The writes done during a page walk are logged into PML, which means that
we are guaranteed to get multiple entries.  The PML test adds 4 entries
in each loop while waiting for the PML full event and unluckily, the one
extra entry fills PML just before the vmcall (3 entries are added before
checking the stage and one after).  The vmcall then sees a wrong stage
and exits.

This solution makes sure that the PML exit will not happen between the
check for stage and the vmcall.  (It wastes the first vmcall, but the
loop happens ~125 times anyway, so it's not a huge waste.)

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
 x86/vmx_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox


diff --git a/x86/vmx_tests.c b/x86/vmx_tests.c
index 567f7143b427..25e91aa81477 100644
--- a/x86/vmx_tests.c
+++ b/x86/vmx_tests.c
@@ -1354,10 +1354,10 @@  static void pml_main()
 	report("PML - Dirty GPA Logging", vmx_get_test_stage() == 1);
 	while (vmx_get_test_stage() == 1) {
+		vmcall();
 		*((u32 *)data_page2) = 0x1;
 		if (count++ > PML_INDEX)
-		vmcall();
 	report("PML Full Event", vmx_get_test_stage() == 2);