public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] riscv: hwprobe: do not produce frtace relocation
@ 2024-03-13  7:35 Vladimir Isaev
  2024-03-19  3:54 ` Guo Ren
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Vladimir Isaev @ 2024-03-13  7:35 UTC (permalink / raw)
  To: paul.walmsley, palmer, aou, catalin.marinas, evan, nicolas, tglx,
	samitolvanen, masahiroy, maskray, linux-riscv, linux-kernel,
	guoren
  Cc: Vladimir Isaev, Roman Artemev

Such relocation causes crash of android linker similar to one
described in commit e05d57dcb8c7
("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace").

Looks like this relocation is added by CONFIG_DYNAMIC_FTRACE which is
disabled in the default android kernel.

Before:

readelf -rW arch/riscv/kernel/vdso/vdso.so:

Relocation section '.rela.dyn' at offset 0xd00 contains 1 entry:
    Offset             Info             Type
0000000000000d20  0000000000000003 R_RISCV_RELATIVE

objdump:
0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
 c86:   0001                    nop
 c88:   0001                    nop
 c8a:   0001                    nop
 c8c:   0001                    nop
 c8e:   e211                    bnez    a2,c92 <__vdso_riscv_hwprobe...

After:
readelf -rW arch/riscv/kernel/vdso/vdso.so:

There are no relocations in this file.

objdump:
0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
 c86:   e211                    bnez    a2,c8a <__vdso_riscv_hwprobe...
 c88:   c6b9                    beqz    a3,cd6 <__vdso_riscv_hwprobe...
 c8a:   e739                    bnez    a4,cd8 <__vdso_riscv_hwprobe...
 c8c:   ffffd797                auipc   a5,0xffffd

Also disable SCS since it also should not be available in vdso.

Fixes: aa5af0aa90ba ("RISC-V: Add hwprobe vDSO function and data")
Signed-off-by: Roman Artemev <roman.artemev@syntacore.com>
Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
---
 arch/riscv/kernel/vdso/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
index 9b517fe1b8a8..272c431ac5b9 100644
--- a/arch/riscv/kernel/vdso/Makefile
+++ b/arch/riscv/kernel/vdso/Makefile
@@ -37,6 +37,7 @@ endif
 
 # Disable -pg to prevent insert call site
 CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
+CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
 
 # Disable profiling and instrumentation for VDSO code
 GCOV_PROFILE := n
-- 
2.43.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: hwprobe: do not produce frtace relocation
  2024-03-13  7:35 [PATCH] riscv: hwprobe: do not produce frtace relocation Vladimir Isaev
@ 2024-03-19  3:54 ` Guo Ren
  2024-03-26  8:56 ` Alexandre Ghiti
  2024-03-26 21:10 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Guo Ren @ 2024-03-19  3:54 UTC (permalink / raw)
  To: Vladimir Isaev
  Cc: paul.walmsley, palmer, aou, catalin.marinas, evan, nicolas, tglx,
	samitolvanen, masahiroy, maskray, linux-riscv, linux-kernel,
	Roman Artemev

On Wed, Mar 13, 2024 at 5:05 PM Vladimir Isaev
<vladimir.isaev@syntacore.com> wrote:
>
> Such relocation causes crash of android linker similar to one
> described in commit e05d57dcb8c7
> ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace").
>
> Looks like this relocation is added by CONFIG_DYNAMIC_FTRACE which is
> disabled in the default android kernel.
>
> Before:
>
> readelf -rW arch/riscv/kernel/vdso/vdso.so:
>
> Relocation section '.rela.dyn' at offset 0xd00 contains 1 entry:
>     Offset             Info             Type
> 0000000000000d20  0000000000000003 R_RISCV_RELATIVE
>
> objdump:
> 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
>  c86:   0001                    nop
>  c88:   0001                    nop
>  c8a:   0001                    nop
>  c8c:   0001                    nop
>  c8e:   e211                    bnez    a2,c92 <__vdso_riscv_hwprobe...
>
> After:
> readelf -rW arch/riscv/kernel/vdso/vdso.so:
>
> There are no relocations in this file.
>
> objdump:
> 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
>  c86:   e211                    bnez    a2,c8a <__vdso_riscv_hwprobe...
>  c88:   c6b9                    beqz    a3,cd6 <__vdso_riscv_hwprobe...
>  c8a:   e739                    bnez    a4,cd8 <__vdso_riscv_hwprobe...
>  c8c:   ffffd797                auipc   a5,0xffffd
>
> Also disable SCS since it also should not be available in vdso.
>
> Fixes: aa5af0aa90ba ("RISC-V: Add hwprobe vDSO function and data")
> Signed-off-by: Roman Artemev <roman.artemev@syntacore.com>
> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
> ---
>  arch/riscv/kernel/vdso/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 9b517fe1b8a8..272c431ac5b9 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -37,6 +37,7 @@ endif
>
>  # Disable -pg to prevent insert call site
>  CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
> +CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
LGTM, good catch, thanks :)

Reviewed-by: Guo Ren <guoren@kernel.org>

>
>  # Disable profiling and instrumentation for VDSO code
>  GCOV_PROFILE := n
> --
> 2.43.0
>


-- 
Best Regards
 Guo Ren

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: hwprobe: do not produce frtace relocation
  2024-03-13  7:35 [PATCH] riscv: hwprobe: do not produce frtace relocation Vladimir Isaev
  2024-03-19  3:54 ` Guo Ren
