Blame SOURCES/kvm-pseries-do-not-allow-memory-less-cpu-less-NUMA-node.patch

016a62
From 7ab2261eebf90ea8a3cf5701fa177d181fe665d1 Mon Sep 17 00:00:00 2001
016a62
From: Laurent Vivier <lvivier@redhat.com>
016a62
Date: Thu, 10 Oct 2019 07:34:38 +0100
016a62
Subject: [PATCH 22/22] pseries: do not allow memory-less/cpu-less NUMA node
016a62
MIME-Version: 1.0
016a62
Content-Type: text/plain; charset=UTF-8
016a62
Content-Transfer-Encoding: 8bit
016a62
016a62
RH-Author: Laurent Vivier <lvivier@redhat.com>
016a62
Message-id: <20191010073438.16478-1-lvivier@redhat.com>
016a62
Patchwork-id: 91379
016a62
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH] pseries: do not allow memory-less/cpu-less NUMA node
016a62
Bugzilla: 1651474
016a62
RH-Acked-by: David Gibson <dgibson@redhat.com>
016a62
RH-Acked-by: Thomas Huth <thuth@redhat.com>
016a62
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
016a62
016a62
When we hotplug a CPU on memory-less/cpu-less node, the linux kernel
016a62
crashes.
016a62
016a62
This happens because linux kernel needs to know the NUMA topology at
016a62
start to be able to initialize the distance lookup table.
016a62
016a62
On pseries, the topology is provided by the firmware via the existing
016a62
CPUs and memory information. Thus a node without memory and CPU cannot be
016a62
discovered by the kernel.
016a62
016a62
To avoid the kernel crash, do not allow to start pseries with empty
016a62
nodes.
016a62
016a62
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
016a62
Message-Id: <20190830161345.22436-1-lvivier@redhat.com>
016a62
[dwg: Rework to cope with movement of numa state from globals to MachineState]
016a62
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
016a62
(cherry picked from commit 58c46efa451caa3935224223f950216872e2eee3)
016a62
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
016a62
016a62
Conflicts in the context:
016a62
	hw/ppc/spapr.c
016a62
because of missing downstream commits:
016a62
  0550b1206a91 ("spapr: don't advertise radix GTSE if max-compat-cpu < power9")
016a62
  ad99d04c76de ("target/ppc: Allow cpu compatiblity checks based on type, not instance")
016a62
016a62
because of missing donwtream commit:
016a62
016a62
  7e721e7b10e1 ("numa: move numa global variable numa_info into MachineState")
016a62
016a62
replaced numa_state by numa_info (revert dwg rework), back to original
016a62
patch I sent:
016a62
016a62
  https://patchew.org/QEMU/20190830161345.22436-1-lvivier@redhat.com/
016a62
016a62
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1651474
016a62
BRANCH: rhel-8.2.0
016a62
UPSTREAM: merged
016a62
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23924908
016a62
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
016a62
---
016a62
 hw/ppc/spapr.c | 33 +++++++++++++++++++++++++++++++++
016a62
 1 file changed, 33 insertions(+)
016a62
016a62
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
016a62
index 1a2f0d9..b4c9993 100644
016a62
--- a/hw/ppc/spapr.c
016a62
+++ b/hw/ppc/spapr.c
016a62
@@ -2527,6 +2527,39 @@ static void spapr_machine_init(MachineState *machine)
016a62
     /* init CPUs */
016a62
     spapr_init_cpus(spapr);
016a62
 
016a62
+    /*
016a62
+     * check we don't have a memory-less/cpu-less NUMA node
016a62
+     * Firmware relies on the existing memory/cpu topology to provide the
016a62
+     * NUMA topology to the kernel.
016a62
+     * And the linux kernel needs to know the NUMA topology at start
016a62
+     * to be able to hotplug CPUs later.
016a62
+     */
016a62
+    if (nb_numa_nodes) {
016a62
+        for (i = 0; i < nb_numa_nodes; ++i) {
016a62
+            /* check for memory-less node */
016a62
+            if (numa_info[i].node_mem == 0) {
016a62
+                CPUState *cs;
016a62
+                int found = 0;
016a62
+                /* check for cpu-less node */
016a62
+                CPU_FOREACH(cs) {
016a62
+                    PowerPCCPU *cpu = POWERPC_CPU(cs);
016a62
+                    if (cpu->node_id == i) {
016a62
+                        found = 1;
016a62
+                        break;
016a62
+                    }
016a62
+                }
016a62
+                /* memory-less and cpu-less node */
016a62
+                if (!found) {
016a62
+                    error_report(
016a62
+                       "Memory-less/cpu-less nodes are not supported (node %d)",
016a62
+                                 i);
016a62
+                    exit(1);
016a62
+                }
016a62
+            }
016a62
+        }
016a62
+
016a62
+    }
016a62
+
016a62
     if (kvm_enabled()) {
016a62
         /* Enable H_LOGICAL_CI_* so SLOF can talk to in-kernel devices */
016a62
         kvmppc_enable_logical_ci_hcalls();
016a62
-- 
016a62
1.8.3.1
016a62