All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] powerpc: Build fixes
@ 2023-04-26  5:58 Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes Nicholas Piggin
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

This series is against powerpc next. The first two patches are
independent build fixes for recent patches. Patches 3-5 separate
boot Makefile BOOTCFLAGS and BOOTASFLAGS and stops passing some
C code generation flags to the assembler which causes some
warnings for llvm. Patches 6-9 are not fixes but a bunch of other
improvements I noticed along the way.

Thanks,
Nick

Nicholas Piggin (9):
  powerpc: Fix merge conflict between pcrel and copy_thread changes
  powerpc/64s: Disable pcrel code model on Clang
  powerpc/boot: Seperate target flags from BOOTCFLAGS
  powerpc/boot: Seperate CPP flags from BOOTCFLAGS
  powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS
  powerpc/boot: Clean up Makefile after cflags and asflags separation
  powerpc/build: Remove -pipe from compilation flags
  powerpc/64s: Permit d-form memops in asm when building with prefix on
    clang
  powerpc/64s: Work around llvm-as not recognising pla

 arch/powerpc/Kconfig               | 19 ++++++++-
 arch/powerpc/Makefile              |  2 +-
 arch/powerpc/boot/Makefile         | 62 +++++++++++++++---------------
 arch/powerpc/include/asm/atomic.h  |  8 ++--
 arch/powerpc/include/asm/io.h      |  2 +-
 arch/powerpc/include/asm/ppc_asm.h |  5 +++
 arch/powerpc/include/asm/uaccess.h |  4 +-
 arch/powerpc/kernel/interrupt_64.S |  2 +-
 arch/powerpc/kernel/vector.S       |  6 +++
 9 files changed, 70 insertions(+), 40 deletions(-)

-- 
2.40.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 2/9] powerpc/64s: Disable pcrel code model on Clang Nicholas Piggin
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Fix a conflict between commit 4e991e3c16a35 ("powerpc: add CFUNC
assembly label annotation") and commit b504b6aade040 ("powerpc:
differentiate kthread from user kernel thread start").

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/interrupt_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/interrupt_64.S b/arch/powerpc/kernel/interrupt_64.S
index 6730d676284c..bd863702d812 100644
--- a/arch/powerpc/kernel/interrupt_64.S
+++ b/arch/powerpc/kernel/interrupt_64.S
@@ -756,7 +756,7 @@ _GLOBAL(ret_from_kernel_user_thread)
 	b	.Lsyscall_exit
 
 _GLOBAL(start_kernel_thread)
-	bl	schedule_tail
+	bl	CFUNC(schedule_tail)
 	mtctr	r14
 	mr	r3,r15
 #ifdef CONFIG_PPC64_ELF_ABI_V2
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/9] powerpc/64s: Disable pcrel code model on Clang
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 3/9] powerpc/boot: Seperate target flags from BOOTCFLAGS Nicholas Piggin
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Clang has a bug that casues the pcrel code model not to be used when any of
-msoft-float, -mno-altivec, or -mno-vsx are set. Leaving these off causes
FP/vector instructions to be generated, causing crashes. So disable pcrel
for clang for now.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Kconfig | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 7a0f25a09759..261e9453b43c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -8,7 +8,12 @@ config CC_HAS_PREFIXED
 	def_bool PPC64 && $(cc-option, -mcpu=power10 -mprefixed)
 
 config CC_HAS_PCREL
-	def_bool PPC64 && $(cc-option, -mcpu=power10 -mpcrel)
+	# Clang has a bug (https://github.com/llvm/llvm-project/issues/62372)
+	# where pcrel code is not generated if -msoft-float, -mno-altivec, or
+	# -mno-vsx options are also given. Without these options, fp/vec
+	# instructions are generated from regular kernel code. So Clang can't
+	# do pcrel yet.
+	def_bool PPC64 && CC_IS_GCC &&  $(cc-option, -mcpu=power10 -mpcrel)
 
 config 32BIT
 	bool
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/9] powerpc/boot: Seperate target flags from BOOTCFLAGS
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 2/9] powerpc/64s: Disable pcrel code model on Clang Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 4/9] powerpc/boot: Seperate CPP " Nicholas Piggin
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Add BOOTTARGETFLAGS variable with target / ABI options common to
CFLAGS and AFLAGS.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/Makefile | 40 ++++++++++++++++++++------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 85cde5bf04b7..84a5b630c739 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -41,36 +41,48 @@ BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		 $(LINUXINCLUDE)
 
 ifdef CONFIG_PPC64_BOOT_WRAPPER
-BOOTCFLAGS	+= -m64
+BOOTTARGETFLAGS	:= -m64
 ifdef CONFIG_PPC64_ELF_ABI_V2
-BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
+BOOTTARGETFLAGS	+= $(call cc-option,-mabi=elfv2)
 endif
 else
-BOOTCFLAGS	+= -m32
+BOOTTARGETFLAGS	:= -m32
 endif
 
 ifdef CONFIG_TARGET_CPU_BOOL
-BOOTCFLAGS	+= -mcpu=$(CONFIG_TARGET_CPU)
+BOOTTARGETFLAGS	+= -mcpu=$(CONFIG_TARGET_CPU)
 else ifdef CONFIG_PPC64_BOOT_WRAPPER
 ifdef CONFIG_CPU_LITTLE_ENDIAN
-BOOTCFLAGS	+= -mcpu=powerpc64le
+BOOTTARGETFLAGS	+= -mcpu=powerpc64le
 else
-BOOTCFLAGS	+= -mcpu=powerpc64
+BOOTTARGETFLAGS	+= -mcpu=powerpc64
 endif
 endif
 
+$(obj)/4xx.o: BOOTTARGETFLAGS += -mcpu=405
+$(obj)/ebony.o: BOOTTARGETFLAGS += -mcpu=440
+$(obj)/cuboot-hotfoot.o: BOOTTARGETFLAGS += -mcpu=405
+$(obj)/cuboot-taishan.o: BOOTTARGETFLAGS += -mcpu=440
+$(obj)/cuboot-katmai.o: BOOTTARGETFLAGS += -mcpu=440
+$(obj)/cuboot-acadia.o: BOOTTARGETFLAGS += -mcpu=405
+$(obj)/treeboot-iss4xx.o: BOOTTARGETFLAGS += -mcpu=405
+$(obj)/treeboot-currituck.o: BOOTTARGETFLAGS += -mcpu=405
+$(obj)/treeboot-akebono.o: BOOTTARGETFLAGS += -mcpu=405
+
 BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
 ifdef CONFIG_CPU_BIG_ENDIAN
-BOOTCFLAGS	+= -mbig-endian
+BOOTTARGETFLAGS	+= -mbig-endian
 else
-BOOTCFLAGS	+= -mlittle-endian
+BOOTTARGETFLAGS	+= -mlittle-endian
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) $(BOOTCFLAGS) -nostdinc
 
 BOOTARFLAGS	:= -crD
 
+BOOTCFLAGS	+= $(BOOTTARGETFLAGS)
+
 ifdef CONFIG_CC_IS_CLANG
 BOOTCFLAGS += $(CLANG_FLAGS)
 BOOTAFLAGS += $(CLANG_FLAGS)
@@ -89,16 +101,6 @@ BOOTCFLAGS	+= -I$(objtree)/$(obj) -I$(srctree)/$(obj)
 
 DTC_FLAGS	?= -p 1024
 
