[dpdk-stable] patch 'bus/pci: align next mapping address on page boundary' has been queued to LTS release 17.11.10

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Dec 19 15:34:25 CET 2019


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)" <seven.wangyu at huawei.com>
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 <dengxiaofeng at huawei.com>
Signed-off-by: Wangyu (Eric) <seven.wangyu at huawei.com>
Acked-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
Acked-by: Min Hu (Connor) <humin29 at huawei.com>
Acked-by: Anatoly Burakov <anatoly.burakov at intel.com>
Acked-by: Gavin Hu <gavin.hu at arm.com>
---
 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)" <seven.wangyu at huawei.com>
 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 at dpdk.org
 
 Signed-off-by: Xiaofeng Deng <dengxiaofeng at huawei.com>
 Signed-off-by: Wangyu (Eric) <seven.wangyu at huawei.com>
@@ -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
 


More information about the stable mailing list