From patchwork Wed Dec 1 12:21:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Dumitrescu X-Patchwork-Id: 104791 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 412CFA0C41; Wed, 1 Dec 2021 13:21:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B64E04067B; Wed, 1 Dec 2021 13:21:35 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id B164D40140 for ; Wed, 1 Dec 2021 13:21:29 +0100 (CET) X-IronPort-AV: E=McAfee;i="6200,9189,10184"; a="236390686" X-IronPort-AV: E=Sophos;i="5.87,278,1631602800"; d="scan'208";a="236390686" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2021 04:21:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,278,1631602800"; d="scan'208";a="500230300" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by orsmga007.jf.intel.com with ESMTP; 01 Dec 2021 04:21:19 -0800 From: Cristian Dumitrescu To: dev@dpdk.org Cc: Harshad Narayane Subject: [PATCH] pipeline: add check against loops Date: Wed, 1 Dec 2021 12:21:19 +0000 Message-Id: <20211201122119.77423-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 Signed-off-by: Harshad Narayane --- 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];