From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8D6C4A04F0 for ; Thu, 19 Dec 2019 15:41:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 83BEE1BF74; Thu, 19 Dec 2019 15:41:45 +0100 (CET) Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by dpdk.org (Postfix) with ESMTP id 046761BF75 for ; Thu, 19 Dec 2019 15:41:44 +0100 (CET) Received: by mail-wm1-f66.google.com with SMTP id q9so5692557wmj.5 for ; Thu, 19 Dec 2019 06:41:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pnVDBPURulmRGALzg1Q2eQBTpG9A1oa/seOCdjmomgE=; b=aHN4cuhhwGIQA73K16Q20W9wyFiPnASpU2p94gh3U4X6IERPjTmkMnvx7bA7at1yGK g1zcVE44JBU5z0HiP9pc0TYaj39yaq4y+WN0Jox82Xl2NoDz4Bc782C3mIpb8Smqvw5M Bt62VX/AJuUPOzlBs+hpf52vJOJt+dZoDWyBJKw9dhTsM4d2meFABuIy11QtT7awjhGK ssjdG/j+zYOriPom8WNYCMt7c/BAXedj+ZLAtcdTshG7V4ELW/cEO7RzYca/nHmi+qii ZbgpdSqDyrjPDZ/dc43TJc0Nbb16oyibbh2qjCiTm7HPlcOTKELOsU6YoDBlYTsaBHUJ mf4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pnVDBPURulmRGALzg1Q2eQBTpG9A1oa/seOCdjmomgE=; b=kge5kjVxWD3+xv1THqv0wOXLBflQi0vT/gMdrqXI4lZ6wFCsUBluKJOcrvWYmyLVAy 4YubaIUWQrGOPMtAyT/8kxvhxZoRPwI2hYEvVReKFTpwu0j5sNIBXRCbdcDB4SbYCSfK nu9Qfsm6UTUZXrvZzfEVUOHyLtLjV+/OQpb+sixkRGugeJNxQzW7MmMt3fs+MGnD8GHC dysysYEpk68O5o5ptoEuGTN9MhSc9tAsgyc/Xs2znPWVj5NmBCDRU6Ab/NYDN1G/rTb2 u98Nba3g9gS88dc+QyNqptVpmPV0C6LvMfgOPCblBbXZ42L/DGEHJfPv9ND2Wdn56iUy VNGQ== X-Gm-Message-State: APjAAAVrg1e+UGLwZqCGJrqTay9c0bilKbT7jIIu3WsmAuNYnEqzLTkm yA1hL0iU1VvPsiMtcwGCNqY= X-Google-Smtp-Source: APXvYqw4n76zUBEWvZ4PMENR1LgHw7szSkUIOrlKwI5bSNgxVheqL9vW35GdsuNcnajW/LVGU/gerg== X-Received: by 2002:a1c:c910:: with SMTP id f16mr1207034wmb.1.1576766503687; Thu, 19 Dec 2019 06:41:43 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id m7sm6582374wrr.40.2019.12.19.06.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Dec 2019 06:41:43 -0800 (PST) From: luca.boccassi@gmail.com To: "Wangyu (Eric)" Cc: Xiaofeng Deng , Wei Hu , Min Hu , Anatoly Burakov , Gavin Hu , dpdk stable Date: Thu, 19 Dec 2019 14:34:25 +0000 Message-Id: <20191219143447.21506-118-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191219143447.21506-1-luca.boccassi@gmail.com> References: <20191219143447.21506-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'bus/pci: align next mapping address on page boundary' has been queued to LTS release 17.11.10 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 17.11.10 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 12/21/19. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Thanks. Luca Boccassi --- >From 950af583f277b5563e3d101ae982732090a7ad2b Mon Sep 17 00:00:00 2001 From: "Wangyu (Eric)" Date: Wed, 13 Nov 2019 07:17:30 +0000 Subject: [PATCH] bus/pci: align next mapping address on page boundary [ upstream commit d25ab4b7f128610cb5310b424c1f608686173f13 ] Currently, the next address picked by PCI mapping infrastructure may be page-unaligned due to BAR length being smaller than page size. This leads to a situation where the requested map address is invalid, resulting in mmap() call returning an arbitrary address, which will later interfere with device BAR mapping in secondary processes. Fix it by always aligning the next requested address on page boundary. Fixes: c752998b5e2e ("pci: introduce library and driver") Signed-off-by: Xiaofeng Deng Signed-off-by: Wangyu (Eric) Acked-by: Wei Hu (Xavier) Acked-by: Min Hu (Connor) Acked-by: Anatoly Burakov Acked-by: Gavin Hu --- drivers/bus/pci/linux/pci_uio.c | 2 ++ drivers/bus/pci/linux/pci_vfio.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 39176ac73a..2b2ad77ec7 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -358,6 +358,8 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, pci_map_addr = RTE_PTR_ADD(mapaddr, (size_t)dev->mem_resource[res_idx].len); + pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, sysconf(_SC_PAGE_SIZE)); + maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr; maps[map_idx].size = dev->mem_resource[res_idx].len; maps[map_idx].addr = mapaddr; diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c index 98f2ec9b8e..8b485deace 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c @@ -532,6 +532,9 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) bar_addr = pci_map_addr; pci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg.size); + pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, + sysconf(_SC_PAGE_SIZE)); + maps[i].addr = bar_addr; maps[i].offset = reg.offset; maps[i].size = reg.size; -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-12-19 14:32:31.017070037 +0000 +++ 0118-bus-pci-align-next-mapping-address-on-page-boundary.patch 2019-12-19 14:32:26.297301633 +0000 @@ -1,8 +1,10 @@ -From d25ab4b7f128610cb5310b424c1f608686173f13 Mon Sep 17 00:00:00 2001 +From 950af583f277b5563e3d101ae982732090a7ad2b Mon Sep 17 00:00:00 2001 From: "Wangyu (Eric)" Date: Wed, 13 Nov 2019 07:17:30 +0000 Subject: [PATCH] bus/pci: align next mapping address on page boundary +[ upstream commit d25ab4b7f128610cb5310b424c1f608686173f13 ] + Currently, the next address picked by PCI mapping infrastructure may be page-unaligned due to BAR length being smaller than page size. This leads to a situation where the requested map address is invalid, @@ -12,7 +14,6 @@ Fix it by always aligning the next requested address on page boundary. Fixes: c752998b5e2e ("pci: introduce library and driver") -Cc: stable@dpdk.org Signed-off-by: Xiaofeng Deng Signed-off-by: Wangyu (Eric) @@ -26,10 +27,10 @@ 2 files changed, 5 insertions(+) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c -index 6dca05a986..097dc19225 100644 +index 39176ac73a..2b2ad77ec7 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c -@@ -351,6 +351,8 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, +@@ -358,6 +358,8 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, pci_map_addr = RTE_PTR_ADD(mapaddr, (size_t)dev->mem_resource[res_idx].len); @@ -39,19 +40,19 @@ maps[map_idx].size = dev->mem_resource[res_idx].len; maps[map_idx].addr = mapaddr; diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c -index b8faa23f82..64cd84a689 100644 +index 98f2ec9b8e..8b485deace 100644 --- a/drivers/bus/pci/linux/pci_vfio.c +++ b/drivers/bus/pci/linux/pci_vfio.c -@@ -750,6 +750,9 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) +@@ -532,6 +532,9 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev) bar_addr = pci_map_addr; - pci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg->size); + pci_map_addr = RTE_PTR_ADD(bar_addr, (size_t) reg.size); + pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, + sysconf(_SC_PAGE_SIZE)); + maps[i].addr = bar_addr; - maps[i].offset = reg->offset; - maps[i].size = reg->size; + maps[i].offset = reg.offset; + maps[i].size = reg.size; -- 2.20.1