linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
@ 2025-03-20 23:27 Sami Tolvanen
  2025-04-06 13:21 ` Masahiro Yamada
  2025-04-07  8:25 ` Sam James
  0 siblings, 2 replies; 6+ messages in thread
From: Sami Tolvanen @ 2025-03-20 23:27 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Luis Chamberlain, Petr Pavlu, Daniel Gomez, linux-modules,
	linux-kbuild, linux-kernel, Sami Tolvanen, Paolo Pisati

With CONFIG_GENDWARFKSYMS, __gendwarfksyms_ptr variables are added
to the kernel in EXPORT_SYMBOL() to ensure DWARF type information
is available for exported symbols in the TUs where they're actually
exported. These symbols are dropped when linking vmlinux, but
dangling references to them remain in DWARF.

With CONFIG_DEBUG_INFO_BTF enabled on X86, pahole versions
before commit 9810758003ce ("btf_encoder: Verify 0 address
DWARF variables are in ELF section") place these symbols in the
.data..percpu section, which results in an "Invalid offset" error in
btf_datasec_check_meta() during boot, as all the variables are at
zero offset and have non-zero size. If CONFIG_DEBUG_INFO_BTF_MODULES
is enabled, this also results in a failure to load modules with:

  failed to validate module [$module] BTF: -22

The pahole commit that adds 0 address DWARF variable verification
was merged after v1.29 was released, so later versions of pahole
shouldn't have this issue. Require pahole >v1.29 when GENDWARFKSYMS
is enabled with DEBUG_INFO_BTF on X86.

Reported-by: Paolo Pisati <paolo.pisati@canonical.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 kernel/module/Kconfig | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
index d7762ef5949a..7c75832aa1af 100644
--- a/kernel/module/Kconfig
+++ b/kernel/module/Kconfig
@@ -192,6 +192,10 @@ config GENDWARFKSYMS
 	depends on !DEBUG_INFO_REDUCED && !DEBUG_INFO_SPLIT
 	# Requires ELF object files.
 	depends on !LTO
+	# Requires pahole commit 9810758003ce ("btf_encoder: Verify 0 address
+	# DWARF variables are in ELF section") on X86 to avoid conflicts with
+	# __gendwarfksyms_ptr symbols.
+	depends on !X86 || !DEBUG_INFO_BTF || PAHOLE_VERSION > 129
 	help
 	  Calculate symbol versions from DWARF debugging information using
 	  gendwarfksyms. Requires DEBUG_INFO to be enabled.

base-commit: 4701f33a10702d5fc577c32434eb62adde0a1ae1
-- 
2.49.0.395.g12beb8f557-goog


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

* Re: [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
  2025-03-20 23:27 [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86 Sami Tolvanen
@ 2025-04-06 13:21 ` Masahiro Yamada
  2025-04-07 23:05   ` Sami Tolvanen
  2025-04-07  8:25 ` Sam James
  1 sibling, 1 reply; 6+ messages in thread
From: Masahiro Yamada @ 2025-04-06 13:21 UTC (permalink / raw)
  To: Sami Tolvanen
  Cc: Luis Chamberlain, Petr Pavlu, Daniel Gomez, linux-modules,
	linux-kbuild, linux-kernel, Paolo Pisati

On Fri, Mar 21, 2025 at 8:28 AM Sami Tolvanen <samitolvanen@google.com> wrote:
>
> With CONFIG_GENDWARFKSYMS, __gendwarfksyms_ptr variables are added
> to the kernel in EXPORT_SYMBOL() to ensure DWARF type information
> is available for exported symbols in the TUs where they're actually
> exported. These symbols are dropped when linking vmlinux, but
> dangling references to them remain in DWARF.
>
> With CONFIG_DEBUG_INFO_BTF enabled on X86, pahole versions
> before commit 9810758003ce ("btf_encoder: Verify 0 address
> DWARF variables are in ELF section") place these symbols in the
> .data..percpu section, which results in an "Invalid offset" error in
> btf_datasec_check_meta() during boot, as all the variables are at
> zero offset and have non-zero size. If CONFIG_DEBUG_INFO_BTF_MODULES
> is enabled, this also results in a failure to load modules with:
>
>   failed to validate module [$module] BTF: -22
>
> The pahole commit that adds 0 address DWARF variable verification
> was merged after v1.29 was released, so later versions of pahole
> shouldn't have this issue. Require pahole >v1.29 when GENDWARFKSYMS
> is enabled with DEBUG_INFO_BTF on X86.
>
> Reported-by: Paolo Pisati <paolo.pisati@canonical.com>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

The issue occurs with
47dcb534e253 ("btf_encoder: Stop indexing symbols for VARs"),
then fixed by  9810758003ce ("btf_encoder: Verify 0 address
DWARF variables are in ELF section")


Perhaps, does it make sense to do this?

 depends on !X86 || !DEBUG_INFO_BTF || (PAHOLE_VERSION > 129 ||
PAHOLE_VERSION < 128)



> ---
>  kernel/module/Kconfig | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
> index d7762ef5949a..7c75832aa1af 100644
> --- a/kernel/module/Kconfig
> +++ b/kernel/module/Kconfig
> @@ -192,6 +192,10 @@ config GENDWARFKSYMS
>         depends on !DEBUG_INFO_REDUCED && !DEBUG_INFO_SPLIT
>         # Requires ELF object files.
>         depends on !LTO
> +       # Requires pahole commit 9810758003ce ("btf_encoder: Verify 0 address
> +       # DWARF variables are in ELF section") on X86 to avoid conflicts with
> +       # __gendwarfksyms_ptr symbols.
> +       depends on !X86 || !DEBUG_INFO_BTF || PAHOLE_VERSION > 129
>         help
>           Calculate symbol versions from DWARF debugging information using
>           gendwarfksyms. Requires DEBUG_INFO to be enabled.
>
> base-commit: 4701f33a10702d5fc577c32434eb62adde0a1ae1
> --
> 2.49.0.395.g12beb8f557-goog
>


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
  2025-03-20 23:27 [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86 Sami Tolvanen
  2025-04-06 13:21 ` Masahiro Yamada
@ 2025-04-07  8:25 ` Sam James
  2025-04-07 12:50   ` Alan Maguire
  1 sibling, 1 reply; 6+ messages in thread
From: Sam James @ 2025-04-07  8:25 UTC (permalink / raw)
  To: dwarves
  Cc: da.gomez, linux-kbuild, linux-kernel, linux-modules, masahiroy,
	mcgrof, paolo.pisati, petr.pavlu, samitolvanen,
	Matthias Schwarzott

[with regard to
https://lore.kernel.org/linux-kbuild/20250320232757.2283956-2-samitolvanen@google.com/]

Would it be possible to have a new release with that fix, to avoid
distros all having to cherrypick the fix commit?

Thanks in advance,
sam

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

* Re: [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
  2025-04-07  8:25 ` Sam James
@ 2025-04-07 12:50   ` Alan Maguire
  2025-04-08  3:04     ` Sam James
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Maguire @ 2025-04-07 12:50 UTC (permalink / raw)
  To: Sam James, dwarves
  Cc: da.gomez, linux-kbuild, linux-kernel, linux-modules, masahiroy,
	mcgrof, paolo.pisati, petr.pavlu, samitolvanen,
	Matthias Schwarzott

On 07/04/2025 09:25, Sam James wrote:
> [with regard to
> https://lore.kernel.org/linux-kbuild/20250320232757.2283956-2-samitolvanen@google.com/]
> 
> Would it be possible to have a new release with that fix, to avoid
> distros all having to cherrypick the fix commit?
> 
> Thanks in advance,
> sam
> 

We're planning to release 1.30 shortly to follow the recent 6.14 kernel
release - hopefully this week, or perhaps early next week if any bugs
are discovered during final testing.

If folks can help by testing the next branch of

https://git.kernel.org/pub/scm/devel/pahole/pahole.git

...prior to that, that would be great. Thanks!

Alan

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

* Re: [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
  2025-04-06 13:21 ` Masahiro Yamada
@ 2025-04-07 23:05   ` Sami Tolvanen
  0 siblings, 0 replies; 6+ messages in thread
From: Sami Tolvanen @ 2025-04-07 23:05 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Luis Chamberlain, Petr Pavlu, Daniel Gomez, linux-modules,
	linux-kbuild, linux-kernel, Paolo Pisati

Hi Masahiro,

On Sun, Apr 6, 2025 at 1:21 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Fri, Mar 21, 2025 at 8:28 AM Sami Tolvanen <samitolvanen@google.com> wrote:
> >
> > With CONFIG_GENDWARFKSYMS, __gendwarfksyms_ptr variables are added
> > to the kernel in EXPORT_SYMBOL() to ensure DWARF type information
> > is available for exported symbols in the TUs where they're actually
> > exported. These symbols are dropped when linking vmlinux, but
> > dangling references to them remain in DWARF.
> >
> > With CONFIG_DEBUG_INFO_BTF enabled on X86, pahole versions
> > before commit 9810758003ce ("btf_encoder: Verify 0 address
> > DWARF variables are in ELF section") place these symbols in the
> > .data..percpu section, which results in an "Invalid offset" error in
> > btf_datasec_check_meta() during boot, as all the variables are at
> > zero offset and have non-zero size. If CONFIG_DEBUG_INFO_BTF_MODULES
> > is enabled, this also results in a failure to load modules with:
> >
> >   failed to validate module [$module] BTF: -22
> >
> > The pahole commit that adds 0 address DWARF variable verification
> > was merged after v1.29 was released, so later versions of pahole
> > shouldn't have this issue. Require pahole >v1.29 when GENDWARFKSYMS
> > is enabled with DEBUG_INFO_BTF on X86.
> >
> > Reported-by: Paolo Pisati <paolo.pisati@canonical.com>
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>
> The issue occurs with
> 47dcb534e253 ("btf_encoder: Stop indexing symbols for VARs"),
> then fixed by  9810758003ce ("btf_encoder: Verify 0 address
> DWARF variables are in ELF section")
>
>
> Perhaps, does it make sense to do this?
>
>  depends on !X86 || !DEBUG_INFO_BTF || (PAHOLE_VERSION > 129 ||
> PAHOLE_VERSION < 128)

That's a good point. I confirmed that v1.27 works fine too. I'll send v2.

Sami

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

* Re: [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86
  2025-04-07 12:50   ` Alan Maguire
@ 2025-04-08  3:04     ` Sam James
  0 siblings, 0 replies; 6+ messages in thread
From: Sam James @ 2025-04-08  3:04 UTC (permalink / raw)
  To: Alan Maguire
  Cc: dwarves, da.gomez, linux-kbuild, linux-kernel, linux-modules,
	masahiroy, mcgrof, paolo.pisati, petr.pavlu, samitolvanen,
	Matthias Schwarzott

Alan Maguire <alan.maguire@oracle.com> writes:

> On 07/04/2025 09:25, Sam James wrote:
>> [with regard to
>> https://lore.kernel.org/linux-kbuild/20250320232757.2283956-2-samitolvanen@google.com/]
>> 
>> Would it be possible to have a new release with that fix, to avoid
>> distros all having to cherrypick the fix commit?
>> 
>> Thanks in advance,
>> sam
>> 
>
> We're planning to release 1.30 shortly to follow the recent 6.14 kernel
> release - hopefully this week, or perhaps early next week if any bugs
> are discovered during final testing.
>
> If folks can help by testing the next branch of
>
> https://git.kernel.org/pub/scm/devel/pahole/pahole.git
>
> ...prior to that, that would be great. Thanks!

Will do, thanks!

>
> Alan

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

end of thread, other threads:[~2025-04-08  3:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 23:27 [PATCH] kbuild: Require pahole >v1.29 with GENDWARFKSYMS and BTF on X86 Sami Tolvanen
2025-04-06 13:21 ` Masahiro Yamada
2025-04-07 23:05   ` Sami Tolvanen
2025-04-07  8:25 ` Sam James
2025-04-07 12:50   ` Alan Maguire
2025-04-08  3:04     ` Sam James

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).