[kvm-unit-tests PATCH 2/3] x86: nSVM: Check #BP exception handling in L2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add coverage for BP exception handling in L2 when only L2 BP
exception handler is registered

BP exception is generated using int3 instruction and it is handled
by L2 BP exception handler.

Signed-off-by: Manali Shukla <manali.shukla@xxxxxxx>
---
 x86/svm_tests.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 681272c..ed67ae1 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -2962,6 +2962,26 @@ static bool vgif_check(struct svm_test *test)
     return get_test_stage(test) == 3;
 }
 
+static int bp_test_counter;
+
+static void guest_test_bp_handler(struct ex_regs *r)
+{
+    bp_test_counter++;
+}
+
+static void svm_bp_test_guest(struct svm_test *test)
+{
+    asm volatile("int3");
+}
+
+static void svm_int3_test(void)
+{
+    handle_exception(BP_VECTOR, guest_test_bp_handler);
+    test_set_guest(svm_bp_test_guest);
+    report(svm_vmrun() == SVM_EXIT_VMMCALL && bp_test_counter == 1,
+        "#BP is handled in L2 exception handler");
+}
+
 static int nm_test_counter;
 
 static void guest_test_nm_handler(struct ex_regs *r)
@@ -3127,5 +3147,6 @@ struct svm_test svm_tests[] = {
     TEST(svm_vmload_vmsave),
     TEST(svm_test_singlestep),
     TEST(svm_nm_test),
+    TEST(svm_int3_test),
     { NULL, NULL, NULL, NULL, NULL, NULL, NULL }
 };
-- 
2.30.2




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux