diff mbox series

[1/7] powerpc/build: put sys_call_table in .data.rel.ro if RELOCATABLE

Message ID 20220914154746.1122482-2-npiggin@gmail.com (mailing list archive)
State Superseded
Headers show
Series powerpc: build / linker improvements | expand

Commit Message

Nicholas Piggin Sept. 14, 2022, 3:47 p.m. UTC
Const function pointers live in .data.rel.ro rather than .rodata because
they must be relocated. This change prevents powerpc/32 from generating
R_PPC_UADDR32 relocations (which are not handled). The sys_call_table is
moved to writeable memory, but a later change will move it back.

After this patch, 44x_defconfig + CONFIG_RELOCATABLE boots to busybox.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kernel/systbl.S | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Christophe Leroy Sept. 15, 2022, 5:53 a.m. UTC | #1
Le 14/09/2022 à 17:47, Nicholas Piggin a écrit :
> Const function pointers live in .data.rel.ro rather than .rodata because
> they must be relocated. This change prevents powerpc/32 from generating
> R_PPC_UADDR32 relocations (which are not handled). The sys_call_table is
> moved to writeable memory, but a later change will move it back.

Aren't you missing commit c7acee3d2f12 ("powerpc: align syscall table 
for ppc32") ?

I can't see any R_PPC_UADDR32 relocations generated by ppc4xx_defconfig 
+ CONFIG_RELOCATABLE unless I revert that commit.



> 
> After this patch, 44x_defconfig + CONFIG_RELOCATABLE boots to busybox.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   arch/powerpc/kernel/systbl.S | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
> index cb3358886203..0bec33e86f50 100644
> --- a/arch/powerpc/kernel/systbl.S
> +++ b/arch/powerpc/kernel/systbl.S
> @@ -12,7 +12,11 @@
>   
>   #include <asm/ppc_asm.h>
>   
> +#ifdef CONFIG_RELOCATABLE
> +.section .data.rel.ro,"aw"
> +#else
>   .section .rodata,"a"
> +#endif
>   
>   #ifdef CONFIG_PPC64
>   	.p2align	3
Michael Ellerman Sept. 15, 2022, 12:51 p.m. UTC | #2
Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> Le 14/09/2022 à 17:47, Nicholas Piggin a écrit :
>> Const function pointers live in .data.rel.ro rather than .rodata because
>> they must be relocated. This change prevents powerpc/32 from generating
>> R_PPC_UADDR32 relocations (which are not handled). The sys_call_table is
>> moved to writeable memory, but a later change will move it back.
>
> Aren't you missing commit c7acee3d2f12 ("powerpc: align syscall table 
> for ppc32") ?

That's in fixes. I'll sort it out when I apply this, or when I merge
fixes into next.

> I can't see any R_PPC_UADDR32 relocations generated by ppc4xx_defconfig 
> + CONFIG_RELOCATABLE unless I revert that commit.

Presumably this change accidentally aligns the syscall table.

>> After this patch, 44x_defconfig + CONFIG_RELOCATABLE boots to busybox.
 
So that's probably just because of the alignment too.

I think this patch should go after .data.rel.ro is made read only.

cheers
Nicholas Piggin Sept. 16, 2022, 12:30 a.m. UTC | #3
On Thu Sep 15, 2022 at 10:51 PM AEST, Michael Ellerman wrote:
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
> > Le 14/09/2022 à 17:47, Nicholas Piggin a écrit :
> >> Const function pointers live in .data.rel.ro rather than .rodata because
> >> they must be relocated. This change prevents powerpc/32 from generating
> >> R_PPC_UADDR32 relocations (which are not handled). The sys_call_table is
> >> moved to writeable memory, but a later change will move it back.
> >
> > Aren't you missing commit c7acee3d2f12 ("powerpc: align syscall table 
> > for ppc32") ?
>
> That's in fixes. I'll sort it out when I apply this, or when I merge
> fixes into next.

Yeah that explains the relocations I was seeing, I should have dug
further into that, so they're really unrelated to this patch.

> > I can't see any R_PPC_UADDR32 relocations generated by ppc4xx_defconfig 
> > + CONFIG_RELOCATABLE unless I revert that commit.
>
> Presumably this change accidentally aligns the syscall table.
>
> >> After this patch, 44x_defconfig + CONFIG_RELOCATABLE boots to busybox.
>  
> So that's probably just because of the alignment too.
>
> I think this patch should go after .data.rel.ro is made read only.

Yeah that should be fine.

Thanks,
Nick
diff mbox series

Patch

diff --git a/arch/powerpc/kernel/systbl.S b/arch/powerpc/kernel/systbl.S
index cb3358886203..0bec33e86f50 100644
--- a/arch/powerpc/kernel/systbl.S
+++ b/arch/powerpc/kernel/systbl.S
@@ -12,7 +12,11 @@ 
 
 #include <asm/ppc_asm.h>
 
+#ifdef CONFIG_RELOCATABLE
+.section .data.rel.ro,"aw"
+#else
 .section .rodata,"a"
+#endif
 
 #ifdef CONFIG_PPC64
 	.p2align	3