* [PATCH 0/2] riscv: improve __ex_table section handling
@ 2021-08-08 17:25 Jisheng Zhang
2021-08-08 17:25 ` [PATCH 1/2] riscv: Enable BUILDTIME_TABLE_SORT Jisheng Zhang
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jisheng Zhang @ 2021-08-08 17:25 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: linux-riscv, linux-kernel
From: Jisheng Zhang <jszhang@kernel.org>
Enable BUILDTIME_TABLE_SORT to sort the exception table at build time
then move exception table to RO_DATA segment.
Jisheng Zhang (2):
riscv: Enable BUILDTIME_TABLE_SORT
riscv: Move EXCEPTION_TABLE to RO_DATA segment
arch/riscv/Kconfig | 1 +
arch/riscv/kernel/vmlinux-xip.lds.S | 1 -
arch/riscv/kernel/vmlinux.lds.S | 4 ++--
scripts/sorttable.c | 1 +
4 files changed, 4 insertions(+), 3 deletions(-)
--
2.32.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] riscv: Enable BUILDTIME_TABLE_SORT
2021-08-08 17:25 [PATCH 0/2] riscv: improve __ex_table section handling Jisheng Zhang
@ 2021-08-08 17:25 ` Jisheng Zhang
2021-08-08 17:26 ` [PATCH 2/2] riscv: Move EXCEPTION_TABLE to RO_DATA segment Jisheng Zhang
2021-08-26 6:47 ` [PATCH 0/2] riscv: improve __ex_table section handling Palmer Dabbelt
2 siblings, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2021-08-08 17:25 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: linux-riscv, linux-kernel
From: Jisheng Zhang <jszhang@kernel.org>
Enable BUILDTIME_TABLE_SORT to sort the exception table at build time
rather than during boot.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
arch/riscv/Kconfig | 1 +
scripts/sorttable.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 80a7aa9f74de..570689d3889b 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -40,6 +40,7 @@ config RISCV
select ARCH_WANT_FRAME_POINTERS
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU
+ select BUILDTIME_TABLE_SORT
select CLONE_BACKWARDS
select CLINT_TIMER if !MMU
select COMMON_CLK
diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index 0ef3abfc4a51..f355869c65cd 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -349,6 +349,7 @@ static int do_file(char const *const fname, void *addr)
case EM_ARM:
case EM_MICROBLAZE:
case EM_MIPS:
+ case EM_RISCV:
case EM_XTENSA:
break;
default:
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] riscv: Move EXCEPTION_TABLE to RO_DATA segment
2021-08-08 17:25 [PATCH 0/2] riscv: improve __ex_table section handling Jisheng Zhang
2021-08-08 17:25 ` [PATCH 1/2] riscv: Enable BUILDTIME_TABLE_SORT Jisheng Zhang
@ 2021-08-08 17:26 ` Jisheng Zhang
2021-08-26 6:47 ` [PATCH 0/2] riscv: improve __ex_table section handling Palmer Dabbelt
2 siblings, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2021-08-08 17:26 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: linux-riscv, linux-kernel
From: Jisheng Zhang <jszhang@kernel.org>
The _ex_table section is read-only, so move it to RO_DATA.
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
arch/riscv/kernel/vmlinux-xip.lds.S | 1 -
arch/riscv/kernel/vmlinux.lds.S | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/vmlinux-xip.lds.S b/arch/riscv/kernel/vmlinux-xip.lds.S
index af776555ded9..9c9f35091ef0 100644
--- a/arch/riscv/kernel/vmlinux-xip.lds.S
+++ b/arch/riscv/kernel/vmlinux-xip.lds.S
@@ -121,7 +121,6 @@ SECTIONS
}
BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0)
- EXCEPTION_TABLE(0x10)
.rel.dyn : AT(ADDR(.rel.dyn) - LOAD_OFFSET) {
*(.rel.dyn*)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 502d0826ecb1..5104f3a871e3 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -4,6 +4,8 @@
* Copyright (C) 2017 SiFive
*/
+#define RO_EXCEPTION_TABLE_ALIGN 16
+
#ifdef CONFIG_XIP_KERNEL
#include "vmlinux-xip.lds.S"
#else
@@ -112,8 +114,6 @@ SECTIONS
*(.srodata*)
}
- EXCEPTION_TABLE(0x10)
-
. = ALIGN(SECTION_ALIGN);
_data = .;
--
2.32.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] riscv: improve __ex_table section handling
2021-08-08 17:25 [PATCH 0/2] riscv: improve __ex_table section handling Jisheng Zhang
2021-08-08 17:25 ` [PATCH 1/2] riscv: Enable BUILDTIME_TABLE_SORT Jisheng Zhang
2021-08-08 17:26 ` [PATCH 2/2] riscv: Move EXCEPTION_TABLE to RO_DATA segment Jisheng Zhang
@ 2021-08-26 6:47 ` Palmer Dabbelt
2021-08-26 14:06 ` Jisheng Zhang
2 siblings, 1 reply; 5+ messages in thread
From: Palmer Dabbelt @ 2021-08-26 6:47 UTC (permalink / raw)
To: jszhang3; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel
On Sun, 08 Aug 2021 10:25:09 PDT (-0700), jszhang3@mail.ustc.edu.cn wrote:
> From: Jisheng Zhang <jszhang@kernel.org>
>
> Enable BUILDTIME_TABLE_SORT to sort the exception table at build time
> then move exception table to RO_DATA segment.
>
> Jisheng Zhang (2):
> riscv: Enable BUILDTIME_TABLE_SORT
> riscv: Move EXCEPTION_TABLE to RO_DATA segment
>
> arch/riscv/Kconfig | 1 +
> arch/riscv/kernel/vmlinux-xip.lds.S | 1 -
> arch/riscv/kernel/vmlinux.lds.S | 4 ++--
> scripts/sorttable.c | 1 +
> 4 files changed, 4 insertions(+), 3 deletions(-)
This seems reasonable, but it's failing for some configurations (at
least tinyconfig) saying there is no __ex_table. I'm not entirely sure
how that comes about, as we've got them for futexes and uaccess.
Maybe the right thing to do here is to fix scripts/sorttable.c so it can
handle files with nothing to sort? I think it's just as simple as a
successful early out like this
diff --git a/scripts/sorttable.h b/scripts/sorttable.h
index a2baa2fefb13..207ddeddb506 100644
--- a/scripts/sorttable.h
+++ b/scripts/sorttable.h
@@ -294,8 +294,9 @@ static int do_sort(Elf_Ehdr *ehdr,
goto out;
}
#endif
+ /* If there is no __ex_table section there is no work do to. */
if (!extab_sec) {
- fprintf(stderr, "no __ex_table in file: %s\n", fname);
+ rc = 0;
goto out;
}
I'm not entirely sure though -- my logic is essentially just "there's no
__ex_table, so there's nothing to sort, so just don't try".
All the configurations I can actually boot have an __ex_table, so I'm
not sure how to test that.
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] riscv: improve __ex_table section handling
2021-08-26 6:47 ` [PATCH 0/2] riscv: improve __ex_table section handling Palmer Dabbelt
@ 2021-08-26 14:06 ` Jisheng Zhang
0 siblings, 0 replies; 5+ messages in thread
From: Jisheng Zhang @ 2021-08-26 14:06 UTC (permalink / raw)
To: Palmer Dabbelt; +Cc: Paul Walmsley, aou, linux-riscv, linux-kernel
On Wed, 25 Aug 2021 23:47:02 -0700 (PDT)
Palmer Dabbelt <palmer@dabbelt.com> wrote:
> On Sun, 08 Aug 2021 10:25:09 PDT (-0700), jszhang3@mail.ustc.edu.cn wrote:
> > From: Jisheng Zhang <jszhang@kernel.org>
> >
> > Enable BUILDTIME_TABLE_SORT to sort the exception table at build time
> > then move exception table to RO_DATA segment.
> >
> > Jisheng Zhang (2):
> > riscv: Enable BUILDTIME_TABLE_SORT
> > riscv: Move EXCEPTION_TABLE to RO_DATA segment
> >
> > arch/riscv/Kconfig | 1 +
> > arch/riscv/kernel/vmlinux-xip.lds.S | 1 -
> > arch/riscv/kernel/vmlinux.lds.S | 4 ++--
> > scripts/sorttable.c | 1 +
> > 4 files changed, 4 insertions(+), 3 deletions(-)
>
> This seems reasonable, but it's failing for some configurations (at
> least tinyconfig) saying there is no __ex_table. I'm not entirely sure
Nice catch! tinyconfig in riscv means NOMMU which indicates no __ex_table at all.
It seems we have to only enable BUILDTIME_TABLE_SORT for MMU case.
will send out V2 soon.
Thanks
> how that comes about, as we've got them for futexes and uaccess.
>
> Maybe the right thing to do here is to fix scripts/sorttable.c so it can
> handle files with nothing to sort? I think it's just as simple as a
> successful early out like this
>
> diff --git a/scripts/sorttable.h b/scripts/sorttable.h
> index a2baa2fefb13..207ddeddb506 100644
> --- a/scripts/sorttable.h
> +++ b/scripts/sorttable.h
> @@ -294,8 +294,9 @@ static int do_sort(Elf_Ehdr *ehdr,
> goto out;
> }
> #endif
> + /* If there is no __ex_table section there is no work do to. */
> if (!extab_sec) {
> - fprintf(stderr, "no __ex_table in file: %s\n", fname);
> + rc = 0;
> goto out;
> }
>
> I'm not entirely sure though -- my logic is essentially just "there's no
> __ex_table, so there's nothing to sort, so just don't try".
>
> All the configurations I can actually boot have an __ex_table, so I'm
> not sure how to test that.
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-26 14:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-08 17:25 [PATCH 0/2] riscv: improve __ex_table section handling Jisheng Zhang
2021-08-08 17:25 ` [PATCH 1/2] riscv: Enable BUILDTIME_TABLE_SORT Jisheng Zhang
2021-08-08 17:26 ` [PATCH 2/2] riscv: Move EXCEPTION_TABLE to RO_DATA segment Jisheng Zhang
2021-08-26 6:47 ` [PATCH 0/2] riscv: improve __ex_table section handling Palmer Dabbelt
2021-08-26 14:06 ` Jisheng Zhang
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).