linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig
@ 2022-12-19 18:45 Christophe Leroy
  2022-12-19 18:45 ` [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler Christophe Leroy
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Christophe Leroy @ 2022-12-19 18:45 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, jbglaw
  Cc: Pali Rohár, linuxppc-dev, linux-kernel

Since 0069f3d14e7a ("powerpc/64e: Tie PPC_BOOK3E_64 to PPC_E500MC"), the
only possible BOOK3E/64 are E500, so no need of a default CPU over the
E5500.

When the user selects book3e, they must have an e500 compatible
compiler, and it won't work anymore with the default -mcpu=power64, see
commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
(unrecognized opcode: `wrteei')").

For book3s/64, replace GENERIC_CPU by POWERPC64_CPU to match the PPC32
POWERPC_CPU, and set a default mpcu value in Kconfig directly.

When a user selects a particular CPU, they must ensure the compiler has
the requested capability. Therefore, remove hidden fallback, instead
offer user the possibility to say they want to use the toolchain
default.

It also fixes the non existing E5500_CPU which is a leftover of
commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
(unrecognized opcode: `wrteei')")

Fixes: d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12 (unrecognized opcode: `wrteei')")
Reported-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Makefile                  | 22 +++++-----------------
 arch/powerpc/platforms/Kconfig.cputype | 12 +++++++-----
 2 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dc4cbf0a5ca9..bf5f0a998273 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -146,19 +146,6 @@ CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
 
 CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
 
-ifdef CONFIG_PPC_BOOK3S_64
-ifdef CONFIG_CPU_LITTLE_ENDIAN
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
-else
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
-endif
-CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power10,	\
-				  $(call cc-option,-mtune=power9,	\
-				  $(call cc-option,-mtune=power8)))
-else ifdef CONFIG_PPC_BOOK3E_64
-CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
-endif
-
 ifdef CONFIG_FUNCTION_TRACER
 CC_FLAGS_FTRACE := -pg
 ifdef CONFIG_MPROFILE_KERNEL
@@ -166,11 +153,12 @@ CC_FLAGS_FTRACE += -mprofile-kernel
 endif
 endif
 
-CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
-AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
+CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
+AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
 
-CFLAGS-$(CONFIG_E5500_CPU) += $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
-CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
+CFLAGS-$(CONFIG_POWERPC64_CPU) += $(call cc-option,-mtune=power10,	\
+				  $(call cc-option,-mtune=power9,	\
+				  $(call cc-option,-mtune=power8)))
 
 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
 
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 9563336e3348..31cea2eeb59e 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -118,19 +118,18 @@ endchoice
 
 choice
 	prompt "CPU selection"
-	default GENERIC_CPU
 	help
 	  This will create a kernel which is optimised for a particular CPU.
 	  The resulting kernel may not run on other CPUs, so use this with care.
 
 	  If unsure, select Generic.
 
-config GENERIC_CPU
+config POWERPC64_CPU
 	bool "Generic (POWER5 and PowerPC 970 and above)"
 	depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
 	select PPC_64S_HASH_MMU
 
-config GENERIC_CPU
+config POWERPC64_CPU
 	bool "Generic (POWER8 and above)"
 	depends on PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
 	select ARCH_HAS_FAST_MULTIPLIER
@@ -233,13 +232,12 @@ config E500MC_CPU
 
 config TOOLCHAIN_DEFAULT_CPU
 	bool "Rely on the toolchain's implicit default CPU"
-	depends on PPC32
 
 endchoice
 
 config TARGET_CPU_BOOL
 	bool
-	default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU
+	default !TOOLCHAIN_DEFAULT_CPU
 
 config TARGET_CPU
 	string
@@ -251,6 +249,10 @@ config TARGET_CPU
 	default "power8" if POWER8_CPU
 	default "power9" if POWER9_CPU
 	default "power10" if POWER10_CPU
+	default "e500mc64" if E5500_CPU
+	default "e6500" if E6500_CPU
+	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
+	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
 	default "405" if 405_CPU
 	default "440" if 440_CPU
 	default "464" if 464_CPU
-- 
2.38.1


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

