Re: [PATCH 6/7] x86/sev: Register the guest with the SVSM APIC protocol
From: Tom Lendacky
Date: Fri Jul 31 2026 - 15:18:42 EST
On 7/29/26 20:48, Melody Wang wrote:
> The SVSM APIC protocol supports 5 calls. SVSM_APIC_CONFIGURE_EMULATION
> (shortened to SVSM_APIC_CONFIG_EMULATION for brevity), call 1, provides
> the controls whether the guest can make use of the SVSM APIC protocol.
>
> Implement this call, and register Alternate Injection for the guest
> by default.
>
> Signed-off-by: Melody Wang <huibo.wang@xxxxxxx>
> ---
> arch/x86/boot/compressed/sev.c | 17 +++++++++++++++++
> arch/x86/boot/compressed/sev.h | 6 ++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/arch/x86/boot/compressed/sev.c b/arch/x86/boot/compressed/sev.c
> index 655291a03dcc..a98185b3869a 100644
> --- a/arch/x86/boot/compressed/sev.c
> +++ b/arch/x86/boot/compressed/sev.c
> @@ -518,5 +518,22 @@ u64 sev_prepare(void)
> if (unsupported)
> return unsupported;
>
> + /* Register Alternate Injection */
> + if (early_is_sevsnp_guest() && snp_vmpl) {
> + struct svsm_call call = {};
> + int ret;
> +
> + if (!(sev_get_status() & MSR_AMD64_SNP_ALTERNATE_INJ))
> + return 0;
> +
> + call.caa = (struct svsm_ca *)boot_svsm_caa_pa;
> + call.rax = SVSM_APIC_CALL(SVSM_APIC_CONFIG_EMULATION);
> + call.rcx = SVSM_AI_REGISTER;
> +
> + ret = svsm_call_msr_protocol(&call);
> + if (ret)
> + sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
Shouldn't this really be where the permissive setting of allowing all
interrupts be done, too, instead of where it is done in patch #3?
Thanks,
Tom
> + }
> +
> return 0;
> }
> diff --git a/arch/x86/boot/compressed/sev.h b/arch/x86/boot/compressed/sev.h
> index 22637b416b46..dd058af2e7aa 100644
> --- a/arch/x86/boot/compressed/sev.h
> +++ b/arch/x86/boot/compressed/sev.h
> @@ -12,6 +12,12 @@
>
> #include <asm/shared/msr.h>
>
> +enum svsm_ai_ctrl {
> + SVSM_AI_DISABLE,
Isn't the zero value "Query APIC Emulation", not disable?
> + SVSM_AI_DEREGISTER,
s/DEREGISTER/UNREGISTER/
Thanks,
Tom
> + SVSM_AI_REGISTER,
> +};
> +
> void snp_accept_memory(phys_addr_t start, phys_addr_t end);
> u64 sev_get_status(void);
> bool early_is_sevsnp_guest(void);