Linux-RISC-V Archive mirror
 help / color / mirror / Atom feed
* [PATCH] Revert "riscv: disable generation of unwind tables"
@ 2024-04-16  1:31 Zong Li
  2024-04-22 19:13 ` Charlie Jenkins
  0 siblings, 1 reply; 3+ messages in thread
From: Zong Li @ 2024-04-16  1:31 UTC (permalink / raw
  To: paul.walmsley, palmer, aou, schwab, linux-riscv, linux-kernel; +Cc: Zong Li

This reverts commit 2f394c0e7d1129a35156e492bc8f445fb20f43ac.

RISC-V has supported the complete relocation types in module loader by
'8fd6c5142395 ("riscv: Add remaining module relocations")'.
Now RISC-V port can enable unwind tables in case eh_frame parsing is
needed.

Signed-off-by: Zong Li <zong.li@sifive.com>
---
 arch/riscv/Makefile | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 5b3115a19852..9216bf8a2691 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -94,9 +94,6 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
 	KBUILD_CFLAGS += -mcmodel=medany
 endif
 
-# Avoid generating .eh_frame sections.
-KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
-
 # The RISC-V attributes frequently cause compatibility issues and provide no
 # information, so just turn them off.
 KBUILD_CFLAGS += $(call cc-option,-mno-riscv-attribute)
-- 
2.17.1


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

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

* Re: [PATCH] Revert "riscv: disable generation of unwind tables"
  2024-04-16  1:31 [PATCH] Revert "riscv: disable generation of unwind tables" Zong Li
@ 2024-04-22 19:13 ` Charlie Jenkins
  2024-04-24  6:44   ` Zong Li
  0 siblings, 1 reply; 3+ messages in thread
From: Charlie Jenkins @ 2024-04-22 19:13 UTC (permalink / raw
  To: Zong Li; +Cc: paul.walmsley, palmer, aou, schwab, linux-riscv, linux-kernel

On Tue, Apr 16, 2024 at 09:31:38AM +0800, Zong Li wrote:
> This reverts commit 2f394c0e7d1129a35156e492bc8f445fb20f43ac.
> 
> RISC-V has supported the complete relocation types in module loader by
> '8fd6c5142395 ("riscv: Add remaining module relocations")'.
> Now RISC-V port can enable unwind tables in case eh_frame parsing is
> needed.
> 
> Signed-off-by: Zong Li <zong.li@sifive.com>
> ---
>  arch/riscv/Makefile | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> index 5b3115a19852..9216bf8a2691 100644
> --- a/arch/riscv/Makefile
> +++ b/arch/riscv/Makefile
> @@ -94,9 +94,6 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
>  	KBUILD_CFLAGS += -mcmodel=medany
>  endif
>  
> -# Avoid generating .eh_frame sections.
> -KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> -

There are a lot of orphaned sections created by this, which throws a lot
of warnings. These warnings will only be present on GCC-13+ since
-fno-asynchronous-unwind-tables was a default before GCC-13.

The .eh_frame orphaned sections can be resolved by including

.eh_frame : {*(.eh_frame)}

in arch/riscv/kernel/vmlinux.lds.S. arm64 places it in the init section,
but outside init_data and init_text, so right after the .alternative
definition seems like a good place.

.init.eh_frame sections in drivers/firmware/efi/libstub also complain
about being orphaned, and other architectures have disabled unwind
tables for that compilation unit, so -fno-unwind-tables and
-fno-asynchronous-unwind-tables should be added to
drivers/firmware/efi/libstub/Makefile for riscv.

This also causes the resulting image (with defconfig) to increase from
22M to 24M. There are currently no users of unwind tables in riscv so
this should be hidden behind a config. arm64 uses this config as:

# Avoid generating .eh_frame* sections.
ifneq ($(CONFIG_UNWIND_TABLES),y)
KBUILD_CFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
KBUILD_AFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
else
KBUILD_CFLAGS   += -fasynchronous-unwind-tables
KBUILD_AFLAGS   += -fasynchronous-unwind-tables
endif

Using this same config name for riscv would allow riscv to use the
standard .eh_frame code introduced in
https://lore.kernel.org/linux-arm-kernel/20221027155908.1940624-2-ardb@kernel.org/.

This config is only enabled if some other config selects it in arm64,
but riscv does not contain any users so maybe this config can be left
unselected until there is a user of unwind tables in riscv.

- Charlie

>  # The RISC-V attributes frequently cause compatibility issues and provide no
>  # information, so just turn them off.
>  KBUILD_CFLAGS += $(call cc-option,-mno-riscv-attribute)
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv

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

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

* Re: [PATCH] Revert "riscv: disable generation of unwind tables"
  2024-04-22 19:13 ` Charlie Jenkins
