Commit d49a0626 authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

arch: Introduce CONFIG_FUNCTION_ALIGNMENT



Generic function-alignment infrastructure.

Architectures can select FUNCTION_ALIGNMENT_xxB symbols; the
FUNCTION_ALIGNMENT symbol is then set to the largest such selected
size, 0 otherwise.

From this the -falign-functions compiler argument and __ALIGN macro
are set.

This incorporates the DEBUG_FORCE_FUNCTION_ALIGN_64B knob and future
alignment requirements for x86_64 (later in this series) into a single
place.

NOTE: also removes the 0x90 filler byte from the generic __ALIGN
      primitive, that value makes no sense outside of x86.

NOTE: .balign 0 reverts to a no-op.

Requested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220915111143.719248727@infradead.org
parent 24a9c543
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1004,8 +1004,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
@@ -1428,4 +1428,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)")
+2 −0
Original line number Diff line number Diff line
@@ -290,6 +290,8 @@ config X86
	select X86_FEATURE_NAMES		if PROC_FS
	select PROC_PID_ARCH_STATUS		if PROC_FS
	select HAVE_ARCH_NODE_DEV_GROUP		if X86_SGX
	select FUNCTION_ALIGNMENT_16B		if X86_64 || X86_ALIGNMENT_16
	select FUNCTION_ALIGNMENT_4B
	imply IMA_SECURE_AND_OR_TRUSTED_BOOT    if EFI
	select HAVE_DYNAMIC_FTRACE_NO_PATCHABLE

Loading