linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kbuild: Require pahole <v1.28 or >v1.29 with GENDWARFKSYMS on X86
@ 2025-04-07 23:08 Sami Tolvanen
  2025-05-06  7:03 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Sami Tolvanen @ 2025-04-07 23:08 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 after
commit 47dcb534e253 ("btf_encoder: Stop indexing symbols for
VARs") and 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

As the issue occurs in pahole v1.28 and the fix was merged
after v1.29 was released, require pahole <v1.28 or >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>
---

Changes in v2:
- Also allow pahole <v1.28.
- Update comment to include the affected commit range.

---
 kernel/module/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
index d7762ef5949a..39278737bb68 100644
--- a/kernel/module/Kconfig
+++ b/kernel/module/Kconfig
@@ -192,6 +192,11 @@ config GENDWARFKSYMS
 	depends on !DEBUG_INFO_REDUCED && !DEBUG_INFO_SPLIT
 	# Requires ELF object files.
 	depends on !LTO
+	# To avoid conflicts with the discarded __gendwarfksyms_ptr symbols on
+	# X86, requires pahole before commit 47dcb534e253 ("btf_encoder: Stop
+	# indexing symbols for VARs") or after commit 9810758003ce ("btf_encoder:
+	# Verify 0 address DWARF variables are in ELF section").
+	depends on !X86 || !DEBUG_INFO_BTF || PAHOLE_VERSION < 128 || PAHOLE_VERSION > 129
 	help
 	  Calculate symbol versions from DWARF debugging information using
 	  gendwarfksyms. Requires DEBUG_INFO to be enabled.

base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
-- 
2.49.0.504.g3bcea36a83-goog


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

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

On Tue, Apr 8, 2025 at 8:08 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 after
> commit 47dcb534e253 ("btf_encoder: Stop indexing symbols for
> VARs") and 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
>
> As the issue occurs in pahole v1.28 and the fix was merged
> after v1.29 was released, require pahole <v1.28 or >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>
> ---
>

Applied to linux-kbuild.

Thanks.



> Changes in v2:
> - Also allow pahole <v1.28.
> - Update comment to include the affected commit range.
>
> ---
>  kernel/module/Kconfig | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
> index d7762ef5949a..39278737bb68 100644
> --- a/kernel/module/Kconfig
> +++ b/kernel/module/Kconfig
> @@ -192,6 +192,11 @@ config GENDWARFKSYMS
>         depends on !DEBUG_INFO_REDUCED && !DEBUG_INFO_SPLIT
>         # Requires ELF object files.
>         depends on !LTO
> +       # To avoid conflicts with the discarded __gendwarfksyms_ptr symbols on
> +       # X86, requires pahole before commit 47dcb534e253 ("btf_encoder: Stop
> +       # indexing symbols for VARs") or after commit 9810758003ce ("btf_encoder:
> +       # Verify 0 address DWARF variables are in ELF section").
> +       depends on !X86 || !DEBUG_INFO_BTF || PAHOLE_VERSION < 128 || PAHOLE_VERSION > 129
>         help
>           Calculate symbol versions from DWARF debugging information using
>           gendwarfksyms. Requires DEBUG_INFO to be enabled.
>
> base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
> --
> 2.49.0.504.g3bcea36a83-goog
>


-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2025-05-06  7:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 23:08 [PATCH v2] kbuild: Require pahole <v1.28 or >v1.29 with GENDWARFKSYMS on X86 Sami Tolvanen
2025-05-06  7:03 ` Masahiro Yamada

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