-$(obj)/4xx.o: BOOTCFLAGS += -mcpu=405
-$(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
-$(obj)/cuboot-hotfoot.o: BOOTCFLAGS += -mcpu=405
-$(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
-$(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
-$(obj)/cuboot-acadia.o: BOOTCFLAGS += -mcpu=405
-$(obj)/treeboot-iss4xx.o: BOOTCFLAGS += -mcpu=405
-$(obj)/treeboot-currituck.o: BOOTCFLAGS += -mcpu=405
-$(obj)/treeboot-akebono.o: BOOTCFLAGS += -mcpu=405
-
 # The pre-boot decompressors pull in a lot of kernel headers and other source
 # files. This creates a bit of a dependency headache since we need to copy
 # these files into the build dir, fix up any includes and ensure that dependent
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/9] powerpc/boot: Seperate CPP flags from BOOTCFLAGS
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (2 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 3/9] powerpc/boot: Seperate target flags from BOOTCFLAGS Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS Nicholas Piggin
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Add BOOTCPPFLAGS variable for the CPP options required by C and AS.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/Makefile | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 84a5b630c739..bfeb7a9fef9c 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,13 +32,15 @@ else
     BOOTAR := $(AR)
 endif
 
+BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
+BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
+
 BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
 		 $(call cc-option,-mno-prefixed) $(call cc-option,-mno-pcrel) \
 		 $(call cc-option,-mno-mma) \
 		 $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
-		 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
-		 $(LINUXINCLUDE)
+		 -pipe -fomit-frame-pointer -fno-builtin -fPIC
 
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTTARGETFLAGS	:= -m64
@@ -69,15 +71,13 @@ $(obj)/treeboot-iss4xx.o: BOOTTARGETFLAGS += -mcpu=405
 $(obj)/treeboot-currituck.o: BOOTTARGETFLAGS += -mcpu=405
 $(obj)/treeboot-akebono.o: BOOTTARGETFLAGS += -mcpu=405
 
-BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
-
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTTARGETFLAGS	+= -mbig-endian
 else
 BOOTTARGETFLAGS	+= -mlittle-endian
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) $(BOOTCFLAGS) -nostdinc
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) $(BOOTCFLAGS)
 
 BOOTARFLAGS	:= -crD
 
@@ -224,10 +224,10 @@ clean-files := $(zlib-) $(zlibheader-) $(zliblinuxheader-) \
 		empty.c zImage.coff.lds zImage.ps3.lds zImage.lds
 
 quiet_cmd_bootcc = BOOTCC  $@
-      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
+      cmd_bootcc = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCPPFLAGS) $(BOOTCFLAGS) -c -o $@ $<
 
 quiet_cmd_bootas = BOOTAS  $@
-      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
+      cmd_bootas = $(BOOTCC) -Wp,-MD,$(depfile) $(BOOTCPPFLAGS) $(BOOTAFLAGS) -c -o $@ $<
 
 quiet_cmd_bootar = BOOTAR  $@
       cmd_bootar = $(BOOTAR) $(BOOTARFLAGS) $@.$$$$ $(real-prereqs); mv $@.$$$$ $@
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (3 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 4/9] powerpc/boot: Seperate CPP " Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26 15:11   ` Linus Torvalds
  2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: Clean up Makefile after cflags and asflags separation Nicholas Piggin
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Linus Torvalds, Nicholas Piggin

BOOTCFLAGS no longer contains anything that BOOTASFLAGS needs (except
-pipe). Separate them to avoid fragility with cross-contamination of
flags which has caused several build problems.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/lkml/CAHk-=whyWUdJDeOBN1hRWYSkQkvzYiQ5RbSW5rJjExgnbSNX9Q@mail.gmail.com/
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index bfeb7a9fef9c..99f56c94177f 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -77,7 +77,7 @@ else
 BOOTTARGETFLAGS	+= -mlittle-endian
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) $(BOOTCFLAGS)
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) -pipe
 
 BOOTARFLAGS	:= -crD
 
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/9] powerpc/boot: Clean up Makefile after cflags and asflags separation
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (4 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: clean up Makefile flags Nicholas Piggin
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Tidy pass over boot Makefile. Move variables together where possible.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/Makefile | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 99f56c94177f..0982a7025e66 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,16 +32,6 @@ else
     BOOTAR := $(AR)
 endif
 
-BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
-BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
-
-BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
-		 $(call cc-option,-mno-prefixed) $(call cc-option,-mno-pcrel) \
-		 $(call cc-option,-mno-mma) \
-		 $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
-		 -pipe -fomit-frame-pointer -fno-builtin -fPIC
-
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTTARGETFLAGS	:= -m64
 ifdef CONFIG_PPC64_ELF_ABI_V2
@@ -77,11 +67,21 @@ else
 BOOTTARGETFLAGS	+= -mlittle-endian
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) -pipe
+BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
+BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
-BOOTARFLAGS	:= -crD
+BOOTCFLAGS	:= -pipe $(BOOTTARGETFLAGS) \
+		   -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+		   -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
+		   $(call cc-option,-mno-prefixed) \
+		   $(call cc-option,-mno-pcrel) \
+		   $(call cc-option,-mno-mma) \
+		   $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
+		   -fomit-frame-pointer -fno-builtin -fPIC
 
