Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Ryosuke Yasuoka <ryasuoka@redhat.com>
To: pbonzini@redhat.com
Cc: Ryosuke Yasuoka <ryasuoka@redhat.com>, kvm@vger.kernel.org
Subject: [kvm-unit-tests PATCH] svm: Add SMI handler for svm_intr_intercept_mix_smi test
Date: Tue, 18 Aug 2026 13:34:40 +0000	[thread overview]
Message-ID: <20260818133445.8688-1-ryasuoka@redhat.com> (raw)

L1 intercepts L2's SMI and the SMI is still pending at L0. When L1
re-enables GIF via stgi(), L0 delivers the SMI to L1. Without an SMI
handler, L1 enters SMM and aborts.

Install a trivial RSM handler at the default SMBASE entry point so L1
can return from SMM.

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 x86/svm_tests.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index ccbab1d0..11770854 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -3543,8 +3543,28 @@ static void svm_intr_intercept_mix_smi_guest(struct svm_test *test)
 	report(0, "must not reach here");
 }
 
+#define SMBASE	0x30000
+#define SMBASE_ENTRY	(SMBASE + 0x8000)
+#define RSM_OPCODE	0xaa0f
+
+/*
+ * Install a trivial SMI handler that executes RSM at the default SMBASE
+ * entry point. Without this, entering SMM causes an abort.
+ */
+static void install_smi_handler(void)
+{
+	WRITE_ONCE(*(u16 *)SMBASE_ENTRY, RSM_OPCODE);
+}
+
 static void svm_intr_intercept_mix_smi(void)
 {
+	/*
+	 * L1 intercepts L2's SMI. It makes L0 deliver the SMI to L1
+	 * when L1 re-enables GIF via stgi(), so L1 needs an SMI handler
+	 * to avoid aborting.
+	 */
+	install_smi_handler();
+
 	vmcb_set_intercept(INTERCEPT_SMI);
 	vmcb->control.int_ctl &= ~V_INTR_MASKING_MASK;
 	test_set_guest(svm_intr_intercept_mix_smi_guest);
-- 
2.55.0


             reply	other threads:[~2026-08-18 13:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 13:34 Ryosuke Yasuoka [this message]
2026-08-19 17:26 ` [kvm-unit-tests PATCH] svm: Add SMI handler for svm_intr_intercept_mix_smi test mlevitsk

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=20260818133445.8688-1-ryasuoka@redhat.com \
    --to=ryasuoka@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox