diff mbox series

[kvm-unit-tests,2/9] svm: Fix reg_corruption test, to avoid timer interrupt firing in later tests.

Message ID 20220322205613.250925-3-mlevitsk@redhat.com (mailing list archive)
State New, archived
Headers show
Series KVM unit tests for SVM options features | expand

Commit Message

Maxim Levitsky March 22, 2022, 8:56 p.m. UTC
The test were setting APIC periodic timer but not disabling it later.

Fixes: da338a3 ("SVM: add test for nested guest RIP corruption")

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 x86/svm_tests.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 0707786..7a97847 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -1847,7 +1847,7 @@  static bool reg_corruption_finished(struct svm_test *test)
         report_pass("No RIP corruption detected after %d timer interrupts",
                     isr_cnt);
         set_test_stage(test, 1);
-        return true;
+        goto cleanup;
     }
 
     if (vmcb->control.exit_code == SVM_EXIT_INTR) {
@@ -1861,11 +1861,16 @@  static bool reg_corruption_finished(struct svm_test *test)
         if (guest_rip == insb_instruction_label && io_port_var != 0xAA) {
             report_fail("RIP corruption detected after %d timer interrupts",
                         isr_cnt);
-            return true;
+            goto cleanup;
         }
 
     }
     return false;
+cleanup:
+    apic_write(APIC_LVTT, APIC_LVT_TIMER_MASK);
+    apic_write(APIC_TMICT, 0);
+    return true;
+
 }
 
 static bool reg_corruption_check(struct svm_test *test)