-BOOTCFLAGS	+= $(BOOTTARGETFLAGS)
+BOOTAFLAGS	:= -pipe $(BOOTTARGETFLAGS) -D__ASSEMBLY__
+
+BOOTARFLAGS	:= -crD
 
 ifdef CONFIG_CC_IS_CLANG
 BOOTCFLAGS += $(CLANG_FLAGS)
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/9] powerpc/boot: clean up Makefile flags
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (5 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: Clean up Makefile after cflags and asflags separation Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 7/9] powerpc/build: Remove -pipe from compilation flags Nicholas Piggin
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Tidy pass over boot Makefile. Move variables together where possible.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/boot/Makefile | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 99f56c94177f..0982a7025e66 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,16 +32,6 @@ else
     BOOTAR := $(AR)
 endif
 
-BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
-BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
-
-BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
-		 $(call cc-option,-mno-prefixed) $(call cc-option,-mno-pcrel) \
-		 $(call cc-option,-mno-mma) \
-		 $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
-		 -pipe -fomit-frame-pointer -fno-builtin -fPIC
-
 ifdef CONFIG_PPC64_BOOT_WRAPPER
 BOOTTARGETFLAGS	:= -m64
 ifdef CONFIG_PPC64_ELF_ABI_V2
@@ -77,11 +67,21 @@ else
 BOOTTARGETFLAGS	+= -mlittle-endian
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTTARGETFLAGS) -pipe
+BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
+BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
-BOOTARFLAGS	:= -crD
+BOOTCFLAGS	:= -pipe $(BOOTTARGETFLAGS) \
+		   -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+		   -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
+		   $(call cc-option,-mno-prefixed) \
+		   $(call cc-option,-mno-pcrel) \
+		   $(call cc-option,-mno-mma) \
+		   $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
+		   -fomit-frame-pointer -fno-builtin -fPIC
 
-BOOTCFLAGS	+= $(BOOTTARGETFLAGS)
+BOOTAFLAGS	:= -pipe $(BOOTTARGETFLAGS) -D__ASSEMBLY__
+
+BOOTARFLAGS	:= -crD
 
 ifdef CONFIG_CC_IS_CLANG
 BOOTCFLAGS += $(CLANG_FLAGS)
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 7/9] powerpc/build: Remove -pipe from compilation flags
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (6 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: clean up Makefile flags Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 8/9] powerpc/64s: Permit d-form memops in asm when building with prefix on clang Nicholas Piggin
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

x86 removed -pipe in commit 437e88ab8f9e2 ("x86/build: Remove -pipe from
KBUILD_CFLAGS") and the newer arm64 and riscv seem to have never used it,
so that seems to be the way the world's going.

Compile performance building defconfig on a POWER10 PowerNV system
was in the noise after 10 builds each. No point in adding options unless
they help something, so remove it.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Makefile      | 2 +-
 arch/powerpc/boot/Makefile | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dca73f673d70..76fc7cc26780 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -166,7 +166,7 @@ asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
 KBUILD_CPPFLAGS	+= -I $(srctree)/arch/$(ARCH) $(asinstr)
 KBUILD_AFLAGS	+= $(AFLAGS-y)
 KBUILD_CFLAGS	+= $(call cc-option,-msoft-float)
-KBUILD_CFLAGS	+= -pipe $(CFLAGS-y)
+KBUILD_CFLAGS	+= $(CFLAGS-y)
 CPP		= $(CC) -E $(KBUILD_CFLAGS)
 
 CHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 0982a7025e66..1c9951153bae 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -70,7 +70,7 @@ endif
 BOOTCPPFLAGS	:= -nostdinc $(LINUXINCLUDE)
 BOOTCPPFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
-BOOTCFLAGS	:= -pipe $(BOOTTARGETFLAGS) \
+BOOTCFLAGS	:= $(BOOTTARGETFLAGS) \
 		   -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
 		   $(call cc-option,-mno-prefixed) \
@@ -79,7 +79,7 @@ BOOTCFLAGS	:= -pipe $(BOOTTARGETFLAGS) \
 		   $(call cc-option,-mno-spe) $(call cc-option,-mspe=no) \
 		   -fomit-frame-pointer -fno-builtin -fPIC
 
-BOOTAFLAGS	:= -pipe $(BOOTTARGETFLAGS) -D__ASSEMBLY__
+BOOTAFLAGS	:= $(BOOTTARGETFLAGS) -D__ASSEMBLY__
 
 BOOTARFLAGS	:= -crD
 
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 8/9] powerpc/64s: Permit d-form memops in asm when building with prefix on clang
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (7 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 7/9] powerpc/build: Remove -pipe from compilation flags Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26  5:58 ` [PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla Nicholas Piggin
  2023-04-26 12:01 ` (subset) [PATCH 0/9] powerpc: Build fixes Michael Ellerman
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