@ 2024-04-24  6:44   ` Zong Li
  0 siblings, 0 replies; 3+ messages in thread
From: Zong Li @ 2024-04-24  6:44 UTC (permalink / raw
  To: Charlie Jenkins
  Cc: paul.walmsley, palmer, aou, schwab, linux-riscv, linux-kernel

On Tue, Apr 23, 2024 at 3:14 AM Charlie Jenkins <charlie@rivosinc.com> wrote:
>
> On Tue, Apr 16, 2024 at 09:31:38AM +0800, Zong Li wrote:
> > This reverts commit 2f394c0e7d1129a35156e492bc8f445fb20f43ac.
> >
> > RISC-V has supported the complete relocation types in module loader by
> > '8fd6c5142395 ("riscv: Add remaining module relocations")'.
> > Now RISC-V port can enable unwind tables in case eh_frame parsing is
> > needed.
> >
> > Signed-off-by: Zong Li <zong.li@sifive.com>
> > ---
> >  arch/riscv/Makefile | 3 ---
> >  1 file changed, 3 deletions(-)
> >
> > diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
> > index 5b3115a19852..9216bf8a2691 100644
> > --- a/arch/riscv/Makefile
> > +++ b/arch/riscv/Makefile
> > @@ -94,9 +94,6 @@ ifeq ($(CONFIG_CMODEL_MEDANY),y)
> >       KBUILD_CFLAGS += -mcmodel=medany
> >  endif
> >
> > -# Avoid generating .eh_frame sections.
> > -KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
> > -
>
> There are a lot of orphaned sections created by this, which throws a lot
> of warnings. These warnings will only be present on GCC-13+ since
> -fno-asynchronous-unwind-tables was a default before GCC-13.
>
> The .eh_frame orphaned sections can be resolved by including
>
> .eh_frame : {*(.eh_frame)}
>
> in arch/riscv/kernel/vmlinux.lds.S. arm64 places it in the init section,
> but outside init_data and init_text, so right after the .alternative
> definition seems like a good place.
>
> .init.eh_frame sections in drivers/firmware/efi/libstub also complain
> about being orphaned, and other architectures have disabled unwind
> tables for that compilation unit, so -fno-unwind-tables and
> -fno-asynchronous-unwind-tables should be added to
> drivers/firmware/efi/libstub/Makefile for riscv.
>
> This also causes the resulting image (with defconfig) to increase from
> 22M to 24M. There are currently no users of unwind tables in riscv so
> this should be hidden behind a config. arm64 uses this config as:
>
> # Avoid generating .eh_frame* sections.
> ifneq ($(CONFIG_UNWIND_TABLES),y)
> KBUILD_CFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
> KBUILD_AFLAGS   += -fno-asynchronous-unwind-tables -fno-unwind-tables
> else
> KBUILD_CFLAGS   += -fasynchronous-unwind-tables
> KBUILD_AFLAGS   += -fasynchronous-unwind-tables
> endif
>
> Using this same config name for riscv would allow riscv to use the
> standard .eh_frame code introduced in
> https://lore.kernel.org/linux-arm-kernel/20221027155908.1940624-2-ardb@kernel.org/.
>
> This config is only enabled if some other config selects it in arm64,
> but riscv does not contain any users so maybe this config can be left
> unselected until there is a user of unwind tables in riscv.
>

Hi Charlie,
Thanks a lot for the tips and information, I will use gcc-13+ to
verify the next patch.

> - Charlie
>
> >  # The RISC-V attributes frequently cause compatibility issues and provide no
> >  # information, so just turn them off.
> >  KBUILD_CFLAGS += $(call cc-option,-mno-riscv-attribute)
> > --
> > 2.17.1
> >
> >
> > _______________________________________________
> > linux-riscv mailing list
> > linux-riscv@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-riscv

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

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

end of thread, other threads:[~2024-04-24  6:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-16  1:31 [PATCH] Revert "riscv: disable generation of unwind tables" Zong Li
2024-04-22 19:13 ` Charlie Jenkins
2024-04-24  6:44   ` Zong Li

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 read-only IMAP folder(s) and NNTP newsgroup(s).