All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manali Shukla <manali.shukla@amd.com>
To: <kvm@vger.kernel.org>
Subject: [kvm-unit-tests PATCH 2/3] x86: nSVM: Check #BP exception handling in L2
Date: Wed, 29 Dec 2021 06:22:00 +0000	[thread overview]
Message-ID: <20211229062201.26269-3-manali.shukla@amd.com> (raw)
In-Reply-To: <20211229062201.26269-1-manali.shukla@amd.com>

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@amd.com>
---
 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


  parent reply	other threads:[~2021-12-29  6:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-29  6:21 [kvm-unit-tests PATCH 0/3] Add L2 exception handling KVM unit tests for nSVM Manali Shukla
2021-12-29  6:21 ` [kvm-unit-tests PATCH 1/3] x86: nSVM: Check #NM exception handling in L2 Manali Shukla
2021-12-29  6:22 ` Manali Shukla [this message]
2021-12-29  6:22 ` [kvm-unit-tests PATCH 3/3] x86: nSVM: Check #OF " Manali Shukla
2022-01-07  4:05 ` [kvm-unit-tests PATCH 0/3] Add L2 exception handling KVM unit tests for nSVM Shukla, Manali
2022-01-12 21:29 ` Sean Christopherson
2022-01-18 11:11   ` Shukla, Manali
2022-01-18 11:38     ` Paolo Bonzini
2022-01-18  9:21 ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211229062201.26269-3-manali.shukla@amd.com \
    --to=manali.shukla@amd.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.