Skip to content

Commit 85c7cbd

Browse files
sigsegv7Andy-Python-Programmer
authored andcommitted
misc(kernel): use load fence before swapgs
Avoid potential speculative execution issues with swapgs, such as swapgs being speculatively missed. Signed-off-by: Ian Moffett <[email protected]>
1 parent 6874ab3 commit 85c7cbd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ interrupt_handler_%1:
3939
test qword [rsp + 16], 0x3
4040
; skip the SWAPGS instruction if CS & 0b11 == 0b00.
4141
jz .dont_swapgs
42+
lfence
4243
swapgs
4344
.dont_swapgs:
4445

@@ -70,6 +71,7 @@ interrupt_handler_%1:
7071
test qword [rsp + 8], 0x3
7172
; skip the SWAPGS instruction if CS & 0b11 == 0b00.
7273
jz .dont_swapgs_again
74+
lfence
7375
swapgs
7476
.dont_swapgs_again:
7577

0 commit comments

Comments
 (0)