* [PATCH] hw/acpi: propagate vcpu hotplug after switch to modern interface
[not found] <cover.1702398644.git.Aaron.Young@oracle.com>
@ 2023-12-12 16:51 ` Aaron Young
2023-12-18 19:02 ` Aaron Young
0 siblings, 1 reply; 2+ messages in thread
From: Aaron Young @ 2023-12-12 16:51 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo
If a vcpu with an apic-id that is not supported by the legacy
interface (>255) is hot-plugged, the legacy code will dynamically switch
to the modern interface. However, the hotplug event is not forwarded to
the new interface resulting in the vcpu not being fully/properly added
to the machine config. This BUG is evidenced by OVMF when it
it attempts to count the vcpus and reports an inconsistent vcpu count
reported by the fw_cfg interface and the modern hotpug interface.
Fix is to propagate the hotplug event after making the switch from
the legacy interface to the modern interface.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Aaron Young <aaron.young@oracle.com>
---
hw/acpi/cpu_hotplug.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 634bbec..6f78db0 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -59,7 +59,8 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
},
};
-static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
+static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
+ bool *swtchd_to_modern)
{
CPUClass *k = CPU_GET_CLASS(cpu);
int64_t cpu_id;
@@ -68,23 +69,34 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {
object_property_set_bool(g->device, "cpu-hotplug-legacy", false,
&error_abort);
+ *swtchd_to_modern = true;
return;
}
+ *swtchd_to_modern = false;
g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
}
void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
{
- acpi_set_cpu_present_bit(g, CPU(dev));
- acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+ bool swtchd_to_modern;
+ Error *local_err = NULL;
+
+ acpi_set_cpu_present_bit(g, CPU(dev), &swtchd_to_modern);
+ if (swtchd_to_modern) {
+ /* propagate the hotplug to the modern interface */
+ hotplug_handler_plug(hotplug_dev, dev, &local_err);
+ } else {
+ acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+ }
}
void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
AcpiCpuHotplug *gpe_cpu, uint16_t base)
{
CPUState *cpu;
+ bool swtchd_to_modern;
memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,
gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
@@ -92,7 +104,7 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
gpe_cpu->device = owner;
CPU_FOREACH(cpu) {
- acpi_set_cpu_present_bit(gpe_cpu, cpu);
+ acpi_set_cpu_present_bit(gpe_cpu, cpu, &swtchd_to_modern);
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] hw/acpi: propagate vcpu hotplug after switch to modern interface
2023-12-12 16:51 ` [PATCH] hw/acpi: propagate vcpu hotplug after switch to modern interface Aaron Young
@ 2023-12-18 19:02 ` Aaron Young
0 siblings, 0 replies; 2+ messages in thread
From: Aaron Young @ 2023-12-18 19:02 UTC (permalink / raw)
To: qemu-devel; +Cc: mst, imammedo, Aaron Young
Hi. I wanted to follow up with information to test/reproduce this BUG/issue.
Steps to reproduce:
1. Use the following options with QEMU (configured with OVMF):
-S -smp 2,maxcpus=260,sockets=2,cores=65,threads=2
2. Start QEMU and when QEMU reaches the paused state (due to -S),
issue the following command from the QMP Shell:
device_add driver=qemu64-x86_64-cpu socket-id=1 core-id=64 thread-id=0
3. Continue booting the VM and OVMF will report the following error
to the OVMF debug log indicating the BUG/error condition:
QEMU v2.7 reset bug: BootCpuCount=3 Present=2
BTW: This BUG often results in intermittent OVMF Exceptions/ASSERTs as well.
Thanks,
-Aaron
________________________________________
From: qemu-devel-bounces+aaron.young=oracle.com@nongnu.org <qemu-devel-bounces+aaron.young=oracle.com@nongnu.org> on behalf of Aaron Young <Aaron.Young@oracle.com>
Sent: Tuesday, December 12, 2023 8:51 AM
To: qemu-devel@nongnu.org
Cc: mst@redhat.com; imammedo@redhat.com
Subject: [PATCH] hw/acpi: propagate vcpu hotplug after switch to modern interface
If a vcpu with an apic-id that is not supported by the legacy
interface (>255) is hot-plugged, the legacy code will dynamically switch
to the modern interface. However, the hotplug event is not forwarded to
the new interface resulting in the vcpu not being fully/properly added
to the machine config. This BUG is evidenced by OVMF when it
it attempts to count the vcpus and reports an inconsistent vcpu count
reported by the fw_cfg interface and the modern hotpug interface.
Fix is to propagate the hotplug event after making the switch from
the legacy interface to the modern interface.
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Aaron Young <aaron.young@oracle.com>
---
hw/acpi/cpu_hotplug.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 634bbec..6f78db0 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -59,7 +59,8 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
},
};
-static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
+static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu,
+ bool *swtchd_to_modern)
{
CPUClass *k = CPU_GET_CLASS(cpu);
int64_t cpu_id;
@@ -68,23 +69,34 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu)
if ((cpu_id / 8) >= ACPI_GPE_PROC_LEN) {
object_property_set_bool(g->device, "cpu-hotplug-legacy", false,
&error_abort);
+ *swtchd_to_modern = true;
return;
}
+ *swtchd_to_modern = false;
g->sts[cpu_id / 8] |= (1 << (cpu_id % 8));
}
void legacy_acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
AcpiCpuHotplug *g, DeviceState *dev, Error **errp)
{
- acpi_set_cpu_present_bit(g, CPU(dev));
- acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+ bool swtchd_to_modern;
+ Error *local_err = NULL;
+
+ acpi_set_cpu_present_bit(g, CPU(dev), &swtchd_to_modern);
+ if (swtchd_to_modern) {
+ /* propagate the hotplug to the modern interface */
+ hotplug_handler_plug(hotplug_dev, dev, &local_err);
+ } else {
+ acpi_send_event(DEVICE(hotplug_dev), ACPI_CPU_HOTPLUG_STATUS);
+ }
}
void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
AcpiCpuHotplug *gpe_cpu, uint16_t base)
{
CPUState *cpu;
+ bool swtchd_to_modern;
memory_region_init_io(&gpe_cpu->io, owner, &AcpiCpuHotplug_ops,
gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
@@ -92,7 +104,7 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
gpe_cpu->device = owner;
CPU_FOREACH(cpu) {
- acpi_set_cpu_present_bit(gpe_cpu, cpu);
+ acpi_set_cpu_present_bit(gpe_cpu, cpu, &swtchd_to_modern);
}
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-18 19:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1702398644.git.Aaron.Young@oracle.com>
2023-12-12 16:51 ` [PATCH] hw/acpi: propagate vcpu hotplug after switch to modern interface Aaron Young
2023-12-18 19:02 ` Aaron Young
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.