]> git.baikalelectronics.ru Git - kernel.git/commit
x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()
authorLai Jiangshan <laijs@linux.alibaba.com>
Fri, 26 Nov 2021 10:11:21 +0000 (18:11 +0800)
committerBorislav Petkov <bp@suse.de>
Fri, 3 Dec 2021 17:55:47 +0000 (18:55 +0100)
commit1ef48a7c6e8a8f93d4bb4c365afc15f0a1f0b785
treefb19b8238d7f71203addc526d7393944ee8c4491
parent99f82ab04b0b68a73c77ca6e4bd63dcdb836ca06
x86/entry: Add a fence for kernel entry SWAPGS in paranoid_entry()

Commit

  e05deb47eed1d ("x86/speculation: Prepare entry code for Spectre v1 swapgs mitigations")

added FENCE_SWAPGS_{KERNEL|USER}_ENTRY for conditional SWAPGS. In
paranoid_entry(), it uses only FENCE_SWAPGS_KERNEL_ENTRY for both
branches. This is because the fence is required for both cases since the
CR3 write is conditional even when PTI is enabled.

But

  f86cbc276c054 ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry")

changed the order of SWAPGS and the CR3 write. And it missed the needed
FENCE_SWAPGS_KERNEL_ENTRY for the user gsbase case.

Add it back by changing the branches so that FENCE_SWAPGS_KERNEL_ENTRY
can cover both branches.

  [ bp: Massage, fix typos, remove obsolete comment while at it. ]

Fixes: f86cbc276c054 ("x86/entry/64: Switch CR3 before SWAPGS in paranoid entry")
Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20211126101209.8613-2-jiangshanlai@gmail.com
arch/x86/entry/entry_64.S