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 9/9] KVM: SVM: Enable Alternate Injection for an SEV-SNP guest
Date: Tue, 10 Nov 2026 08:28:54 +0000 [thread overview]
Message-ID: <a6cc7810268bcda31aa5ba89d86fdffd5a2863cc.1794295647.git.huibo.wang@amd.com> (raw)
In-Reply-To: <cover.1794295647.git.huibo.wang@amd.com>
When the SVSM detects that the hypervisor supports Alternate Injection,
it can configure Alternate Injection and create APs with it enabled in
sev_features.
Add Alternate Injection support to the hypervisor advertised features
Signed-off-by: Melody Wang <huibo.wang@amd.com>
---
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/include/asm/sev-common.h | 1 +
arch/x86/kvm/svm/sev.c | 12 +++++++++++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index 41af7bd2473c..b2746a4d926a 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -454,6 +454,7 @@
#define X86_FEATURE_V_TSC_AUX (19*32+ 9) /* Virtual TSC_AUX */
#define X86_FEATURE_SME_COHERENT (19*32+10) /* hardware-enforced cache coherency */
#define X86_FEATURE_RESTRICTED_INJECTION (19*32+12) /* Restricted Injection */
+#define X86_FEATURE_ALTERNATE_INJECTION (19*32+13) /* Alternate Injection */
#define X86_FEATURE_DEBUG_SWAP (19*32+14) /* "debug_swap" SEV-ES full debug state swap support */
#define X86_FEATURE_RMPREAD (19*32+21) /* RMPREAD instruction */
#define X86_FEATURE_SEGMENTED_RMP (19*32+23) /* Segmented RMP support */
diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h
index a09cf5690aba..62f0c3aa7549 100644
--- a/arch/x86/include/asm/sev-common.h
+++ b/arch/x86/include/asm/sev-common.h
@@ -145,6 +145,7 @@ enum psc_op {
#define GHCB_HV_FT_SNP_RINJ (BIT_ULL(2) | GHCB_HV_FT_SNP_AP_CREATION)
#define GHCB_HV_FT_APIC_ID_LIST BIT_ULL(4)
#define GHCB_HV_FT_SNP_MULTI_VMPL BIT_ULL(5)
+#define GHCB_HV_FT_SNP_ALT_INJ BIT_ULL(9)
/*
* SNP Page State Change NAE event
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 7846d4ebb278..fd0212abc3af 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -44,6 +44,7 @@
GHCB_HV_FT_SNP_AP_CREATION | \
GHCB_HV_FT_SNP_RINJ | \
GHCB_HV_FT_APIC_ID_LIST | \
+ GHCB_HV_FT_SNP_ALT_INJ | \
GHCB_HV_FT_SNP_MULTI_VMPL)
/*
@@ -72,6 +73,10 @@ module_param_named(sev_snp, sev_snp_enabled, bool, 0444);
static bool sev_snp_restricted_injection_enabled = true;
module_param_named(restricted_injection, sev_snp_restricted_injection_enabled, bool, 0444);
+/* enable/disable SEV-SNP Alternate Injection support */
+static bool sev_snp_alternate_injection_enabled = true;
+module_param_named(alternate_injection, sev_snp_alternate_injection_enabled, bool, 0444);
+
static unsigned int __ro_after_init nr_ciphertext_hiding_asids;
module_param_named(ciphertext_hiding_asids, nr_ciphertext_hiding_asids, uint, 0444);
@@ -3242,9 +3247,14 @@ void __init sev_hardware_setup(void)
if (!sev_snp_enabled || !cpu_feature_enabled(X86_FEATURE_RESTRICTED_INJECTION))
sev_snp_restricted_injection_enabled = false;
+ if (!sev_snp_enabled || !cpu_feature_enabled(X86_FEATURE_ALTERNATE_INJECTION))
+ sev_snp_alternate_injection_enabled = false;
- if (sev_snp_restricted_injection_enabled)
+ if (sev_snp_restricted_injection_enabled) {
sev_supported_vmsa_features |= SVM_SEV_FEAT_RESTRICTED_INJECTION;
+ if (sev_snp_alternate_injection_enabled)
+ sev_supported_vmsa_features |= SVM_SEV_FEAT_ALTERNATE_INJECTION;
+ }
}
void sev_hardware_unsetup(void)
--
2.43.0
prev parent reply other threads:[~2026-11-10 8:31 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 ` [RFC PATCH 8/9] KVM: SVM: Clear AVIC Enable when Alternate Injection is enabled Melody Wang
2026-11-10 8:28 ` Melody Wang [this message]
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=a6cc7810268bcda31aa5ba89d86fdffd5a2863cc.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®