DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Cc: Harshad Narayane <harshad.suresh.narayane@intel.com>
Subject: [PATCH] pipeline: add check against loops
Date: Wed,  1 Dec 2021 12:21:19 +0000	[thread overview]
Message-ID: <20211201122119.77423-1-cristian.dumitrescu@intel.com> (raw)

Detect when a jump instruction, either conditional or unconditional,
is jumping to itself, thus creating a loop, which is not allowed in
data plane code.

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Signed-off-by: Harshad Narayane <harshad.suresh.narayane@intel.com>
---
 lib/pipeline/rte_swx_pipeline.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/pipeline/rte_swx_pipeline.c b/lib/pipeline/rte_swx_pipeline.c
index c332d44bd1..1a50c4bb72 100644
--- a/lib/pipeline/rte_swx_pipeline.c
+++ b/lib/pipeline/rte_swx_pipeline.c
@@ -6000,6 +6000,19 @@ instr_label_check(struct instruction_data *instruction_data,
 			CHECK(strcmp(label, instruction_data[j].label), EINVAL);
 	}
 
+	/* Check that no jump instruction (either conditional or not) can jump to itself (loop). */
+	for (i = 0; i < n_instructions; i++) {
+		struct instruction_data *data = &instruction_data[i];
+		char *label = data->label;
+		char *jmp_label = data->jmp_label;
+
+		/* Continue if this instruction does not have a label or it is not a jump. */
+		if (!label[0] || !jmp_label[0])
+			continue;
+
+		CHECK(strcmp(label, jmp_label), EINVAL);
+	}
+
 	/* Get users for each instruction label. */
 	for (i = 0; i < n_instructions; i++) {
 		struct instruction_data *data = &instruction_data[i];
-- 
2.17.1


             reply	other threads:[~2021-12-01 12:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 12:21 Cristian Dumitrescu [this message]
2022-02-13 19:49 ` Thomas Monjalon
2022-02-14 10:41   ` Dumitrescu, Cristian

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=20211201122119.77423-1-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    --cc=harshad.suresh.narayane@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).