yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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