Skip to contentSkip to conversation

powerpc: align syscall table for ppc32

PATCH Applied Masahiro Yamada 4 participants 6 messages Aug 20, 2022 – Aug 31, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: align syscall table for ppc32

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

  $ powerpc-linux-gnu-nm -n vmlinux
    ...
  c0b31258 d spe_aligninfo
  c0b31298 d __func__.0
  c0b312a9 D sys_call_table
  c0b319b8 d __func__.0

Commit 7b4537199a4a is not the root cause. Even before that, I can reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

It is just that nobody did not notice it because when CONFIG_MODVERSIONS is enabled, a __crc_* symbol inserted before sys_call_table was hiding the unalignment issue.

I checked the commit history, but I could not understand commit 46b45b10f142 ("[POWERPC] Align the sys_call_table").

It said 'Our _GLOBAL macro does a ".align 2" so the alignment is fine for 32 bit'. I checked the _GLOBAL in include/asm-powerpc/ppc_asm.h at that time. _GLOBAL specifies ".align 2" for ppc64, but no .align for ppc32.

Commit c857c43b34ec ("powerpc: Don't use a function descriptor for system call table") removed _GLOBAL from the syscall table.

Anyway, adding alignment to the syscall table for ppc32 fixes the issue.

I am not giving Fixes tag because I do not know since when it has been broken, but presumably it has been for a long while.

---

 arch/powerpc/kernel/systbl.S | 1 +
 1 file changed, 1 insertion(+)
arch/powerpc/kernel/systbl.S +1 -0
index cb3358886203..6c1db3b6de2d 100644
@@ -18,6 +18,7 @@
 	.p2align	3
 #define __SYSCALL(nr, entry)	.8byte entry
 #else
+	.p2align	2
 #define __SYSCALL(nr, entry)	.long entry
 #endif
 
Signature · 1 line
2.34.1
Tested-by on v1 1/1
#1 lore raw

Le 20/08/2022 à 18:51, Masahiro Yamada a écrit :

Quoted 47 lines

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

   c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
   c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
   c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
   c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
   c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
       ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

   $ powerpc-linux-gnu-nm -n vmlinux
     ...
   c0b31258 d spe_aligninfo
   c0b31298 d __func__.0
   c0b312a9 D sys_call_table
   c0b319b8 d __func__.0

Commit 7b4537199a4a is not the root cause. Even before that, I can reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

It is just that nobody did not notice it because when CONFIG_MODVERSIONS is enabled, a __crc_* symbol inserted before sys_call_table was hiding the unalignment issue.

I checked the commit history, but I could not understand commit 46b45b10f142 ("[POWERPC] Align the sys_call_table").

It said 'Our _GLOBAL macro does a ".align 2" so the alignment is fine for 32 bit'. I checked the _GLOBAL in include/asm-powerpc/ppc_asm.h at that time. _GLOBAL specifies ".align 2" for ppc64, but no .align for ppc32.

Commit c857c43b34ec ("powerpc: Don't use a function descriptor for system call table") removed _GLOBAL from the syscall table.

Quoted 8 lines

Anyway, adding alignment to the syscall table for ppc32 fixes the issue.

I am not giving Fixes tag because I do not know since when it has been broken, but presumably it has been for a long while.

Quoted 17 lines

---

  arch/powerpc/kernel/systbl.S | 1 +
  1 file changed, 1 insertion(+)
arch/powerpc/kernel/systbl.S +1 -0
index cb3358886203..6c1db3b6de2d 100644
@@ -18,6 +18,7 @@
  	.p2align	3
  #define __SYSCALL(nr, entry)	.8byte entry
  #else
+	.p2align	2
  #define __SYSCALL(nr, entry)	.long entry
  #endif
 
#2 lore raw
In reply to Masahiro Yamada
Quoted 44 lines · Masahiro Yamada

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

  $ powerpc-linux-gnu-nm -n vmlinux
    ...
  c0b31258 d spe_aligninfo
  c0b31298 d __func__.0
  c0b312a9 D sys_call_table
  c0b319b8 d __func__.0

Commit 7b4537199a4a is not the root cause. Even before that, I can reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

It is just that nobody did not notice it because when CONFIG_MODVERSIONS is enabled, a __crc_* symbol inserted before sys_call_table was hiding the unalignment issue.

I checked the commit history, but I could not understand commit 46b45b10f142 ("[POWERPC] Align the sys_call_table").

It said 'Our _GLOBAL macro does a ".align 2" so the alignment is fine for 32 bit'. I checked the _GLOBAL in include/asm-powerpc/ppc_asm.h at that time. _GLOBAL specifies ".align 2" for ppc64, but no .align for ppc32.

Quoted 7 lines

Commit c857c43b34ec ("powerpc: Don't use a function descriptor for system call table") removed _GLOBAL from the syscall table.

Anyway, adding alignment to the syscall table for ppc32 fixes the issue.

I am not giving Fixes tag because I do not know since when it has been broken, but presumably it has been for a long while.

Thanks.

I trimmed the change log a bit just to say ~= it's been broken for ever, and added a Cc to stable.

cheers

#3 lore raw
Quoted 30 lines · Michael Ellerman
Quoted 28 lines · Masahiro Yamada

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

  $ powerpc-linux-gnu-nm -n vmlinux
    ...
  c0b31258 d spe_aligninfo
  c0b31298 d __func__.0
  c0b312a9 D sys_call_table
  c0b319b8 d __func__.0
Quoted 5 lines
Quoted 5 lines

Commit 7b4537199a4a is not the root cause. Even before that, I can reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

It is just that nobody did not notice it because when CONFIG_MODVERSIONS

I wrote weird English (double negation)

nobody did not notice --> nobody noticed

Please fix it if you have not yet.

Thank you.

Quoted 25 lines
Quoted 11 lines

is enabled, a __crc_* symbol inserted before sys_call_table was hiding the unalignment issue.

I checked the commit history, but I could not understand commit 46b45b10f142 ("[POWERPC] Align the sys_call_table").

It said 'Our _GLOBAL macro does a ".align 2" so the alignment is fine for 32 bit'. I checked the _GLOBAL in include/asm-powerpc/ppc_asm.h at that time. _GLOBAL specifies ".align 2" for ppc64, but no .align for ppc32.

Quoted 7 lines

Commit c857c43b34ec ("powerpc: Don't use a function descriptor for system call table") removed _GLOBAL from the syscall table.

Anyway, adding alignment to the syscall table for ppc32 fixes the issue.

I am not giving Fixes tag because I do not know since when it has been broken, but presumably it has been for a long while.

Thanks.

I trimmed the change log a bit just to say ~= it's been broken for ever, and added a Cc to stable.

cheers

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
Quoted 35 lines · Masahiro Yamada
Quoted 34 lines · Michael Ellerman
Quoted 32 lines · Masahiro Yamada

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

The compiler emits a bunch of R_PPC_UADDR32, which is not supported by arch/powerpc/kernel/reloc_32.S.

The reason is there exists an unaligned symbol.

  $ powerpc-linux-gnu-nm -n vmlinux
    ...
  c0b31258 d spe_aligninfo
  c0b31298 d __func__.0
  c0b312a9 D sys_call_table
  c0b319b8 d __func__.0

Commit 7b4537199a4a is not the root cause. Even before that, I can reproduce the same issue for mpc85xx_defconfig + CONFIG_RELOCATABLE=y
+ CONFIG_MODVERSIONS=n.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

It is just that nobody did not notice it because when CONFIG_MODVERSIONS

I wrote weird English (double negation)

nobody did not notice --> nobody noticed

Please fix it if you have not yet.

Yeah I did fix it up when applying :)

It is just that nobody noticed because when CONFIG_MODVERSIONS is enabled, a __crc_* symbol inserted before sys_call_table was hiding the unalignment issue.

cheers

#5 lore raw
In reply to Masahiro Yamada
Quoted 9 lines · Masahiro Yamada

Christophe Leroy reported that commit 7b4537199a4a ("kbuild: link symbol CRCs at final link, removing CONFIG_MODULE_REL_CRCS") broke mpc85xx_defconfig + CONFIG_RELOCATABLE=y.

LD vmlinux
SYSMAP System.map
SORTTAB vmlinux
CHKREL vmlinux
WARNING: 451 bad relocations

Quoted 8 lines
  c0b312a9 R_PPC_UADDR32     .head.text-0x3ff9ed54
  c0b312ad R_PPC_UADDR32     .head.text-0x3ffac224
  c0b312b1 R_PPC_UADDR32     .head.text-0x3ffb09f4
  c0b312b5 R_PPC_UADDR32     .head.text-0x3fe184dc
  c0b312b9 R_PPC_UADDR32     .head.text-0x3fe183a8
      ...

[...]

Applied to powerpc/fixes.

[1/1] powerpc: align syscall table for ppc32

      https://git.kernel.org/powerpc/c/c7acee3d2f128a38b68fb7af85dbbd91bfd0b4ad

cheers