qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 4/7] spapr: Split memory nodes to power-of-two block


From: Alexey Kardashevskiy
Subject: [Qemu-devel] [PATCH 4/7] spapr: Split memory nodes to power-of-two blocks
Date: Mon, 16 Jun 2014 17:53:50 +1000

Linux kernel expects nodes to have power-of-two size and
does WARN_ON if this is not the case:
[    0.041052] devtmpfs: initialized
[    0.041292] ------------[ cut here ]------------
[    0.041456] WARNING: at drivers/base/memory.c:115

This splits memory nodes into set of smaller blocks with
a size which is a power of two. This makes sure the start
address of every node is aligned to the node size.

Signed-off-by: Alexey Kardashevskiy <address@hidden>
---
 hw/ppc/spapr.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 666b676..10202e2 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -710,8 +710,18 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, 
void *fdt)
             mem_start += spapr->rma_size;
             node_size -= spapr->rma_size;
         }
-        spapr_populate_memory_node(fdt, i, mem_start, node_size);
-        mem_start += node_size;
+        for ( ; node_size; ) {
+            hwaddr sizetmp = pow2floor(node_size);
+
+            /* mem_start != 0 here */
+            if (ffs(mem_start) < ffs(sizetmp)) {
+                sizetmp = MIN(sizetmp, 1 << (ffs(mem_start) - 1));
+            }
+
+            spapr_populate_memory_node(fdt, i, mem_start, sizetmp);
+            node_size -= sizetmp;
+            mem_start += sizetmp;
+        }
     }
 
     return 0;
-- 
2.0.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]