From patchwork Mon Sep 27 13:25:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nipun Gupta X-Patchwork-Id: 99796 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 D5DA4A0548; Mon, 27 Sep 2021 15:26:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F233341152; Mon, 27 Sep 2021 15:25:37 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id A7E43410F2; Mon, 27 Sep 2021 15:25:25 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 7E1852013DC; Mon, 27 Sep 2021 15:25:25 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 43065201116; Mon, 27 Sep 2021 15:25:25 +0200 (CEST) Received: from lsv03274.swis.in-blr01.nxp.com (lsv03274.swis.in-blr01.nxp.com [92.120.147.114]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 898D9183AD15; Mon, 27 Sep 2021 21:25:24 +0800 (+08) From: nipun.gupta@nxp.com To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, hemant.agrawal@nxp.com, sachin.saxena@nxp.com, stable@dpdk.org, Gagandeep Singh , Nipun Gupta Date: Mon, 27 Sep 2021 18:55:19 +0530 Message-Id: <20210927132519.19264-12-nipun.gupta@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210927132519.19264-1-nipun.gupta@nxp.com> References: <20210927122650.30881-1-nipun.gupta@nxp.com> <20210927132519.19264-1-nipun.gupta@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v1 11/11] common/dpaax: fix paddr to vaddr invalid conversion 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 Sender: "dev" From: Gagandeep Singh If some of the VA entries of table are somehow not populated and are NULL, it can add offset to NULL and return the invalid VA in PA to VA conversion. In this patch, adding a check if the VA entry has valid address only then add offset and return VA. Fixes: 2f3d633aa593 ("common/dpaax: add library for PA/VA translation table") Cc: stable@dpdk.org Signed-off-by: Gagandeep Singh Signed-off-by: Nipun Gupta --- drivers/common/dpaax/dpaax_iova_table.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/common/dpaax/dpaax_iova_table.h b/drivers/common/dpaax/dpaax_iova_table.h index 230fba8ba0..d7087ee7ca 100644 --- a/drivers/common/dpaax/dpaax_iova_table.h +++ b/drivers/common/dpaax/dpaax_iova_table.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018 NXP + * Copyright 2018-2021 NXP */ #ifndef _DPAAX_IOVA_TABLE_H_ @@ -101,6 +101,12 @@ dpaax_iova_table_get_va(phys_addr_t paddr) { /* paddr > entry->start && paddr <= entry->(start+len) */ index = (paddr_align - entry[i].start)/DPAAX_MEM_SPLIT; + /* paddr is within range, but no vaddr entry ever written + * at index + */ + if ((void *)entry[i].pages[index] == NULL) + return NULL; + vaddr = (void *)((uintptr_t)entry[i].pages[index] + offset); break; } while (1);