Skip to content

Commit c2a0304

Browse files
joergroedelsuryasaimadhu
authored andcommitted
x86/boot/compressed/64: Call set_sev_encryption_mask() earlier
Call set_sev_encryption_mask() while still on the stage 1 #VC-handler because the stage 2 handler needs the kernel's own page tables to be set up, to which calling set_sev_encryption_mask() is a prerequisite. Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 29dcc60 commit c2a0304

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

arch/x86/boot/compressed/head_64.S

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,16 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
543543
rep stosq
544544

545545
/*
546-
* Load stage2 IDT and switch to our own page-table
546+
* If running as an SEV guest, the encryption mask is required in the
547+
* page-table setup code below. When the guest also has SEV-ES enabled
548+
* set_sev_encryption_mask() will cause #VC exceptions, but the stage2
549+
* handler can't map its GHCB because the page-table is not set up yet.
550+
* So set up the encryption mask here while still on the stage1 #VC
551+
* handler. Then load stage2 IDT and switch to the kernel's own
552+
* page-table.
547553
*/
548554
pushq %rsi
555+
call set_sev_encryption_mask
549556
call load_stage2_idt
550557
call initialize_identity_maps
551558
popq %rsi

arch/x86/boot/compressed/ident_map_64.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ static void add_identity_map(unsigned long start, unsigned long end)
105105
/* Locates and clears a region for a new top level page table. */
106106
void initialize_identity_maps(void)
107107
{
108-
/* If running as an SEV guest, the encryption mask is required. */
109-
set_sev_encryption_mask();
110-
111108
/* Exclude the encryption mask from __PHYSICAL_MASK */
112109
physical_mask &= ~sme_me_mask;
113110

0 commit comments

Comments
 (0)