Skip to contentSkip to conversation

powerpc/stack_protector: Fix external modules building

RFC PATCH In review Alexey Kardashevskiy 3 participants 4 messages Jan 10, 2019 – Jan 11, 2019 PowerPC

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 powerpc/stack_protector: Fix external modules building

c3ff2a519 "powerpc/32: add stack protector support" addes stack protector support so now powerpc's "prepare" target depends on prepare0 (via stack_protector_prepare target).

It works fine until we try build an external module where it fails with:
Run: 'make -j128 SYSSRC=/home/aik/p/kernel SYSOUT=/home/aik/pbuild/kernel-le-pseries/ ARCH=powerpc' make[1]: Entering directory '/home/aik/p/kernel'
make[2]: Entering directory '/home/aik/pbuild/kernel-le-pseries'
make[2]: *** No rule to make target 'prepare0', needed by 'stack_protector_prepare'. Stop.

The reason for that is that the main Linux Makefile defines "prepare0" only if KBUILD_EXTMOD=="".

This hacks powerpc's Makefile to make external modules build again.

Fixes c3ff2a519 "powerpc/32: add stack protector support"

---

It has been suggested that there is a better way of fixing this hence RFC.

---
 arch/powerpc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/Makefile +4 -0
index 488c9ed..0492f62 100644
@@ -419,7 +419,11 @@ archheaders:
 ifdef CONFIG_STACKPROTECTOR
 prepare: stack_protector_prepare
 
+ifeq ($(KBUILD_EXTMOD),)
 stack_protector_prepare: prepare0
+else
+stack_protector_prepare:
+endif
 ifdef CONFIG_PPC64
 	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
 else
Signature · 1 line
2.17.1
#1 lore raw
Quoted 33 lines · Alexey Kardashevskiy

c3ff2a519 "powerpc/32: add stack protector support" addes stack protector support so now powerpc's "prepare" target depends on prepare0 (via stack_protector_prepare target).

It works fine until we try build an external module where it fails with:
Run: 'make -j128 SYSSRC=/home/aik/p/kernel SYSOUT=/home/aik/pbuild/kernel-le-pseries/ ARCH=powerpc' make[1]: Entering directory '/home/aik/p/kernel'
make[2]: Entering directory '/home/aik/pbuild/kernel-le-pseries'
make[2]: *** No rule to make target 'prepare0', needed by 'stack_protector_prepare'. Stop.

The reason for that is that the main Linux Makefile defines "prepare0" only if KBUILD_EXTMOD=="".

This hacks powerpc's Makefile to make external modules build again.

Fixes c3ff2a519 "powerpc/32: add stack protector support"

---

It has been suggested that there is a better way of fixing this hence RFC.

---
 arch/powerpc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/Makefile +0 -0
index 488c9ed..0492f62 100644

arch/powerpc/Makefile archheaders: · line 426

Quoted 8 lines
arch/powerpc/Makefile +4 -0
@@ -419,7 +419,11 @@ archheaders:
 ifdef CONFIG_STACKPROTECTOR
 prepare: stack_protector_prepare
 
+ifeq ($(KBUILD_EXTMOD),)
 stack_protector_prepare: prepare0
+else
+stack_protector_prepare:
+endif

Honestly, I think this is ugly.

Do you want me to send an alternative solution?

Quoted 6 lines
arch/powerpc/Makefile +0 -1
 ifdef CONFIG_PPC64
        $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
 else
--

2.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 46 lines · Masahiro Yamada
Quoted 33 lines · Alexey Kardashevskiy

c3ff2a519 "powerpc/32: add stack protector support" addes stack protector support so now powerpc's "prepare" target depends on prepare0 (via stack_protector_prepare target).

It works fine until we try build an external module where it fails with:
Run: 'make -j128 SYSSRC=/home/aik/p/kernel SYSOUT=/home/aik/pbuild/kernel-le-pseries/ ARCH=powerpc' make[1]: Entering directory '/home/aik/p/kernel'
make[2]: Entering directory '/home/aik/pbuild/kernel-le-pseries'
make[2]: *** No rule to make target 'prepare0', needed by 'stack_protector_prepare'. Stop.

The reason for that is that the main Linux Makefile defines "prepare0" only if KBUILD_EXTMOD=="".

This hacks powerpc's Makefile to make external modules build again.

Fixes c3ff2a519 "powerpc/32: add stack protector support"

---

It has been suggested that there is a better way of fixing this hence RFC.

---
 arch/powerpc/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/Makefile +0 -0
index 488c9ed..0492f62 100644

arch/powerpc/Makefile archheaders: · line 426

Quoted 8 lines
arch/powerpc/Makefile +4 -0
@@ -419,7 +419,11 @@ archheaders:
 ifdef CONFIG_STACKPROTECTOR
 prepare: stack_protector_prepare
 
+ifeq ($(KBUILD_EXTMOD),)
 stack_protector_prepare: prepare0
+else
+stack_protector_prepare:
+endif

Honestly, I think this is ugly.

Quoted 1 line

Do you want me to send an alternative solution?

YES! Thanks :)

Quoted 12 lines
Quoted 10 lines
arch/powerpc/Makefile +0 -1
 ifdef CONFIG_PPC64
        $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
 else
--

2.17.1

Signature · 1 line
Alexey
#3 lore raw
In reply to Masahiro Yamada
Quoted 1 line · Masahiro Yamada

On Thu, Jan 10, 2019 at 2:44 PM Alexey Kardashevskiy <[email protected]> wrote:

...

Quoted 8 lines
Quoted 8 lines
arch/powerpc/Makefile +0 -0
index 488c9ed..0492f62 100644
@@ -419,7 +419,11 @@ archheaders:
 ifdef CONFIG_STACKPROTECTOR
 prepare: stack_protector_prepare
 
Quoted 8 lines

arch/powerpc/Makefile archheaders: · line 426

Quoted 5 lines
arch/powerpc/Makefile +4 -0
+ifeq ($(KBUILD_EXTMOD),)
 stack_protector_prepare: prepare0
+else
+stack_protector_prepare:
+endif

Honestly, I think this is ugly.

Yes I would call it a hack :)

Quoted 1 line

Do you want me to send an alternative solution?

I don't grok how external modules are built well enough to work out what the right solution is. So if you can come up with something better that would be awesome.

cheers