Skip to content

Commit 3ecacdb

Browse files
joergroedelsuryasaimadhu
authored andcommitted
x86/head/64: Don't call verify_cpu() on starting APs
The APs are not ready to handle exceptions when verify_cpu() is called in secondary_startup_64(). Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Kees Cook <keescook@chromium.org> Link: https://lkml.kernel.org/r/20200907131613.12703-69-joro@8bytes.org
1 parent 520d030 commit 3ecacdb

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

arch/x86/include/asm/realmode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern unsigned char startup_32_smp[];
7272
extern unsigned char boot_gdt[];
7373
#else
7474
extern unsigned char secondary_startup_64[];
75+
extern unsigned char secondary_startup_64_no_verify[];
7576
#endif
7677

7778
static inline size_t real_mode_size_needed(void)

arch/x86/kernel/head_64.S

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ SYM_CODE_START(secondary_startup_64)
125125
/* Sanitize CPU configuration */
126126
call verify_cpu
127127

128+
/*
129+
* The secondary_startup_64_no_verify entry point is only used by
130+
* SEV-ES guests. In those guests the call to verify_cpu() would cause
131+
* #VC exceptions which can not be handled at this stage of secondary
132+
* CPU bringup.
133+
*
134+
* All non SEV-ES systems, especially Intel systems, need to execute
135+
* verify_cpu() above to make sure NX is enabled.
136+
*/
137+
SYM_INNER_LABEL(secondary_startup_64_no_verify, SYM_L_GLOBAL)
138+
UNWIND_HINT_EMPTY
139+
128140
/*
129141
* Retrieve the modifier (SME encryption mask if SME is active) to be
130142
* added to the initial pgdir entry that will be programmed into CR3.

arch/x86/realmode/init.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ static void sme_sev_setup_real_mode(struct trampoline_header *th)
4646
th->flags |= TH_FLAGS_SME_ACTIVE;
4747

4848
if (sev_es_active()) {
49+
/*
50+
* Skip the call to verify_cpu() in secondary_startup_64 as it
51+
* will cause #VC exceptions when the AP can't handle them yet.
52+
*/
53+
th->start = (u64) secondary_startup_64_no_verify;
54+
4955
if (sev_es_setup_ap_jump_table(real_mode_header))
5056
panic("Failed to get/update SEV-ES AP Jump Table");
5157
}

0 commit comments

Comments
 (0)