Re: [PATCH 6/7] x86/sev: Register the guest with the SVSM APIC protocol
From: Melody Wang
Date: Thu Aug 27 2026 - 23:35:41 EST
Hi Tom,
On 7/31/26 12:18 PM, Tom Lendacky wrote:
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?
Yes, I think it makes sense to allow all of interrupts right after registering the SVSM APIC protocol because this is just another SVSM call that is going to happen and I don't see anything wrong with doing that there.
I did run it and it works so my next revision will have it.
Thanks,
Melody
Thanks,
Tom