]> www.infradead.org Git - users/hch/misc.git/commitdiff
x86/sev: Use MSR protocol for remapping SVSM calling area
authorArd Biesheuvel <ardb@kernel.org>
Thu, 28 Aug 2025 10:22:05 +0000 (12:22 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Sun, 31 Aug 2025 10:40:55 +0000 (12:40 +0200)
As the preceding code comment already indicates, remapping the SVSM
calling area occurs long before the GHCB page is configured, and so
calling svsm_perform_call_protocol() is guaranteed to result in a call
to svsm_perform_msr_protocol().

So just call the latter directly. This allows most of the GHCB based API
infrastructure to be moved out of the startup code in a subsequent
patch.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/20250828102202.1849035-26-ardb+git@google.com
arch/x86/boot/startup/sev-shared.c
arch/x86/boot/startup/sev-startup.c

index ed88dfe7605e53f7cbd5eaaa113efb1ac5de0f3f..975d2b02926a9ec40733e4aed5504fb6abcf11d0 100644 (file)
@@ -724,6 +724,17 @@ static void __head setup_cpuid_table(const struct cc_blob_sev_info *cc_info)
        }
 }
 
+static int __head svsm_call_msr_protocol(struct svsm_call *call)
+{
+       int ret;
+
+       do {
+               ret = svsm_perform_msr_protocol(call);
+       } while (ret == -EAGAIN);
+
+       return ret;
+}
+
 static void __head svsm_pval_4k_page(unsigned long paddr, bool validate)
 {
        struct svsm_pvalidate_call *pc;
index 0b7e3b9501838971b39fec5662ab265402acebf9..8412807a865c872547ff6dd9c8a837e1d929d0da 100644 (file)
@@ -295,7 +295,6 @@ found_cc_info:
 static __head void svsm_setup(struct cc_blob_sev_info *cc_info)
 {
        struct svsm_call call = {};
-       int ret;
        u64 pa;
 
        /*
@@ -325,8 +324,8 @@ static __head void svsm_setup(struct cc_blob_sev_info *cc_info)
        call.caa = svsm_get_caa();
        call.rax = SVSM_CORE_CALL(SVSM_CORE_REMAP_CA);
        call.rcx = pa;
-       ret = svsm_perform_call_protocol(&call);
-       if (ret)
+
+       if (svsm_call_msr_protocol(&call))
                sev_es_terminate(SEV_TERM_SET_LINUX, GHCB_TERM_SVSM_CA_REMAP_FAIL);
 
        boot_svsm_caa = (struct svsm_ca *)pa;