* [PATCH bpf-next v1] bpf: correct use/def for may_goto instruction
@ 2025-03-05 8:54 Eduard Zingerman
2025-03-05 17:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Eduard Zingerman @ 2025-03-05 8:54 UTC (permalink / raw)
To: bpf, ast
Cc: andrii, daniel, martin.lau, kernel-team, yonghong.song,
Eduard Zingerman
may_goto instruction does not use any registers,
but in compute_insn_live_regs() it was treated as a regular
conditional jump of kind BPF_K with r0 as source register.
Thus unnecessarily marking r0 as used.
Fixes: 7dad03653567 ("bpf: simple DFA-based live registers analysis")
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
---
kernel/bpf/verifier.c | 1 +
tools/testing/selftests/bpf/progs/compute_live_registers.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 4edb2db0f889..3303a3605ee8 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -23567,6 +23567,7 @@ static void compute_insn_live_regs(struct bpf_verifier_env *env,
case BPF_JMP32:
switch (code) {
case BPF_JA:
+ case BPF_JCOND:
def = 0;
use = 0;
break;
diff --git a/tools/testing/selftests/bpf/progs/compute_live_registers.c b/tools/testing/selftests/bpf/progs/compute_live_registers.c
index 14df92949e81..f3d79aecbf93 100644
--- a/tools/testing/selftests/bpf/progs/compute_live_registers.c
+++ b/tools/testing/selftests/bpf/progs/compute_live_registers.c
@@ -294,9 +294,9 @@ __naked void gotol(void)
SEC("socket")
__log_level(2)
-__msg("0: 0......... (b7) r1 = 1")
-__msg("1: 01........ (e5) may_goto pc+1")
-__msg("2: 0......... (05) goto pc-3")
+__msg("0: .......... (b7) r1 = 1")
+__msg("1: .1........ (e5) may_goto pc+1")
+__msg("2: .......... (05) goto pc-3")
__msg("3: .1........ (bf) r0 = r1")
__msg("4: 0......... (95) exit")
__naked void may_goto(void)
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next v1] bpf: correct use/def for may_goto instruction
2025-03-05 8:54 [PATCH bpf-next v1] bpf: correct use/def for may_goto instruction Eduard Zingerman
@ 2025-03-05 17:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-05 17:00 UTC (permalink / raw)
To: Eduard Zingerman
Cc: bpf, ast, andrii, daniel, martin.lau, kernel-team, yonghong.song
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Wed, 5 Mar 2025 00:54:36 -0800 you wrote:
> may_goto instruction does not use any registers,
> but in compute_insn_live_regs() it was treated as a regular
> conditional jump of kind BPF_K with r0 as source register.
> Thus unnecessarily marking r0 as used.
>
> Fixes: 7dad03653567 ("bpf: simple DFA-based live registers analysis")
> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
>
> [...]
Here is the summary with links:
- [bpf-next,v1] bpf: correct use/def for may_goto instruction
https://git.kernel.org/bpf/bpf-next/c/aae1add9053e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-05 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-05 8:54 [PATCH bpf-next v1] bpf: correct use/def for may_goto instruction Eduard Zingerman
2025-03-05 17:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox