Skip to content

Commit bf5ff27

Browse files
joergroedelsuryasaimadhu
authored andcommitted
x86/realmode: Add SEV-ES specific trampoline entry point
The code at the trampoline entry point is executed in real-mode. In real-mode, #VC exceptions can't be handled so anything that might cause such an exception must be avoided. In the standard trampoline entry code this is the WBINVD instruction and the call to verify_cpu(), which are both not needed anyway when running as an SEV-ES guest. Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20200907131613.12703-66-joro@8bytes.org
1 parent 1a222de commit bf5ff27

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

arch/x86/include/asm/realmode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ struct real_mode_header {
2121
/* SMP trampoline */
2222
u32 trampoline_start;
2323
u32 trampoline_header;
24+
#ifdef CONFIG_AMD_MEM_ENCRYPT
25+
u32 sev_es_trampoline_start;
26+
#endif
2427
#ifdef CONFIG_X86_64
2528
u32 trampoline_pgd;
2629
#endif

arch/x86/realmode/rm/header.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ SYM_DATA_START(real_mode_header)
2020
/* SMP trampoline */
2121
.long pa_trampoline_start
2222
.long pa_trampoline_header
23+
#ifdef CONFIG_AMD_MEM_ENCRYPT
24+
.long pa_sev_es_trampoline_start
25+
#endif
2326
#ifdef CONFIG_X86_64
2427
.long pa_trampoline_pgd;
2528
#endif

arch/x86/realmode/rm/trampoline_64.S

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ SYM_CODE_START(trampoline_start)
5656
testl %eax, %eax # Check for return code
5757
jnz no_longmode
5858

59+
.Lswitch_to_protected:
5960
/*
6061
* GDT tables in non default location kernel can be beyond 16MB and
6162
* lgdt will not be able to load the address as in real mode default
@@ -80,6 +81,25 @@ no_longmode:
8081
jmp no_longmode
8182
SYM_CODE_END(trampoline_start)
8283

84+
#ifdef CONFIG_AMD_MEM_ENCRYPT
85+
/* SEV-ES supports non-zero IP for entry points - no alignment needed */
86+
SYM_CODE_START(sev_es_trampoline_start)
87+
cli # We should be safe anyway
88+
89+
LJMPW_RM(1f)
90+
1:
91+
mov %cs, %ax # Code and data in the same place
92+
mov %ax, %ds
93+
mov %ax, %es
94+
mov %ax, %ss
95+
96+
# Setup stack
97+
movl $rm_stack_end, %esp
98+
99+
jmp .Lswitch_to_protected
100+
SYM_CODE_END(sev_es_trampoline_start)
101+
#endif /* CONFIG_AMD_MEM_ENCRYPT */
102+
83103
#include "../kernel/verify_cpu.S"
84104

85105
.section ".text32","ax"

0 commit comments

Comments
 (0)