Re: [PATCH v6 1/7] x86/sev: Add support for Alternate Injection
From: Tom Lendacky
Date: Fri Nov 20 2026 - 12:04:52 EST
On 11/5/26 19:25, Melody Wang wrote:
> The Alternate Injection feature is a method to protect a SNP guest from
> malicious injection attacks. It allows the guest to control the
> interrupt injection.
>
> When this feature is enabled, interrupts are injected with the help of
> an agent called a Secure VM Service Module (SVSM) which executes in the
> security realm of the guest and uses Restricted Injection as the sole
> method to receive interrupts from the hypervisor.
>
> Add support for Alternate Injection.
This doesn't really add support for Alternate Injection. You're adding a
config option and changing the existing bit name, which arguably should be
two separate patches.
Also, the config option doesn't get used anywhere, yet. Just wondering if
it should be created when used (ditto for the
CC_ATTR_SNP_ALTERNATE_INJECTION attribute).
Thanks,
Tom
>
> Signed-off-by: Melody Wang <huibo.wang@xxxxxxx>
> ---
> arch/x86/Kconfig | 14 ++++++++++++++
> arch/x86/boot/compressed/sev.c | 2 +-
> arch/x86/coco/core.c | 3 +++
> arch/x86/coco/sev/core.c | 2 +-
> arch/x86/include/asm/msr-index.h | 4 ++--
> include/linux/cc_platform.h | 8 ++++++++
> tools/arch/x86/include/asm/msr-index.h | 4 ++--
> 7 files changed, 31 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 58dce0b66179..d1f02ff74adb 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -494,6 +494,20 @@ config AMD_SECURE_AVIC
>
> If you don't know what to do here, say N.
>
> +config AMD_ALTERNATE_INJ
> + bool "Support Alternate Injection"
> + depends on X86_X2APIC && AMD_MEM_ENCRYPT
> + help
> + Enable AMD Alternate Injection support for SNP guests.
> +
> + The Alternate Injection feature of SEV-SNP enhances the security of
> + a confidential VM by preventing the untrusted host from presenting
> + unexpected interrupts or exceptions, while still preserving the
> + standard interrupt dispatch semantics inherent to the x86
> + architecture.
> +
> + If you don't know what to do here, say N.
> +
> config X86_POSTED_MSI
> bool "Enable MSI and MSI-x delivery by posted interrupts"
> depends on X86_64 && IRQ_REMAP
> diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
> index c6512f2ea31e..fc2029746c50 100644
> --- a/arch/x86/boot/compressed/sev.c
> +++ b/arch/x86/boot/compressed/sev.c
> @@ -179,7 +179,7 @@ bool sev_es_check_ghcb_fault(unsigned long address)
> #define SNP_FEATURES_IMPL_REQ (MSR_AMD64_SNP_VTOM | \
> MSR_AMD64_SNP_REFLECT_VC | \
> MSR_AMD64_SNP_RESTRICTED_INJ | \
> - MSR_AMD64_SNP_ALT_INJ | \
> + MSR_AMD64_SNP_ALTERNATE_INJ | \
> MSR_AMD64_SNP_DEBUG_SWAP | \
> MSR_AMD64_SNP_VMPL_SSS | \
> MSR_AMD64_SNP_SECURE_TSC | \
> diff --git a/arch/x86/coco/core.c b/arch/x86/coco/core.c
> index 989ca9f72ba3..aabda3ddc0e2 100644
> --- a/arch/x86/coco/core.c
> +++ b/arch/x86/coco/core.c
> @@ -107,6 +107,9 @@ static bool noinstr amd_cc_platform_has(enum cc_attr attr)
> case CC_ATTR_SNP_SECURE_AVIC:
> return sev_status & MSR_AMD64_SNP_SECURE_AVIC;
>
> + case CC_ATTR_SNP_ALTERNATE_INJECTION:
> + return sev_status & MSR_AMD64_SNP_ALTERNATE_INJ;
> +
> default:
> return false;
> }
> diff --git a/arch/x86/coco/sev/core.c b/arch/x86/coco/sev/core.c
> index eb2e853e950a..900a7ff8b639 100644
> --- a/arch/x86/coco/sev/core.c
> +++ b/arch/x86/coco/sev/core.c
> @@ -78,7 +78,7 @@ static const char * const sev_status_feat_names[] = {
> [MSR_AMD64_SNP_VTOM_BIT] = "vTom",
> [MSR_AMD64_SNP_REFLECT_VC_BIT] = "ReflectVC",
> [MSR_AMD64_SNP_RESTRICTED_INJ_BIT] = "RI",
> - [MSR_AMD64_SNP_ALT_INJ_BIT] = "AI",
> + [MSR_AMD64_SNP_ALTERNATE_INJ_BIT] = "AI",
> [MSR_AMD64_SNP_DEBUG_SWAP_BIT] = "DebugSwap",
> [MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT] = "NoHostIBS",
> [MSR_AMD64_SNP_BTB_ISOLATION_BIT] = "BTBIsol",
> diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
> index c0914829a925..d6aede40fcdd 100644
> --- a/arch/x86/include/asm/msr-index.h
> +++ b/arch/x86/include/asm/msr-index.h
> @@ -730,8 +730,8 @@
> #define MSR_AMD64_SNP_REFLECT_VC BIT_ULL(MSR_AMD64_SNP_REFLECT_VC_BIT)
> #define MSR_AMD64_SNP_RESTRICTED_INJ_BIT 5
> #define MSR_AMD64_SNP_RESTRICTED_INJ BIT_ULL(MSR_AMD64_SNP_RESTRICTED_INJ_BIT)
> -#define MSR_AMD64_SNP_ALT_INJ_BIT 6
> -#define MSR_AMD64_SNP_ALT_INJ BIT_ULL(MSR_AMD64_SNP_ALT_INJ_BIT)
> +#define MSR_AMD64_SNP_ALTERNATE_INJ_BIT 6
> +#define MSR_AMD64_SNP_ALTERNATE_INJ BIT_ULL(MSR_AMD64_SNP_ALTERNATE_INJ_BIT)
> #define MSR_AMD64_SNP_DEBUG_SWAP_BIT 7
> #define MSR_AMD64_SNP_DEBUG_SWAP BIT_ULL(MSR_AMD64_SNP_DEBUG_SWAP_BIT)
> #define MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT 8
> diff --git a/include/linux/cc_platform.h b/include/linux/cc_platform.h
> index 559353ad64ac..80d9f1de2ae8 100644
> --- a/include/linux/cc_platform.h
> +++ b/include/linux/cc_platform.h
> @@ -104,6 +104,14 @@ enum cc_attr {
> * to run SEV-SNP guests with full Secure AVIC capabilities.
> */
> CC_ATTR_SNP_SECURE_AVIC,
> +
> + /**
> + * @CC_ATTR_SNP_ALTERNATE_INJECTION: AMD Alternate Injection enabled.
> + *
> + * A Secure VM Service Module (SVSM) has started the guest with
> + * Alternate Injection enabled.
> + */
> + CC_ATTR_SNP_ALTERNATE_INJECTION,
> };
>
> #ifdef CONFIG_ARCH_HAS_CC_PLATFORM
> diff --git a/tools/arch/x86/include/asm/msr-index.h b/tools/arch/x86/include/asm/msr-index.h
> index 9c26d4075c5f..0c26cdbfa8ff 100644
> --- a/tools/arch/x86/include/asm/msr-index.h
> +++ b/tools/arch/x86/include/asm/msr-index.h
> @@ -728,8 +728,8 @@
> #define MSR_AMD64_SNP_REFLECT_VC BIT_ULL(MSR_AMD64_SNP_REFLECT_VC_BIT)
> #define MSR_AMD64_SNP_RESTRICTED_INJ_BIT 5
> #define MSR_AMD64_SNP_RESTRICTED_INJ BIT_ULL(MSR_AMD64_SNP_RESTRICTED_INJ_BIT)
> -#define MSR_AMD64_SNP_ALT_INJ_BIT 6
> -#define MSR_AMD64_SNP_ALT_INJ BIT_ULL(MSR_AMD64_SNP_ALT_INJ_BIT)
> +#define MSR_AMD64_SNP_ALTERNATE_INJ_BIT 6
> +#define MSR_AMD64_SNP_ALTERNATE_INJ BIT_ULL(MSR_AMD64_SNP_ALTERNATE_INJ_BIT)
> #define MSR_AMD64_SNP_DEBUG_SWAP_BIT 7
> #define MSR_AMD64_SNP_DEBUG_SWAP BIT_ULL(MSR_AMD64_SNP_DEBUG_SWAP_BIT)
> #define MSR_AMD64_SNP_PREVENT_HOST_IBS_BIT 8