DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marat Khalili <qm2k21@gmail.com>
To: Konstantin Ananyev <konstantin.ananyev@huawei.com>,
	Marat Khalili <qm2k21@gmail.com>
Cc: dev@dpdk.org, Marat Khalili <marat.khalili@huawei.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v4 4/7] bpf/validate: add jump notification events
Date: Thu, 17 Sep 2026 14:35:34 +0000	[thread overview]
Message-ID: <20260917143539.46951-5-qm2k21@gmail.com> (raw)
In-Reply-To: <20260917143539.46951-1-qm2k21@gmail.com>

From: Marat Khalili <marat.khalili@huawei.com>

Add events notifying validate debug client of instructions that may
change program counter. This is particularly useful to an interactive
debugger to track conditional and unconditional jumps without trying to
parse the program and interpret instructions independently.

Signed-off-by: Marat Khalili <marat.khalili@huawei.com>
---
 lib/bpf/bpf_validate.c           | 10 ++++++++--
 lib/bpf/bpf_validate_debug.c     |  2 ++
 lib/bpf/rte_bpf_validate_debug.h |  5 +++++
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/bpf/bpf_validate.c b/lib/bpf/bpf_validate.c
index f4258c2fb5..d503db8361 100644
--- a/lib/bpf/bpf_validate.c
+++ b/lib/bpf/bpf_validate.c
@@ -2899,13 +2899,19 @@ is_branch_start(const struct inst_node *node)
 }
 
 static uint64_t
-step_events(const struct inst_node *node)
+step_events(const struct inst_node *node, uint8_t op)
 {
 	uint64_t events = RTE_BIT64(RTE_BPF_VALIDATE_DEBUG_EVENT_STEP);
 
 	if (is_branch_start(node))
 		events |= RTE_BIT64(RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_ENTER);
 
+	if (op == (BPF_JMP | BPF_JA))
+		events |= RTE_BIT64(RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_ALWAYS);
+
+	if (node->nb_edge > 1)
+		events |= RTE_BIT64(RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_CONDITIONAL);
+
 	return events;
 }
 
@@ -3005,7 +3011,7 @@ evaluate(struct bpf_verifier *bvf)
 			}
 
 			rc = __rte_bpf_validate_debug_evaluate_update(debug, idx,
-				step_events(node));
+				step_events(node, op));
 			if (rc < 0)
 				break;
 
diff --git a/lib/bpf/bpf_validate_debug.c b/lib/bpf/bpf_validate_debug.c
index db6d13f9cb..098a88026d 100644
--- a/lib/bpf/bpf_validate_debug.c
+++ b/lib/bpf/bpf_validate_debug.c
@@ -600,6 +600,8 @@ __rte_bpf_validate_debug_evaluate_update(struct rte_bpf_validate_debug *debug,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_PRUNE,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_RETURN,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_UNREACHABLE,
+		RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_ALWAYS,
+		RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_CONDITIONAL,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_STEP,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_SUCCESS,
 		RTE_BPF_VALIDATE_DEBUG_EVENT_VALIDATION_FAILURE,
diff --git a/lib/bpf/rte_bpf_validate_debug.h b/lib/bpf/rte_bpf_validate_debug.h
index b3fedd5428..f1ee8769d0 100644
--- a/lib/bpf/rte_bpf_validate_debug.h
+++ b/lib/bpf/rte_bpf_validate_debug.h
@@ -35,6 +35,7 @@ extern "C" {
  * At any given evaluation step, callbacks are fired in the following order:
  * - Validation start event;
  * - Branching and invalid-state events (can be interleaved);
+ * - Jump-instruction events (before evaluating jump instruction);
  * - Instruction breakpoints (before evaluating instruction);
  * - Step (before evaluating instruction) or validation result (if done) event;
  */
@@ -57,6 +58,10 @@ enum rte_bpf_validate_debug_event {
 	RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_RETURN,
 	/* Pruning branch as dynamically unreachable (pc points to branch start). */
 	RTE_BPF_VALIDATE_DEBUG_EVENT_BRANCH_UNREACHABLE,
+	/* Program counter points to a jump-always instruction. */
+	RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_ALWAYS,
+	/* Program counter points to a conditional jump instruction. */
+	RTE_BPF_VALIDATE_DEBUG_EVENT_JUMP_CONDITIONAL,
 	/* Number of valid event values. */
 	RTE_BPF_VALIDATE_DEBUG_EVENT_END,
 };
-- 
2.43.0


  parent reply	other threads:[~2026-09-17 14:37 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 10:39 [PATCH 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-11 10:39 ` [PATCH 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-11 10:40 ` [PATCH 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-11 10:40 ` [PATCH 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-11 10:40 ` [PATCH 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-11 10:40 ` [PATCH 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-11 10:40 ` [PATCH 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-11 10:40 ` [PATCH 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-14 14:54 ` [PATCH v2 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-14 14:54   ` [PATCH v2 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-14 14:54   ` [PATCH v2 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-14 14:54   ` [PATCH v2 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-14 14:54   ` [PATCH v2 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-14 14:54   ` [PATCH v2 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-14 14:54   ` [PATCH v2 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-14 14:54   ` [PATCH v2 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-14 18:41     ` Stephen Hemminger
2026-09-15 13:13     ` Stephen Hemminger
2026-09-14 18:42   ` [PATCH v2 0/7] validate-bpf: add standalone validation debug tool Stephen Hemminger
2026-09-15 19:27     ` Marat Khalili
2026-09-15 19:26   ` [PATCH v3 " Marat Khalili
2026-09-15 19:26     ` [PATCH v3 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-15 19:26     ` [PATCH v3 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-15 19:26     ` [PATCH v3 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-15 19:26     ` [PATCH v3 4/7] bpf/validate: add jump notification events Marat Khalili
2026-09-15 19:26     ` [PATCH v3 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-15 19:26     ` [PATCH v3 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-15 19:26     ` [PATCH v3 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-16 16:36       ` Konstantin Ananyev
2026-09-17 14:35     ` [PATCH v4 0/7] validate-bpf: add standalone validation debug tool Marat Khalili
2026-09-17 14:35       ` [PATCH v4 1/7] bpf/validate: fix finished status on restart Marat Khalili
2026-09-17 14:35       ` [PATCH v4 2/7] bpf/validate: refactor internal step function Marat Khalili
2026-09-17 14:35       ` [PATCH v4 3/7] bpf/validate: formalize call back requirements Marat Khalili
2026-09-17 14:35       ` Marat Khalili [this message]
2026-09-17 14:35       ` [PATCH v4 5/7] bpf/validate: add get current event API Marat Khalili
2026-09-17 14:35       ` [PATCH v4 6/7] app/test: add test for bpf validate debug events Marat Khalili
2026-09-17 14:35       ` [PATCH v4 7/7] app/validate-bpf: add BPF validation application Marat Khalili
2026-09-17 16:16       ` [PATCH v4 0/7] validate-bpf: add standalone validation debug tool Konstantin Ananyev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260917143539.46951-5-qm2k21@gmail.com \
    --to=qm2k21@gmail.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@huawei.com \
    --cc=marat.khalili@huawei.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox