linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: align syscall table for ppc32
@ 2022-08-20 16:51 Masahiro Yamada
  2022-08-20 17:50 ` Christophe Leroy
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-08-20 16:51 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy, linuxppc-dev
  Cc: linux-kbuild, Masahiro Yamada, linux-kernel

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.

Link: https://lore.kernel.org/lkml/38605f6a-a568-f884-f06f-ea4da5b214f0@csgroup.eu/
Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 arch/powerpc/kernel/systbl.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
index cb3358886203..6c1db3b6de2d 100644
--- a/arch/powerpc/kernel/systbl.S
+++ b/arch/powerpc/kernel/systbl.S
@@ -18,6 +18,7 @@
 	.p2align	3
 #define __SYSCALL(nr, entry)	.8byte entry
 #else
+	.p2align	2
 #define __SYSCALL(nr, entry)	.long entry
 #endif
 
-- 
2.34.1


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

* Re: [PATCH] powerpc: align syscall table for ppc32
  2022-08-20 16:51 [PATCH] powerpc: align syscall table for ppc32 Masahiro Yamada
@ 2022-08-20 17:50 ` Christophe Leroy
  2022-08-25  7:53 ` Michael Ellerman
  2022-08-31 13:12 ` Michael Ellerman
  2 siblings, 0 replies; 6+ messages in thread
From: Christophe Leroy @ 2022-08-20 17:50 UTC (permalink / raw)
  To: Masahiro Yamada, Michael Ellerman, Nicholas Piggin, linuxppc-dev
  Cc: linux-kbuild, linux-kernel



Le 20/08/2022 à 18:51, Masahiro Yamada a écrit :
> 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.
> 
> Link: https://lore.kernel.org/lkml/38605f6a-a568-f884-f06f-ea4da5b214f0@csgroup.eu/
> Reported-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Tested-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
> 
>   arch/powerpc/kernel/systbl.S | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
> index cb3358886203..6c1db3b6de2d 100644
> --- a/arch/powerpc/kernel/systbl.S
> +++ b/arch/powerpc/kernel/systbl.S
> @@ -18,6 +18,7 @@
>   	.p2align	3
>   #define __SYSCALL(nr, entry)	.8byte entry
>   #else
> +	.p2align	2
>   #define __SYSCALL(nr, entry)	.long entry
>   #endif
>   

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

* Re: [PATCH] powerpc: align syscall table for ppc32
  2022-08-20 16:51 [PATCH] powerpc: align syscall table for ppc32 Masahiro Yamada
  2022-08-20 17:50 ` Christophe Leroy
@ 2022-08-25  7:53 ` Michael Ellerman
  2022-08-25 13:13   ` Masahiro Yamada
  2022-08-31 13:12 ` Michael Ellerman
  2 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2022-08-25  7:53 UTC (permalink / raw)
  To: Masahiro Yamada, Nicholas Piggin, Christophe Leroy, linuxppc-dev
  Cc: linux-kbuild, Masahiro Yamada, linux-kernel

Masahiro Yamada <masahiroy@kernel.org> writes:
> 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.

Thanks.

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

cheers

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

* Re: [PATCH] powerpc: align syscall table for ppc32
  2022-08-25  7:53 ` Michael Ellerman
@ 2022-08-25 13:13   ` Masahiro Yamada
  2022-08-25 22:51     ` Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2022-08-25 13:13 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Nicholas Piggin, Christophe Leroy, linuxppc-dev,
	Linux Kbuild mailing list, Linux Kernel Mailing List

On Thu, Aug 25, 2022 at 4:53 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Masahiro Yamada <masahiroy@kernel.org> writes:
> > 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



I wrote weird English (double negation)


nobody did not notice   --> nobody noticed



Please fix it if you have not yet.


Thank you.





> > 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.
>
> Thanks.
>
> I trimmed the change log a bit just to say ~= it's been broken for ever,
> and added a Cc to stable.
>
> cheers






-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] powerpc: align syscall table for ppc32
  2022-08-25 13:13   ` Masahiro Yamada
@ 2022-08-25 22:51     ` Michael Ellerman
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2022-08-25 22:51 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Nicholas Piggin, Christophe Leroy, linuxppc-dev,
	Linux Kbuild mailing list, Linux Kernel Mailing List

Masahiro Yamada <masahiroy@kernel.org> writes:
> On Thu, Aug 25, 2022 at 4:53 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>>
>> Masahiro Yamada <masahiroy@kernel.org> writes:
>> > 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
>
> 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

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

* Re: [PATCH] powerpc: align syscall table for ppc32
  2022-08-20 16:51 [PATCH] powerpc: align syscall table for ppc32 Masahiro Yamada
  2022-08-20 17:50 ` Christophe Leroy
  2022-08-25  7:53 ` Michael Ellerman
@ 2022-08-31 13:12 ` Michael Ellerman
  2 siblings, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2022-08-31 13:12 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev, Michael Ellerman,
	Christophe Leroy, Masahiro Yamada
  Cc: linux-kernel, linux-kbuild

On Sun, 21 Aug 2022 01:51:29 +0900, Masahiro Yamada wrote:
> 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
>       ...
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc: align syscall table for ppc32
      https://git.kernel.org/powerpc/c/c7acee3d2f128a38b68fb7af85dbbd91bfd0b4ad

cheers

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

end of thread, other threads:[~2022-08-31 13:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-20 16:51 [PATCH] powerpc: align syscall table for ppc32 Masahiro Yamada
2022-08-20 17:50 ` Christophe Leroy
2022-08-25  7:53 ` Michael Ellerman
2022-08-25 13:13   ` Masahiro Yamada
2022-08-25 22:51     ` Michael Ellerman
2022-08-31 13:12 ` Michael Ellerman

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