--- /dev/null
+From 613fe169237785a4bb1d06397b52606b2967da53 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Tue, 1 Feb 2022 13:56:21 -0700
+Subject: kbuild: Add CONFIG_PAHOLE_VERSION
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 613fe169237785a4bb1d06397b52606b2967da53 upstream.
+
+There are a few different places where pahole's version is turned into a
+three digit form with the exact same command. Move this command into
+scripts/pahole-version.sh to reduce the amount of duplication across the
+tree.
+
+Create CONFIG_PAHOLE_VERSION so the version code can be used in Kconfig
+to enable and disable configuration options based on the pahole version,
+which is already done in a couple of places.
+
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Acked-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20220201205624.652313-3-nathan@kernel.org
+Signed-off-by: Matthias Maennich <maennich@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ MAINTAINERS | 1 +
+ init/Kconfig | 4 ++++
+ scripts/pahole-version.sh | 13 +++++++++++++
+ 3 files changed, 18 insertions(+)
+ create mode 100755 scripts/pahole-version.sh
+
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -3407,6 +3407,7 @@ F: net/sched/act_bpf.c
+ F: net/sched/cls_bpf.c
+ F: samples/bpf/
+ F: scripts/bpf_doc.py
++F: scripts/pahole-version.sh
+ F: tools/bpf/
+ F: tools/lib/bpf/
+ F: tools/testing/selftests/bpf/
+--- a/init/Kconfig
++++ b/init/Kconfig
+@@ -91,6 +91,10 @@ config CC_HAS_ASM_INLINE
+ config CC_HAS_NO_PROFILE_FN_ATTR
+ def_bool $(success,echo '__attribute__((no_profile_instrument_function)) int x();' | $(CC) -x c - -c -o /dev/null -Werror)
+
++config PAHOLE_VERSION
++ int
++ default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))
++
+ config CONSTRUCTORS
+ bool
+
+--- /dev/null
++++ b/scripts/pahole-version.sh
+@@ -0,0 +1,13 @@
++#!/bin/sh
++# SPDX-License-Identifier: GPL-2.0
++#
++# Usage: $ ./pahole-version.sh pahole
++#
++# Prints pahole's version in a 3-digit form, such as 119 for v1.19.
++
++if [ ! -x "$(command -v "$@")" ]; then
++ echo 0
++ exit 1
++fi
++
++"$@" --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'
--- /dev/null
+From 42d9b379e3e1790eafb87c799c9edfd0b37a37c7 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Tue, 1 Feb 2022 13:56:24 -0700
+Subject: lib/Kconfig.debug: Allow BTF + DWARF5 with pahole 1.21+
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 42d9b379e3e1790eafb87c799c9edfd0b37a37c7 upstream.
+
+Commit 98cd6f521f10 ("Kconfig: allow explicit opt in to DWARF v5")
+prevented CONFIG_DEBUG_INFO_DWARF5 from being selected when
+CONFIG_DEBUG_INFO_BTF is enabled because pahole had issues with clang's
+DWARF5 info. This was resolved by [1], which is in pahole v1.21.
+
+Allow DEBUG_INFO_DWARF5 to be selected with DEBUG_INFO_BTF when using
+pahole v1.21 or newer.
+
+[1]: https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?id=7d8e829f636f47aba2e1b6eda57e74d8e31f733c
+
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Acked-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20220201205624.652313-6-nathan@kernel.org
+Signed-off-by: Matthias Maennich <maennich@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ lib/Kconfig.debug | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/Kconfig.debug
++++ b/lib/Kconfig.debug
+@@ -302,7 +302,7 @@ config DEBUG_INFO_DWARF4
+ config DEBUG_INFO_DWARF5
+ bool "Generate DWARF Version 5 debuginfo"
+ depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
+- depends on !DEBUG_INFO_BTF
++ depends on !DEBUG_INFO_BTF || PAHOLE_VERSION >= 121
+ help
+ Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
+ 5.0+ accepts the -gdwarf-5 flag but only had partial support for some
--- /dev/null
+From 6323c81350b73a4569cf52df85f80273faa64071 Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Tue, 1 Feb 2022 13:56:23 -0700
+Subject: lib/Kconfig.debug: Use CONFIG_PAHOLE_VERSION
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 6323c81350b73a4569cf52df85f80273faa64071 upstream.
+
+Now that CONFIG_PAHOLE_VERSION exists, use it in the definition of
+CONFIG_PAHOLE_HAS_SPLIT_BTF and CONFIG_PAHOLE_HAS_BTF_TAG to reduce the
+amount of duplication across the tree.
+
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Acked-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20220201205624.652313-5-nathan@kernel.org
+[maennich: omitted patching non-existing config PAHOLE_HAS_BTF_TAG]
+Signed-off-by: Matthias Maennich <maennich@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ lib/Kconfig.debug | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/lib/Kconfig.debug
++++ b/lib/Kconfig.debug
+@@ -328,7 +328,7 @@ config DEBUG_INFO_BTF
+ DWARF type info into equivalent deduplicated BTF type info.
+
+ config PAHOLE_HAS_SPLIT_BTF
+- def_bool $(success, test `$(PAHOLE) --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/'` -ge "119")
++ def_bool PAHOLE_VERSION >= 119
+
+ config DEBUG_INFO_BTF_MODULES
+ def_bool y
--- /dev/null
+From 2d6c9810eb8915c4ddede707b8e167a1d919e1ca Mon Sep 17 00:00:00 2001
+From: Nathan Chancellor <nathan@kernel.org>
+Date: Tue, 1 Feb 2022 13:56:22 -0700
+Subject: scripts/pahole-flags.sh: Use pahole-version.sh
+
+From: Nathan Chancellor <nathan@kernel.org>
+
+commit 2d6c9810eb8915c4ddede707b8e167a1d919e1ca upstream.
+
+Use pahole-version.sh to get pahole's version code to reduce the amount
+of duplication across the tree.
+
+Signed-off-by: Nathan Chancellor <nathan@kernel.org>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Acked-by: Andrii Nakryiko <andrii@kernel.org>
+Link: https://lore.kernel.org/bpf/20220201205624.652313-4-nathan@kernel.org
+Signed-off-by: Matthias Maennich <maennich@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/pahole-flags.sh | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/scripts/pahole-flags.sh
++++ b/scripts/pahole-flags.sh
+@@ -7,7 +7,7 @@ if ! [ -x "$(command -v ${PAHOLE})" ]; t
+ exit 0
+ fi
+
+-pahole_ver=$(${PAHOLE} --version | sed -E 's/v([0-9]+)\.([0-9]+)/\1\2/')
++pahole_ver=$($(dirname $0)/pahole-version.sh ${PAHOLE})
+
+ if [ "${pahole_ver}" -ge "118" ] && [ "${pahole_ver}" -le "121" ]; then
+ # pahole 1.18 through 1.21 can't handle zero-sized per-CPU vars
wifi-mwifiex-add-missing-compatible-string-for-sd8787.patch
audit-update-the-mailing-list-in-maintainers.patch
ext4-fix-function-prototype-mismatch-for-ext4_feat_ktype.patch
+kbuild-add-config_pahole_version.patch
+scripts-pahole-flags.sh-use-pahole-version.sh.patch
+lib-kconfig.debug-use-config_pahole_version.patch
+lib-kconfig.debug-allow-btf-dwarf5-with-pahole-1.21.patch