Skip to content

Commit

Permalink
amd64: remove lfence after swapgs on syscall entry
Browse files Browse the repository at this point in the history
According to the description of SBSS issue at
https://software.intel.com/content/www/us/en/develop/articles/software-security-guidance/technical-documentation/speculative-behavior-swapgs-and-segment-registers.html
lfence after swapgs is needed only for the case when swapgs could be
speculatively executed.  Since syscall entry, unlike exception and
interrupt entries, executes swapgs unconditionally, there is no
opportunity for speculation.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D31682
  • Loading branch information
kostikbel committed Aug 26, 2021
1 parent 58d868c commit 7aa47ca
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions sys/amd64/amd64/exception.S
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ prot_addrf:
SUPERALIGN_TEXT
IDTVEC(fast_syscall_pti)
swapgs
lfence
cmpq $~0,PCPU(UCR3)
je fast_syscall_common
movq %rax,PCPU(SCRATCH_RAX)
Expand All @@ -535,7 +534,6 @@ IDTVEC(fast_syscall_pti)
SUPERALIGN_TEXT
IDTVEC(fast_syscall)
swapgs
lfence
fast_syscall_common:
movq %rsp,PCPU(SCRATCH_RSP)
movq PCPU(RSP0),%rsp
Expand Down

0 comments on commit 7aa47ca

Please sign in to comment.