From: Melody Wang <huibo.wang@amd.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <bonzini@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Tom Lendacky <thomas.lendacky@amd.com>, <x86@kernel.org>,
Melody Wang <huibo.wang@amd.com>
Subject: [RFC PATCH 7/9] KVM: SVM: Notify the SVSM an intercept happened during interrupt delivery
Date: Tue, 10 Nov 2026 08:28:52 +0000 [thread overview]
Message-ID: <ba18342e0dd2249eb81c77f418125deada1e26d0.1794295647.git.huibo.wang@amd.com> (raw)
In-Reply-To: <cover.1794295647.git.huibo.wang@amd.com>
When the guest VMEXITs with EXITINTINFO.V=1 (valid bit) is set, that
means an intercept happened during the interrupt delivery.
When the hypervisor sees the valid bit, it should queue the interrupt so
it does not get lost.
However, with Alternate Injection, the hypervisor can not queue the
interrupt directly but the SVSM needs to do that. Notify the SVSM when
the intercept happened.
Signed-off-by: Melody Wang <huibo.wang@amd.com>
---
arch/x86/kvm/svm/sev.c | 2 +-
arch/x86/kvm/svm/svm.c | 11 ++++++++++-
arch/x86/kvm/svm/svm.h | 2 ++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 40f55e7a78e3..019412173062 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4618,7 +4618,7 @@ static void sev_get_apic_ids(struct vcpu_svm *svm)
kvfree(desc);
}
-static int __sev_snp_run_vmpl(struct vcpu_svm *svm, unsigned int vmpl)
+int __sev_snp_run_vmpl(struct vcpu_svm *svm, unsigned int vmpl)
{
struct kvm_vcpu *vcpu = &svm->vcpu;
struct kvm_vcpu *target = vcpu->common->vcpus[vmpl];
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 756b11bebb5a..6d3d9debe5e8 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3663,6 +3663,7 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
{
struct vcpu_svm *svm = to_svm(vcpu);
struct kvm_run *kvm_run = vcpu->run;
+ int ret;
/* SEV-ES guests must use the CR write traps to track CR registers. */
if (!is_sev_es_guest(vcpu)) {
@@ -3698,7 +3699,15 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
if (exit_fastpath != EXIT_FASTPATH_NONE)
return 1;
- return svm_invoke_exit_handler(vcpu, svm->vmcb->control.exit_code);
+ ret = svm_invoke_exit_handler(vcpu, svm->vmcb->control.exit_code);
+
+ if (sev_snp_is_ai_active(vcpu)) {
+ if (svm->vmcb->control.exit_int_info & SVM_EVTINJ_VALID)
+ __sev_snp_run_vmpl(svm, SVM_SEV_VMPL0);
+ }
+
+ return ret;
+
}
static void svm_set_nested_run_soft_int_state(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 1ec0a045b1ea..d5f42fa31565 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -1009,6 +1009,7 @@ bool sev_snp_ai_update_doorbell(enum inject_type type, struct kvm_vcpu *vcpu, in
void sev_snp_cancel_ai_injection(struct kvm_vcpu *vcpu);
bool sev_snp_ai_blocked(enum inject_type type, struct kvm_vcpu *vcpu);
bool sev_snp_ai_inject(struct kvm_vcpu *vcpu);
+int __sev_snp_run_vmpl(struct vcpu_svm *svm, unsigned int vmpl);
static inline bool sev_snp_is_rinj_active(struct kvm_vcpu *vcpu)
{
@@ -1082,6 +1083,7 @@ static inline void sev_snp_cancel_ai_injection(struct kvm_vcpu *vcpu) {}
static inline bool sev_snp_ai_blocked(enum inject_type type, struct kvm_vcpu *vcpu) { return false; }
static inline bool sev_snp_ai_inject(struct kvm_vcpu *vcpu) { return false; }
static inline bool sev_snp_is_ai_active(struct kvm_vcpu *vcpu) { return false; }
+static inline int __sev_snp_run_vmpl(struct vcpu_svm *svm, unsigned int vmpl) { return -EINVAL; };
#endif
/* vmenter.S */
--
2.43.0
next prev parent reply other threads:[~2026-11-10 8:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 8:28 [RFC PATCH 0/9] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests Melody Wang
2026-11-10 8:28 ` [RFC PATCH 1/9] x86/sev: Define extended #HV doorbell page structure Melody Wang
2026-11-10 8:28 ` [RFC PATCH 2/9] KVM: SVM: Add support for Alternate Injection for the SEV-SNP #HV doorbell page NAE event Melody Wang
2026-11-10 8:28 ` [RFC PATCH 3/9] KVM: SVM: Add Alternate Injection support Melody Wang
2026-11-10 8:28 ` [RFC PATCH 4/9] KVM: SVM: Add Alternate Injection path Melody Wang
2026-11-10 8:28 ` [RFC PATCH 5/9] KVM: SVM: Bypass lapic for VMPL1-3 guest with Alternate Injection enabled Melody Wang
2026-11-10 8:28 ` [RFC PATCH 6/9] KVM: SVM: Inject #HV into VMPL0 " Melody Wang
2026-11-10 8:28 ` Melody Wang [this message]
2026-11-10 8:28 ` [RFC PATCH 8/9] KVM: SVM: Clear AVIC Enable when Alternate Injection is enabled Melody Wang
2026-11-10 8:28 ` [RFC PATCH 9/9] KVM: SVM: Enable Alternate Injection for an SEV-SNP guest Melody Wang
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=ba18342e0dd2249eb81c77f418125deada1e26d0.1794295647.git.huibo.wang@amd.com \
--to=huibo.wang@amd.com \
--cc=bonzini@redhat.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seanjc@google.com \
--cc=thomas.lendacky@amd.com \
--cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®