* [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
@ 2022-12-19 18:45 ` Christophe Leroy
  2022-12-20 20:14   ` Pali Rohár
  2022-12-19 18:45 ` [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500 Christophe Leroy
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Christophe Leroy @ 2022-12-19 18:45 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, jbglaw; +Cc: linuxppc-dev, linux-kernel

Jan-Benedict reported issue with building ppc64e_defconfig
with mainline GCC work:

  powerpc64-linux-gcc -Wp,-MMD,arch/powerpc/kernel/vdso/.gettimeofday-64.o.d -nostdinc -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -D__ASSEMBLY__ -fno-PIE -m64 -Wl,-a64 -mabi=elfv1 -Wa,-me500 -Wa,-me500mc -mabi=elfv1 -mbig-endian    -Wl,-soname=linux-vdso64.so.1 -D__VDSO64__ -s -c -o arch/powerpc/kernel/vdso/gettimeofday-64.o arch/powerpc/kernel/vdso/gettimeofday.S
	arch/powerpc/kernel/vdso/gettimeofday.S: Assembler messages:
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `stdu'
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `stdu'
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `std'
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `std'
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `ld'
	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `ld'
	...
	make[1]: *** [arch/powerpc/kernel/vdso/Makefile:76: arch/powerpc/kernel/vdso/gettimeofday-64.o] Error 1
	make: *** [arch/powerpc/Makefile:387: vdso_prepare] Error 2

This is due to assembler being called with -me500mc which is
a 32 bits target.

The problem comes from the fact that CONFIG_PPC_E500MC is selected for
both the e500mc (32 bits) and the e5500 (64 bits), and therefore the
following makefile rule is wrong:

  cpu-as-$(CONFIG_PPC_E500MC)    += $(call as-option,-Wa$(comma)-me500mc)

Today we have CONFIG_TARGET_CPU which provides the identification of the
expected CPU, it is used for GCC. Once GCC knows the target CPU, it adds
the correct CPU option to assembler, no need to add it explicitely.

With that change (And also commit 825eada7717c ("powerpc/64: Set
default CPU in Kconfig")), it now is:

  powerpc64-linux-gcc -Wp,-MMD,arch/powerpc/kernel/vdso/.gettimeofday-64.o.d -nostdinc -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -D__ASSEMBLY__ -fno-PIE -m64 -Wl,-a64 -mabi=elfv1 -mcpu=e500mc64 -mabi=elfv1 -mbig-endian    -Wl,-soname=linux-vdso64.so.1 -D__VDSO64__ -s -c -o arch/powerpc/kernel/vdso/gettimeofday-64.o arch/powerpc/kernel/vdso/gettimeofday.S

Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v3: Remove -Wa,-mXXX completery as there are additional mismatches between -mcpu and -Wa-m (eg: 8540 vs e500). When given the proper -mcpu=, GCC gives the correct option to assembler.

v2: When target cpu is powerpc, the option to be used is -mppc

Commit 825eada7717c is in powerpc/next-test branch. Make sure the SHA doesn't change when it goes into powerpc/next
---
 arch/powerpc/Makefile | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index bf5f0a998273..0f9f291895cb 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -201,18 +201,14 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
 # often slow when they are implemented at all
 KBUILD_CFLAGS		+= $(call cc-option,-mno-string)
 
-cpu-as-$(CONFIG_40x)		+= -Wa,-m405
-cpu-as-$(CONFIG_44x)		+= -Wa,-m440
 cpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
-cpu-as-$(CONFIG_PPC_E500)		+= -Wa,-me500
 
 # When using '-many -mpower4' gas will first try and find a matching power4
 # mnemonic and failing that it will allow any valid mnemonic that GAS knows
 # about. GCC will pass -many to GAS when assembling, clang does not.
 # LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
 # but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
-cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-mpower4) $(call as-option,-Wa$(comma)-many)
-cpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
+cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-many)
 
 KBUILD_AFLAGS += $(cpu-as-y)
 KBUILD_CFLAGS += $(cpu-as-y)
-- 
2.38.1


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

* [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
  2022-12-19 18:45 ` [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler Christophe Leroy
@ 2022-12-19 18:45 ` Christophe Leroy
  2022-12-20 20:15   ` Pali Rohár
  2022-12-19 18:45 ` [PATCH v1 4/5] powerpc: Remove cpu-as-y completely Christophe Leroy
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Christophe Leroy @ 2022-12-19 18:45 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, jbglaw; +Cc: linuxppc-dev, linux-kernel

E500MC64 is a processor pre-dating E5500 that has never been
commercialised. Use -mcpu=e5500 for E5500 core.

More details at https://gcc.gnu.org/PR108149

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/platforms/Kconfig.cputype | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 31cea2eeb59e..29d6be033576 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -249,7 +249,7 @@ config TARGET_CPU
 	default "power8" if POWER8_CPU
 	default "power9" if POWER9_CPU
 	default "power10" if POWER10_CPU
-	default "e500mc64" if E5500_CPU
+	default "e5500" if E5500_CPU
 	default "e6500" if E6500_CPU
 	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
 	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
-- 
2.38.1


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

* [PATCH v1 4/5] powerpc: Remove cpu-as-y completely
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
  2022-12-19 18:45 ` [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler Christophe Leroy
  2022-12-19 18:45 ` [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500 Christophe Leroy
@ 2022-12-19 18:45 ` Christophe Leroy
  2022-12-20 20:15   ` Pali Rohár
  2023-02-20  6:00   ` Michael Ellerman
  2022-12-19 18:46 ` [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke Christophe Leroy
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Christophe Leroy @ 2022-12-19 18:45 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, jbglaw; +Cc: linuxppc-dev, linux-kernel

cpu-as-y is there to force assembler building options.
But there is no need for that. Gcc is passed the necessary
options and it automatically pass the appropriate option to
GAS.

GCC is given -maltivec when relevant, so no need
for -Wa,-maltivec in addition

And -Wa,-many is wrong as it will hide innapropriate
instructions. Better to detect them and handle them on a
case by case basis.
-Wa,-many was added by commit 960e30029863 ("powerpc/Makefile:
Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue with
clang and the passed -Wa,-mpower4 option. But we have now
removed it expecting the compiler to automatically pass the
proper options and instructions based on -mcpu=power4

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
 arch/powerpc/Makefile | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 0f9f291895cb..7e67f939a243 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -201,18 +201,6 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
 # often slow when they are implemented at all
 KBUILD_CFLAGS		+= $(call cc-option,-mno-string)
 
-cpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
-
-# When using '-many -mpower4' gas will first try and find a matching power4
-# mnemonic and failing that it will allow any valid mnemonic that GAS knows
-# about. GCC will pass -many to GAS when assembling, clang does not.
-# LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
-# but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
-cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-many)
-
-KBUILD_AFLAGS += $(cpu-as-y)
-KBUILD_CFLAGS += $(cpu-as-y)
-
 KBUILD_AFLAGS += $(aflags-y)
 KBUILD_CFLAGS += $(cflags-y)
 
-- 
2.38.1


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

* [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
                   ` (2 preceding siblings ...)
  2022-12-19 18:45 ` [PATCH v1 4/5] powerpc: Remove cpu-as-y completely Christophe Leroy
@ 2022-12-19 18:46 ` Christophe Leroy
  2022-12-20 20:21   ` Pali Rohár
  2022-12-20 20:13 ` [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Pali Rohár
  2023-02-20  3:53 ` Michael Ellerman
  5 siblings, 1 reply; 17+ messages in thread
From: Christophe Leroy @ 2022-12-19 18:46 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, jbglaw; +Cc: linuxppc-dev, linux-kernel

wrteei is only for booke. Use the standard mfmsr/ori/mtmsr
when non booke.

Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
Not sure this is needed at all, the commit that introduced the code says it is for e500, but there's no such limitation in Kconfig. Maybe we should limit all the file to CONFIG_PPC_E500
---
 arch/powerpc/kernel/epapr_hcalls.S | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
index 69a912550577..033116e465d0 100644
--- a/arch/powerpc/kernel/epapr_hcalls.S
+++ b/arch/powerpc/kernel/epapr_hcalls.S
@@ -21,7 +21,13 @@ _GLOBAL(epapr_ev_idle)
 	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
 	PPC_STL	r4, TI_LOCAL_FLAGS(r2)	/* it will return to our caller */
 
+#ifdef CONFIG_BOOKE_OR_40x
 	wrteei	1
+#else
+	mfmsr	r4
+	ori	r4, r4, MSR_EE
+	mtmsr	r4
+#endif
 
 idle_loop:
 	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
-- 
2.38.1


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

* Re: [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
                   ` (3 preceding siblings ...)
  2022-12-19 18:46 ` [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke Christophe Leroy
@ 2022-12-20 20:13 ` Pali Rohár
  2023-02-20  3:53 ` Michael Ellerman
  5 siblings, 0 replies; 17+ messages in thread
From: Pali Rohár @ 2022-12-20 20:13 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Monday 19 December 2022 19:45:56 Christophe Leroy wrote:
> Since 0069f3d14e7a ("powerpc/64e: Tie PPC_BOOK3E_64 to PPC_E500MC"), the
> only possible BOOK3E/64 are E500, so no need of a default CPU over the
> E5500.
> 
> When the user selects book3e, they must have an e500 compatible
> compiler, and it won't work anymore with the default -mcpu=power64, see
> commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
> (unrecognized opcode: `wrteei')").
> 
> For book3s/64, replace GENERIC_CPU by POWERPC64_CPU to match the PPC32
> POWERPC_CPU, and set a default mpcu value in Kconfig directly.
> 
> When a user selects a particular CPU, they must ensure the compiler has
> the requested capability. Therefore, remove hidden fallback, instead
> offer user the possibility to say they want to use the toolchain
> default.
> 
> It also fixes the non existing E5500_CPU which is a leftover of
> commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
> (unrecognized opcode: `wrteei')")
> 
> Fixes: d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12 (unrecognized opcode: `wrteei')")
> Reported-by: Pali Rohár <pali@kernel.org>
> Tested-by: Pali Rohár <pali@kernel.org>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Pali Rohár <pali@kernel.org>

> ---
>  arch/powerpc/Makefile                  | 22 +++++-----------------
>  arch/powerpc/platforms/Kconfig.cputype | 12 +++++++-----
>  2 files changed, 12 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index dc4cbf0a5ca9..bf5f0a998273 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -146,19 +146,6 @@ CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
>  
>  CFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
>  
> -ifdef CONFIG_PPC_BOOK3S_64
> -ifdef CONFIG_CPU_LITTLE_ENDIAN
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
> -else
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
> -endif
> -CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power10,	\
> -				  $(call cc-option,-mtune=power9,	\
> -				  $(call cc-option,-mtune=power8)))
> -else ifdef CONFIG_PPC_BOOK3E_64
> -CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
> -endif
> -
>  ifdef CONFIG_FUNCTION_TRACER
>  CC_FLAGS_FTRACE := -pg
>  ifdef CONFIG_MPROFILE_KERNEL
> @@ -166,11 +153,12 @@ CC_FLAGS_FTRACE += -mprofile-kernel
>  endif
>  endif
>  
> -CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> -AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
> +CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
> +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
>  
> -CFLAGS-$(CONFIG_E5500_CPU) += $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
> -CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
> +CFLAGS-$(CONFIG_POWERPC64_CPU) += $(call cc-option,-mtune=power10,	\
> +				  $(call cc-option,-mtune=power9,	\
> +				  $(call cc-option,-mtune=power8)))
>  
>  asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
>  
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index 9563336e3348..31cea2eeb59e 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -118,19 +118,18 @@ endchoice
>  
>  choice
>  	prompt "CPU selection"
> -	default GENERIC_CPU
>  	help
>  	  This will create a kernel which is optimised for a particular CPU.
>  	  The resulting kernel may not run on other CPUs, so use this with care.
>  
>  	  If unsure, select Generic.
>  
> -config GENERIC_CPU
> +config POWERPC64_CPU
>  	bool "Generic (POWER5 and PowerPC 970 and above)"
>  	depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
>  	select PPC_64S_HASH_MMU
>  
> -config GENERIC_CPU
> +config POWERPC64_CPU
>  	bool "Generic (POWER8 and above)"
>  	depends on PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN
>  	select ARCH_HAS_FAST_MULTIPLIER
> @@ -233,13 +232,12 @@ config E500MC_CPU
>  
>  config TOOLCHAIN_DEFAULT_CPU
>  	bool "Rely on the toolchain's implicit default CPU"
> -	depends on PPC32
>  
>  endchoice
>  
>  config TARGET_CPU_BOOL
>  	bool
> -	default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU
> +	default !TOOLCHAIN_DEFAULT_CPU
>  
>  config TARGET_CPU
>  	string
> @@ -251,6 +249,10 @@ config TARGET_CPU
>  	default "power8" if POWER8_CPU
>  	default "power9" if POWER9_CPU
>  	default "power10" if POWER10_CPU
> +	default "e500mc64" if E5500_CPU
> +	default "e6500" if E6500_CPU
> +	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
> +	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
>  	default "405" if 405_CPU
>  	default "440" if 440_CPU
>  	default "464" if 464_CPU
> -- 
> 2.38.1
> 

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

* Re: [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler
  2022-12-19 18:45 ` [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler Christophe Leroy
@ 2022-12-20 20:14   ` Pali Rohár
  0 siblings, 0 replies; 17+ messages in thread
From: Pali Rohár @ 2022-12-20 20:14 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Monday 19 December 2022 19:45:57 Christophe Leroy wrote:
> Jan-Benedict reported issue with building ppc64e_defconfig
> with mainline GCC work:
> 
>   powerpc64-linux-gcc -Wp,-MMD,arch/powerpc/kernel/vdso/.gettimeofday-64.o.d -nostdinc -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -D__ASSEMBLY__ -fno-PIE -m64 -Wl,-a64 -mabi=elfv1 -Wa,-me500 -Wa,-me500mc -mabi=elfv1 -mbig-endian    -Wl,-soname=linux-vdso64.so.1 -D__VDSO64__ -s -c -o arch/powerpc/kernel/vdso/gettimeofday-64.o arch/powerpc/kernel/vdso/gettimeofday.S
> 	arch/powerpc/kernel/vdso/gettimeofday.S: Assembler messages:
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `stdu'
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `stdu'
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `std'
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `std'
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `ld'
> 	arch/powerpc/kernel/vdso/gettimeofday.S:72: Error: unrecognized opcode: `ld'
> 	...
> 	make[1]: *** [arch/powerpc/kernel/vdso/Makefile:76: arch/powerpc/kernel/vdso/gettimeofday-64.o] Error 1
> 	make: *** [arch/powerpc/Makefile:387: vdso_prepare] Error 2
> 
> This is due to assembler being called with -me500mc which is
> a 32 bits target.
> 
> The problem comes from the fact that CONFIG_PPC_E500MC is selected for
> both the e500mc (32 bits) and the e5500 (64 bits), and therefore the
> following makefile rule is wrong:
> 
>   cpu-as-$(CONFIG_PPC_E500MC)    += $(call as-option,-Wa$(comma)-me500mc)
> 
> Today we have CONFIG_TARGET_CPU which provides the identification of the
> expected CPU, it is used for GCC. Once GCC knows the target CPU, it adds
> the correct CPU option to assembler, no need to add it explicitely.
> 
> With that change (And also commit 825eada7717c ("powerpc/64: Set
> default CPU in Kconfig")), it now is:
> 
>   powerpc64-linux-gcc -Wp,-MMD,arch/powerpc/kernel/vdso/.gettimeofday-64.o.d -nostdinc -I./arch/powerpc/include -I./arch/powerpc/include/generated  -I./include -I./arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -D__KERNEL__ -I ./arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=./= -D__ASSEMBLY__ -fno-PIE -m64 -Wl,-a64 -mabi=elfv1 -mcpu=e500mc64 -mabi=elfv1 -mbig-endian    -Wl,-soname=linux-vdso64.so.1 -D__VDSO64__ -s -c -o arch/powerpc/kernel/vdso/gettimeofday-64.o arch/powerpc/kernel/vdso/gettimeofday.S
> 
> Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Pali Rohár <pali@kernel.org>

> ---
> v3: Remove -Wa,-mXXX completery as there are additional mismatches between -mcpu and -Wa-m (eg: 8540 vs e500). When given the proper -mcpu=, GCC gives the correct option to assembler.
> 
> v2: When target cpu is powerpc, the option to be used is -mppc
> 
> Commit 825eada7717c is in powerpc/next-test branch. Make sure the SHA doesn't change when it goes into powerpc/next
> ---
>  arch/powerpc/Makefile | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index bf5f0a998273..0f9f291895cb 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -201,18 +201,14 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
>  # often slow when they are implemented at all
>  KBUILD_CFLAGS		+= $(call cc-option,-mno-string)
>  
> -cpu-as-$(CONFIG_40x)		+= -Wa,-m405
> -cpu-as-$(CONFIG_44x)		+= -Wa,-m440
>  cpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
> -cpu-as-$(CONFIG_PPC_E500)		+= -Wa,-me500
>  
>  # When using '-many -mpower4' gas will first try and find a matching power4
>  # mnemonic and failing that it will allow any valid mnemonic that GAS knows
>  # about. GCC will pass -many to GAS when assembling, clang does not.
>  # LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
>  # but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
> -cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-mpower4) $(call as-option,-Wa$(comma)-many)
> -cpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
> +cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-many)
>  
>  KBUILD_AFLAGS += $(cpu-as-y)
>  KBUILD_CFLAGS += $(cpu-as-y)
> -- 
> 2.38.1
> 

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

* Re: [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500
  2022-12-19 18:45 ` [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500 Christophe Leroy
@ 2022-12-20 20:15   ` Pali Rohár
  2023-02-01 23:46     ` Pali Rohár
  0 siblings, 1 reply; 17+ messages in thread
From: Pali Rohár @ 2022-12-20 20:15 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Monday 19 December 2022 19:45:58 Christophe Leroy wrote:
> E500MC64 is a processor pre-dating E5500 that has never been
> commercialised. Use -mcpu=e5500 for E5500 core.
> 
> More details at https://gcc.gnu.org/PR108149
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Pali Rohár <pali@kernel.org>

> ---
>  arch/powerpc/platforms/Kconfig.cputype | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> index 31cea2eeb59e..29d6be033576 100644
> --- a/arch/powerpc/platforms/Kconfig.cputype
> +++ b/arch/powerpc/platforms/Kconfig.cputype
> @@ -249,7 +249,7 @@ config TARGET_CPU
>  	default "power8" if POWER8_CPU
>  	default "power9" if POWER9_CPU
>  	default "power10" if POWER10_CPU
> -	default "e500mc64" if E5500_CPU
> +	default "e5500" if E5500_CPU
>  	default "e6500" if E6500_CPU
>  	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
>  	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
> -- 
> 2.38.1
> 

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

* Re: [PATCH v1 4/5] powerpc: Remove cpu-as-y completely
  2022-12-19 18:45 ` [PATCH v1 4/5] powerpc: Remove cpu-as-y completely Christophe Leroy
@ 2022-12-20 20:15   ` Pali Rohár
  2023-02-20  6:00   ` Michael Ellerman
  1 sibling, 0 replies; 17+ messages in thread
From: Pali Rohár @ 2022-12-20 20:15 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Monday 19 December 2022 19:45:59 Christophe Leroy wrote:
> cpu-as-y is there to force assembler building options.
> But there is no need for that. Gcc is passed the necessary
> options and it automatically pass the appropriate option to
> GAS.
> 
> GCC is given -maltivec when relevant, so no need
> for -Wa,-maltivec in addition
> 
> And -Wa,-many is wrong as it will hide innapropriate
> instructions. Better to detect them and handle them on a
> case by case basis.
> -Wa,-many was added by commit 960e30029863 ("powerpc/Makefile:
> Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue with
> clang and the passed -Wa,-mpower4 option. But we have now
> removed it expecting the compiler to automatically pass the
> proper options and instructions based on -mcpu=power4
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>

Acked-by: Pali Rohár <pali@kernel.org>

> ---
>  arch/powerpc/Makefile | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index 0f9f291895cb..7e67f939a243 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -201,18 +201,6 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
>  # often slow when they are implemented at all
>  KBUILD_CFLAGS		+= $(call cc-option,-mno-string)
>  
> -cpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
> -
> -# When using '-many -mpower4' gas will first try and find a matching power4
> -# mnemonic and failing that it will allow any valid mnemonic that GAS knows
> -# about. GCC will pass -many to GAS when assembling, clang does not.
> -# LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
> -# but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
> -cpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-many)
> -
> -KBUILD_AFLAGS += $(cpu-as-y)
> -KBUILD_CFLAGS += $(cpu-as-y)
> -
>  KBUILD_AFLAGS += $(aflags-y)
>  KBUILD_CFLAGS += $(cflags-y)
>  
> -- 
> 2.38.1
> 

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

* Re: [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke
  2022-12-19 18:46 ` [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke Christophe Leroy
@ 2022-12-20 20:21   ` Pali Rohár
  2023-02-15 23:15     ` Pali Rohár
  0 siblings, 1 reply; 17+ messages in thread
From: Pali Rohár @ 2022-12-20 20:21 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Monday 19 December 2022 19:46:00 Christophe Leroy wrote:
> wrteei is only for booke. Use the standard mfmsr/ori/mtmsr
> when non booke.
> 
> Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> Not sure this is needed at all, the commit that introduced the code says it is for e500, but there's no such limitation in Kconfig. Maybe we should limit all the file to CONFIG_PPC_E500

This ePAPR code is according to ePAPR v1.1. So it does not have to be
e500 specific. But is there anything else in this category?

> ---
>  arch/powerpc/kernel/epapr_hcalls.S | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
> index 69a912550577..033116e465d0 100644
> --- a/arch/powerpc/kernel/epapr_hcalls.S
> +++ b/arch/powerpc/kernel/epapr_hcalls.S
> @@ -21,7 +21,13 @@ _GLOBAL(epapr_ev_idle)
>  	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
>  	PPC_STL	r4, TI_LOCAL_FLAGS(r2)	/* it will return to our caller */
>  
> +#ifdef CONFIG_BOOKE_OR_40x
>  	wrteei	1
> +#else
> +	mfmsr	r4
> +	ori	r4, r4, MSR_EE
> +	mtmsr	r4
> +#endif
>  
>  idle_loop:
>  	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
> -- 
> 2.38.1
> 

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

* Re: [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500
  2022-12-20 20:15   ` Pali Rohár
@ 2023-02-01 23:46     ` Pali Rohár
  2023-02-03 18:23       ` Christophe Leroy
  0 siblings, 1 reply; 17+ messages in thread
From: Pali Rohár @ 2023-02-01 23:46 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Tuesday 20 December 2022 21:15:08 Pali Rohár wrote:
> On Monday 19 December 2022 19:45:58 Christophe Leroy wrote:
> > E500MC64 is a processor pre-dating E5500 that has never been
> > commercialised. Use -mcpu=e5500 for E5500 core.
> > 
> > More details at https://gcc.gnu.org/PR108149
> > 
> > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> Acked-by: Pali Rohár <pali@kernel.org>
> 
> > ---
> >  arch/powerpc/platforms/Kconfig.cputype | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
> > index 31cea2eeb59e..29d6be033576 100644
> > --- a/arch/powerpc/platforms/Kconfig.cputype
> > +++ b/arch/powerpc/platforms/Kconfig.cputype
> > @@ -249,7 +249,7 @@ config TARGET_CPU
> >  	default "power8" if POWER8_CPU
> >  	default "power9" if POWER9_CPU
> >  	default "power10" if POWER10_CPU
> > -	default "e500mc64" if E5500_CPU
> > +	default "e5500" if E5500_CPU
> >  	default "e6500" if E6500_CPU
> >  	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
> >  	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
> > -- 
> > 2.38.1
> > 

It looks like that this patch is also missing in powerpc tree...

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

* Re: [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500
  2023-02-01 23:46     ` Pali Rohár
@ 2023-02-03 18:23       ` Christophe Leroy
  0 siblings, 0 replies; 17+ messages in thread
From: Christophe Leroy @ 2023-02-03 18:23 UTC (permalink / raw)
  To: Pali Rohár; +Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel



Le 02/02/2023 à 00:46, Pali Rohár a écrit :
> On Tuesday 20 December 2022 21:15:08 Pali Rohár wrote:
>> On Monday 19 December 2022 19:45:58 Christophe Leroy wrote:
>>> E500MC64 is a processor pre-dating E5500 that has never been
>>> commercialised. Use -mcpu=e5500 for E5500 core.
>>>
>>> More details at https://gcc.gnu.org/PR108149
>>>
>>> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
>>
>> Acked-by: Pali Rohár <pali@kernel.org>
>>
>>> ---
>>>   arch/powerpc/platforms/Kconfig.cputype | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
>>> index 31cea2eeb59e..29d6be033576 100644
>>> --- a/arch/powerpc/platforms/Kconfig.cputype
>>> +++ b/arch/powerpc/platforms/Kconfig.cputype
>>> @@ -249,7 +249,7 @@ config TARGET_CPU
>>>   	default "power8" if POWER8_CPU
>>>   	default "power9" if POWER9_CPU
>>>   	default "power10" if POWER10_CPU
>>> -	default "e500mc64" if E5500_CPU
>>> +	default "e5500" if E5500_CPU
>>>   	default "e6500" if E6500_CPU
>>>   	default "power4" if POWERPC64_CPU && !CPU_LITTLE_ENDIAN
>>>   	default "power8" if POWERPC64_CPU && CPU_LITTLE_ENDIAN
>>> -- 
>>> 2.38.1
>>>
> 
> It looks like that this patch is also missing in powerpc tree...

The entire series is not taken yet indeed, only patch 1 is in the pipe 
because I submitted it as a fix in parallel.

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

* Re: [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke
  2022-12-20 20:21   ` Pali Rohár
@ 2023-02-15 23:15     ` Pali Rohár
  0 siblings, 0 replies; 17+ messages in thread
From: Pali Rohár @ 2023-02-15 23:15 UTC (permalink / raw)
  To: Scott Wood, Christophe Leroy
  Cc: linuxppc-dev, jbglaw, Nicholas Piggin, linux-kernel

On Tuesday 20 December 2022 21:21:11 Pali Rohár wrote:
> On Monday 19 December 2022 19:46:00 Christophe Leroy wrote:
> > wrteei is only for booke. Use the standard mfmsr/ori/mtmsr
> > when non booke.
> > 
> > Reported-by: Jan-Benedict Glaw <jbglaw@lug-owl.de>
> > Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> > ---
> > Not sure this is needed at all, the commit that introduced the code says it is for e500, but there's no such limitation in Kconfig. Maybe we should limit all the file to CONFIG_PPC_E500
> 
> This ePAPR code is according to ePAPR v1.1. So it does not have to be
> e500 specific. But is there anything else in this category?

Scott Wood: Do you know any details about it?

> > ---
> >  arch/powerpc/kernel/epapr_hcalls.S | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/arch/powerpc/kernel/epapr_hcalls.S b/arch/powerpc/kernel/epapr_hcalls.S
> > index 69a912550577..033116e465d0 100644
> > --- a/arch/powerpc/kernel/epapr_hcalls.S
> > +++ b/arch/powerpc/kernel/epapr_hcalls.S
> > @@ -21,7 +21,13 @@ _GLOBAL(epapr_ev_idle)
> >  	ori	r4, r4,_TLF_NAPPING	/* so when we take an exception */
> >  	PPC_STL	r4, TI_LOCAL_FLAGS(r2)	/* it will return to our caller */
> >  
> > +#ifdef CONFIG_BOOKE_OR_40x
> >  	wrteei	1
> > +#else
> > +	mfmsr	r4
> > +	ori	r4, r4, MSR_EE
> > +	mtmsr	r4
> > +#endif
> >  
> >  idle_loop:
> >  	LOAD_REG_IMMEDIATE(r11, EV_HCALL_TOKEN(EV_IDLE))
> > -- 
> > 2.38.1
> > 

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

* Re: [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig
  2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
                   ` (4 preceding siblings ...)
  2022-12-20 20:13 ` [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Pali Rohár
@ 2023-02-20  3:53 ` Michael Ellerman
  5 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2023-02-20  3:53 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy, jbglaw
  Cc: Pali Rohár, linuxppc-dev, linux-kernel

On Mon, 19 Dec 2022 19:45:56 +0100, Christophe Leroy wrote:
> Since 0069f3d14e7a ("powerpc/64e: Tie PPC_BOOK3E_64 to PPC_E500MC"), the
> only possible BOOK3E/64 are E500, so no need of a default CPU over the
> E5500.
> 
> When the user selects book3e, they must have an e500 compatible
> compiler, and it won't work anymore with the default -mcpu=power64, see
> commit d6b551b8f90c ("powerpc/64e: Fix build failure with GCC 12
> (unrecognized opcode: `wrteei')").
> 
> [...]

Patches 2, 3 & 5 applied to powerpc/next.

[2/5] powerpc: Pass correct CPU reference to assembler
      https://git.kernel.org/powerpc/c/bfb03af71a3798b5a88a945a9c19ad67e1c4986d
[3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500
      https://git.kernel.org/powerpc/c/77e82fa1f9781a958a6ea4aed7aec41239a5a22f
[5/5] powerpc/epapr: Don't use wrteei on non booke
      https://git.kernel.org/powerpc/c/3c2ce4912a6f44dfb11bc5d241b13e9f5d79078b

cheers

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

* Re: [PATCH v1 4/5] powerpc: Remove cpu-as-y completely
  2022-12-19 18:45 ` [PATCH v1 4/5] powerpc: Remove cpu-as-y completely Christophe Leroy
  2022-12-20 20:15   ` Pali Rohár
@ 2023-02-20  6:00   ` Michael Ellerman
  2024-02-16 15:25     ` Christophe Leroy
  1 sibling, 1 reply; 17+ messages in thread
From: Michael Ellerman @ 2023-02-20  6:00 UTC (permalink / raw)
  To: Christophe Leroy, Nicholas Piggin, jbglaw; +Cc: linuxppc-dev, linux-kernel

Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> cpu-as-y is there to force assembler building options.
> But there is no need for that. Gcc is passed the necessary
> options and it automatically pass the appropriate option to
> GAS.
>
> GCC is given -maltivec when relevant, so no need
> for -Wa,-maltivec in addition
>
> And -Wa,-many is wrong as it will hide innapropriate
> instructions. Better to detect them and handle them on a
> case by case basis.
> -Wa,-many was added by commit 960e30029863 ("powerpc/Makefile:
> Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue with
> clang and the passed -Wa,-mpower4 option. But we have now
> removed it expecting the compiler to automatically pass the
> proper options and instructions based on -mcpu=power4

I wanted to apply this one, but it caused a lot of breakage for big
endian Book3S-64 builds - where we build for power4 but have lots of
code that uses >= power5 instructions.

I'll try and get those all fixed and pick this up for the next merge
window.

cheers

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

* Re: [PATCH v1 4/5] powerpc: Remove cpu-as-y completely
  2023-02-20  6:00   ` Michael Ellerman
@ 2024-02-16 15:25     ` Christophe Leroy
  2024-02-24 23:52       ` Michael Ellerman
  0 siblings, 1 reply; 17+ messages in thread
From: Christophe Leroy @ 2024-02-16 15:25 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, linux-kernel, Nicholas Piggin, jbglaw



Le 20/02/2023 à 07:00, Michael Ellerman a écrit :
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> cpu-as-y is there to force assembler building options.
>> But there is no need for that. Gcc is passed the necessary
>> options and it automatically pass the appropriate option to
>> GAS.
>>
>> GCC is given -maltivec when relevant, so no need
>> for -Wa,-maltivec in addition
>>
>> And -Wa,-many is wrong as it will hide innapropriate
>> instructions. Better to detect them and handle them on a
>> case by case basis.
>> -Wa,-many was added by commit 960e30029863 ("powerpc/Makefile:
>> Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue with
>> clang and the passed -Wa,-mpower4 option. But we have now
>> removed it expecting the compiler to automatically pass the
>> proper options and instructions based on -mcpu=power4
> 
> I wanted to apply this one, but it caused a lot of breakage for big
> endian Book3S-64 builds - where we build for power4 but have lots of
> code that uses >= power5 instructions.
> 
> I'll try and get those all fixed and pick this up for the next merge
> window.
> 

ping ?

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

* Re: [PATCH v1 4/5] powerpc: Remove cpu-as-y completely
  2024-02-16 15:25     ` Christophe Leroy
@ 2024-02-24 23:52       ` Michael Ellerman
  0 siblings, 0 replies; 17+ messages in thread
From: Michael Ellerman @ 2024-02-24 23:52 UTC (permalink / raw)
  To: Christophe Leroy; +Cc: linuxppc-dev, linux-kernel, Nicholas Piggin, jbglaw

Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 20/02/2023 à 07:00, Michael Ellerman a écrit :
>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>> cpu-as-y is there to force assembler building options.
>>> But there is no need for that. Gcc is passed the necessary
>>> options and it automatically pass the appropriate option to
>>> GAS.
>>>
>>> GCC is given -maltivec when relevant, so no need
>>> for -Wa,-maltivec in addition
>>>
>>> And -Wa,-many is wrong as it will hide innapropriate
>>> instructions. Better to detect them and handle them on a
>>> case by case basis.
>>> -Wa,-many was added by commit 960e30029863 ("powerpc/Makefile:
>>> Fix PPC_BOOK3S_64 ASFLAGS") in order to fix an issue with
>>> clang and the passed -Wa,-mpower4 option. But we have now
>>> removed it expecting the compiler to automatically pass the
>>> proper options and instructions based on -mcpu=power4
>> 
>> I wanted to apply this one, but it caused a lot of breakage for big
>> endian Book3S-64 builds - where we build for power4 but have lots of
>> code that uses >= power5 instructions.
>> 
>> I'll try and get those all fixed and pick this up for the next merge
>> window.
>
> ping ?

Brutal :)

There's still a few issues, I have patches for most of them I think.
Will post this week.

cheers

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

end of thread, other threads:[~2024-02-24 23:53 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-19 18:45 [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Christophe Leroy
2022-12-19 18:45 ` [PATCH v1 2/5] powerpc: Pass correct CPU reference to assembler Christophe Leroy
2022-12-20 20:14   ` Pali Rohár
2022-12-19 18:45 ` [PATCH v1 3/5] powerpc/64: Replace -mcpu=e500mc64 by -mcpu=e5500 Christophe Leroy
2022-12-20 20:15   ` Pali Rohár
2023-02-01 23:46     ` Pali Rohár
2023-02-03 18:23       ` Christophe Leroy
2022-12-19 18:45 ` [PATCH v1 4/5] powerpc: Remove cpu-as-y completely Christophe Leroy
2022-12-20 20:15   ` Pali Rohár
2023-02-20  6:00   ` Michael Ellerman
2024-02-16 15:25     ` Christophe Leroy
2024-02-24 23:52       ` Michael Ellerman
2022-12-19 18:46 ` [PATCH v1 5/5] powerpc/epapr: Don't use wrteei on non booke Christophe Leroy
2022-12-20 20:21   ` Pali Rohár
2023-02-15 23:15     ` Pali Rohár
2022-12-20 20:13 ` [PATCH v1 1/5] powerpc/64: Set default CPU in Kconfig Pali Rohár
2023-02-20  3:53 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).