* [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel
@ 2025-02-26 13:28 Xi Ruoyao
2025-02-26 15:43 ` Steven Rostedt
2025-02-27 10:12 ` Thomas Bogendoerfer
0 siblings, 2 replies; 4+ messages in thread
From: Xi Ruoyao @ 2025-02-26 13:28 UTC (permalink / raw)
To: Thomas Bogendoerfer, Steven Rostedt, Jiaxun Yang
Cc: Matt Redfearn, linux-mips, linux-kbuild, linux-kernel, Xi Ruoyao
Since commit 6f2c2f93a190 ("scripts/sorttable: Remove unneeded
Elf_Rel"), sorttable no longer clears relocs against __ex_table,
claiming "it was never used." But in fact MIPS relocatable kernel had
been implicitly depending on this behavior, so after this commit the
MIPS relocatable kernel has started to spit oops like:
CPU 1 Unable to handle kernel paging request at virtual address 000000fffbbdbff8, epc == ffffffff818f9a6c, ra == ffffffff813ad7d0
... ...
Call Trace:
[<ffffffff818f9a6c>] __raw_copy_from_user+0x48/0x2fc
[<ffffffff813ad7d0>] cp_statx+0x1a0/0x1e0
[<ffffffff813ae528>] do_statx_fd+0xa8/0x118
[<ffffffff813ae670>] sys_statx+0xd8/0xf8
[<ffffffff81156cc8>] syscall_common+0x34/0x58
So ignore those relocs on our own to fix the issue.
Fixes: 6f2c2f93a190 ("scripts/sorttable: Remove unneeded Elf_Rel")
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
arch/mips/boot/tools/relocs.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/mips/boot/tools/relocs.c b/arch/mips/boot/tools/relocs.c
index a88d66c46d7f..9863e1d5c62e 100644
--- a/arch/mips/boot/tools/relocs.c
+++ b/arch/mips/boot/tools/relocs.c
@@ -468,6 +468,8 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
Elf_Sym *sym, const char *symname))
{
int i;
+ struct section *extab_sec = sec_lookup("__ex_table");
+ int extab_index = extab_sec ? extab_sec - secs : -1;
/* Walk through the relocations */
for (i = 0; i < ehdr.e_shnum; i++) {
@@ -480,6 +482,9 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
if (sec->shdr.sh_type != SHT_REL_TYPE)
continue;
+ if (sec->shdr.sh_info == extab_index)
+ continue;
+
sec_symtab = sec->link;
sec_applies = &secs[sec->shdr.sh_info];
if (!(sec_applies->shdr.sh_flags & SHF_ALLOC))
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel
2025-02-26 13:28 [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel Xi Ruoyao
@ 2025-02-26 15:43 ` Steven Rostedt
2025-02-26 18:10 ` Thomas Bogendoerfer
2025-02-27 10:12 ` Thomas Bogendoerfer
1 sibling, 1 reply; 4+ messages in thread
From: Steven Rostedt @ 2025-02-26 15:43 UTC (permalink / raw)
To: Xi Ruoyao
Cc: Thomas Bogendoerfer, Jiaxun Yang, Matt Redfearn, linux-mips,
linux-kbuild, linux-kernel
On Wed, 26 Feb 2025 21:28:41 +0800
Xi Ruoyao <xry111@xry111.site> wrote:
> Since commit 6f2c2f93a190 ("scripts/sorttable: Remove unneeded
> Elf_Rel"), sorttable no longer clears relocs against __ex_table,
> claiming "it was never used." But in fact MIPS relocatable kernel had
> been implicitly depending on this behavior, so after this commit the
> MIPS relocatable kernel has started to spit oops like:
Oops!
>
> CPU 1 Unable to handle kernel paging request at virtual address 000000fffbbdbff8, epc == ffffffff818f9a6c, ra == ffffffff813ad7d0
> ... ...
> Call Trace:
> [<ffffffff818f9a6c>] __raw_copy_from_user+0x48/0x2fc
> [<ffffffff813ad7d0>] cp_statx+0x1a0/0x1e0
> [<ffffffff813ae528>] do_statx_fd+0xa8/0x118
> [<ffffffff813ae670>] sys_statx+0xd8/0xf8
> [<ffffffff81156cc8>] syscall_common+0x34/0x58
>
> So ignore those relocs on our own to fix the issue.
>
> Fixes: 6f2c2f93a190 ("scripts/sorttable: Remove unneeded Elf_Rel")
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Thanks! Yeah, this is better than having an implicit dependency to the
sorttable code.
I take it that this will go through the mips tree?
-- Steve
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel
2025-02-26 15:43 ` Steven Rostedt
@ 2025-02-26 18:10 ` Thomas Bogendoerfer
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2025-02-26 18:10 UTC (permalink / raw)
To: Steven Rostedt
Cc: Xi Ruoyao, Jiaxun Yang, Matt Redfearn, linux-mips, linux-kbuild,
linux-kernel
On Wed, Feb 26, 2025 at 10:43:40AM -0500, Steven Rostedt wrote:
> On Wed, 26 Feb 2025 21:28:41 +0800
> Xi Ruoyao <xry111@xry111.site> wrote:
>
> > Since commit 6f2c2f93a190 ("scripts/sorttable: Remove unneeded
> > Elf_Rel"), sorttable no longer clears relocs against __ex_table,
> > claiming "it was never used." But in fact MIPS relocatable kernel had
> > been implicitly depending on this behavior, so after this commit the
> > MIPS relocatable kernel has started to spit oops like:
>
> Oops!
>
> >
> > CPU 1 Unable to handle kernel paging request at virtual address 000000fffbbdbff8, epc == ffffffff818f9a6c, ra == ffffffff813ad7d0
> > ... ...
> > Call Trace:
> > [<ffffffff818f9a6c>] __raw_copy_from_user+0x48/0x2fc
> > [<ffffffff813ad7d0>] cp_statx+0x1a0/0x1e0
> > [<ffffffff813ae528>] do_statx_fd+0xa8/0x118
> > [<ffffffff813ae670>] sys_statx+0xd8/0xf8
> > [<ffffffff81156cc8>] syscall_common+0x34/0x58
> >
> > So ignore those relocs on our own to fix the issue.
> >
> > Fixes: 6f2c2f93a190 ("scripts/sorttable: Remove unneeded Elf_Rel")
> > Signed-off-by: Xi Ruoyao <xry111@xry111.site>
>
> Thanks! Yeah, this is better than having an implicit dependency to the
> sorttable code.
>
> I take it that this will go through the mips tree?
yes, I'll take it.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel
2025-02-26 13:28 [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel Xi Ruoyao
2025-02-26 15:43 ` Steven Rostedt
@ 2025-02-27 10:12 ` Thomas Bogendoerfer
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Bogendoerfer @ 2025-02-27 10:12 UTC (permalink / raw)
To: Xi Ruoyao
Cc: Steven Rostedt, Jiaxun Yang, Matt Redfearn, linux-mips,
linux-kbuild, linux-kernel
On Wed, Feb 26, 2025 at 09:28:41PM +0800, Xi Ruoyao wrote:
> Since commit 6f2c2f93a190 ("scripts/sorttable: Remove unneeded
> Elf_Rel"), sorttable no longer clears relocs against __ex_table,
> claiming "it was never used." But in fact MIPS relocatable kernel had
> been implicitly depending on this behavior, so after this commit the
> MIPS relocatable kernel has started to spit oops like:
>
> CPU 1 Unable to handle kernel paging request at virtual address 000000fffbbdbff8, epc == ffffffff818f9a6c, ra == ffffffff813ad7d0
> ... ...
> Call Trace:
> [<ffffffff818f9a6c>] __raw_copy_from_user+0x48/0x2fc
> [<ffffffff813ad7d0>] cp_statx+0x1a0/0x1e0
> [<ffffffff813ae528>] do_statx_fd+0xa8/0x118
> [<ffffffff813ae670>] sys_statx+0xd8/0xf8
> [<ffffffff81156cc8>] syscall_common+0x34/0x58
>
> So ignore those relocs on our own to fix the issue.
>
> Fixes: 6f2c2f93a190 ("scripts/sorttable: Remove unneeded Elf_Rel")
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>
> ---
> arch/mips/boot/tools/relocs.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/mips/boot/tools/relocs.c b/arch/mips/boot/tools/relocs.c
> index a88d66c46d7f..9863e1d5c62e 100644
> --- a/arch/mips/boot/tools/relocs.c
> +++ b/arch/mips/boot/tools/relocs.c
> @@ -468,6 +468,8 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
> Elf_Sym *sym, const char *symname))
> {
> int i;
> + struct section *extab_sec = sec_lookup("__ex_table");
> + int extab_index = extab_sec ? extab_sec - secs : -1;
>
> /* Walk through the relocations */
> for (i = 0; i < ehdr.e_shnum; i++) {
> @@ -480,6 +482,9 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
> if (sec->shdr.sh_type != SHT_REL_TYPE)
> continue;
>
> + if (sec->shdr.sh_info == extab_index)
> + continue;
> +
> sec_symtab = sec->link;
> sec_applies = &secs[sec->shdr.sh_info];
> if (!(sec_applies->shdr.sh_flags & SHF_ALLOC))
> --
> 2.48.1
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-27 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-26 13:28 [PATCH] MIPS: Ignore relocs against __ex_table for relocatable kernel Xi Ruoyao
2025-02-26 15:43 ` Steven Rostedt
2025-02-26 18:10 ` Thomas Bogendoerfer
2025-02-27 10:12 ` Thomas Bogendoerfer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox