Skip to content

Commit 061f2b6

Browse files
nathanchancetamaralyne
authored andcommitted
powerpc: Adjust adding stack protector flags to KBUILD_CLAGS for clang
commit bee08a9e6ab03caf14481d97b35a258400ffab8f upstream. After fixing the HAVE_STACKPROTECTER checks for clang's in-progress per-task stack protector support [1], the build fails during prepare0 because '-mstack-protector-guard-offset' has not been added to KBUILD_CFLAGS yet but the other '-mstack-protector-guard' flags have. clang: error: '-mstack-protector-guard=tls' is used without '-mstack-protector-guard-offset', and there is no default clang: error: '-mstack-protector-guard=tls' is used without '-mstack-protector-guard-offset', and there is no default make[4]: *** [scripts/Makefile.build:229: scripts/mod/empty.o] Error 1 make[4]: *** [scripts/Makefile.build:102: scripts/mod/devicetable-offsets.s] Error 1 Mirror other architectures and add all '-mstack-protector-guard' flags to KBUILD_CFLAGS atomically during stack_protector_prepare, which resolves the issue and allows clang's implementation to fully work with the kernel. Cc: [email protected] # 6.1+ Link: llvm/llvm-project#110928 [1] Reviewed-by: Keith Packard <[email protected]> Tested-by: Keith Packard <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://patch.msgid.link/20241009-powerpc-fix-stackprotector-test-clang-v2-2-12fb86b31857@kernel.org Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2fb5b56 commit 061f2b6

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

arch/powerpc/Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ KBUILD_AFLAGS += -m$(BITS)
8989
KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
9090
endif
9191

92-
cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
93-
ifdef CONFIG_PPC64
94-
cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
95-
else
96-
cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
97-
endif
98-
9992
LDFLAGS_vmlinux-y := -Bstatic
10093
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
10194
LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) += -z notext
@@ -408,9 +401,11 @@ prepare: stack_protector_prepare
408401
PHONY += stack_protector_prepare
409402
stack_protector_prepare: prepare0
410403
ifdef CONFIG_PPC64
411-
$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
404+
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 \
405+
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
412406
else
413-
$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
407+
$(eval KBUILD_CFLAGS += -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 \
408+
-mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
414409
endif
415410
endif
416411

0 commit comments

Comments
 (0)