Skip to content

Commit bcce829

Browse files
mdrothsuryasaimadhu
authored andcommitted
x86/sev: Detect/setup SEV/SME features earlier in boot
sme_enable() handles feature detection for both SEV and SME. Future patches will also use it for SEV-SNP feature detection/setup, which will need to be done immediately after the first #VC handler is set up. Move it now in preparation. Signed-off-by: Michael Roth <[email protected]> Signed-off-by: Brijesh Singh <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Venu Busireddy <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent ec1c66a commit bcce829

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

arch/x86/kernel/head64.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ unsigned long __head __startup_64(unsigned long physaddr,
192192
if (load_delta & ~PMD_PAGE_MASK)
193193
for (;;);
194194

195-
/* Activate Secure Memory Encryption (SME) if supported and enabled */
196-
sme_enable(bp);
197-
198195
/* Include the SME encryption mask in the fixup value */
199196
load_delta += sme_get_me_mask();
200197

arch/x86/kernel/head_64.S

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,19 @@ SYM_CODE_START_NOALIGN(startup_64)
6969
call startup_64_setup_env
7070
popq %rsi
7171

72+
#ifdef CONFIG_AMD_MEM_ENCRYPT
73+
/*
74+
* Activate SEV/SME memory encryption if supported/enabled. This needs to
75+
* be done now, since this also includes setup of the SEV-SNP CPUID table,
76+
* which needs to be done before any CPUID instructions are executed in
77+
* subsequent code.
78+
*/
79+
movq %rsi, %rdi
80+
pushq %rsi
81+
call sme_enable
82+
popq %rsi
83+
#endif
84+
7285
/* Now switch to __KERNEL_CS so IRET works reliably */
7386
pushq $__KERNEL_CS
7487
leaq .Lon_kernel_cs(%rip), %rax

0 commit comments

Comments
 (0)