Thread (75 messages) 75 messages, 8 authors, 2021-12-08

Re: [PATCH v7 16/45] x86/sev: Register GHCB memory when SEV-SNP is active

From: Borislav Petkov <bp@alien8.de>
Date: 2021-12-08 17:41:55
Also in: kvm, linux-coco, linux-efi, lkml, platform-driver-x86

On Wed, Nov 10, 2021 at 04:07:02PM -0600, Brijesh Singh wrote:
The SEV-SNP guest is required to perform GHCB GPA registration. This is
because the hypervisor may prefer that a guest use a consistent and/or
specific GPA for the GHCB associated with a vCPU. For more information,
see the GHCB specification section GHCB GPA Registration.

During the boot, init_ghcb() allocates a per-cpu GHCB page. On very first
VC exception,
That is not true anymore - you're doing proper init at init time - no
more #VC hackery.
quoted hunk ↗ jump to hunk
@@ -1977,6 +1978,10 @@ void cpu_init_exception_handling(void)
 
 	load_TR_desc();
 
+	/* Register the GHCB before taking any VC exception */
+	if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT))
No need for that if branch - sev_snp_register_ghcb() already has an
empty stub for the !CONFIG_AMD_MEM_ENCRYPT case so you can simply call
it unconditionally.
quoted hunk ↗ jump to hunk
+		sev_snp_register_ghcb();
+
 	/* Finally load the IDT */
 	load_current_idt();
 }
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 54bf0603002f..968105cec364 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -588,6 +588,9 @@ void early_setup_idt(void)
 
 	bringup_idt_descr.address = (unsigned long)bringup_idt_table;
 	native_load_idt(&bringup_idt_descr);
+
+	if (IS_ENABLED(CONFIG_AMD_MEM_ENCRYPT))
+		sev_snp_register_ghcb();
Ditto.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help