@ 2024-03-26  8:56 ` Alexandre Ghiti
  2024-03-26 21:10 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Ghiti @ 2024-03-26  8:56 UTC (permalink / raw)
  To: Vladimir Isaev, paul.walmsley, palmer, aou, catalin.marinas, evan,
	nicolas, tglx, samitolvanen, masahiroy, maskray, linux-riscv,
	linux-kernel, guoren
  Cc: Roman Artemev

Hi Vladimir,

s/frtace/ftrace

On 13/03/2024 08:35, Vladimir Isaev wrote:
> Such relocation causes crash of android linker similar to one
> described in commit e05d57dcb8c7
> ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace").
>
> Looks like this relocation is added by CONFIG_DYNAMIC_FTRACE which is
> disabled in the default android kernel.
>
> Before:
>
> readelf -rW arch/riscv/kernel/vdso/vdso.so:
>
> Relocation section '.rela.dyn' at offset 0xd00 contains 1 entry:
>      Offset             Info             Type
> 0000000000000d20  0000000000000003 R_RISCV_RELATIVE
>
> objdump:
> 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
>   c86:   0001                    nop
>   c88:   0001                    nop
>   c8a:   0001                    nop
>   c8c:   0001                    nop
>   c8e:   e211                    bnez    a2,c92 <__vdso_riscv_hwprobe...
>
> After:
> readelf -rW arch/riscv/kernel/vdso/vdso.so:
>
> There are no relocations in this file.
>
> objdump:
> 0000000000000c86 <__vdso_riscv_hwprobe@@LINUX_4.15>:
>   c86:   e211                    bnez    a2,c8a <__vdso_riscv_hwprobe...
>   c88:   c6b9                    beqz    a3,cd6 <__vdso_riscv_hwprobe...
>   c8a:   e739                    bnez    a4,cd8 <__vdso_riscv_hwprobe...
>   c8c:   ffffd797                auipc   a5,0xffffd
>
> Also disable SCS since it also should not be available in vdso.
>
> Fixes: aa5af0aa90ba ("RISC-V: Add hwprobe vDSO function and data")
> Signed-off-by: Roman Artemev <roman.artemev@syntacore.com>
> Signed-off-by: Vladimir Isaev <vladimir.isaev@syntacore.com>
> ---
>   arch/riscv/kernel/vdso/Makefile | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
> index 9b517fe1b8a8..272c431ac5b9 100644
> --- a/arch/riscv/kernel/vdso/Makefile
> +++ b/arch/riscv/kernel/vdso/Makefile
> @@ -37,6 +37,7 @@ endif
>   
>   # Disable -pg to prevent insert call site
>   CFLAGS_REMOVE_vgettimeofday.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)
> +CFLAGS_REMOVE_hwprobe.o = $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS)


I did not find a way to remove those flags for all C files 
automatically, too bad. But then I noticed that we were the only 
architecture which does not check for dynamic relocations in vdso, so at 
least we'll fail loudly. I'll send a patch for that soon.

This should go into -fixes.

Anyway, you can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex


>   
>   # Disable profiling and instrumentation for VDSO code
>   GCOV_PROFILE := n

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: hwprobe: do not produce frtace relocation
  2024-03-13  7:35 [PATCH] riscv: hwprobe: do not produce frtace relocation Vladimir Isaev
  2024-03-19  3:54 ` Guo Ren
  2024-03-26  8:56 ` Alexandre Ghiti
@ 2024-03-26 21:10 ` patchwork-bot+linux-riscv
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-03-26 21:10 UTC (permalink / raw)
  To: Vladimir Isaev
  Cc: linux-riscv, paul.walmsley, palmer, aou, catalin.marinas, evan,
	nicolas, tglx, samitolvanen, masahiroy, maskray, linux-kernel,
	guoren, roman.artemev

Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Wed, 13 Mar 2024 10:35:46 +0300 you wrote:
> Such relocation causes crash of android linker similar to one
> described in commit e05d57dcb8c7
> ("riscv: Fixup __vdso_gettimeofday broke dynamic ftrace").
> 
> Looks like this relocation is added by CONFIG_DYNAMIC_FTRACE which is
> disabled in the default android kernel.
> 
> [...]

Here is the summary with links:
  - riscv: hwprobe: do not produce frtace relocation
    https://git.kernel.org/riscv/c/ad14f7ca9f0d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2024-03-26 21:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-13  7:35 [PATCH] riscv: hwprobe: do not produce frtace relocation Vladimir Isaev
2024-03-19  3:54 ` Guo Ren
2024-03-26  8:56 ` Alexandre Ghiti
2024-03-26 21:10 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox