Skip to contentSkip to conversation

q35: catch invalid cpu hotplug configuration

PATCH In review Gerd Hoffmann 3 participants 4 messages Aug 12, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 q35: catch invalid cpu hotplug configuration

Related: https://bugzilla.redhat.com//show_bug.cgi?id=1985924

---
 hw/isa/lpc_ich9.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/isa/lpc_ich9.c +13 -0
index 5f9de0239cf9..5f143dca17aa 100644
@@ -31,6 +31,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "cpu.h"
+#include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"
 #include "hw/isa/isa.h"
@@ -676,6 +677,18 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)
     DeviceState *dev = DEVICE(d);
     ISABus *isa_bus;
 
+    if ((lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)) &&
+        !(lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+        /*
+         * smi_features_ok_callback() throws an error on this.
+         *
+         * So bail out here instead of advertizing the invalid
+         * configuration and get obscure firmware failures from that.
+         */
+        error_setg(errp, "cpu hot-unplug requires cpu hot-plug");
+        return;
+    }
+
     isa_bus = isa_bus_new(DEVICE(d), get_system_memory(), get_system_io(),
                           errp);
     if (!isa_bus) {
Signature · 1 line
2.31.1
#1 lore raw
Quoted 23 lines · Gerd Hoffmann

Related: https://bugzilla.redhat.com//show_bug.cgi?id=1985924

---
 hw/isa/lpc_ich9.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/isa/lpc_ich9.c +2 -0
index 5f9de0239cf9..5f143dca17aa 100644
@@ -31,6 +31,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "cpu.h"
+#include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"
 #include "hw/isa/isa.h"
@@ -676,6 +677,18 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)
     DeviceState *dev = DEVICE(d);
     ISABus *isa_bus;
 
+    if ((lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)) &&

hw/isa/lpc_ich9.c static void ich9_lpc_realize(PCIDevice *d, Error **errp) · line 690

Quoted 10 lines
hw/isa/lpc_ich9.c +10 -0
+        !(lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+        /*
+         * smi_features_ok_callback() throws an error on this.
+         *
+         * So bail out here instead of advertizing the invalid
+         * configuration and get obscure firmware failures from that.
+         */
+        error_setg(errp, "cpu hot-unplug requires cpu hot-plug");
+        return;
+    }

What does this actually mean in practice ? AFAIK from the libvirt side we don't do anything special to enable/disable CPU hotplug. What QEMU config setting is wrong to lead to this scenario, thta the user/mgmt app has to fix ?

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw

Hi,

Quoted 12 lines

hw/isa/lpc_ich9.c static void ich9_lpc_realize(PCIDevice *d, Error **errp) · line 690

Quoted 11 lines
hw/isa/lpc_ich9.c +11 -0
+    if ((lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)) &&
+        !(lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+        /*
+         * smi_features_ok_callback() throws an error on this.
+         *
+         * So bail out here instead of advertizing the invalid
+         * configuration and get obscure firmware failures from that.
+         */
+        error_setg(errp, "cpu hot-unplug requires cpu hot-plug");
+        return;
+    }
Quoted 4 lines

What does this actually mean in practice ? AFAIK from the libvirt side we don't do anything special to enable/disable CPU hotplug. What QEMU config setting is wrong to lead to this scenario, thta the user/mgmt app has to fix ?

It's ICH9-LPC.x-smi-cpu-{hotplug,hotunplug}. user/mgmt should not mess with that, but given it is possible I think printing an error is better than going for an assert().

If this triggers it is most likely qemu getting compat properties wrong.

Full story at https://bugzilla.redhat.com/show_bug.cgi?id=1985924 ;)

take care,
Gerd

Reviewed-by on v1 1/1
#3 lore raw
In reply to Gerd Hoffmann
Quoted 2 lines · On Thu, 12 Aug 2021 12:23:41 +0200 Gerd Hoffmann <[email protected]> wrote:

Related: https://bugzilla.redhat.com//show_bug.cgi?id=1985924

Quoted 35 lines
---
 hw/isa/lpc_ich9.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
hw/isa/lpc_ich9.c +13 -0
index 5f9de0239cf9..5f143dca17aa 100644
@@ -31,6 +31,7 @@
 #include "qemu/osdep.h"
 #include "qemu/log.h"
 #include "cpu.h"
+#include "qapi/error.h"
 #include "qapi/visitor.h"
 #include "qemu/range.h"
 #include "hw/isa/isa.h"
@@ -676,6 +677,18 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)
     DeviceState *dev = DEVICE(d);
     ISABus *isa_bus;
 
+    if ((lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT)) &&
+        !(lpc->smi_host_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+        /*
+         * smi_features_ok_callback() throws an error on this.
+         *
+         * So bail out here instead of advertizing the invalid
+         * configuration and get obscure firmware failures from that.
+         */
+        error_setg(errp, "cpu hot-unplug requires cpu hot-plug");
+        return;
+    }
+
     isa_bus = isa_bus_new(DEVICE(d), get_system_memory(), get_system_io(),
                           errp);
     if (!isa_bus) {