GCC appears to have a bug where it generates immediate offsets beyond
the 16-bit range of d-form memory operations in extended inline asm
when prefix instructions are enabled. So simpler fallback asm is
implemented for CONFIG_PPC_KERNEL_PREFIXED builds for now.

Clang does not have this bug, so this hack can be restricted to GCC.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Kconfig               | 7 +++++++
 arch/powerpc/include/asm/atomic.h  | 8 ++++----
 arch/powerpc/include/asm/io.h      | 2 +-
 arch/powerpc/include/asm/uaccess.h | 4 ++--
 4 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 261e9453b43c..39cd8d3ff846 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -7,6 +7,13 @@ config CC_HAS_ELFV2
 config CC_HAS_PREFIXED
 	def_bool PPC64 && $(cc-option, -mcpu=power10 -mprefixed)
 
+config CC_HAS_BROKEN_DFORM_MEMOP_ASM
+	# GCC has a bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108239)
+	# when compiling with prefixed instructions that causes it to generate
+	# out-of-range offsets for d-form loads and stores from memory
+	# operands.
+	def_bool CC_HAS_PREFIXED && CC_IS_GCC
+
 config CC_HAS_PCREL
 	# Clang has a bug (https://github.com/llvm/llvm-project/issues/62372)
 	# where pcrel code is not generated if -msoft-float, -mno-altivec, or
diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
index 47228b177478..f15c9e54e261 100644
--- a/arch/powerpc/include/asm/atomic.h
+++ b/arch/powerpc/include/asm/atomic.h
@@ -28,7 +28,7 @@ static __inline__ int arch_atomic_read(const atomic_t *v)
 	int t;
 
 	/* -mprefixed can generate offsets beyond range, fall back hack */
-	if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
+	if (IS_ENABLED(CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM))
 		__asm__ __volatile__("lwz %0,0(%1)" : "=r"(t) : "b"(&v->counter));
 	else
 		__asm__ __volatile__("lwz%U1%X1 %0,%1" : "=r"(t) : "m<>"(v->counter));
