Blame SOURCES/0038-vfio-spapr-Fix-levels-calculation.patch

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