Re: [PATCH 3/3] powerpc: Include -m32 / -m64 for stack protector Kconfig test

From
Christophe Leroy <hidden>
Date
2024-10-08 05:14:35
Also in
linux-patches, llvm
Reply to
Nathan Chancellor, 2024-10-08

Le 08/10/2024 à 06:22, Nathan Chancellor a écrit :
Kbuild uses the powerpc64le-linux-gnu target for clang, which causes the
Kconfig check for 32-bit powerpc stack protector support to fail because
nothing flips the target to 32-bit:

   $ clang --target=powerpc64le-linux-gnu \
           -mstack-protector-guard=tls
           -mstack-protector-guard-reg=r2 \
           -mstack-protector-guard-offset=0 \
           -x c -c -o /dev/null /dev/null
   clang: error: invalid value 'r2' in 'mstack-protector-guard-reg=', expected one of: r13
Why is there any restriction at all on which register can be used ? I can't see such restriction in GCC documentation : https://gcc.gnu.org/onlinedocs/gcc/RS_002f6000-and-PowerPC-Options.html


quoted hunk ↗ jump to hunk
Use the Kconfig macro '$(m32-flag)', which expands to '-m32' when
supported, in the stack protector support cc-option call to properly
switch the target to a 32-bit one, which matches what happens in Kbuild.
While the 64-bit macro does not strictly need it, add the equivalent
64-bit option for symmetry.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
  arch/powerpc/Kconfig | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index eb98050b8c016bb23887a9d669d29e69d933c9c8..6aaca48955a34b2a38af1415bfa36f74f35c3f3e 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -275,8 +275,8 @@ config PPC
  	select HAVE_RSEQ
  	select HAVE_SETUP_PER_CPU_AREA		if PPC64
  	select HAVE_SOFTIRQ_ON_OWN_STACK
-	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
-	select HAVE_STACKPROTECTOR		if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=0)
+	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
+	select HAVE_STACKPROTECTOR		if PPC64 && $(cc-option,$(m64-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=0)
You modify the exact same line than Patch 1, if this patch is really required it should be squashed into patch 1 I think.
  	select HAVE_STATIC_CALL			if PPC32
  	select HAVE_SYSCALL_TRACEPOINTS
  	select HAVE_VIRT_CPU_ACCOUNTING
  
Thread (10 messages) 10 messages, 3 authors, last reply 2024-10-08
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help