Commit 94a85511 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull x86 core updates from Borislav Petkov:

 - Add the call depth tracking mitigation for Retbleed which has been
   long in the making. It is a lighterweight software-only fix for
   Skylake-based cores where enabling IBRS is a big hammer and causes a
   significant performance impact.

   What it basically does is, it aligns all kernel functions to 16 bytes
   boundary and adds a 16-byte padding before the function, objtool
   collects all functions' locations and when the mitigation gets
   applied, it patches a call accounting thunk which is used to track
   the call depth of the stack at any time.

   When that call depth reaches a magical, microarchitecture-specific
   value for the Return Stack Buffer, the code stuffs that RSB and
   avoids its underflow which could otherwise lead to the Intel variant
   of Retbleed.

   This software-only solution brings a lot of the lost performance
   back, as benchmarks suggest:

       https://lore.kernel.org/all/20220915111039.092790446@infradead.org/

   That page above also contains a lot more detailed explanation of the
   whole mechanism

 - Implement a new control flow integrity scheme called FineIBT which is
   based on the software kCFI implementation and uses hardware IBT
   support where present to annotate and track indirect branches using a
   hash to validate them

 - Other misc fixes and cleanups

* tag 'x86_core_for_v6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (80 commits)
  x86/paravirt: Use common macro for creating simple asm paravirt functions
  x86/paravirt: Remove clobber bitmask from .parainstructions
  x86/debug: Include percpu.h in debugreg.h to get DECLARE_PER_CPU() et al
  x86/cpufeatures: Move X86_FEATURE_CALL_DEPTH from bit 18 to bit 19 of word 11, to leave space for WIP X86_FEATURE_SGX_EDECCSSA bit
  x86/Kconfig: Enable kernel IBT by default
  x86,pm: Force out-of-line memcpy()
  objtool: Fix weak hole vs prefix symbol
  objtool: Optimize elf_dirty_reloc_sym()
  x86/cfi: Add boot time hash randomization
  x86/cfi: Boot time selection of CFI scheme
  x86/ibt: Implement FineIBT
  objtool: Add --cfi to generate the .cfi_sites section
  x86: Add prefix symbols for function padding
  objtool: Add option to generate prefix symbols
  objtool: Avoid O(bloody terrible) behaviour -- an ode to libelf
  objtool: Slice up elf_create_section_symbol()
  kallsyms: Revert "Take callthunks into account"
  x86: Unconfuse CONFIG_ and X86_FEATURE_ namespaces
  x86/retpoline: Fix crash printing warning
  x86/paravirt: Fix a !PARAVIRT build warning
  ...
parents 93761c93 f1a033cc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1006,8 +1006,8 @@ KBUILD_CFLAGS += $(CC_FLAGS_CFI)
export CC_FLAGS_CFI
endif

ifdef CONFIG_DEBUG_FORCE_FUNCTION_ALIGN_64B
KBUILD_CFLAGS += -falign-functions=64
ifneq ($(CONFIG_FUNCTION_ALIGNMENT),0)
KBUILD_CFLAGS += -falign-functions=$(CONFIG_FUNCTION_ALIGNMENT)
endif

# arch Makefile may override CC so keep this after arch Makefile is included
+24 −0
Original line number Diff line number Diff line
@@ -1438,4 +1438,28 @@ source "kernel/gcov/Kconfig"

source "scripts/gcc-plugins/Kconfig"

config FUNCTION_ALIGNMENT_4B
	bool

config FUNCTION_ALIGNMENT_8B
	bool

config FUNCTION_ALIGNMENT_16B
	bool

config FUNCTION_ALIGNMENT_32B
	bool

config FUNCTION_ALIGNMENT_64B
	bool

config FUNCTION_ALIGNMENT
	int
	default 64 if FUNCTION_ALIGNMENT_64B
	default 32 if FUNCTION_ALIGNMENT_32B
	default 16 if FUNCTION_ALIGNMENT_16B
	default 8 if FUNCTION_ALIGNMENT_8B
	default 4 if FUNCTION_ALIGNMENT_4B
	default 0

endmenu
+1 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ config IA64
	select NUMA if !FLATMEM
	select PCI_MSI_ARCH_FALLBACKS if PCI_MSI
	select ZONE_DMA32
	select FUNCTION_ALIGNMENT_32B
	default y
	help
	  The Itanium Processor Family is Intel's 64-bit successor to
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ KBUILD_AFLAGS_KERNEL := -mconstant-gp
EXTRA		:=

cflags-y	:= -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \
		   -falign-functions=32 -frename-registers -fno-optimize-sibling-calls
		   -frename-registers -fno-optimize-sibling-calls
KBUILD_CFLAGS_KERNEL := -mconstant-gp

GAS_STATUS	= $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)")
+5 −0
Original line number Diff line number Diff line
@@ -444,6 +444,11 @@ void apply_returns(s32 *start, s32 *end)
{
}

void apply_fineibt(s32 *start_retpoline, s32 *end_retpoline,
		   s32 *start_cfi, s32 *end_cfi)
{
}

void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
{
}
Loading