linux-stable/arch/x86/entry
Pawan Gupta bd53ec80f2 x86/bhi: Add support for clearing branch history at syscall entry
commit 7390db8aea upstream.

Branch History Injection (BHI) attacks may allow a malicious application to
influence indirect branch prediction in kernel by poisoning the branch
history. eIBRS isolates indirect branch targets in ring0.  The BHB can
still influence the choice of indirect branch predictor entry, and although
branch predictor entries are isolated between modes when eIBRS is enabled,
the BHB itself is not isolated between modes.

Alder Lake and new processors supports a hardware control BHI_DIS_S to
mitigate BHI.  For older processors Intel has released a software sequence
to clear the branch history on parts that don't support BHI_DIS_S. Add
support to execute the software sequence at syscall entry and VMexit to
overwrite the branch history.

For now, branch history is not cleared at interrupt entry, as malicious
applications are not believed to have sufficient control over the
registers, since previous register state is cleared at interrupt
entry. Researchers continue to poke at this area and it may become
necessary to clear at interrupt entry as well in the future.

This mitigation is only defined here. It is enabled later.

Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Co-developed-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Daniel Sneddon <daniel.sneddon@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-10 16:19:43 +02:00
..
syscalls compat: remove some compat entry points 2021-09-08 15:32:35 -07:00
vdso x86/mm: Fix VDSO and VVAR placement on 5-level paging machines 2023-08-16 18:21:59 +02:00
vsyscall x86/vsyscall_emu/64: Don't use RET in vsyscall emulation 2022-07-23 12:54:00 +02:00
Makefile x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-17 14:24:15 +02:00
calling.h x86/retbleed: Add fine grained Kconfig knobs 2022-07-23 12:54:10 +02:00
common.c x86/syscall: Don't force use of indirect calls for system calls 2024-04-10 16:19:43 +02:00
entry.S x86/bugs: Add asm helpers for executing VERW 2024-04-10 16:18:47 +02:00
entry_32.S x86/entry_32: Add VERW just before userspace transition 2024-04-10 16:18:48 +02:00
entry_64.S x86/bhi: Add support for clearing branch history at syscall entry 2024-04-10 16:19:43 +02:00
entry_64_compat.S x86/bhi: Add support for clearing branch history at syscall entry 2024-04-10 16:19:43 +02:00
syscall_32.c x86/syscall: Don't force use of indirect calls for system calls 2024-04-10 16:19:43 +02:00
syscall_64.c x86/syscall: Don't force use of indirect calls for system calls 2024-04-10 16:19:43 +02:00
syscall_x32.c x86/syscall: Don't force use of indirect calls for system calls 2024-04-10 16:19:43 +02:00
thunk_32.S x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-17 14:24:15 +02:00
thunk_64.S x86/entry: Build thunk_$(BITS) only if CONFIG_PREEMPTION=y 2022-08-17 14:24:15 +02:00