|
|
9bac43 |
From 6ef9f439f68181319e04b5fd6bfb1a2e36d4bbee Mon Sep 17 00:00:00 2001
|
|
|
9bac43 |
From: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Date: Mon, 18 Sep 2017 00:20:08 +0100
|
|
|
9bac43 |
Subject: vfio, spapr: Fix levels calculation
|
|
|
9bac43 |
|
|
|
9bac43 |
RH-Author: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Message-id: <20170918002008.24430-1-dgibson@redhat.com>
|
|
|
9bac43 |
Patchwork-id: 76404
|
|
|
9bac43 |
O-Subject: [Pegas-1.0 qemu-kvm PATCH] vfio, spapr: Fix levels calculation
|
|
|
9bac43 |
Bugzilla: 1491749
|
|
|
9bac43 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Suraj Jitindar Singh <sursingh@redhat.com>
|
|
|
9bac43 |
RH-Acked-by: Sam Bobroff <sbobroff@redhat.com>
|
|
|
9bac43 |
|
|
|
9bac43 |
From: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
9bac43 |
|
|
|
9bac43 |
The existing tries to round up the number of pages but @pages is always
|
|
|
9bac43 |
calculated as the rounded up value minus one which makes ctz64() always
|
|
|
9bac43 |
return 0 and have create.levels always set 1.
|
|
|
9bac43 |
|
|
|
9bac43 |
This removes wrong "-1" and allows having more than 1 levels. This becomes
|
|
|
9bac43 |
handy for >128GB guests with standard 64K pages as this requires blocks
|
|
|
9bac43 |
with zone order 9 and the popular limit of CONFIG_FORCE_MAX_ZONEORDER=9
|
|
|
9bac43 |
means that only blocks up to order 8 are allowed.
|
|
|
9bac43 |
|
|
|
9bac43 |
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
|
|
|
9bac43 |
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
|
|
|
9bac43 |
(cherry picked from commit e100161b69f8cf56dae866912dfffe7dcd7140af)
|
|
|
9bac43 |
Signed-off-by: David Gibson <dgibson@redhat.com>
|
|
|
9bac43 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
9bac43 |
(cherry picked from commit b83a6ae1492fa004c6e0e34cfb3ac8efe21e7bd2)
|
|
|
9bac43 |
---
|
|
|
9bac43 |
hw/vfio/spapr.c | 2 +-
|
|
|
9bac43 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
9bac43 |
|
|
|
9bac43 |
diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c
|
|
|
9bac43 |
index 32fd6a9..259397c 100644
|
|
|
9bac43 |
--- a/hw/vfio/spapr.c
|
|
|
9bac43 |
+++ b/hw/vfio/spapr.c
|
|
|
9bac43 |
@@ -163,7 +163,7 @@ int vfio_spapr_create_window(VFIOContainer *container,
|
|
|
9bac43 |
*/
|
|
|
9bac43 |
entries = create.window_size >> create.page_shift;
|
|
|
9bac43 |
pages = MAX((entries * sizeof(uint64_t)) / getpagesize(), 1);
|
|
|
9bac43 |
- pages = MAX(pow2ceil(pages) - 1, 1); /* Round up */
|
|
|
9bac43 |
+ pages = MAX(pow2ceil(pages), 1); /* Round up */
|
|
|
9bac43 |
create.levels = ctz64(pages) / 6 + 1;
|
|
|
9bac43 |
|
|
|
9bac43 |
ret = ioctl(container->fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
|
|
|
9bac43 |
--
|
|
|
9bac43 |
1.8.3.1
|
|
|
9bac43 |
|