[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240405142637.577046-1-arnd@kernel.org>
Date: Fri, 5 Apr 2024 16:26:25 +0200
From: Arnd Bergmann <arnd@...nel.org>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>
Cc: Arnd Bergmann <arnd@...db.de>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>,
Song Liu <song@...nel.org>,
KP Singh <kpsingh@...nel.org>,
Shung-Hsi Yu <shung-hsi.yu@...e.com>,
Kumar Kartikeya Dwivedi <memxor@...il.com>,
Dave Marchevsky <davemarchevsky@...com>,
bpf@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] bpf: fix perf_snapshot_branch_stack link failure
From: Arnd Bergmann <arnd@...db.de>
The newly added code to handle bpf_get_branch_snapshot fails to link when
CONFIG_PERF_EVENTS is disabled:
aarch64-linux-ld: kernel/bpf/verifier.o: in function `do_misc_fixups':
verifier.c:(.text+0x1090c): undefined reference to `__SCK__perf_snapshot_branch_stack'
Add a build-time check for that Kconfig symbol around the code to
remove the link time dependency.
Fixes: 314a53623cd4 ("bpf: inline bpf_get_branch_snapshot() helper")
Signed-off-by: Arnd Bergmann <arnd@...db.de>
---
kernel/bpf/verifier.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index aca00ba61232..b34cdeff415e 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -20192,7 +20192,8 @@ static int do_misc_fixups(struct bpf_verifier_env *env)
}
/* Implement bpf_get_branch_snapshot inline. */
- if (prog->jit_requested && BITS_PER_LONG == 64 &&
+ if (IS_ENABLED(CONFIG_PERF_EVENTS) &&
+ prog->jit_requested && BITS_PER_LONG == 64 &&
insn->imm == BPF_FUNC_get_branch_snapshot) {
/* We are dealing with the following func protos:
* u64 bpf_get_branch_snapshot(void *buf, u32 size, u64 flags);
--
2.39.2
Powered by blists - more mailing lists