@@ -39,7 +39,7 @@ static __inline__ int arch_atomic_read(const atomic_t *v)
 static __inline__ void arch_atomic_set(atomic_t *v, int i)
 {
 	/* -mprefixed can generate offsets beyond range, fall back hack */
-	if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
+	if (IS_ENABLED(CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM))
 		__asm__ __volatile__("stw %1,0(%2)" : "=m"(v->counter) : "r"(i), "b"(&v->counter));
 	else
 		__asm__ __volatile__("stw%U0%X0 %1,%0" : "=m<>"(v->counter) : "r"(i));
@@ -206,7 +206,7 @@ static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
 	s64 t;
 
 	/* -mprefixed can generate offsets beyond range, fall back hack */
-	if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
+	if (IS_ENABLED(CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM))
 		__asm__ __volatile__("ld %0,0(%1)" : "=r"(t) : "b"(&v->counter));
 	else
 		__asm__ __volatile__("ld%U1%X1 %0,%1" : "=r"(t) : "m<>"(v->counter));
@@ -217,7 +217,7 @@ static __inline__ s64 arch_atomic64_read(const atomic64_t *v)
 static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i)
 {
 	/* -mprefixed can generate offsets beyond range, fall back hack */
-	if (IS_ENABLED(CONFIG_PPC_KERNEL_PREFIXED))
+	if (IS_ENABLED(CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM))
 		__asm__ __volatile__("std %1,0(%2)" : "=m"(v->counter) : "r"(i), "b"(&v->counter));
 	else
 		__asm__ __volatile__("std%U0%X0 %1,%0" : "=m<>"(v->counter) : "r"(i));
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index f1e657c9bbe8..2e6061f26c09 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -98,7 +98,7 @@ extern bool isa_io_special;
  */
 
 /* -mprefixed can generate offsets beyond range, fall back hack */
-#ifdef CONFIG_PPC_KERNEL_PREFIXED
+#ifdef CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM
 #define DEF_MMIO_IN_X(name, size, insn)				\
 static inline u##size name(const volatile u##size __iomem *addr)	\
 {									\
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index a2d255aa9627..6fdca4cddcf3 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -72,7 +72,7 @@ __pu_failed:							\
  * are no aliasing issues.
  */
 /* -mprefixed can generate offsets beyond range, fall back hack */
-#ifdef CONFIG_PPC_KERNEL_PREFIXED
+#ifdef CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM
 #define __put_user_asm_goto(x, addr, label, op)			\
 	asm_volatile_goto(					\
 		"1:	" op " %0,0(%1)	# put_user\n"		\
@@ -144,7 +144,7 @@ do {								\
 #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
 
 /* -mprefixed can generate offsets beyond range, fall back hack */
-#ifdef CONFIG_PPC_KERNEL_PREFIXED
+#ifdef CONFIG_CC_HAS_BROKEN_DFORM_MEMOP_ASM
 #define __get_user_asm_goto(x, addr, label, op)			\
 	asm_volatile_goto(					\
 		"1:	"op" %0,0(%1)	# get_user\n"		\
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (8 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 8/9] powerpc/64s: Permit d-form memops in asm when building with prefix on clang Nicholas Piggin
@ 2023-04-26  5:58 ` Nicholas Piggin
  2023-04-26 12:01 ` (subset) [PATCH 0/9] powerpc: Build fixes Michael Ellerman
  10 siblings, 0 replies; 13+ messages in thread
From: Nicholas Piggin @ 2023-04-26  5:58 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

llvm-as does not recognise the pla mnemonic, which is used for pcrel
address generation. Use the equivalent paddi opcode instead. Clang
can not build working pcrel kernels yet, but this patch does allow it
to build a non-working pcrel kernel with llvm-as.

This could be unconditional or use a raw encoding, but this gives a
placeholder to track the issue.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/Kconfig               | 5 +++++
 arch/powerpc/include/asm/ppc_asm.h | 5 +++++
 arch/powerpc/kernel/vector.S       | 6 ++++++
 3 files changed, 16 insertions(+)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 39cd8d3ff846..2f7840577f7f 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -22,6 +22,11 @@ config CC_HAS_PCREL
 	# do pcrel yet.
 	def_bool PPC64 && CC_IS_GCC &&  $(cc-option, -mcpu=power10 -mpcrel)
 
+config AS_HAS_MISSING_PLA_INSN
+	# llvm-as is missing some extended mnemonics including pla
+	# (https://github.com/llvm/llvm-project/issues/62373).
+	def_bool AS_IS_LLVM
+
 config 32BIT
 	bool
 	default y if PPC32
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 5f05a984b103..736202ebc1be 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -380,8 +380,13 @@ GLUE(.,name):
 	rldimi	reg, tmp, 32, 0
 
 #ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LOAD_REG_ADDR(reg,name)			\
+	paddi	reg,0,name@pcrel,1
+#else
 #define LOAD_REG_ADDR(reg,name)			\
 	pla	reg,name@pcrel
+#endif
 
 #else
 #define LOAD_REG_ADDR(reg,name)			\
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index fcc0ad6d9c7b..c2feaea5e673 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -178,9 +178,15 @@ fphalf:
 	.quad	0x3fe0000000000000	/* 0.5 */
 
 #ifdef CONFIG_PPC_KERNEL_PCREL
+#ifdef CONFIG_AS_HAS_MISSING_PLA_INSN
+#define LDCONST(fr, name)		\
+	paddi	r11,0,name@pcrel,1;	\
+	lfd	fr,0(r11)
+#else
 #define LDCONST(fr, name)		\
 	pla	r11,name@pcrel;		\
 	lfd	fr,0(r11)
+#endif
 #else
 #define LDCONST(fr, name)		\
 	addis	r11,r2,name@toc@ha;	\
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: (subset) [PATCH 0/9] powerpc: Build fixes
  2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
                   ` (9 preceding siblings ...)
  2023-04-26  5:58 ` [PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla Nicholas Piggin
@ 2023-04-26 12:01 ` Michael Ellerman
  10 siblings, 0 replies; 13+ messages in thread
From: Michael Ellerman @ 2023-04-26 12:01 UTC (permalink / raw)
  To: linuxppc-dev, Nicholas Piggin

On Wed, 26 Apr 2023 15:58:37 +1000, Nicholas Piggin wrote:
> This series is against powerpc next. The first two patches are
> independent build fixes for recent patches. Patches 3-5 separate
> boot Makefile BOOTCFLAGS and BOOTASFLAGS and stops passing some
> C code generation flags to the assembler which causes some
> warnings for llvm. Patches 6-9 are not fixes but a bunch of other
> improvements I noticed along the way.
> 
> [...]

Patches 1& 2 applied to powerpc/next.

[1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes
      https://git.kernel.org/powerpc/c/0c993300d52bf5ce9b951c3b6b25d0d14acc49a9
[2/9] powerpc/64s: Disable pcrel code model on Clang
      https://git.kernel.org/powerpc/c/169f8997968ab620d750d9a45e15c5288d498356

cheers

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS
  2023-04-26  5:58 ` [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS Nicholas Piggin
@ 2023-04-26 15:11   ` Linus Torvalds
  0 siblings, 0 replies; 13+ messages in thread
From: Linus Torvalds @ 2023-04-26 15:11 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Tue, Apr 25, 2023 at 10:59 PM Nicholas Piggin <npiggin@gmail.com> wrote:
>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>

I was all "what is Nick talking about", and had to follow the link to
remember that old discussion at all.

Patch obviously looks fine to me, I'll presumably be getting it at
some future point as part of a ppc pull request.

              Linus

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-04-26 15:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-26  5:58 [PATCH 0/9] powerpc: Build fixes Nicholas Piggin
2023-04-26  5:58 ` [PATCH 1/9] powerpc: Fix merge conflict between pcrel and copy_thread changes Nicholas Piggin
2023-04-26  5:58 ` [PATCH 2/9] powerpc/64s: Disable pcrel code model on Clang Nicholas Piggin
2023-04-26  5:58 ` [PATCH 3/9] powerpc/boot: Seperate target flags from BOOTCFLAGS Nicholas Piggin
2023-04-26  5:58 ` [PATCH 4/9] powerpc/boot: Seperate CPP " Nicholas Piggin
2023-04-26  5:58 ` [PATCH 5/9] powerpc/boot: Separate BOOTCFLAGS from BOOTASFLAGS Nicholas Piggin
2023-04-26 15:11   ` Linus Torvalds
2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: Clean up Makefile after cflags and asflags separation Nicholas Piggin
2023-04-26  5:58 ` [PATCH 6/9] powerpc/boot: clean up Makefile flags Nicholas Piggin
2023-04-26  5:58 ` [PATCH 7/9] powerpc/build: Remove -pipe from compilation flags Nicholas Piggin
2023-04-26  5:58 ` [PATCH 8/9] powerpc/64s: Permit d-form memops in asm when building with prefix on clang Nicholas Piggin
2023-04-26  5:58 ` [PATCH 9/9] powerpc/64s: Work around llvm-as not recognising pla Nicholas Piggin
2023-04-26 12:01 ` (subset) [PATCH 0/9] powerpc: Build fixes Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.