BPF List
 help / color / mirror / Atom feed
* [PATCH] bpf-next: Avoid goto in regs_refine_cond_op()
@ 2024-03-21  0:29 Harishankar Vishwanathan
  2024-03-21 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Harishankar Vishwanathan @ 2024-03-21  0:29 UTC (permalink / raw)
  To: alexei.starovoitov
  Cc: harishankar.vishwanathan, andrii, sn624, sn349, m.shachnai, paul,
	daniel, Harishankar Vishwanathan, Alexei Starovoitov,
	John Fastabend, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	bpf, linux-kernel

In case of GE/GT/SGE/JST instructions, regs_refine_cond_op()
reuses the logic that does analysis of LE/LT/SLE/SLT instructions.
This commit avoids the use of a goto to perform the reuse.

Signed-off-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
---
 kernel/bpf/verifier.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index de7813947981..ca6cacf7b42f 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -14544,7 +14544,19 @@ static void regs_refine_cond_op(struct bpf_reg_state *reg1, struct bpf_reg_state
 	struct tnum t;
 	u64 val;
 
-again:
+	/* In case of GE/GT/SGE/JST, reuse LE/LT/SLE/SLT logic from below */
+	switch (opcode) {
+	case BPF_JGE:
+	case BPF_JGT:
+	case BPF_JSGE:
+	case BPF_JSGT:
+		opcode = flip_opcode(opcode);
+		swap(reg1, reg2);
+		break;
+	default:
+		break;
+	}
+
 	switch (opcode) {
 	case BPF_JEQ:
 		if (is_jmp32) {
@@ -14687,14 +14699,6 @@ static void regs_refine_cond_op(struct bpf_reg_state *reg1, struct bpf_reg_state
 			reg2->smin_value = max(reg1->smin_value + 1, reg2->smin_value);
 		}
 		break;
-	case BPF_JGE:
-	case BPF_JGT:
-	case BPF_JSGE:
-	case BPF_JSGT:
-		/* just reuse LE/LT logic above */
-		opcode = flip_opcode(opcode);
-		swap(reg1, reg2);
-		goto again;
 	default:
 		return;
 	}
-- 
2.40.1


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

* Re: [PATCH] bpf-next: Avoid goto in regs_refine_cond_op()
  2024-03-21  0:29 [PATCH] bpf-next: Avoid goto in regs_refine_cond_op() Harishankar Vishwanathan
@ 2024-03-21 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-21 19:00 UTC (permalink / raw)
  To: Harishankar Vishwanathan
  Cc: alexei.starovoitov, harishankar.vishwanathan, andrii, sn624,
	sn349, m.shachnai, paul, daniel, ast, john.fastabend, martin.lau,
	eddyz87, song, yonghong.song, kpsingh, sdf, haoluo, jolsa, bpf,
	linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Wed, 20 Mar 2024 20:29:54 -0400 you wrote:
> In case of GE/GT/SGE/JST instructions, regs_refine_cond_op()
> reuses the logic that does analysis of LE/LT/SLE/SLT instructions.
> This commit avoids the use of a goto to perform the reuse.
> 
> Signed-off-by: Harishankar Vishwanathan <harishankar.vishwanathan@gmail.com>
> ---
>  kernel/bpf/verifier.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)

Here is the summary with links:
  - bpf-next: Avoid goto in regs_refine_cond_op()
    https://git.kernel.org/bpf/bpf-next/c/4c2a26fc80bc

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:[~2024-03-21 19:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21  0:29 [PATCH] bpf-next: Avoid goto in regs_refine_cond_op() Harishankar Vishwanathan
2024-03-21 19: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