Skip to content

Commit

Permalink
x86/boot/compressed/64: Call set_sev_encryption_mask() earlier
Browse files Browse the repository at this point in the history
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 <jroedel@suse.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200907131613.12703-21-joro@8bytes.org
  • Loading branch information
Joerg Roedel authored and Borislav Petkov committed Sep 7, 2020
1 parent 29dcc60 commit c2a0304
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 8 additions & 1 deletion arch/x86/boot/compressed/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,16 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
rep stosq

/*
* Load stage2 IDT and switch to our own page-table
* If running as an SEV guest, the encryption mask is required in the
* page-table setup code below. When the guest also has SEV-ES enabled
* set_sev_encryption_mask() will cause #VC exceptions, but the stage2
* handler can't map its GHCB because the page-table is not set up yet.
* So set up the encryption mask here while still on the stage1 #VC
* handler. Then load stage2 IDT and switch to the kernel's own
* page-table.
*/
pushq %rsi
call set_sev_encryption_mask
call load_stage2_idt
call initialize_identity_maps
popq %rsi
Expand Down
3 changes: 0 additions & 3 deletions arch/x86/boot/compressed/ident_map_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ static void add_identity_map(unsigned long start, unsigned long end)
/* Locates and clears a region for a new top level page table. */
void initialize_identity_maps(void)
{
/* If running as an SEV guest, the encryption mask is required. */
set_sev_encryption_mask();

/* Exclude the encryption mask from __PHYSICAL_MASK */
physical_mask &= ~sme_me_mask;

Expand Down

0 comments on commit c2a0304

Please sign in to comment.