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 8/9] KVM: SVM: Clear AVIC Enable when Alternate Injection is enabled
Date: Tue, 10 Nov 2026 08:28:53 +0000 [thread overview]
Message-ID: <bb0e384c986a4401b799be2b6b0dc0a69abdce34.1794295647.git.huibo.wang@amd.com> (raw)
In-Reply-To: <cover.1794295647.git.huibo.wang@amd.com>
VMRUN fails with VMEXIT_INVALID if the AVIC Enable bit is set while the
guest uses Alternate Injection. Historically, the AVIC Enable bit wasn’t
set during AVIC VMCB initialization under SEV because AVIC is inhibited.
Commit 3989a6d036c8 ("KVM: SVM: Initialize AVIC VMCB fields if AVIC is
enabled with in-kernel APIC") changed this by populating AVIC VMCB
fields even when AVIC is inhibited under SEV. As a result, the AVIC
Enable bit may remain set and trigger VMEXIT_INVALID with Alternate
Injection.
Rather than altering the AVIC VMCB initialization, explicitly clear the
AVIC Enable bit only when Alternate Injection is enabled.
Signed-off-by: Melody Wang <huibo.wang@amd.com>
---
arch/x86/kvm/svm/sev.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 019412173062..7846d4ebb278 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -5089,9 +5089,15 @@ static void sev_snp_init_vmcb(struct vcpu_svm *svm)
{
struct kvm_sev_info_plane *sev_plane = &to_kvm_svm_plane(svm->vcpu.plane)->sev_info_plane;
- /* V_NMI is not supported when Restricted Injection is enabled */
- if (sev_plane->vmsa_features & SVM_SEV_FEAT_RESTRICTED_INJECTION)
+ /*
+ * V_NMI and AVIC are not supported when Restricted Injection or Alternate
+ * Injection is enabled.
+ */
+ if (sev_plane->vmsa_features & (SVM_SEV_FEAT_RESTRICTED_INJECTION |
+ SVM_SEV_FEAT_ALTERNATE_INJECTION)) {
svm->vmcb->control.int_ctl &= ~V_NMI_ENABLE_MASK;
+ svm->vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK;
+ }
}
static void sev_es_init_vmcb(struct vcpu_svm *svm, bool init_event)
--
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 ` [RFC PATCH 7/9] KVM: SVM: Notify the SVSM an intercept happened during interrupt delivery Melody Wang
2026-11-10 8:28 ` Melody Wang [this message]
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=bb0e384c986a4401b799be2b6b0dc0a69abdce34.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®