Skip to content

Commit 1105ab4

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
x86/sev: Disable jump tables in SEV startup code
When retpolines and IBT are both disabled, the compiler is free to use jump tables to optimize switch instructions. However, these are emitted by Clang as absolute references into .rodata: jmp *-0x7dfffe90(,%r9,8) R_X86_64_32S .rodata+0x170 Given that this code will execute before that address in .rodata has even been mapped, it is guaranteed to crash a SEV-SNP guest in a way that is difficult to diagnose. So disable jump tables when building this code. It would be better if we could attach this annotation to the __head macro but this appears to be impossible. Reported-by: Linus Torvalds <[email protected]> Tested-by: Linus Torvalds <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9c5968d commit 1105ab4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/x86/coco/sev/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
obj-y += core.o
44

5+
# jump tables are emitted using absolute references in non-PIC code
6+
# so they cannot be used in the early SEV startup code
7+
CFLAGS_core.o += -fno-jump-tables
8+
59
ifdef CONFIG_FUNCTION_TRACER
610
CFLAGS_REMOVE_core.o = -pg
711
endif

0 commit comments

Comments
 (0)