[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/3] hw/386: Fix uninitialized memory with -device and CPU hot
From: |
Babu Moger |
Subject: |
[PATCH v2 3/3] hw/386: Fix uninitialized memory with -device and CPU hotplug |
Date: |
Wed, 01 Jul 2020 12:31:15 -0500 |
User-agent: |
StGit/unknown-version |
Noticed the following command failure while testing CPU hotplug.
$ qemu-system-x86_64 -machine q35,accel=kvm -smp 1,maxcpus=2,
cores=1, threads=1,sockets=2 -cpu EPYC -device EPYC-x86_64-
cpu,core-id=0,socket-id=1,thread-id=0
qemu-system-x86_64: -device EPYC-x86_64-cpu,core-id=0,socket-id=1,
thread-id=0: Invalid CPU [socket: 21855, die: 0, core: 0, thread: 0]
with APIC ID 21855, valid index range 0:1
This happens because APIC ID is calculated using uninitialized memory.
This is happening after the addition of new field node_id in X86CPUTopoIDs
structure. The node_id field is uninitialized while calling
apicid_from_topo_ids. The problem is discussed in the thread below.
https://lore.kernel.org/qemu-devel/20200602171838.GG577771@habkost.net/
Fix the problem by initializing the node_id from the device being added.
Fixes:
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1828750
Signed-off-by: Babu Moger <babu.moger@amd.com>
---
hw/i386/pc.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e613b2299f..aa9fb48834 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1553,6 +1553,15 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
cpu->die_id = 0;
}
+ /*
+ * If node_id is not set, initialize it to zero for now. If the user
+ * does not pass the correct node in case of numa configuration, it
+ * will be rejected eventually.
+ */
+ if (cpu->node_id < 0) {
+ cpu->node_id = 0;
+ }
+
if (cpu->socket_id < 0) {
error_setg(errp, "CPU socket-id is not set");
return;
@@ -1587,6 +1596,7 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
}
topo_ids.pkg_id = cpu->socket_id;
+ topo_ids.node_id = cpu->node_id;
topo_ids.die_id = cpu->die_id;
topo_ids.core_id = cpu->core_id;
topo_ids.smt_id = cpu->thread_id;
- Re: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, (continued)
- Re: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Igor Mammedov, 2020/07/24
- RE: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Babu Moger, 2020/07/27
- Re: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Igor Mammedov, 2020/07/27
- RE: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Babu Moger, 2020/07/27
- Re: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Igor Mammedov, 2020/07/29
- RE: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Babu Moger, 2020/07/29
- Re: [PATCH v2 1/3] hw/i386: Initialize topo_ids from CpuInstanceProperties, Igor Mammedov, 2020/07/30
[PATCH v2 2/3] hw/i386: Build apic_id from CpuInstanceProperties, Babu Moger, 2020/07/01
[PATCH v2 3/3] hw/386: Fix uninitialized memory with -device and CPU hotplug,
Babu Moger <=