All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
@ 2020-04-28 11:25 Nicholas Piggin
  2020-04-28 23:40 ` Segher Boessenkool
  2021-05-02 16:57 ` Michal Suchánek
  0 siblings, 2 replies; 16+ messages in thread
From: Nicholas Piggin @ 2020-04-28 11:25 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

Provide an option to use ELFv2 ABI for big endian builds. This works on
GCC and clang (since 2014). It is less well tested and supported by the
GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
for BE (e.g., less stack usage). Some distros even build BE ELFv2
userspace.

Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
Since v1:
- Improved the override flavour name suggested by Segher.
- Improved changelog wording.


 arch/powerpc/Kconfig            | 19 +++++++++++++++++++
 arch/powerpc/Makefile           | 15 ++++++++++-----
 arch/powerpc/boot/Makefile      |  4 ++++
 drivers/crypto/vmx/Makefile     |  8 ++++++--
 drivers/crypto/vmx/ppc-xlate.pl | 10 ++++++----
 5 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 924c541a9260..d9d2abc06c2c 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -147,6 +147,7 @@ config PPC
 	select ARCH_WEAK_RELEASE_ACQUIRE
 	select BINFMT_ELF
 	select BUILDTIME_TABLE_SORT
+	select BUILD_ELF_V2			if PPC64 && CPU_LITTLE_ENDIAN
 	select CLONE_BACKWARDS
 	select DCACHE_WORD_ACCESS		if PPC64 && CPU_LITTLE_ENDIAN
 	select DYNAMIC_FTRACE			if FUNCTION_TRACER
@@ -541,6 +542,24 @@ config KEXEC_FILE
 config ARCH_HAS_KEXEC_PURGATORY
 	def_bool KEXEC_FILE
 
+config BUILD_ELF_V2
+	bool
+
+config BUILD_BIG_ENDIAN_ELF_V2
+	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
+	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
+	default n
+	select BUILD_ELF_V2
+	help
+	  This builds the kernel image using the ELFv2 ABI, which has a
+	  reduced stack overhead and faster function calls. This does not
+	  affect the userspace ABIs.
+
+	  ELFv2 is the standard ABI for little-endian, but for big-endian
+	  this is an experimental option that is less tested (kernel and
+	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
+	  newer.
+
 config RELOCATABLE
 	bool "Build a relocatable kernel"
 	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index f310c32e88a4..e306b39d847e 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -92,10 +92,14 @@ endif
 
 ifdef CONFIG_PPC64
 ifndef CONFIG_CC_IS_CLANG
-cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
-cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
-aflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
-aflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
+ifdef CONFIG_BUILD_ELF_V2
+cflags-y				+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
+aflags-y				+= $(call cc-option,-mabi=elfv2)
+else
+cflags-y				+= $(call cc-option,-mabi=elfv1)
+cflags-y				+= $(call cc-option,-mcall-aixdesc)
+aflags-y				+= $(call cc-option,-mabi=elfv1)
+endif
 endif
 endif
 
@@ -144,7 +148,7 @@ endif
 
 CFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
 ifndef CONFIG_CC_IS_CLANG
-ifdef CONFIG_CPU_LITTLE_ENDIAN
+ifdef CONFIG_BUILD_ELF_V2
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
 AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
 else
@@ -153,6 +157,7 @@ CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
 AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
 endif
 endif
+
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
 CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
 
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index c53a1b8bba8b..03942d08695d 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -41,6 +41,10 @@ endif
 
 BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
+ifdef CONFIG_BUILD_ELF_V2
+BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
+endif
+
 ifdef CONFIG_CPU_BIG_ENDIAN
 BOOTCFLAGS	+= -mbig-endian
 else
diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
index 709670d2b553..9aea34602beb 100644
--- a/drivers/crypto/vmx/Makefile
+++ b/drivers/crypto/vmx/Makefile
@@ -5,18 +5,22 @@ vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes
 ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
 override flavour := linux-ppc64le
 else
+ifdef CONFIG_BUILD_ELF_V2
+override flavour := linux-ppc64-elfv2
+else
 override flavour := linux-ppc64
 endif
+endif
 
 quiet_cmd_perl = PERL $@
       cmd_perl = $(PERL) $(<) $(flavour) > $(@)
 
 targets += aesp8-ppc.S ghashp8-ppc.S
 
-$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl FORCE
+$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl $(src)/ppc-xlate.pl FORCE
 	$(call if_changed,perl)
   
-$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl FORCE
+$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl $(src)/ppc-xlate.pl FORCE
 	$(call if_changed,perl)
 
 clean-files := aesp8-ppc.S ghashp8-ppc.S
diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl
index 36db2ef09e5b..9db0937d318b 100644
--- a/drivers/crypto/vmx/ppc-xlate.pl
+++ b/drivers/crypto/vmx/ppc-xlate.pl
@@ -9,6 +9,8 @@ open STDOUT,">$output" || die "can't open $output: $!";
 
 my %GLOBALS;
 my $dotinlocallabels=($flavour=~/linux/)?1:0;
+my $abielfv2=(($flavour =~ /linux-ppc64le/) or ($flavour =~ /linux-ppc64-elfv2/))?1:0;
+my $dotfunctions=($abielfv2=~1)?0:1;
 
 ################################################################
 # directives which need special treatment on different platforms
@@ -40,7 +42,7 @@ my $globl = sub {
 };
 my $text = sub {
     my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
-    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
+    $ret = ".abiversion	2\n".$ret	if ($abielfv2);
     $ret;
 };
 my $machine = sub {
@@ -56,8 +58,8 @@ my $size = sub {
     if ($flavour =~ /linux/)
     {	shift;
 	my $name = shift; $name =~ s|^[\.\_]||;
-	my $ret  = ".size	$name,.-".($flavour=~/64$/?".":"").$name;
-	$ret .= "\n.size	.$name,.-.$name" if ($flavour=~/64$/);
+	my $ret  = ".size	$name,.-".($dotfunctions?".":"").$name;
+	$ret .= "\n.size	.$name,.-.$name" if ($dotfunctions);
 	$ret;
     }
     else
@@ -142,7 +144,7 @@ my $vmr = sub {
 
 # Some ABIs specify vrsave, special-purpose register #256, as reserved
 # for system use.
-my $no_vrsave = ($flavour =~ /linux-ppc64le/);
+my $no_vrsave = ($abielfv2);
 my $mtspr = sub {
     my ($f,$idx,$ra) = @_;
     if ($idx == 256 && $no_vrsave) {
-- 
2.23.0


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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2020-04-28 11:25 [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels Nicholas Piggin
@ 2020-04-28 23:40 ` Segher Boessenkool
  2020-04-29  0:57   ` Nicholas Piggin
  2021-05-02 16:57 ` Michal Suchánek
  1 sibling, 1 reply; 16+ messages in thread
From: Segher Boessenkool @ 2020-04-28 23:40 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

Hi!

On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> +config BUILD_BIG_ENDIAN_ELF_V2
> +	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
> +	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
> +	default n
> +	select BUILD_ELF_V2
> +	help
> +	  This builds the kernel image using the ELFv2 ABI, which has a
> +	  reduced stack overhead and faster function calls. This does not
> +	  affect the userspace ABIs.
> +
> +	  ELFv2 is the standard ABI for little-endian, but for big-endian
> +	  this is an experimental option that is less tested (kernel and
> +	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
> +	  newer.

Is it clear that this is only for 64-bit?  Maybe this text should fit
that in somewhere?

It's not obvious to people who do not already know that ELFv2 is just
the (nick-)name of a particular ABI, not a new kind of ELF (it is just
version 1 ELF in fact), and that ABI is for 64-bit Power only.


Segher

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2020-04-28 23:40 ` Segher Boessenkool
@ 2020-04-29  0:57   ` Nicholas Piggin
  2021-05-02 17:55     ` Segher Boessenkool
  0 siblings, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2020-04-29  0:57 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Excerpts from Segher Boessenkool's message of April 29, 2020 9:40 am:
> Hi!
> 
> On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
>> +config BUILD_BIG_ENDIAN_ELF_V2
>> +	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
>> +	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
>> +	default n
>> +	select BUILD_ELF_V2
>> +	help
>> +	  This builds the kernel image using the ELFv2 ABI, which has a
>> +	  reduced stack overhead and faster function calls. This does not
>> +	  affect the userspace ABIs.
>> +
>> +	  ELFv2 is the standard ABI for little-endian, but for big-endian
>> +	  this is an experimental option that is less tested (kernel and
>> +	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
>> +	  newer.
> 
> Is it clear that this is only for 64-bit?  Maybe this text should fit
> that in somewhere?

Don't know if it's necessary, the option only appears when 64-bit is
selected.

> It's not obvious to people who do not already know that ELFv2 is just
> the (nick-)name of a particular ABI, not a new kind of ELF (it is just
> version 1 ELF in fact), and that ABI is for 64-bit Power only.

I blame toolchain for -mabi=elfv2 ! And also some blame on ABI document 
which is called ELF V2 ABI rather than ELF ABI V2 which would have been 
unambiguous.

Kernel mostly gets it right (in the code I didn't write), and uses these

#if defined(_CALL_ELF) && _CALL_ELF == 2
#define PPC64_ELF_ABI_v2
#else
#define PPC64_ELF_ABI_v1
#endif

I can go through and change all my stuff and config options to ELF_ABI_v2.

Thanks,
Nick


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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2020-04-28 11:25 [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels Nicholas Piggin
  2020-04-28 23:40 ` Segher Boessenkool
@ 2021-05-02 16:57 ` Michal Suchánek
  2021-05-03  0:58   ` Nicholas Piggin
  1 sibling, 1 reply; 16+ messages in thread
From: Michal Suchánek @ 2021-05-02 16:57 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> Provide an option to use ELFv2 ABI for big endian builds. This works on
> GCC and clang (since 2014). It is less well tested and supported by the
> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
> for BE (e.g., less stack usage). Some distros even build BE ELFv2
> userspace.

Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.

Tested-by: Michal Suchánek <msuchanek@suse.de>

Also can we enable mprofile on BE now?

I don't see anything endian-specific in the mprofile code at a glance
but don't have any idea how to test it.

Thanks

Michal

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6a4ad11f6349..75b3afbfc378 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -495,7 +495,7 @@ config LD_HEAD_STUB_CATCH
 	  If unsure, say "N".
 
 config MPROFILE_KERNEL
-	depends on PPC64 && CPU_LITTLE_ENDIAN && FUNCTION_TRACER
+	depends on PPC64 && BUILD_ELF_V2 && FUNCTION_TRACER
 	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
 
 config HOTPLUG_CPU
> 
> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
> Since v1:
> - Improved the override flavour name suggested by Segher.
> - Improved changelog wording.
> 
> 
>  arch/powerpc/Kconfig            | 19 +++++++++++++++++++
>  arch/powerpc/Makefile           | 15 ++++++++++-----
>  arch/powerpc/boot/Makefile      |  4 ++++
>  drivers/crypto/vmx/Makefile     |  8 ++++++--
>  drivers/crypto/vmx/ppc-xlate.pl | 10 ++++++----
>  5 files changed, 45 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 924c541a9260..d9d2abc06c2c 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -147,6 +147,7 @@ config PPC
>  	select ARCH_WEAK_RELEASE_ACQUIRE
>  	select BINFMT_ELF
>  	select BUILDTIME_TABLE_SORT
> +	select BUILD_ELF_V2			if PPC64 && CPU_LITTLE_ENDIAN
>  	select CLONE_BACKWARDS
>  	select DCACHE_WORD_ACCESS		if PPC64 && CPU_LITTLE_ENDIAN
>  	select DYNAMIC_FTRACE			if FUNCTION_TRACER
> @@ -541,6 +542,24 @@ config KEXEC_FILE
>  config ARCH_HAS_KEXEC_PURGATORY
>  	def_bool KEXEC_FILE
>  
> +config BUILD_ELF_V2
> +	bool
> +
> +config BUILD_BIG_ENDIAN_ELF_V2
> +	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
> +	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
> +	default n
> +	select BUILD_ELF_V2
> +	help
> +	  This builds the kernel image using the ELFv2 ABI, which has a
> +	  reduced stack overhead and faster function calls. This does not
> +	  affect the userspace ABIs.
> +
> +	  ELFv2 is the standard ABI for little-endian, but for big-endian
> +	  this is an experimental option that is less tested (kernel and
> +	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
> +	  newer.
> +
>  config RELOCATABLE
>  	bool "Build a relocatable kernel"
>  	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index f310c32e88a4..e306b39d847e 100644
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -92,10 +92,14 @@ endif
>  
>  ifdef CONFIG_PPC64
>  ifndef CONFIG_CC_IS_CLANG
> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
> -aflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
> -aflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
> +ifdef CONFIG_BUILD_ELF_V2
> +cflags-y				+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
> +aflags-y				+= $(call cc-option,-mabi=elfv2)
> +else
> +cflags-y				+= $(call cc-option,-mabi=elfv1)
> +cflags-y				+= $(call cc-option,-mcall-aixdesc)
> +aflags-y				+= $(call cc-option,-mabi=elfv1)
> +endif
>  endif
>  endif
>  
> @@ -144,7 +148,7 @@ endif
>  
>  CFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
>  ifndef CONFIG_CC_IS_CLANG
> -ifdef CONFIG_CPU_LITTLE_ENDIAN
> +ifdef CONFIG_BUILD_ELF_V2
>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
>  else
> @@ -153,6 +157,7 @@ CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
>  endif
>  endif
> +
>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
>  
> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> index c53a1b8bba8b..03942d08695d 100644
> --- a/arch/powerpc/boot/Makefile
> +++ b/arch/powerpc/boot/Makefile
> @@ -41,6 +41,10 @@ endif
>  
>  BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
>  
> +ifdef CONFIG_BUILD_ELF_V2
> +BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
> +endif
> +
>  ifdef CONFIG_CPU_BIG_ENDIAN
>  BOOTCFLAGS	+= -mbig-endian
>  else
> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> index 709670d2b553..9aea34602beb 100644
> --- a/drivers/crypto/vmx/Makefile
> +++ b/drivers/crypto/vmx/Makefile
> @@ -5,18 +5,22 @@ vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes
>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
>  override flavour := linux-ppc64le
>  else
> +ifdef CONFIG_BUILD_ELF_V2
> +override flavour := linux-ppc64-elfv2
> +else
>  override flavour := linux-ppc64
>  endif
> +endif
>  
>  quiet_cmd_perl = PERL $@
>        cmd_perl = $(PERL) $(<) $(flavour) > $(@)
>  
>  targets += aesp8-ppc.S ghashp8-ppc.S
>  
> -$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl FORCE
> +$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl $(src)/ppc-xlate.pl FORCE
>  	$(call if_changed,perl)
>    
> -$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl FORCE
> +$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl $(src)/ppc-xlate.pl FORCE
>  	$(call if_changed,perl)
>  
>  clean-files := aesp8-ppc.S ghashp8-ppc.S
> diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl
> index 36db2ef09e5b..9db0937d318b 100644
> --- a/drivers/crypto/vmx/ppc-xlate.pl
> +++ b/drivers/crypto/vmx/ppc-xlate.pl
> @@ -9,6 +9,8 @@ open STDOUT,">$output" || die "can't open $output: $!";
>  
>  my %GLOBALS;
>  my $dotinlocallabels=($flavour=~/linux/)?1:0;
> +my $abielfv2=(($flavour =~ /linux-ppc64le/) or ($flavour =~ /linux-ppc64-elfv2/))?1:0;
> +my $dotfunctions=($abielfv2=~1)?0:1;
>  
>  ################################################################
>  # directives which need special treatment on different platforms
> @@ -40,7 +42,7 @@ my $globl = sub {
>  };
>  my $text = sub {
>      my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
> -    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
> +    $ret = ".abiversion	2\n".$ret	if ($abielfv2);
>      $ret;
>  };
>  my $machine = sub {
> @@ -56,8 +58,8 @@ my $size = sub {
>      if ($flavour =~ /linux/)
>      {	shift;
>  	my $name = shift; $name =~ s|^[\.\_]||;
> -	my $ret  = ".size	$name,.-".($flavour=~/64$/?".":"").$name;
> -	$ret .= "\n.size	.$name,.-.$name" if ($flavour=~/64$/);
> +	my $ret  = ".size	$name,.-".($dotfunctions?".":"").$name;
> +	$ret .= "\n.size	.$name,.-.$name" if ($dotfunctions);
>  	$ret;
>      }
>      else
> @@ -142,7 +144,7 @@ my $vmr = sub {
>  
>  # Some ABIs specify vrsave, special-purpose register #256, as reserved
>  # for system use.
> -my $no_vrsave = ($flavour =~ /linux-ppc64le/);
> +my $no_vrsave = ($abielfv2);
>  my $mtspr = sub {
>      my ($f,$idx,$ra) = @_;
>      if ($idx == 256 && $no_vrsave) {
> -- 
> 2.23.0
> 

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2020-04-29  0:57   ` Nicholas Piggin
@ 2021-05-02 17:55     ` Segher Boessenkool
  2021-05-03  0:51       ` Nicholas Piggin
  0 siblings, 1 reply; 16+ messages in thread
From: Segher Boessenkool @ 2021-05-02 17:55 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Wed, Apr 29, 2020 at 10:57:16AM +1000, Nicholas Piggin wrote:
> Excerpts from Segher Boessenkool's message of April 29, 2020 9:40 am:
> I blame toolchain for -mabi=elfv2 ! And also some blame on ABI document 
> which is called ELF V2 ABI rather than ELF ABI V2 which would have been 
> unambiguous.

At least ELFv2 ABI is correct.  "ELF ABI v2" is not.

> I can go through and change all my stuff and config options to ELF_ABI_v2.

Please don't.  It is wrong.  Both the original PowerPC ELF ABI and the
ELFv2 one have versions themselves.  Also, the base ELF standard has a
version, and is set up so there can be incompatible versions even!  Of
course it still is version 1 to this day, but :-)


Segher

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-02 17:55     ` Segher Boessenkool
@ 2021-05-03  0:51       ` Nicholas Piggin
  2021-05-03 15:18         ` Segher Boessenkool
  0 siblings, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2021-05-03  0:51 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev

Excerpts from Segher Boessenkool's message of May 3, 2021 3:55 am:
> On Wed, Apr 29, 2020 at 10:57:16AM +1000, Nicholas Piggin wrote:
>> Excerpts from Segher Boessenkool's message of April 29, 2020 9:40 am:
>> I blame toolchain for -mabi=elfv2 ! And also some blame on ABI document 
>> which is called ELF V2 ABI rather than ELF ABI V2 which would have been 
>> unambiguous.
> 
> At least ELFv2 ABI is correct.  "ELF ABI v2" is not.
> 
>> I can go through and change all my stuff and config options to ELF_ABI_v2.
> 
> Please don't.  It is wrong.

Then I'm not sure what the point of your previous mail was, what did I 
miss?

> Both the original PowerPC ELF ABI and the
> ELFv2 one have versions themselves.  Also, the base ELF standard has a
> version, and is set up so there can be incompatible versions even!  Of
> course it still is version 1 to this day, but :-)

The point was for people who don't know ELFv2 has a specific meaning for 
powerpc, then ELF ABIv2 is more explanatory about it being an abi change
rather than base elf change, even if it's not the "correct" name.

If you don't want that then good, I also prefer to just use ELFv2. I 
think people who change this option can easily look up the name in 
toolchain and other docs.

Thanks,
Nick

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-02 16:57 ` Michal Suchánek
@ 2021-05-03  0:58   ` Nicholas Piggin
  2021-05-03  7:11     ` Michal Suchánek
  0 siblings, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2021-05-03  0:58 UTC (permalink / raw)
  To: Michal Suchánek; +Cc: linuxppc-dev

Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
> On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
>> Provide an option to use ELFv2 ABI for big endian builds. This works on
>> GCC and clang (since 2014). It is less well tested and supported by the
>> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
>> for BE (e.g., less stack usage). Some distros even build BE ELFv2
>> userspace.
> 
> Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.

What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
at least make it depend on BUILD_ELF_V2?

> 
> Tested-by: Michal Suchánek <msuchanek@suse.de>
> 
> Also can we enable mprofile on BE now?
> 
> I don't see anything endian-specific in the mprofile code at a glance
> but don't have any idea how to test it.

AFAIK it's just a different ABI for the _mcount call so just running
some ftrace and ftrace with call graph should test it reasonably well.

> 
> Thanks
> 
> Michal
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 6a4ad11f6349..75b3afbfc378 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -495,7 +495,7 @@ config LD_HEAD_STUB_CATCH
>  	  If unsure, say "N".
>  
>  config MPROFILE_KERNEL
> -	depends on PPC64 && CPU_LITTLE_ENDIAN && FUNCTION_TRACER
> +	depends on PPC64 && BUILD_ELF_V2 && FUNCTION_TRACER
>  	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)

Good idea. I can't remember if I did a grep for LITTLE_ENDIAN to check 
for other such opportunities.

Thanks,
Nick

>  
>  config HOTPLUG_CPU
>> 
>> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>> Since v1:
>> - Improved the override flavour name suggested by Segher.
>> - Improved changelog wording.
>> 
>> 
>>  arch/powerpc/Kconfig            | 19 +++++++++++++++++++
>>  arch/powerpc/Makefile           | 15 ++++++++++-----
>>  arch/powerpc/boot/Makefile      |  4 ++++
>>  drivers/crypto/vmx/Makefile     |  8 ++++++--
>>  drivers/crypto/vmx/ppc-xlate.pl | 10 ++++++----
>>  5 files changed, 45 insertions(+), 11 deletions(-)
>> 
>> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
>> index 924c541a9260..d9d2abc06c2c 100644
>> --- a/arch/powerpc/Kconfig
>> +++ b/arch/powerpc/Kconfig
>> @@ -147,6 +147,7 @@ config PPC
>>  	select ARCH_WEAK_RELEASE_ACQUIRE
>>  	select BINFMT_ELF
>>  	select BUILDTIME_TABLE_SORT
>> +	select BUILD_ELF_V2			if PPC64 && CPU_LITTLE_ENDIAN
>>  	select CLONE_BACKWARDS
>>  	select DCACHE_WORD_ACCESS		if PPC64 && CPU_LITTLE_ENDIAN
>>  	select DYNAMIC_FTRACE			if FUNCTION_TRACER
>> @@ -541,6 +542,24 @@ config KEXEC_FILE
>>  config ARCH_HAS_KEXEC_PURGATORY
>>  	def_bool KEXEC_FILE
>>  
>> +config BUILD_ELF_V2
>> +	bool
>> +
>> +config BUILD_BIG_ENDIAN_ELF_V2
>> +	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
>> +	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
>> +	default n
>> +	select BUILD_ELF_V2
>> +	help
>> +	  This builds the kernel image using the ELFv2 ABI, which has a
>> +	  reduced stack overhead and faster function calls. This does not
>> +	  affect the userspace ABIs.
>> +
>> +	  ELFv2 is the standard ABI for little-endian, but for big-endian
>> +	  this is an experimental option that is less tested (kernel and
>> +	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
>> +	  newer.
>> +
>>  config RELOCATABLE
>>  	bool "Build a relocatable kernel"
>>  	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
>> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
>> index f310c32e88a4..e306b39d847e 100644
>> --- a/arch/powerpc/Makefile
>> +++ b/arch/powerpc/Makefile
>> @@ -92,10 +92,14 @@ endif
>>  
>>  ifdef CONFIG_PPC64
>>  ifndef CONFIG_CC_IS_CLANG
>> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
>> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
>> -aflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
>> -aflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
>> +ifdef CONFIG_BUILD_ELF_V2
>> +cflags-y				+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
>> +aflags-y				+= $(call cc-option,-mabi=elfv2)
>> +else
>> +cflags-y				+= $(call cc-option,-mabi=elfv1)
>> +cflags-y				+= $(call cc-option,-mcall-aixdesc)
>> +aflags-y				+= $(call cc-option,-mabi=elfv1)
>> +endif
>>  endif
>>  endif
>>  
>> @@ -144,7 +148,7 @@ endif
>>  
>>  CFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
>>  ifndef CONFIG_CC_IS_CLANG
>> -ifdef CONFIG_CPU_LITTLE_ENDIAN
>> +ifdef CONFIG_BUILD_ELF_V2
>>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
>>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
>>  else
>> @@ -153,6 +157,7 @@ CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
>>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
>>  endif
>>  endif
>> +
>>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
>>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
>>  
>> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
>> index c53a1b8bba8b..03942d08695d 100644
>> --- a/arch/powerpc/boot/Makefile
>> +++ b/arch/powerpc/boot/Makefile
>> @@ -41,6 +41,10 @@ endif
>>  
>>  BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
>>  
>> +ifdef CONFIG_BUILD_ELF_V2
>> +BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
>> +endif
>> +
>>  ifdef CONFIG_CPU_BIG_ENDIAN
>>  BOOTCFLAGS	+= -mbig-endian
>>  else
>> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
>> index 709670d2b553..9aea34602beb 100644
>> --- a/drivers/crypto/vmx/Makefile
>> +++ b/drivers/crypto/vmx/Makefile
>> @@ -5,18 +5,22 @@ vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes
>>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
>>  override flavour := linux-ppc64le
>>  else
>> +ifdef CONFIG_BUILD_ELF_V2
>> +override flavour := linux-ppc64-elfv2
>> +else
>>  override flavour := linux-ppc64
>>  endif
>> +endif
>>  
>>  quiet_cmd_perl = PERL $@
>>        cmd_perl = $(PERL) $(<) $(flavour) > $(@)
>>  
>>  targets += aesp8-ppc.S ghashp8-ppc.S
>>  
>> -$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl FORCE
>> +$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl $(src)/ppc-xlate.pl FORCE
>>  	$(call if_changed,perl)
>>    
>> -$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl FORCE
>> +$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl $(src)/ppc-xlate.pl FORCE
>>  	$(call if_changed,perl)
>>  
>>  clean-files := aesp8-ppc.S ghashp8-ppc.S
>> diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl
>> index 36db2ef09e5b..9db0937d318b 100644
>> --- a/drivers/crypto/vmx/ppc-xlate.pl
>> +++ b/drivers/crypto/vmx/ppc-xlate.pl
>> @@ -9,6 +9,8 @@ open STDOUT,">$output" || die "can't open $output: $!";
>>  
>>  my %GLOBALS;
>>  my $dotinlocallabels=($flavour=~/linux/)?1:0;
>> +my $abielfv2=(($flavour =~ /linux-ppc64le/) or ($flavour =~ /linux-ppc64-elfv2/))?1:0;
>> +my $dotfunctions=($abielfv2=~1)?0:1;
>>  
>>  ################################################################
>>  # directives which need special treatment on different platforms
>> @@ -40,7 +42,7 @@ my $globl = sub {
>>  };
>>  my $text = sub {
>>      my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
>> -    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
>> +    $ret = ".abiversion	2\n".$ret	if ($abielfv2);
>>      $ret;
>>  };
>>  my $machine = sub {
>> @@ -56,8 +58,8 @@ my $size = sub {
>>      if ($flavour =~ /linux/)
>>      {	shift;
>>  	my $name = shift; $name =~ s|^[\.\_]||;
>> -	my $ret  = ".size	$name,.-".($flavour=~/64$/?".":"").$name;
>> -	$ret .= "\n.size	.$name,.-.$name" if ($flavour=~/64$/);
>> +	my $ret  = ".size	$name,.-".($dotfunctions?".":"").$name;
>> +	$ret .= "\n.size	.$name,.-.$name" if ($dotfunctions);
>>  	$ret;
>>      }
>>      else
>> @@ -142,7 +144,7 @@ my $vmr = sub {
>>  
>>  # Some ABIs specify vrsave, special-purpose register #256, as reserved
>>  # for system use.
>> -my $no_vrsave = ($flavour =~ /linux-ppc64le/);
>> +my $no_vrsave = ($abielfv2);
>>  my $mtspr = sub {
>>      my ($f,$idx,$ra) = @_;
>>      if ($idx == 256 && $no_vrsave) {
>> -- 
>> 2.23.0
>> 
> 

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03  0:58   ` Nicholas Piggin
@ 2021-05-03  7:11     ` Michal Suchánek
  2021-05-03  9:34       ` Michal Suchánek
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Suchánek @ 2021-05-03  7:11 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
> Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
> > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> >> Provide an option to use ELFv2 ABI for big endian builds. This works on
> >> GCC and clang (since 2014). It is less well tested and supported by the
> >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
> >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
> >> userspace.
> > 
> > Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.
> 
> What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
> at least make it depend on BUILD_ELF_V2?

Looks like symbols are prefixed with a dot in ABIv1 and BTFID tool is
not aware of that. It can be disabled on ABIv1 easily.

Thanks

Michal

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 678c13967580..e703c26e9b80 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
 	bool "Generate BTF typeinfo"
 	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
 	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
+	depends on !PPC64 || BUILD_ELF_V2
 	help
 	  Generate deduplicated BTF type information from DWARF debug info.
 	  Turning this on expects presence of pahole tool, which will convert

> 
> > 
> > Tested-by: Michal Suchánek <msuchanek@suse.de>
> > 
> > Also can we enable mprofile on BE now?
> > 
> > I don't see anything endian-specific in the mprofile code at a glance
> > but don't have any idea how to test it.
> 
> AFAIK it's just a different ABI for the _mcount call so just running
> some ftrace and ftrace with call graph should test it reasonably well.
> 
> > 
> > Thanks
> > 
> > Michal
> > 
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index 6a4ad11f6349..75b3afbfc378 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -495,7 +495,7 @@ config LD_HEAD_STUB_CATCH
> >  	  If unsure, say "N".
> >  
> >  config MPROFILE_KERNEL
> > -	depends on PPC64 && CPU_LITTLE_ENDIAN && FUNCTION_TRACER
> > +	depends on PPC64 && BUILD_ELF_V2 && FUNCTION_TRACER
> >  	def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
> 
> Good idea. I can't remember if I did a grep for LITTLE_ENDIAN to check 
> for other such opportunities.
> 
> Thanks,
> Nick
> 
> >  
> >  config HOTPLUG_CPU
> >> 
> >> Reviewed-by: Segher Boessenkool <segher@kernel.crashing.org>
> >> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> >> ---
> >> Since v1:
> >> - Improved the override flavour name suggested by Segher.
> >> - Improved changelog wording.
> >> 
> >> 
> >>  arch/powerpc/Kconfig            | 19 +++++++++++++++++++
> >>  arch/powerpc/Makefile           | 15 ++++++++++-----
> >>  arch/powerpc/boot/Makefile      |  4 ++++
> >>  drivers/crypto/vmx/Makefile     |  8 ++++++--
> >>  drivers/crypto/vmx/ppc-xlate.pl | 10 ++++++----
> >>  5 files changed, 45 insertions(+), 11 deletions(-)
> >> 
> >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> >> index 924c541a9260..d9d2abc06c2c 100644
> >> --- a/arch/powerpc/Kconfig
> >> +++ b/arch/powerpc/Kconfig
> >> @@ -147,6 +147,7 @@ config PPC
> >>  	select ARCH_WEAK_RELEASE_ACQUIRE
> >>  	select BINFMT_ELF
> >>  	select BUILDTIME_TABLE_SORT
> >> +	select BUILD_ELF_V2			if PPC64 && CPU_LITTLE_ENDIAN
> >>  	select CLONE_BACKWARDS
> >>  	select DCACHE_WORD_ACCESS		if PPC64 && CPU_LITTLE_ENDIAN
> >>  	select DYNAMIC_FTRACE			if FUNCTION_TRACER
> >> @@ -541,6 +542,24 @@ config KEXEC_FILE
> >>  config ARCH_HAS_KEXEC_PURGATORY
> >>  	def_bool KEXEC_FILE
> >>  
> >> +config BUILD_ELF_V2
> >> +	bool
> >> +
> >> +config BUILD_BIG_ENDIAN_ELF_V2
> >> +	bool "Build big-endian kernel using ELFv2 ABI (EXPERIMENTAL)"
> >> +	depends on PPC64 && CPU_BIG_ENDIAN && EXPERT
> >> +	default n
> >> +	select BUILD_ELF_V2
> >> +	help
> >> +	  This builds the kernel image using the ELFv2 ABI, which has a
> >> +	  reduced stack overhead and faster function calls. This does not
> >> +	  affect the userspace ABIs.
> >> +
> >> +	  ELFv2 is the standard ABI for little-endian, but for big-endian
> >> +	  this is an experimental option that is less tested (kernel and
> >> +	  toolchain). This requires gcc 4.9 or newer and binutils 2.24 or
> >> +	  newer.
> >> +
> >>  config RELOCATABLE
> >>  	bool "Build a relocatable kernel"
> >>  	depends on PPC64 || (FLATMEM && (44x || FSL_BOOKE))
> >> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> >> index f310c32e88a4..e306b39d847e 100644
> >> --- a/arch/powerpc/Makefile
> >> +++ b/arch/powerpc/Makefile
> >> @@ -92,10 +92,14 @@ endif
> >>  
> >>  ifdef CONFIG_PPC64
> >>  ifndef CONFIG_CC_IS_CLANG
> >> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
> >> -cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
> >> -aflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
> >> -aflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
> >> +ifdef CONFIG_BUILD_ELF_V2
> >> +cflags-y				+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
> >> +aflags-y				+= $(call cc-option,-mabi=elfv2)
> >> +else
> >> +cflags-y				+= $(call cc-option,-mabi=elfv1)
> >> +cflags-y				+= $(call cc-option,-mcall-aixdesc)
> >> +aflags-y				+= $(call cc-option,-mabi=elfv1)
> >> +endif
> >>  endif
> >>  endif
> >>  
> >> @@ -144,7 +148,7 @@ endif
> >>  
> >>  CFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
> >>  ifndef CONFIG_CC_IS_CLANG
> >> -ifdef CONFIG_CPU_LITTLE_ENDIAN
> >> +ifdef CONFIG_BUILD_ELF_V2
> >>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
> >>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
> >>  else
> >> @@ -153,6 +157,7 @@ CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
> >>  AFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
> >>  endif
> >>  endif
> >> +
> >>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
> >>  CFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
> >>  
> >> diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
> >> index c53a1b8bba8b..03942d08695d 100644
> >> --- a/arch/powerpc/boot/Makefile
> >> +++ b/arch/powerpc/boot/Makefile
> >> @@ -41,6 +41,10 @@ endif
> >>  
> >>  BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
> >>  
> >> +ifdef CONFIG_BUILD_ELF_V2
> >> +BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
> >> +endif
> >> +
> >>  ifdef CONFIG_CPU_BIG_ENDIAN
> >>  BOOTCFLAGS	+= -mbig-endian
> >>  else
> >> diff --git a/drivers/crypto/vmx/Makefile b/drivers/crypto/vmx/Makefile
> >> index 709670d2b553..9aea34602beb 100644
> >> --- a/drivers/crypto/vmx/Makefile
> >> +++ b/drivers/crypto/vmx/Makefile
> >> @@ -5,18 +5,22 @@ vmx-crypto-objs := vmx.o aesp8-ppc.o ghashp8-ppc.o aes.o aes_cbc.o aes_ctr.o aes
> >>  ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
> >>  override flavour := linux-ppc64le
> >>  else
> >> +ifdef CONFIG_BUILD_ELF_V2
> >> +override flavour := linux-ppc64-elfv2
> >> +else
> >>  override flavour := linux-ppc64
> >>  endif
> >> +endif
> >>  
> >>  quiet_cmd_perl = PERL $@
> >>        cmd_perl = $(PERL) $(<) $(flavour) > $(@)
> >>  
> >>  targets += aesp8-ppc.S ghashp8-ppc.S
> >>  
> >> -$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl FORCE
> >> +$(obj)/aesp8-ppc.S: $(src)/aesp8-ppc.pl $(src)/ppc-xlate.pl FORCE
> >>  	$(call if_changed,perl)
> >>    
> >> -$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl FORCE
> >> +$(obj)/ghashp8-ppc.S: $(src)/ghashp8-ppc.pl $(src)/ppc-xlate.pl FORCE
> >>  	$(call if_changed,perl)
> >>  
> >>  clean-files := aesp8-ppc.S ghashp8-ppc.S
> >> diff --git a/drivers/crypto/vmx/ppc-xlate.pl b/drivers/crypto/vmx/ppc-xlate.pl
> >> index 36db2ef09e5b..9db0937d318b 100644
> >> --- a/drivers/crypto/vmx/ppc-xlate.pl
> >> +++ b/drivers/crypto/vmx/ppc-xlate.pl
> >> @@ -9,6 +9,8 @@ open STDOUT,">$output" || die "can't open $output: $!";
> >>  
> >>  my %GLOBALS;
> >>  my $dotinlocallabels=($flavour=~/linux/)?1:0;
> >> +my $abielfv2=(($flavour =~ /linux-ppc64le/) or ($flavour =~ /linux-ppc64-elfv2/))?1:0;
> >> +my $dotfunctions=($abielfv2=~1)?0:1;
> >>  
> >>  ################################################################
> >>  # directives which need special treatment on different platforms
> >> @@ -40,7 +42,7 @@ my $globl = sub {
> >>  };
> >>  my $text = sub {
> >>      my $ret = ($flavour =~ /aix/) ? ".csect\t.text[PR],7" : ".text";
> >> -    $ret = ".abiversion	2\n".$ret	if ($flavour =~ /linux.*64le/);
> >> +    $ret = ".abiversion	2\n".$ret	if ($abielfv2);
> >>      $ret;
> >>  };
> >>  my $machine = sub {
> >> @@ -56,8 +58,8 @@ my $size = sub {
> >>      if ($flavour =~ /linux/)
> >>      {	shift;
> >>  	my $name = shift; $name =~ s|^[\.\_]||;
> >> -	my $ret  = ".size	$name,.-".($flavour=~/64$/?".":"").$name;
> >> -	$ret .= "\n.size	.$name,.-.$name" if ($flavour=~/64$/);
> >> +	my $ret  = ".size	$name,.-".($dotfunctions?".":"").$name;
> >> +	$ret .= "\n.size	.$name,.-.$name" if ($dotfunctions);
> >>  	$ret;
> >>      }
> >>      else
> >> @@ -142,7 +144,7 @@ my $vmr = sub {
> >>  
> >>  # Some ABIs specify vrsave, special-purpose register #256, as reserved
> >>  # for system use.
> >> -my $no_vrsave = ($flavour =~ /linux-ppc64le/);
> >> +my $no_vrsave = ($abielfv2);
> >>  my $mtspr = sub {
> >>      my ($f,$idx,$ra) = @_;
> >>      if ($idx == 256 && $no_vrsave) {
> >> -- 
> >> 2.23.0
> >> 
> > 

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03  7:11     ` Michal Suchánek
@ 2021-05-03  9:34       ` Michal Suchánek
  2021-05-03 20:17         ` Michal Suchánek
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Suchánek @ 2021-05-03  9:34 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Mon, May 03, 2021 at 09:11:16AM +0200, Michal Suchánek wrote:
> On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
> > Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
> > > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> > >> Provide an option to use ELFv2 ABI for big endian builds. This works on
> > >> GCC and clang (since 2014). It is less well tested and supported by the
> > >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
> > >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
> > >> userspace.
> > > 
> > > Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.
> > 
> > What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
> > at least make it depend on BUILD_ELF_V2?
> 
> Looks like symbols are prefixed with a dot in ABIv1 and BTFID tool is
> not aware of that. It can be disabled on ABIv1 easily.
> 
> Thanks
> 
> Michal
> 
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 678c13967580..e703c26e9b80 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
>  	bool "Generate BTF typeinfo"
>  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
>  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
> +	depends on !PPC64 || BUILD_ELF_V2
>  	help
>  	  Generate deduplicated BTF type information from DWARF debug info.
>  	  Turning this on expects presence of pahole tool, which will convert
> 
> > 
> > > 
> > > Tested-by: Michal Suchánek <msuchanek@suse.de>
> > > 
> > > Also can we enable mprofile on BE now?
> > > 
> > > I don't see anything endian-specific in the mprofile code at a glance
> > > but don't have any idea how to test it.
> > 
> > AFAIK it's just a different ABI for the _mcount call so just running
> > some ftrace and ftrace with call graph should test it reasonably well.

It does not crash and burn but there are some regressions from LE to BE
on the ftrace kernel selftest:

--- ftraceLE.txt	2021-05-03 11:19:14.830000000 +0200
+++ ftraceBE.txt	2021-05-03 11:27:24.770000000 +0200
@@ -7,8 +7,8 @@
 [n] Change the ringbuffer size	[PASS]
 [n] Snapshot and tracing setting	[PASS]
 [n] trace_pipe and trace_marker	[PASS]
-[n] Test ftrace direct functions against tracers	[UNRESOLVED]
-[n] Test ftrace direct functions against kprobes	[UNRESOLVED]
+[n] Test ftrace direct functions against tracers	[FAIL]
+[n] Test ftrace direct functions against kprobes	[FAIL]
 [n] Generic dynamic event - add/remove kprobe events	[PASS]
 [n] Generic dynamic event - add/remove synthetic events	[PASS]
 [n] Generic dynamic event - selective clear (compatibility)	[PASS]
@@ -16,10 +16,10 @@
 [n] event tracing - enable/disable with event level files	[PASS]
 [n] event tracing - restricts events based on pid notrace filtering	[PASS]
 [n] event tracing - restricts events based on pid	[PASS]
-[n] event tracing - enable/disable with subsystem level files	[PASS]
+[n] event tracing - enable/disable with subsystem level files	[FAIL]
 [n] event tracing - enable/disable with top level files	[PASS]
-[n] Test trace_printk from module	[UNRESOLVED]
-[n] ftrace - function graph filters with stack tracer	[PASS]
+[n] Test trace_printk from module	[FAIL]
+[n] ftrace - function graph filters with stack tracer	[FAIL]
 [n] ftrace - function graph filters	[PASS]
 [n] ftrace - function trace with cpumask	[PASS]
 [n] ftrace - test for function event triggers	[PASS]
@@ -27,7 +27,7 @@
 [n] ftrace - function pid notrace filters	[PASS]
 [n] ftrace - function pid filters	[PASS]
 [n] ftrace - stacktrace filter command	[PASS]
-[n] ftrace - function trace on module	[UNRESOLVED]
+[n] ftrace - function trace on module	[FAIL]
 [n] ftrace - function profiler with function tracing	[PASS]
 [n] ftrace - function profiling	[PASS]
 [n] ftrace - test reading of set_ftrace_filter	[PASS]
@@ -44,10 +44,10 @@
 [n] Kprobe event argument syntax	[PASS]
 [n] Kprobe dynamic event with arguments	[PASS]
 [n] Kprobes event arguments with types	[PASS]
-[n] Kprobe event user-memory access	[UNSUPPORTED]
+[n] Kprobe event user-memory access	[FAIL]
 [n] Kprobe event auto/manual naming	[PASS]
 [n] Kprobe dynamic event with function tracer	[PASS]
-[n] Kprobe dynamic event - probing module	[UNRESOLVED]
+[n] Kprobe dynamic event - probing module	[FAIL]
 [n] Create/delete multiprobe on kprobe event	[PASS]
 [n] Kprobe event parser error log check	[PASS]
 [n] Kretprobe dynamic event with arguments	[PASS]
@@ -57,11 +57,11 @@
 [n] Kprobe events - probe points	[PASS]
 [n] Kprobe dynamic event - adding and removing	[PASS]
 [n] Uprobe event parser error log check	[PASS]
-[n] test for the preemptirqsoff tracer	[UNSUPPORTED]
-[n] Meta-selftest: Checkbashisms	[UNRESOLVED]
+[n] test for the preemptirqsoff tracer	[FAIL]
+[n] Meta-selftest: Checkbashisms	[FAIL]
 [n] Test wakeup RT tracer	[PASS]
 [n] Test wakeup tracer	[PASS]
-[n] event trigger - test inter-event histogram trigger expected fail actions	[XFAIL]
+[n] event trigger - test inter-event histogram trigger expected fail actions	[FAIL]
 [n] event trigger - test field variable support	[PASS]
 [n] event trigger - test inter-event combined histogram trigger	[PASS]
 [n] event trigger - test multiple actions on hist trigger	[PASS]
@@ -96,7 +96,8 @@
 [n] (instance)  event tracing - enable/disable with event level files	[PASS]
 [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
 [n] (instance)  event tracing - restricts events based on pid	[PASS]
-[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
+[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
+rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.mceByV': Device or resource busy
 [n] (instance)  ftrace - test for function event triggers	[PASS]
 [n] (instance)  ftrace - function pid notrace filters	[PASS]
 [n] (instance)  ftrace - function pid filters	[PASS]

I needed to add a test timeout to get this far because
"event tracing - enable/disable with subsystem level files" gets stuck.

Thanks

Michal

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03  0:51       ` Nicholas Piggin
@ 2021-05-03 15:18         ` Segher Boessenkool
  2021-05-04 12:15           ` Michael Ellerman
  0 siblings, 1 reply; 16+ messages in thread
From: Segher Boessenkool @ 2021-05-03 15:18 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

Hi!

On Mon, May 03, 2021 at 10:51:41AM +1000, Nicholas Piggin wrote:
> Excerpts from Segher Boessenkool's message of May 3, 2021 3:55 am:
> > On Wed, Apr 29, 2020 at 10:57:16AM +1000, Nicholas Piggin wrote:
> >> Excerpts from Segher Boessenkool's message of April 29, 2020 9:40 am:
> >> I blame toolchain for -mabi=elfv2 ! And also some blame on ABI document 
> >> which is called ELF V2 ABI rather than ELF ABI V2 which would have been 
> >> unambiguous.
> > 
> > At least ELFv2 ABI is correct.  "ELF ABI v2" is not.
> > 
> >> I can go through and change all my stuff and config options to ELF_ABI_v2.
> > 
> > Please don't.  It is wrong.
> 
> Then I'm not sure what the point of your previous mail was, what did I 
> miss?

I asked if you could make it clearer to people who do not know what this
is whether they want to use it.  Or that was my intention, anyhow :-/

> > Both the original PowerPC ELF ABI and the
> > ELFv2 one have versions themselves.  Also, the base ELF standard has a
> > version, and is set up so there can be incompatible versions even!  Of
> > course it still is version 1 to this day, but :-)
> 
> The point was for people who don't know ELFv2 has a specific meaning for 
> powerpc,

It does not have *any* meaning outside of Power.  But people who do not
know what it is can assume the wrong things about it.  It isn't a great
name because of that :-(

(It's not as bad as the MIPS ABIs -- an older one is called "new" :-) )

> then ELF ABIv2 is more explanatory about it being an abi change
> rather than base elf change, even if it's not the "correct" name.

I very much disagree.  "ELF ABIv2" is completely meaningless.

> If you don't want that then good, I also prefer to just use ELFv2. I 

Good :-)

> think people who change this option can easily look up the name in 
> toolchain and other docs.

Yeah.  As long as the defaults are good, whoever blows themselves up has
only themselves to blame :-P


Segher

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03  9:34       ` Michal Suchánek
@ 2021-05-03 20:17         ` Michal Suchánek
  2021-05-04  9:13           ` Nicholas Piggin
  0 siblings, 1 reply; 16+ messages in thread
From: Michal Suchánek @ 2021-05-03 20:17 UTC (permalink / raw)
  To: Nicholas Piggin; +Cc: linuxppc-dev

On Mon, May 03, 2021 at 11:34:25AM +0200, Michal Suchánek wrote:
> On Mon, May 03, 2021 at 09:11:16AM +0200, Michal Suchánek wrote:
> > On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
> > > Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
> > > > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> > > >> Provide an option to use ELFv2 ABI for big endian builds. This works on
> > > >> GCC and clang (since 2014). It is less well tested and supported by the
> > > >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
> > > >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
> > > >> userspace.
> > > > 
> > > > Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.
> > > 
> > > What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
> > > at least make it depend on BUILD_ELF_V2?
> > 
> > Looks like symbols are prefixed with a dot in ABIv1 and BTFID tool is
> > not aware of that. It can be disabled on ABIv1 easily.
> > 
> > Thanks
> > 
> > Michal
> > 
> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > index 678c13967580..e703c26e9b80 100644
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
> >  	bool "Generate BTF typeinfo"
> >  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
> >  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
> > +	depends on !PPC64 || BUILD_ELF_V2
> >  	help
> >  	  Generate deduplicated BTF type information from DWARF debug info.
> >  	  Turning this on expects presence of pahole tool, which will convert
> > 
> > > 
> > > > 
> > > > Tested-by: Michal Suchánek <msuchanek@suse.de>
> > > > 
> > > > Also can we enable mprofile on BE now?
> > > > 
> > > > I don't see anything endian-specific in the mprofile code at a glance
> > > > but don't have any idea how to test it.
> > > 
> > > AFAIK it's just a different ABI for the _mcount call so just running
> > > some ftrace and ftrace with call graph should test it reasonably well.
> 
> It does not crash and burn but there are some regressions from LE to BE
> on the ftrace kernel selftest:
> 
> --- ftraceLE.txt	2021-05-03 11:19:14.830000000 +0200
> +++ ftraceBE.txt	2021-05-03 11:27:24.770000000 +0200
> @@ -7,8 +7,8 @@
>  [n] Change the ringbuffer size	[PASS]
>  [n] Snapshot and tracing setting	[PASS]
>  [n] trace_pipe and trace_marker	[PASS]
> -[n] Test ftrace direct functions against tracers	[UNRESOLVED]
> -[n] Test ftrace direct functions against kprobes	[UNRESOLVED]
> +[n] Test ftrace direct functions against tracers	[FAIL]
> +[n] Test ftrace direct functions against kprobes	[FAIL]
>  [n] Generic dynamic event - add/remove kprobe events	[PASS]
>  [n] Generic dynamic event - add/remove synthetic events	[PASS]
>  [n] Generic dynamic event - selective clear (compatibility)	[PASS]
> @@ -16,10 +16,10 @@
>  [n] event tracing - enable/disable with event level files	[PASS]
>  [n] event tracing - restricts events based on pid notrace filtering	[PASS]
>  [n] event tracing - restricts events based on pid	[PASS]
> -[n] event tracing - enable/disable with subsystem level files	[PASS]
> +[n] event tracing - enable/disable with subsystem level files	[FAIL]
>  [n] event tracing - enable/disable with top level files	[PASS]
> -[n] Test trace_printk from module	[UNRESOLVED]
> -[n] ftrace - function graph filters with stack tracer	[PASS]
> +[n] Test trace_printk from module	[FAIL]
> +[n] ftrace - function graph filters with stack tracer	[FAIL]
>  [n] ftrace - function graph filters	[PASS]
>  [n] ftrace - function trace with cpumask	[PASS]
>  [n] ftrace - test for function event triggers	[PASS]
> @@ -27,7 +27,7 @@
>  [n] ftrace - function pid notrace filters	[PASS]
>  [n] ftrace - function pid filters	[PASS]
>  [n] ftrace - stacktrace filter command	[PASS]
> -[n] ftrace - function trace on module	[UNRESOLVED]
> +[n] ftrace - function trace on module	[FAIL]
>  [n] ftrace - function profiler with function tracing	[PASS]
>  [n] ftrace - function profiling	[PASS]
>  [n] ftrace - test reading of set_ftrace_filter	[PASS]
> @@ -44,10 +44,10 @@
>  [n] Kprobe event argument syntax	[PASS]
>  [n] Kprobe dynamic event with arguments	[PASS]
>  [n] Kprobes event arguments with types	[PASS]
> -[n] Kprobe event user-memory access	[UNSUPPORTED]
> +[n] Kprobe event user-memory access	[FAIL]
>  [n] Kprobe event auto/manual naming	[PASS]
>  [n] Kprobe dynamic event with function tracer	[PASS]
> -[n] Kprobe dynamic event - probing module	[UNRESOLVED]
> +[n] Kprobe dynamic event - probing module	[FAIL]
>  [n] Create/delete multiprobe on kprobe event	[PASS]
>  [n] Kprobe event parser error log check	[PASS]
>  [n] Kretprobe dynamic event with arguments	[PASS]
> @@ -57,11 +57,11 @@
>  [n] Kprobe events - probe points	[PASS]
>  [n] Kprobe dynamic event - adding and removing	[PASS]
>  [n] Uprobe event parser error log check	[PASS]
> -[n] test for the preemptirqsoff tracer	[UNSUPPORTED]
> -[n] Meta-selftest: Checkbashisms	[UNRESOLVED]
> +[n] test for the preemptirqsoff tracer	[FAIL]
> +[n] Meta-selftest: Checkbashisms	[FAIL]
>  [n] Test wakeup RT tracer	[PASS]
>  [n] Test wakeup tracer	[PASS]
> -[n] event trigger - test inter-event histogram trigger expected fail actions	[XFAIL]
> +[n] event trigger - test inter-event histogram trigger expected fail actions	[FAIL]
>  [n] event trigger - test field variable support	[PASS]
>  [n] event trigger - test inter-event combined histogram trigger	[PASS]
>  [n] event trigger - test multiple actions on hist trigger	[PASS]
> @@ -96,7 +96,8 @@
>  [n] (instance)  event tracing - enable/disable with event level files	[PASS]
>  [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
>  [n] (instance)  event tracing - restricts events based on pid	[PASS]
> -[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
> +[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
> +rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.mceByV': Device or resource busy
>  [n] (instance)  ftrace - test for function event triggers	[PASS]
>  [n] (instance)  ftrace - function pid notrace filters	[PASS]
>  [n] (instance)  ftrace - function pid filters	[PASS]
> 
> I needed to add a test timeout to get this far because
> "event tracing - enable/disable with subsystem level files" gets stuck.

There is some regression from mprofile on BE ABIv2

--- ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
+++ ftraceBE.mprofile.txt	2021-05-03 11:27:24.770000000 +0200
@@ -19,7 +19,7 @@
 [n] event tracing - enable/disable with subsystem level files	[FAIL]
 [n] event tracing - enable/disable with top level files	[PASS]
 [n] Test trace_printk from module	[FAIL]
-[n] ftrace - function graph filters with stack tracer	[PASS]
+[n] ftrace - function graph filters with stack tracer	[FAIL]
 [n] ftrace - function graph filters	[PASS]
 [n] ftrace - function trace with cpumask	[PASS]
 [n] ftrace - test for function event triggers	[PASS]
@@ -31,7 +31,7 @@
 [n] ftrace - function profiler with function tracing	[PASS]
 [n] ftrace - function profiling	[PASS]
 [n] ftrace - test reading of set_ftrace_filter	[PASS]
-[n] ftrace - Max stack tracer	[PASS]
+[n] ftrace - Max stack tracer	[FAIL]
 [n] ftrace - test for function traceon/off triggers	[PASS]
 [n] ftrace - test tracing error log support	[PASS]
 [n] Test creation and deletion of trace instances while setting an event	[PASS]

but generally the ftrace on BE is broken overall. The test
"event tracing - enable/disable with subsystem level files" gets stuck
and has to be killed by timeout. Running the testsuite twice the test
"Basic test for tracers" locks up the machine regardless of using
mprofile. The ABIV1 is even much worse with the exception of
"(instance)  event tracing - enable/disable with subsystem level files"
which regresses on BE ABIv2 in general.

--- ftraceBEv1.txt	2021-05-03 22:09:10.690000000 +0200
+++ ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
@@ -9,10 +9,10 @@
 [n] trace_pipe and trace_marker	[PASS]
 [n] Test ftrace direct functions against tracers	[FAIL]
 [n] Test ftrace direct functions against kprobes	[FAIL]
-[n] Generic dynamic event - add/remove kprobe events	[FAIL]
+[n] Generic dynamic event - add/remove kprobe events	[PASS]
 [n] Generic dynamic event - add/remove synthetic events	[PASS]
-[n] Generic dynamic event - selective clear (compatibility)	[FAIL]
-[n] Generic dynamic event - generic clear event	[FAIL]
+[n] Generic dynamic event - selective clear (compatibility)	[PASS]
+[n] Generic dynamic event - generic clear event	[PASS]
 [n] event tracing - enable/disable with event level files	[PASS]
 [n] event tracing - restricts events based on pid notrace filtering	[PASS]
 [n] event tracing - restricts events based on pid	[PASS]
@@ -23,39 +23,39 @@
 [n] ftrace - function graph filters	[PASS]
 [n] ftrace - function trace with cpumask	[PASS]
 [n] ftrace - test for function event triggers	[PASS]
-[n] ftrace - function glob filters	[FAIL]
+[n] ftrace - function glob filters	[PASS]
 [n] ftrace - function pid notrace filters	[PASS]
 [n] ftrace - function pid filters	[PASS]
 [n] ftrace - stacktrace filter command	[PASS]
 [n] ftrace - function trace on module	[FAIL]
 [n] ftrace - function profiler with function tracing	[PASS]
 [n] ftrace - function profiling	[PASS]
-[n] ftrace - test reading of set_ftrace_filter	[FAIL]
+[n] ftrace - test reading of set_ftrace_filter	[PASS]
 [n] ftrace - Max stack tracer	[PASS]
 [n] ftrace - test for function traceon/off triggers	[PASS]
 [n] ftrace - test tracing error log support	[PASS]
 [n] Test creation and deletion of trace instances while setting an event	[PASS]
 [n] Test creation and deletion of trace instances	[PASS]
-[n] Kprobe dynamic event - adding and removing	[FAIL]
-[n] Kprobe dynamic event - busy event check	[FAIL]
-[n] Kprobe dynamic event with arguments	[FAIL]
-[n] Kprobe event with comm arguments	[FAIL]
-[n] Kprobe event string type argument	[FAIL]
-[n] Kprobe event symbol argument	[FAIL]
-[n] Kprobe event argument syntax	[FAIL]
-[n] Kprobes event arguments with types	[FAIL]
+[n] Kprobe dynamic event - adding and removing	[PASS]
+[n] Kprobe dynamic event - busy event check	[PASS]
+[n] Kprobe event with comm arguments	[PASS]
+[n] Kprobe event string type argument	[PASS]
+[n] Kprobe event symbol argument	[PASS]
+[n] Kprobe event argument syntax	[PASS]
+[n] Kprobe dynamic event with arguments	[PASS]
+[n] Kprobes event arguments with types	[PASS]
 [n] Kprobe event user-memory access	[FAIL]
 [n] Kprobe event auto/manual naming	[PASS]
-[n] Kprobe dynamic event with function tracer	[FAIL]
+[n] Kprobe dynamic event with function tracer	[PASS]
 [n] Kprobe dynamic event - probing module	[FAIL]
-[n] Create/delete multiprobe on kprobe event	[FAIL]
-[n] Kprobe event parser error log check	[FAIL]
-[n] Kretprobe dynamic event with arguments	[FAIL]
-[n] Kretprobe dynamic event with maxactive	[FAIL]
-[n] Kretprobe %return suffix test	[FAIL]
-[n] Register/unregister many kprobe events	[FAIL]
-[n] Kprobe events - probe points	[FAIL]
-[n] Kprobe dynamic event - adding and removing	[FAIL]
+[n] Create/delete multiprobe on kprobe event	[PASS]
+[n] Kprobe event parser error log check	[PASS]
+[n] Kretprobe dynamic event with arguments	[PASS]
+[n] Kretprobe dynamic event with maxactive	[PASS]
+[n] Kretprobe %return suffix test	[PASS]
+[n] Register/unregister many kprobe events	[PASS]
+[n] Kprobe events - probe points	[PASS]
+[n] Kprobe dynamic event - adding and removing	[PASS]
 [n] Uprobe event parser error log check	[PASS]
 [n] test for the preemptirqsoff tracer	[FAIL]
 [n] Meta-selftest: Checkbashisms	[FAIL]
@@ -96,7 +96,8 @@
 [n] (instance)  event tracing - enable/disable with event level files	[PASS]
 [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
 [n] (instance)  event tracing - restricts events based on pid	[PASS]
-[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
+[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
+rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.lxCI5k': Device or resource busy
 [n] (instance)  ftrace - test for function event triggers	[PASS]
 [n] (instance)  ftrace - function pid notrace filters	[PASS]
 [n] (instance)  ftrace - function pid filters	[PASS]


Thanks

Michal

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03 20:17         ` Michal Suchánek
@ 2021-05-04  9:13           ` Nicholas Piggin
  2021-05-04 17:41             ` Naveen N. Rao
  0 siblings, 1 reply; 16+ messages in thread
From: Nicholas Piggin @ 2021-05-04  9:13 UTC (permalink / raw)
  To: Michal Suchánek; +Cc: Naveen N. Rao, linuxppc-dev

Excerpts from Michal Suchánek's message of May 4, 2021 6:17 am:
> On Mon, May 03, 2021 at 11:34:25AM +0200, Michal Suchánek wrote:
>> On Mon, May 03, 2021 at 09:11:16AM +0200, Michal Suchánek wrote:
>> > On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
>> > > Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
>> > > > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
>> > > >> Provide an option to use ELFv2 ABI for big endian builds. This works on
>> > > >> GCC and clang (since 2014). It is less well tested and supported by the
>> > > >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
>> > > >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
>> > > >> userspace.
>> > > > 
>> > > > Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.
>> > > 
>> > > What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
>> > > at least make it depend on BUILD_ELF_V2?
>> > 
>> > Looks like symbols are prefixed with a dot in ABIv1 and BTFID tool is
>> > not aware of that. It can be disabled on ABIv1 easily.
>> > 
>> > Thanks
>> > 
>> > Michal
>> > 
>> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
>> > index 678c13967580..e703c26e9b80 100644
>> > --- a/lib/Kconfig.debug
>> > +++ b/lib/Kconfig.debug
>> > @@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
>> >  	bool "Generate BTF typeinfo"
>> >  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
>> >  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
>> > +	depends on !PPC64 || BUILD_ELF_V2
>> >  	help
>> >  	  Generate deduplicated BTF type information from DWARF debug info.
>> >  	  Turning this on expects presence of pahole tool, which will convert
>> > 
>> > > 
>> > > > 
>> > > > Tested-by: Michal Suchánek <msuchanek@suse.de>
>> > > > 
>> > > > Also can we enable mprofile on BE now?
>> > > > 
>> > > > I don't see anything endian-specific in the mprofile code at a glance
>> > > > but don't have any idea how to test it.
>> > > 
>> > > AFAIK it's just a different ABI for the _mcount call so just running
>> > > some ftrace and ftrace with call graph should test it reasonably well.
>> 
>> It does not crash and burn but there are some regressions from LE to BE
>> on the ftrace kernel selftest:
>> 
>> --- ftraceLE.txt	2021-05-03 11:19:14.830000000 +0200
>> +++ ftraceBE.txt	2021-05-03 11:27:24.770000000 +0200
>> @@ -7,8 +7,8 @@
>>  [n] Change the ringbuffer size	[PASS]
>>  [n] Snapshot and tracing setting	[PASS]
>>  [n] trace_pipe and trace_marker	[PASS]
>> -[n] Test ftrace direct functions against tracers	[UNRESOLVED]
>> -[n] Test ftrace direct functions against kprobes	[UNRESOLVED]
>> +[n] Test ftrace direct functions against tracers	[FAIL]
>> +[n] Test ftrace direct functions against kprobes	[FAIL]
>>  [n] Generic dynamic event - add/remove kprobe events	[PASS]
>>  [n] Generic dynamic event - add/remove synthetic events	[PASS]
>>  [n] Generic dynamic event - selective clear (compatibility)	[PASS]
>> @@ -16,10 +16,10 @@
>>  [n] event tracing - enable/disable with event level files	[PASS]
>>  [n] event tracing - restricts events based on pid notrace filtering	[PASS]
>>  [n] event tracing - restricts events based on pid	[PASS]
>> -[n] event tracing - enable/disable with subsystem level files	[PASS]
>> +[n] event tracing - enable/disable with subsystem level files	[FAIL]
>>  [n] event tracing - enable/disable with top level files	[PASS]
>> -[n] Test trace_printk from module	[UNRESOLVED]
>> -[n] ftrace - function graph filters with stack tracer	[PASS]
>> +[n] Test trace_printk from module	[FAIL]
>> +[n] ftrace - function graph filters with stack tracer	[FAIL]
>>  [n] ftrace - function graph filters	[PASS]
>>  [n] ftrace - function trace with cpumask	[PASS]
>>  [n] ftrace - test for function event triggers	[PASS]
>> @@ -27,7 +27,7 @@
>>  [n] ftrace - function pid notrace filters	[PASS]
>>  [n] ftrace - function pid filters	[PASS]
>>  [n] ftrace - stacktrace filter command	[PASS]
>> -[n] ftrace - function trace on module	[UNRESOLVED]
>> +[n] ftrace - function trace on module	[FAIL]
>>  [n] ftrace - function profiler with function tracing	[PASS]
>>  [n] ftrace - function profiling	[PASS]
>>  [n] ftrace - test reading of set_ftrace_filter	[PASS]
>> @@ -44,10 +44,10 @@
>>  [n] Kprobe event argument syntax	[PASS]
>>  [n] Kprobe dynamic event with arguments	[PASS]
>>  [n] Kprobes event arguments with types	[PASS]
>> -[n] Kprobe event user-memory access	[UNSUPPORTED]
>> +[n] Kprobe event user-memory access	[FAIL]
>>  [n] Kprobe event auto/manual naming	[PASS]
>>  [n] Kprobe dynamic event with function tracer	[PASS]
>> -[n] Kprobe dynamic event - probing module	[UNRESOLVED]
>> +[n] Kprobe dynamic event - probing module	[FAIL]
>>  [n] Create/delete multiprobe on kprobe event	[PASS]
>>  [n] Kprobe event parser error log check	[PASS]
>>  [n] Kretprobe dynamic event with arguments	[PASS]
>> @@ -57,11 +57,11 @@
>>  [n] Kprobe events - probe points	[PASS]
>>  [n] Kprobe dynamic event - adding and removing	[PASS]
>>  [n] Uprobe event parser error log check	[PASS]
>> -[n] test for the preemptirqsoff tracer	[UNSUPPORTED]
>> -[n] Meta-selftest: Checkbashisms	[UNRESOLVED]
>> +[n] test for the preemptirqsoff tracer	[FAIL]
>> +[n] Meta-selftest: Checkbashisms	[FAIL]
>>  [n] Test wakeup RT tracer	[PASS]
>>  [n] Test wakeup tracer	[PASS]
>> -[n] event trigger - test inter-event histogram trigger expected fail actions	[XFAIL]
>> +[n] event trigger - test inter-event histogram trigger expected fail actions	[FAIL]
>>  [n] event trigger - test field variable support	[PASS]
>>  [n] event trigger - test inter-event combined histogram trigger	[PASS]
>>  [n] event trigger - test multiple actions on hist trigger	[PASS]
>> @@ -96,7 +96,8 @@
>>  [n] (instance)  event tracing - enable/disable with event level files	[PASS]
>>  [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
>>  [n] (instance)  event tracing - restricts events based on pid	[PASS]
>> -[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
>> +[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
>> +rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.mceByV': Device or resource busy
>>  [n] (instance)  ftrace - test for function event triggers	[PASS]
>>  [n] (instance)  ftrace - function pid notrace filters	[PASS]
>>  [n] (instance)  ftrace - function pid filters	[PASS]
>> 
>> I needed to add a test timeout to get this far because
>> "event tracing - enable/disable with subsystem level files" gets stuck.
> 
> There is some regression from mprofile on BE ABIv2
> 
> --- ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
> +++ ftraceBE.mprofile.txt	2021-05-03 11:27:24.770000000 +0200
> @@ -19,7 +19,7 @@
>  [n] event tracing - enable/disable with subsystem level files	[FAIL]
>  [n] event tracing - enable/disable with top level files	[PASS]
>  [n] Test trace_printk from module	[FAIL]
> -[n] ftrace - function graph filters with stack tracer	[PASS]
> +[n] ftrace - function graph filters with stack tracer	[FAIL]
>  [n] ftrace - function graph filters	[PASS]
>  [n] ftrace - function trace with cpumask	[PASS]
>  [n] ftrace - test for function event triggers	[PASS]
> @@ -31,7 +31,7 @@
>  [n] ftrace - function profiler with function tracing	[PASS]
>  [n] ftrace - function profiling	[PASS]
>  [n] ftrace - test reading of set_ftrace_filter	[PASS]
> -[n] ftrace - Max stack tracer	[PASS]
> +[n] ftrace - Max stack tracer	[FAIL]
>  [n] ftrace - test for function traceon/off triggers	[PASS]
>  [n] ftrace - test tracing error log support	[PASS]
>  [n] Test creation and deletion of trace instances while setting an event	[PASS]

Hmm, I don't see an obvious case where the stack layout is based on
BE when it should be using ELF ABI version, or ftrace_64_mprofile.S
depends on LE. +Naveen

> 
> but generally the ftrace on BE is broken overall. The test
> "event tracing - enable/disable with subsystem level files" gets stuck
> and has to be killed by timeout. Running the testsuite twice the test
> "Basic test for tracers" locks up the machine regardless of using
> mprofile. The ABIV1 is even much worse with the exception of
> "(instance)  event tracing - enable/disable with subsystem level files"
> which regresses on BE ABIv2 in general.

Wow it has fixed quite a few! That event tracing one hardly looks like
a difficult test, hopefully should be something trivial.

Thanks for testing.

Thanks,
Nick

> 
> --- ftraceBEv1.txt	2021-05-03 22:09:10.690000000 +0200
> +++ ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
> @@ -9,10 +9,10 @@
>  [n] trace_pipe and trace_marker	[PASS]
>  [n] Test ftrace direct functions against tracers	[FAIL]
>  [n] Test ftrace direct functions against kprobes	[FAIL]
> -[n] Generic dynamic event - add/remove kprobe events	[FAIL]
> +[n] Generic dynamic event - add/remove kprobe events	[PASS]
>  [n] Generic dynamic event - add/remove synthetic events	[PASS]
> -[n] Generic dynamic event - selective clear (compatibility)	[FAIL]
> -[n] Generic dynamic event - generic clear event	[FAIL]
> +[n] Generic dynamic event - selective clear (compatibility)	[PASS]
> +[n] Generic dynamic event - generic clear event	[PASS]
>  [n] event tracing - enable/disable with event level files	[PASS]
>  [n] event tracing - restricts events based on pid notrace filtering	[PASS]
>  [n] event tracing - restricts events based on pid	[PASS]
> @@ -23,39 +23,39 @@
>  [n] ftrace - function graph filters	[PASS]
>  [n] ftrace - function trace with cpumask	[PASS]
>  [n] ftrace - test for function event triggers	[PASS]
> -[n] ftrace - function glob filters	[FAIL]
> +[n] ftrace - function glob filters	[PASS]
>  [n] ftrace - function pid notrace filters	[PASS]
>  [n] ftrace - function pid filters	[PASS]
>  [n] ftrace - stacktrace filter command	[PASS]
>  [n] ftrace - function trace on module	[FAIL]
>  [n] ftrace - function profiler with function tracing	[PASS]
>  [n] ftrace - function profiling	[PASS]
> -[n] ftrace - test reading of set_ftrace_filter	[FAIL]
> +[n] ftrace - test reading of set_ftrace_filter	[PASS]
>  [n] ftrace - Max stack tracer	[PASS]
>  [n] ftrace - test for function traceon/off triggers	[PASS]
>  [n] ftrace - test tracing error log support	[PASS]
>  [n] Test creation and deletion of trace instances while setting an event	[PASS]
>  [n] Test creation and deletion of trace instances	[PASS]
> -[n] Kprobe dynamic event - adding and removing	[FAIL]
> -[n] Kprobe dynamic event - busy event check	[FAIL]
> -[n] Kprobe dynamic event with arguments	[FAIL]
> -[n] Kprobe event with comm arguments	[FAIL]
> -[n] Kprobe event string type argument	[FAIL]
> -[n] Kprobe event symbol argument	[FAIL]
> -[n] Kprobe event argument syntax	[FAIL]
> -[n] Kprobes event arguments with types	[FAIL]
> +[n] Kprobe dynamic event - adding and removing	[PASS]
> +[n] Kprobe dynamic event - busy event check	[PASS]
> +[n] Kprobe event with comm arguments	[PASS]
> +[n] Kprobe event string type argument	[PASS]
> +[n] Kprobe event symbol argument	[PASS]
> +[n] Kprobe event argument syntax	[PASS]
> +[n] Kprobe dynamic event with arguments	[PASS]
> +[n] Kprobes event arguments with types	[PASS]
>  [n] Kprobe event user-memory access	[FAIL]
>  [n] Kprobe event auto/manual naming	[PASS]
> -[n] Kprobe dynamic event with function tracer	[FAIL]
> +[n] Kprobe dynamic event with function tracer	[PASS]
>  [n] Kprobe dynamic event - probing module	[FAIL]
> -[n] Create/delete multiprobe on kprobe event	[FAIL]
> -[n] Kprobe event parser error log check	[FAIL]
> -[n] Kretprobe dynamic event with arguments	[FAIL]
> -[n] Kretprobe dynamic event with maxactive	[FAIL]
> -[n] Kretprobe %return suffix test	[FAIL]
> -[n] Register/unregister many kprobe events	[FAIL]
> -[n] Kprobe events - probe points	[FAIL]
> -[n] Kprobe dynamic event - adding and removing	[FAIL]
> +[n] Create/delete multiprobe on kprobe event	[PASS]
> +[n] Kprobe event parser error log check	[PASS]
> +[n] Kretprobe dynamic event with arguments	[PASS]
> +[n] Kretprobe dynamic event with maxactive	[PASS]
> +[n] Kretprobe %return suffix test	[PASS]
> +[n] Register/unregister many kprobe events	[PASS]
> +[n] Kprobe events - probe points	[PASS]
> +[n] Kprobe dynamic event - adding and removing	[PASS]
>  [n] Uprobe event parser error log check	[PASS]
>  [n] test for the preemptirqsoff tracer	[FAIL]
>  [n] Meta-selftest: Checkbashisms	[FAIL]
> @@ -96,7 +96,8 @@
>  [n] (instance)  event tracing - enable/disable with event level files	[PASS]
>  [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
>  [n] (instance)  event tracing - restricts events based on pid	[PASS]
> -[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
> +[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
> +rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.lxCI5k': Device or resource busy
>  [n] (instance)  ftrace - test for function event triggers	[PASS]
>  [n] (instance)  ftrace - function pid notrace filters	[PASS]
>  [n] (instance)  ftrace - function pid filters	[PASS]
> 
> 
> Thanks
> 
> Michal
> 

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-03 15:18         ` Segher Boessenkool
@ 2021-05-04 12:15           ` Michael Ellerman
  2021-05-05 12:31             ` Segher Boessenkool
  0 siblings, 1 reply; 16+ messages in thread
From: Michael Ellerman @ 2021-05-04 12:15 UTC (permalink / raw)
  To: Segher Boessenkool, Nicholas Piggin; +Cc: linuxppc-dev

Segher Boessenkool <segher@kernel.crashing.org> writes:
> On Mon, May 03, 2021 at 10:51:41AM +1000, Nicholas Piggin wrote:
>> Excerpts from Segher Boessenkool's message of May 3, 2021 3:55 am:
>> > On Wed, Apr 29, 2020 at 10:57:16AM +1000, Nicholas Piggin wrote:
>> >> Excerpts from Segher Boessenkool's message of April 29, 2020 9:40 am:
>> >> I blame toolchain for -mabi=elfv2 ! And also some blame on ABI document 
>> >> which is called ELF V2 ABI rather than ELF ABI V2 which would have been 
>> >> unambiguous.
>> > 
>> > At least ELFv2 ABI is correct.  "ELF ABI v2" is not.
>> > 
>> >> I can go through and change all my stuff and config options to ELF_ABI_v2.
>> > 
>> > Please don't.  It is wrong.
>> 
>> Then I'm not sure what the point of your previous mail was, what did I 
>> miss?
>
> I asked if you could make it clearer to people who do not know what this
> is whether they want to use it.  Or that was my intention, anyhow :-/
>
>> > Both the original PowerPC ELF ABI and the
>> > ELFv2 one have versions themselves.  Also, the base ELF standard has a
>> > version, and is set up so there can be incompatible versions even!  Of
>> > course it still is version 1 to this day, but :-)
>> 
>> The point was for people who don't know ELFv2 has a specific meaning for 
>> powerpc,
>
> It does not have *any* meaning outside of Power.  But people who do not
> know what it is can assume the wrong things about it.  It isn't a great
> name because of that :-(
>
> (It's not as bad as the MIPS ABIs -- an older one is called "new" :-) )
>
>> then ELF ABIv2 is more explanatory about it being an abi change
>> rather than base elf change, even if it's not the "correct" name.
>
> I very much disagree.  "ELF ABIv2" is completely meaningless.

Except:

$ readelf -h /bin/true
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              DYN (Shared object file)
  Machine:                           PowerPC64
  Version:                           0x1
  Entry point address:               0x1990
  Start of program headers:          64 (bytes into file)
  Start of section headers:          66176 (bytes into file)
  Flags:                             0x2, abiv2
                                          ^^^^^

:)

cheers

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-04  9:13           ` Nicholas Piggin
@ 2021-05-04 17:41             ` Naveen N. Rao
  2021-05-04 18:08               ` Michal Suchánek
  0 siblings, 1 reply; 16+ messages in thread
From: Naveen N. Rao @ 2021-05-04 17:41 UTC (permalink / raw)
  To: Michal Suchánek, Nicholas Piggin; +Cc: linuxppc-dev

Nicholas Piggin wrote:
> Excerpts from Michal Suchánek's message of May 4, 2021 6:17 am:
>> On Mon, May 03, 2021 at 11:34:25AM +0200, Michal Suchánek wrote:
>>> On Mon, May 03, 2021 at 09:11:16AM +0200, Michal Suchánek wrote:
>>> > On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
>>> > > Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
>>> > > > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
>>> > > >> Provide an option to use ELFv2 ABI for big endian builds. This works on
>>> > > >> GCC and clang (since 2014). It is less well tested and supported by the
>>> > > >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
>>> > > >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
>>> > > >> userspace.
>>> > > > 
>>> > > > Fixes BTFID failure on BE for me and the ELF ABIv2 kernel boots.
>>> > > 
>>> > > What's the BTFID failure? Anything we can do to fix it on the v1 ABI or 
>>> > > at least make it depend on BUILD_ELF_V2?
>>> > 
>>> > Looks like symbols are prefixed with a dot in ABIv1 and BTFID tool is
>>> > not aware of that. It can be disabled on ABIv1 easily.

Yes, I think BTF is generated by pahole, so we will need to add support 
for recognising dot symbols there.

>>> > 
>>> > Thanks
>>> > 
>>> > Michal
>>> > 
>>> > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
>>> > index 678c13967580..e703c26e9b80 100644
>>> > --- a/lib/Kconfig.debug
>>> > +++ b/lib/Kconfig.debug
>>> > @@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
>>> >  	bool "Generate BTF typeinfo"
>>> >  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
>>> >  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
>>> > +	depends on !PPC64 || BUILD_ELF_V2
>>> >  	help
>>> >  	  Generate deduplicated BTF type information from DWARF debug info.
>>> >  	  Turning this on expects presence of pahole tool, which will convert
>>> > 
>>> > > 
>>> > > > 
>>> > > > Tested-by: Michal Suchánek <msuchanek@suse.de>
>>> > > > 
>>> > > > Also can we enable mprofile on BE now?
>>> > > > 
>>> > > > I don't see anything endian-specific in the mprofile code at a glance
>>> > > > but don't have any idea how to test it.
>>> > > 
>>> > > AFAIK it's just a different ABI for the _mcount call so just running
>>> > > some ftrace and ftrace with call graph should test it reasonably well.
>>> 
>>> It does not crash and burn but there are some regressions from LE to BE
>>> on the ftrace kernel selftest:
>>> 
>>> --- ftraceLE.txt	2021-05-03 11:19:14.830000000 +0200
>>> +++ ftraceBE.txt	2021-05-03 11:27:24.770000000 +0200
>>> @@ -7,8 +7,8 @@
>>>  [n] Change the ringbuffer size	[PASS]
>>>  [n] Snapshot and tracing setting	[PASS]
>>>  [n] trace_pipe and trace_marker	[PASS]
>>> -[n] Test ftrace direct functions against tracers	[UNRESOLVED]
>>> -[n] Test ftrace direct functions against kprobes	[UNRESOLVED]
>>> +[n] Test ftrace direct functions against tracers	[FAIL]
>>> +[n] Test ftrace direct functions against kprobes	[FAIL]

Strange to see those fail. I don't think my patch to enable ftrace 
direct functions is upstream yet ;)

>>>  [n] Generic dynamic event - add/remove kprobe events	[PASS]
>>>  [n] Generic dynamic event - add/remove synthetic events	[PASS]
>>>  [n] Generic dynamic event - selective clear (compatibility)	[PASS]
>>> @@ -16,10 +16,10 @@
>>>  [n] event tracing - enable/disable with event level files	[PASS]
>>>  [n] event tracing - restricts events based on pid notrace filtering	[PASS]
>>>  [n] event tracing - restricts events based on pid	[PASS]
>>> -[n] event tracing - enable/disable with subsystem level files	[PASS]
>>> +[n] event tracing - enable/disable with subsystem level files	[FAIL]
>>>  [n] event tracing - enable/disable with top level files	[PASS]
>>> -[n] Test trace_printk from module	[UNRESOLVED]
>>> -[n] ftrace - function graph filters with stack tracer	[PASS]
>>> +[n] Test trace_printk from module	[FAIL]
>>> +[n] ftrace - function graph filters with stack tracer	[FAIL]
>>>  [n] ftrace - function graph filters	[PASS]
>>>  [n] ftrace - function trace with cpumask	[PASS]
>>>  [n] ftrace - test for function event triggers	[PASS]
>>> @@ -27,7 +27,7 @@
>>>  [n] ftrace - function pid notrace filters	[PASS]
>>>  [n] ftrace - function pid filters	[PASS]
>>>  [n] ftrace - stacktrace filter command	[PASS]
>>> -[n] ftrace - function trace on module	[UNRESOLVED]
>>> +[n] ftrace - function trace on module	[FAIL]
>>>  [n] ftrace - function profiler with function tracing	[PASS]
>>>  [n] ftrace - function profiling	[PASS]
>>>  [n] ftrace - test reading of set_ftrace_filter	[PASS]
>>> @@ -44,10 +44,10 @@
>>>  [n] Kprobe event argument syntax	[PASS]
>>>  [n] Kprobe dynamic event with arguments	[PASS]
>>>  [n] Kprobes event arguments with types	[PASS]
>>> -[n] Kprobe event user-memory access	[UNSUPPORTED]
>>> +[n] Kprobe event user-memory access	[FAIL]
>>>  [n] Kprobe event auto/manual naming	[PASS]
>>>  [n] Kprobe dynamic event with function tracer	[PASS]
>>> -[n] Kprobe dynamic event - probing module	[UNRESOLVED]
>>> +[n] Kprobe dynamic event - probing module	[FAIL]
>>>  [n] Create/delete multiprobe on kprobe event	[PASS]
>>>  [n] Kprobe event parser error log check	[PASS]
>>>  [n] Kretprobe dynamic event with arguments	[PASS]
>>> @@ -57,11 +57,11 @@
>>>  [n] Kprobe events - probe points	[PASS]
>>>  [n] Kprobe dynamic event - adding and removing	[PASS]
>>>  [n] Uprobe event parser error log check	[PASS]
>>> -[n] test for the preemptirqsoff tracer	[UNSUPPORTED]
>>> -[n] Meta-selftest: Checkbashisms	[UNRESOLVED]
>>> +[n] test for the preemptirqsoff tracer	[FAIL]
>>> +[n] Meta-selftest: Checkbashisms	[FAIL]
>>>  [n] Test wakeup RT tracer	[PASS]
>>>  [n] Test wakeup tracer	[PASS]
>>> -[n] event trigger - test inter-event histogram trigger expected fail actions	[XFAIL]
>>> +[n] event trigger - test inter-event histogram trigger expected fail actions	[FAIL]
>>>  [n] event trigger - test field variable support	[PASS]
>>>  [n] event trigger - test inter-event combined histogram trigger	[PASS]
>>>  [n] event trigger - test multiple actions on hist trigger	[PASS]
>>> @@ -96,7 +96,8 @@
>>>  [n] (instance)  event tracing - enable/disable with event level files	[PASS]
>>>  [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
>>>  [n] (instance)  event tracing - restricts events based on pid	[PASS]
>>> -[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
>>> +[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
>>> +rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.mceByV': Device or resource busy
>>>  [n] (instance)  ftrace - test for function event triggers	[PASS]
>>>  [n] (instance)  ftrace - function pid notrace filters	[PASS]
>>>  [n] (instance)  ftrace - function pid filters	[PASS]
>>> 
>>> I needed to add a test timeout to get this far because
>>> "event tracing - enable/disable with subsystem level files" gets stuck.

Does that test pass on LE for you? In the past, I have seen some lockups 
but will have to go revisit the tests...

>> 
>> There is some regression from mprofile on BE ABIv2
>> 
>> --- ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
>> +++ ftraceBE.mprofile.txt	2021-05-03 11:27:24.770000000 +0200
>> @@ -19,7 +19,7 @@
>>  [n] event tracing - enable/disable with subsystem level files	[FAIL]
>>  [n] event tracing - enable/disable with top level files	[PASS]
>>  [n] Test trace_printk from module	[FAIL]
>> -[n] ftrace - function graph filters with stack tracer	[PASS]
>> +[n] ftrace - function graph filters with stack tracer	[FAIL]
>>  [n] ftrace - function graph filters	[PASS]
>>  [n] ftrace - function trace with cpumask	[PASS]
>>  [n] ftrace - test for function event triggers	[PASS]
>> @@ -31,7 +31,7 @@
>>  [n] ftrace - function profiler with function tracing	[PASS]
>>  [n] ftrace - function profiling	[PASS]
>>  [n] ftrace - test reading of set_ftrace_filter	[PASS]
>> -[n] ftrace - Max stack tracer	[PASS]
>> +[n] ftrace - Max stack tracer	[FAIL]
>>  [n] ftrace - test for function traceon/off triggers	[PASS]
>>  [n] ftrace - test tracing error log support	[PASS]
>>  [n] Test creation and deletion of trace instances while setting an event	[PASS]
> 
> Hmm, I don't see an obvious case where the stack layout is based on
> BE when it should be using ELF ABI version, or ftrace_64_mprofile.S
> depends on LE. +Naveen

Yes, I don't think we ever enabled the stack tracer to work properly on 
LE and -mprofile-kernel. I will take a look tomorrow.

- Naveen


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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-04 17:41             ` Naveen N. Rao
@ 2021-05-04 18:08               ` Michal Suchánek
  0 siblings, 0 replies; 16+ messages in thread
From: Michal Suchánek @ 2021-05-04 18:08 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: linuxppc-dev, Nicholas Piggin

On Tue, May 04, 2021 at 11:11:25PM +0530, Naveen N. Rao wrote:
> Nicholas Piggin wrote:
> > Excerpts from Michal Suchánek's message of May 4, 2021 6:17 am:
> > > On Mon, May 03, 2021 at 11:34:25AM +0200, Michal Suchánek wrote:
> > > > On Mon, May 03, 2021 at 09:11:16AM +0200, Michal Suchánek wrote:
> > > > > On Mon, May 03, 2021 at 10:58:33AM +1000, Nicholas Piggin wrote:
> > > > > > Excerpts from Michal Suchánek's message of May 3, 2021 2:57 am:
> > > > > > > On Tue, Apr 28, 2020 at 09:25:17PM +1000, Nicholas Piggin wrote:
> > > > > > >> Provide an option to use ELFv2 ABI for big endian builds. This works on
> > > > > > >> GCC and clang (since 2014). It is less well tested and supported by the
> > > > > > >> GNU toolchain, but it can give some useful advantages of the ELFv2 ABI
> > > > > > >> for BE (e.g., less stack usage). Some distros even build BE ELFv2
> > > > > > >> userspace.
> > > > > > > > > > Fixes BTFID failure on BE for me and the ELF ABIv2
> > > > kernel boots.
> > > > > > > > What's the BTFID failure? Anything we can do to fix it
> > > > on the v1 ABI or > > at least make it depend on BUILD_ELF_V2?
> > > > > > Looks like symbols are prefixed with a dot in ABIv1 and
> > > > BTFID tool is
> > > > > not aware of that. It can be disabled on ABIv1 easily.
> 
> Yes, I think BTF is generated by pahole, so we will need to add support for
> recognising dot symbols there.

There are symbols both with and without dot, and the dwarves
development is headed towards using the ones without dot. Not sure it's
the correct way to resolve it, though.
https://lore.kernel.org/lkml/8c3cbd22-eb26-ea8b-c8bb-35a629d6d2d8@kernel.org/

> 
> > > > > > diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> > > > > index 678c13967580..e703c26e9b80 100644
> > > > > --- a/lib/Kconfig.debug
> > > > > +++ b/lib/Kconfig.debug
> > > > > @@ -305,6 +305,7 @@ config DEBUG_INFO_BTF
> > > > >  	bool "Generate BTF typeinfo"
> > > > >  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
> > > > >  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
> > > > > +	depends on !PPC64 || BUILD_ELF_V2
> > > > >  	help
> > > > >  	  Generate deduplicated BTF type information from DWARF debug info.
> > > > >  	  Turning this on expects presence of pahole tool, which will convert
> > > > > > > > > > > > > Tested-by: Michal Suchánek <msuchanek@suse.de>
> > > > > > > > > > Also can we enable mprofile on BE now?
> > > > > > > > > > I don't see anything endian-specific in the mprofile
> > > > code at a glance
> > > > > > > but don't have any idea how to test it.
> > > > > > > > AFAIK it's just a different ABI for the _mcount call so
> > > > just running
> > > > > > some ftrace and ftrace with call graph should test it reasonably well.
> > > > 
> > > > It does not crash and burn but there are some regressions from LE to BE
> > > > on the ftrace kernel selftest:
> > > > 
> > > > @@ -16,10 +16,10 @@
> > > >  [n] event tracing - enable/disable with event level files	[PASS]
> > > >  [n] event tracing - restricts events based on pid notrace filtering	[PASS]
> > > >  [n] event tracing - restricts events based on pid	[PASS]
> > > > -[n] event tracing - enable/disable with subsystem level files	[PASS]
> > > > +[n] event tracing - enable/disable with subsystem level files	[FAIL]
> > > >  [n] event tracing - enable/disable with top level files	[PASS]
> > > > -[n] Test trace_printk from module	[UNRESOLVED]
> > > > +[n] Test trace_printk from module	[FAIL]
> > > > -[n] ftrace - function graph filters with stack tracer	[PASS]
> > > > +[n] ftrace - function graph filters with stack tracer	[FAIL]
> > > >  [n] ftrace - function graph filters	[PASS]
> > > >  [n] ftrace - function trace with cpumask	[PASS]
> > > >  [n] ftrace - test for function event triggers	[PASS]
> > > > @@ -96,7 +96,8 @@
> > > >  [n] (instance)  event tracing - enable/disable with event level files	[PASS]
> > > >  [n] (instance)  event tracing - restricts events based on pid notrace filtering	[PASS]
> > > >  [n] (instance)  event tracing - restricts events based on pid	[PASS]
> > > > -[n] (instance)  event tracing - enable/disable with subsystem level files	[PASS]
> > > > +[n] (instance)  event tracing - enable/disable with subsystem level files	[FAIL]
> > > > +rmdir: failed to remove '/sys/kernel/tracing/instances/ftracetest.mceByV': Device or resource busy
> > > >  [n] (instance)  ftrace - test for function event triggers	[PASS]
> > > >  [n] (instance)  ftrace - function pid notrace filters	[PASS]
> > > >  [n] (instance)  ftrace - function pid filters	[PASS]
> > > > 
> > > > I needed to add a test timeout to get this far because
> > > > "event tracing - enable/disable with subsystem level files" gets stuck.
> 
> Does that test pass on LE for you? In the past, I have seen some lockups but
> will have to go revisit the tests...

Yes, it's one of the actual regressions where the test is not marked as
XFAIL, UNRESOLVED or UNSUPPORTED on LE.

> 
> > > 
> > > There is some regression from mprofile on BE ABIv2
> > > 
> > > --- ftraceBEv2.txt	2021-05-03 18:11:01.100000000 +0200
> > > +++ ftraceBE.mprofile.txt	2021-05-03 11:27:24.770000000 +0200
> > > @@ -19,7 +19,7 @@
> > >  [n] event tracing - enable/disable with subsystem level files	[FAIL]
> > >  [n] event tracing - enable/disable with top level files	[PASS]
> > >  [n] Test trace_printk from module	[FAIL]
> > > -[n] ftrace - function graph filters with stack tracer	[PASS]
> > > +[n] ftrace - function graph filters with stack tracer	[FAIL]
> > >  [n] ftrace - function graph filters	[PASS]
> > >  [n] ftrace - function trace with cpumask	[PASS]
> > >  [n] ftrace - test for function event triggers	[PASS]
> > > @@ -31,7 +31,7 @@
> > >  [n] ftrace - function profiler with function tracing	[PASS]
> > >  [n] ftrace - function profiling	[PASS]
> > >  [n] ftrace - test reading of set_ftrace_filter	[PASS]
> > > -[n] ftrace - Max stack tracer	[PASS]
> > > +[n] ftrace - Max stack tracer	[FAIL]
> > >  [n] ftrace - test for function traceon/off triggers	[PASS]
> > >  [n] ftrace - test tracing error log support	[PASS]
> > >  [n] Test creation and deletion of trace instances while setting an event	[PASS]
> > 
> > Hmm, I don't see an obvious case where the stack layout is based on
> > BE when it should be using ELF ABI version, or ftrace_64_mprofile.S
> > depends on LE. +Naveen
> 
> Yes, I don't think we ever enabled the stack tracer to work properly on LE
> and -mprofile-kernel. I will take a look tomorrow.

Right, "Max stack tracer" does not show as regression from LE to BE.

Thanks

Michal

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

* Re: [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels
  2021-05-04 12:15           ` Michael Ellerman
@ 2021-05-05 12:31             ` Segher Boessenkool
  0 siblings, 0 replies; 16+ messages in thread
From: Segher Boessenkool @ 2021-05-05 12:31 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Nicholas Piggin

On Tue, May 04, 2021 at 10:15:34PM +1000, Michael Ellerman wrote:
> Segher Boessenkool <segher@kernel.crashing.org> writes:
> > On Mon, May 03, 2021 at 10:51:41AM +1000, Nicholas Piggin wrote:
> >> then ELF ABIv2 is more explanatory about it being an abi change
> >> rather than base elf change, even if it's not the "correct" name.
> >
> > I very much disagree.  "ELF ABIv2" is completely meaningless.
> 
> Except:
> 
> $ readelf -h /bin/true
> ELF Header:
>   Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
>   Class:                             ELF64
>   Data:                              2's complement, little endian
>   Version:                           1 (current)
>   OS/ABI:                            UNIX - System V
>   ABI Version:                       0
>   Type:                              DYN (Shared object file)
>   Machine:                           PowerPC64
>   Version:                           0x1
>   Entry point address:               0x1990
>   Start of program headers:          64 (bytes into file)
>   Start of section headers:          66176 (bytes into file)
>   Flags:                             0x2, abiv2
>                                           ^^^^^

Ha :-)

This can also print "abiv1" or even "abiv0", btw:

        case EM_PPC64:
          if (e_flags & EF_PPC64_ABI)
            {
              char abi[] = ", abiv0";

              abi[6] += e_flags & EF_PPC64_ABI;
              strcat (buf, abi);
            }
          break;

This is only in readelf, and the main audience for readelf is the people
who know all details about what means what already.  But, do you have a
suggestion for better output here?


Segher

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

end of thread, other threads:[~2021-05-05 12:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 11:25 [PATCH v2] powerpc/64: BE option to use ELFv2 ABI for big endian kernels Nicholas Piggin
2020-04-28 23:40 ` Segher Boessenkool
2020-04-29  0:57   ` Nicholas Piggin
2021-05-02 17:55     ` Segher Boessenkool
2021-05-03  0:51       ` Nicholas Piggin
2021-05-03 15:18         ` Segher Boessenkool
2021-05-04 12:15           ` Michael Ellerman
2021-05-05 12:31             ` Segher Boessenkool
2021-05-02 16:57 ` Michal Suchánek
2021-05-03  0:58   ` Nicholas Piggin
2021-05-03  7:11     ` Michal Suchánek
2021-05-03  9:34       ` Michal Suchánek
2021-05-03 20:17         ` Michal Suchánek
2021-05-04  9:13           ` Nicholas Piggin
2021-05-04 17:41             ` Naveen N. Rao
2021-05-04 18:08               ` Michal Suchánek

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.