2024-04-05 14:26:59

by Arnd Bergmann

[permalink] [raw]
Subject: [PATCH] bpf: fix perf_snapshot_branch_stack link failure

From: Arnd Bergmann <[email protected]>

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 <[email protected]>
---
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



2024-04-05 15:50:51

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] bpf: fix perf_snapshot_branch_stack link failure

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <[email protected]>:

On Fri, 5 Apr 2024 16:26:25 +0200 you wrote:
> From: Arnd Bergmann <[email protected]>
>
> 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'
>
> [...]

Here is the summary with links:
- bpf: fix perf_snapshot_branch_stack link failure
https://git.kernel.org/bpf/bpf-next/c/58babe27180c

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html