Skip to contentSkip to conversation

spapr: make sure RMA is in first mode of first memory node

PATCH Superseded Alexey Kardashevskiy 3 participants 4 messages Nov 6, 2013

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 spapr: make sure RMA is in first mode of first memory node

The SPAPR specification says that the RMA starts at the LPAR's logical address 0 and is the first logical memory block reported in the LPAR’s device tree.

So SLOF only maps the first block and that block needs to span the full RMA.

This makes sure that the RMA area is where SLOF expects it.

Cc Benjamin Herrenschmidt <[email protected]>

---

I came up with v1 of the patch but the actual code came from Alexander Graf. Who should I put as author of this?

---
 hw/ppc/spapr.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +8 -1
index 57b38cf..57473df 100644
@@ -1114,6 +1114,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     hwaddr rma_alloc_size;
+    hwaddr node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
     uint32_t initrd_base = 0;
     long kernel_size = 0, initrd_size = 0;
     long load_limit, rtas_limit, fw_size;
@@ -1138,7 +1139,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
     if (rma_alloc_size && (rma_alloc_size < ram_size)) {
         spapr->rma_size = rma_alloc_size;
     } else {
-        spapr->rma_size = ram_size;
+        spapr->rma_size = node0_size;
 
         /* With KVM, we don't actually know whether KVM supports an
          * unbounded RMA (PR KVM) or is limited by the hash table size
@@ -1155,6 +1156,12 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
         }
     }
 
+    if (spapr->rma_size > node0_size) {
+        fprintf(stderr, "Error: Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")\n",
+                spapr->rma_size);
+        exit(1);
+    }
+
     /* We place the device tree and RTAS just below either the top of the RMA,
      * or just below 2GB, whichever is lowere, so that it can be
      * processed with 32-bit real mode code if necessary */
Signature · 1 line
1.8.4.rc4
#1 lore raw
Quoted 42 lines · On Wed, 6 Nov 2013 18:54:11 +1100 Alexey Kardashevskiy <[email protected]> wrote:

The SPAPR specification says that the RMA starts at the LPAR's logical address 0 and is the first logical memory block reported in the LPAR’s device tree.

So SLOF only maps the first block and that block needs to span the full RMA.

This makes sure that the RMA area is where SLOF expects it.

Cc Benjamin Herrenschmidt <[email protected]>

---

I came up with v1 of the patch but the actual code came from Alexander Graf. Who should I put as author of this?

---
 hw/ppc/spapr.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +2 -1
index 57b38cf..57473df 100644
@@ -1114,6 +1114,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     hwaddr rma_alloc_size;
+    hwaddr node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
     uint32_t initrd_base = 0;
     long kernel_size = 0, initrd_size = 0;
     long load_limit, rtas_limit, fw_size;
@@ -1138,7 +1139,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
     if (rma_alloc_size && (rma_alloc_size < ram_size)) {
         spapr->rma_size = rma_alloc_size;
     } else {
-        spapr->rma_size = ram_size;
+        spapr->rma_size = node0_size;
 
         /* With KVM, we don't actually know whether KVM supports an
          * unbounded RMA (PR KVM) or is limited by the hash table size

hw/ppc/spapr.c static void ppc_spapr_init(QEMUMachineInitArgs *args) · line 1164

Quoted 9 lines
hw/ppc/spapr.c +6 -0
@@ -1155,6 +1156,12 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
         }
     }
 
+    if (spapr->rma_size > node0_size) {
+        fprintf(stderr, "Error: Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")\n",
+                spapr->rma_size);
+        exit(1);
+    }
+

What about the "if (spapr->rma_size > node0_size)" at the beginning of spapr_populate_memory()? Could/should that go away now?

Thomas

#2 lore raw
Quoted 48 lines · Thomas Huth
Quoted 45 lines · On Wed, 6 Nov 2013 18:54:11 +1100 Alexey Kardashevskiy <[email protected]> wrote:

The SPAPR specification says that the RMA starts at the LPAR's logical address 0 and is the first logical memory block reported in the LPAR’s device tree.

So SLOF only maps the first block and that block needs to span the full RMA.

This makes sure that the RMA area is where SLOF expects it.

Cc Benjamin Herrenschmidt <[email protected]>

---

I came up with v1 of the patch but the actual code came from Alexander Graf. Who should I put as author of this?

---
hw/ppc/spapr.c | 9 ++++++++-

1 file changed, 8 insertions(+), 1 deletion(-)
hw/ppc/spapr.c +2 -1
index 57b38cf..57473df 100644
@@ -1114,6 +1114,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
    MemoryRegion *sysmem = get_system_memory();
    MemoryRegion *ram = g_new(MemoryRegion, 1);
    hwaddr rma_alloc_size;
+    hwaddr node0_size = (nb_numa_nodes > 1) ? node_mem[0] : ram_size;
    uint32_t initrd_base = 0;
    long kernel_size = 0, initrd_size = 0;
    long load_limit, rtas_limit, fw_size;
@@ -1138,7 +1139,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
    if (rma_alloc_size && (rma_alloc_size < ram_size)) {
        spapr->rma_size = rma_alloc_size;
    } else {
-        spapr->rma_size = ram_size;
+        spapr->rma_size = node0_size;
 
        /* With KVM, we don't actually know whether KVM supports an
         * unbounded RMA (PR KVM) or is limited by the hash table size
@@ -1155,6 +1156,12 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
        }
    }
 
Quoted 9 lines

hw/ppc/spapr.c static void ppc_spapr_init(QEMUMachineInitArgs *args) · line 1164

Quoted 6 lines
hw/ppc/spapr.c +6 -0
+    if (spapr->rma_size > node0_size) {
+        fprintf(stderr, "Error: Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")\n",
+                spapr->rma_size);
+        exit(1);
+    }
+

What about the "if (spapr->rma_size > node0_size)" at the beginning of spapr_populate_memory()? Could/should that go away now?

It should, yes. It was very wrong in that spot from the first place, as that helper really should only create the fdt entries, not modify global state.

Alex

#3 lore raw
In reply to Alexey Kardashevskiy
Quoted 7 lines · Alexey Kardashevskiy

The SPAPR specification says that the RMA starts at the LPAR's logical address 0 and is the first logical memory block reported in the LPAR’s device tree.

So SLOF only maps the first block and that block needs to span the full RMA.

Quoted 8 lines

This makes sure that the RMA area is where SLOF expects it.

Cc Benjamin Herrenschmidt <[email protected]>

---

I came up with v1 of the patch but the actual code came from Alexander Graf. Who should I put as author of this?

Just declare it as your own ;).

Alex