Skip to contentSkip to conversation

x86: fix cpu hotplug with secure boot

PATCH Superseded Igor Mammedov 3 participants 25 messages Sep 7, 2020 – Sep 23, 2020

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover x86: fix cpu hotplug with secure boot

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch
v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH v5 1/10 x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features

It will allow firmware to notify QEMU that firmware requires SMI being triggered on CPU hot[un]plug, so that it would be able to account for hotplugged CPU and relocate it to new SMM base and/or safely remove CPU on unplug.

Using negotiated features, follow up patches will insert SMI upcall into AML code, to make sure that firmware processes hotplug before guest OS would attempt to use new CPU.

---
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1
(Laszlo Ersek <[email protected]>)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch
v2:
- rebase on top of 5.1 (move compat values to 5.1 machine)
- make "x-smi-cpu-hotunplug" false by default (Laszlo Ersek <[email protected]>)

fixup

---
 include/hw/i386/ich9.h |  2 ++
 hw/i386/pc.c           |  4 +++-
 hw/isa/lpc_ich9.c      | 13 +++++++++++++
 3 files changed, 18 insertions(+), 1 deletion(-)
include/hw/i386/ich9.h +2 -0
index a98d10b252..d1bb3f7bf0 100644
@@ -247,5 +247,7 @@ typedef struct ICH9LPCState {
 
 /* bit positions used in fw_cfg SMI feature negotiation */
 #define ICH9_LPC_SMI_F_BROADCAST_BIT            0
+#define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT          1
+#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT       2
 
 #endif /* HW_ICH9_H */
hw/i386/pc.c +3 -1
index d11daacc23..f32e66c1b2 100644
@@ -97,7 +97,9 @@
 #include "trace.h"
 #include CONFIG_DEVICES
 
-GlobalProperty pc_compat_5_1[] = {};
+GlobalProperty pc_compat_5_1[] = {
+    { "ICH9-LPC", "x-smi-cpu-hotplug", "off" },
+};
 const size_t pc_compat_5_1_len = G_N_ELEMENTS(pc_compat_5_1);
 
 GlobalProperty pc_compat_5_0[] = {
hw/isa/lpc_ich9.c +13 -0
index cd6e169d47..19f32bed3e 100644
@@ -373,6 +373,15 @@ static void smi_features_ok_callback(void *opaque)
         /* guest requests invalid features, leave @features_ok at zero */
         return;
     }
+    if (!(guest_features & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT)) &&
+        guest_features & (BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT) |
+                          BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT))) {
+        /*
+         * cpu hot-[un]plug with SMI requires SMI broadcast,
+         * leave @features_ok at zero
+         */
+        return;
+    }
 
     /* valid feature subset requested, lock it down, report success */
     lpc->smi_negotiated_features = guest_features;
@@ -747,6 +756,10 @@ static Property ich9_lpc_properties[] = {
     DEFINE_PROP_BOOL("noreboot", ICH9LPCState, pin_strap.spkr_hi, true),
     DEFINE_PROP_BIT64("x-smi-broadcast", ICH9LPCState, smi_host_features,
                       ICH9_LPC_SMI_F_BROADCAST_BIT, true),
+    DEFINE_PROP_BIT64("x-smi-cpu-hotplug", ICH9LPCState, smi_host_features,
+                      ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT, true),
+    DEFINE_PROP_BIT64("x-smi-cpu-hotunplug", ICH9LPCState, smi_host_features,
+                      ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT, false),
     DEFINE_PROP_END_OF_LIST(),
 };
 
Signature · 1 line
2.27.0
#2 lore raw

PATCH v5 2/10 x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is in use

In reply to Igor Mammedov

There were reports of guest crash on CPU hotplug, when using q35 machine type and OVMF with SMM, due to hotplugged CPU trying to process SMI at default SMI handler location without it being relocated by firmware first.

Fix it by refusing hotplug if firmware hasn't negotiated CPU hotplug with SMI support while SMI broadcast is in use.

---
v1:
fix typos an use suggested wording in commit and error msg s/secure boot/smm/; s/hotplug SMI/hotplug with SMI/
(Laszlo Ersek <[email protected]>)

---
 hw/acpi/ich9.c | 12 +++++++++++-
 hw/i386/pc.c   | 11 +++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
hw/acpi/ich9.c +11 -1
index 6a19070cec..0acc9a3107 100644
@@ -408,10 +408,20 @@ void ich9_pm_device_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
     ICH9LPCState *lpc = ICH9_LPC_DEVICE(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) &&
-        !lpc->pm.acpi_memory_hotplug.is_enabled)
+        !lpc->pm.acpi_memory_hotplug.is_enabled) {
         error_setg(errp,
                    "memory hotplug is not enabled: %s.memory-hotplug-support "
                    "is not set", object_get_typename(OBJECT(lpc)));
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        uint64_t negotiated = lpc->smi_negotiated_features;
+
+        if (negotiated & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT) &&
+            !(negotiated & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT))) {
+            error_setg(errp, "cpu hotplug with SMI wasn't enabled by firmware");
+            error_append_hint(errp, "update machine type to newer than 5.1 "
+                "and firmware that suppors CPU hotplug with SMM");
+        }
+    }
 }
 
 void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
hw/i386/pc.c +11 -0
index f32e66c1b2..1d4955485b 100644
@@ -1500,6 +1500,17 @@ static void pc_cpu_pre_plug(HotplugHandler *hotplug_dev,
         return;
     }
 
+    if (pcms->acpi_dev) {
+        Error *local_err = NULL;
+
+        hotplug_handler_pre_plug(HOTPLUG_HANDLER(pcms->acpi_dev), dev,
+                                 &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            return;
+        }
+    }
+
     init_topo_info(&topo_info, x86ms);
 
     env->nr_dies = x86ms->smp_dies;
Signature · 1 line
2.27.0
#3 lore raw

PATCH v5 3/10 x86: cpuhp: refuse cpu hot-unplug request earlier if not supported

In reply to Igor Mammedov

CPU hot-unplug with SMM requires firmware participation to prevent guest crash (i.e. CPU can be removed only after OS _and_ firmware were prepared for the action).
Previous patches introduced ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT feature bit, which is advertised by firmware when it has support for CPU hot-unplug. Use it to check if guest is able to handle unplug and make device_del fail gracefully if hot-unplug feature hasn't been negotiated.

---
v2:
- fix typo in commit message
- drop 5.1 version from hint message (Laszlo)

---
 hw/acpi/ich9.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
hw/acpi/ich9.c +12 -0
index 0acc9a3107..95cb0f935b 100644
@@ -460,6 +460,18 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,
                                       errp);
     } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) &&
                !lpc->pm.cpu_hotplug_legacy) {
+        uint64_t negotiated = lpc->smi_negotiated_features;
+
+        if (negotiated & BIT_ULL(ICH9_LPC_SMI_F_BROADCAST_BIT) &&
+            !(negotiated & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT))) {
+            error_setg(errp, "cpu hot-unplug with SMI wasn't enabled "
+                             "by firmware");
+            error_append_hint(errp, "update machine type to a version having "
+                                    "x-smi-cpu-hotunplug=on and firmware that "
+                                    "supports CPU hot-unplug with SMM");
+            return;
+        }
+
         acpi_cpu_unplug_request_cb(hotplug_dev, &lpc->pm.cpuhp_state,
                                    dev, errp);
     } else {
Signature · 1 line
2.27.0
#4 lore raw

PATCH v5 4/10 acpi: add aml_land() and aml_break() primitives

In reply to Igor Mammedov

---
v5:
- fix comment to match spec (Laszlo Ersek <[email protected]>)
- reorder aml_lor() and aml_land() in header (Laszlo Ersek <[email protected]>)

---
 include/hw/acpi/aml-build.h |  2 ++
 hw/acpi/aml-build.c         | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)
include/hw/acpi/aml-build.h +2 -0
index d27da03d64..fe0055fffb 100644
@@ -290,6 +290,7 @@ Aml *aml_to_buffer(Aml *src, Aml *dst);
 Aml *aml_store(Aml *val, Aml *target);
 Aml *aml_and(Aml *arg1, Aml *arg2, Aml *dst);
 Aml *aml_or(Aml *arg1, Aml *arg2, Aml *dst);
+Aml *aml_land(Aml *arg1, Aml *arg2);
 Aml *aml_lor(Aml *arg1, Aml *arg2);
 Aml *aml_shiftleft(Aml *arg1, Aml *count);
 Aml *aml_shiftright(Aml *arg1, Aml *count, Aml *dst);
@@ -300,6 +301,7 @@ Aml *aml_increment(Aml *arg);
 Aml *aml_decrement(Aml *arg);
 Aml *aml_index(Aml *arg1, Aml *idx);
 Aml *aml_notify(Aml *arg1, Aml *arg2);
+Aml *aml_break(void);
 Aml *aml_call0(const char *method);
 Aml *aml_call1(const char *method, Aml *arg1);
 Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2);
hw/acpi/aml-build.c +16 -0
index f6fbc9b95d..3792ba96ce 100644
@@ -556,6 +556,15 @@ Aml *aml_or(Aml *arg1, Aml *arg2, Aml *dst)
     return build_opcode_2arg_dst(0x7D /* OrOp */, arg1, arg2, dst);
 }
 
+/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLAnd */
+Aml *aml_land(Aml *arg1, Aml *arg2)
+{
+    Aml *var = aml_opcode(0x90 /* LAndOp */);
+    aml_append(var, arg1);
+    aml_append(var, arg2);
+    return var;
+}
+
 /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLOr */
 Aml *aml_lor(Aml *arg1, Aml *arg2)
 {
@@ -629,6 +638,13 @@ Aml *aml_notify(Aml *arg1, Aml *arg2)
     return var;
 }
 
+/* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefBreak */
+Aml *aml_break(void)
+{
+    Aml *var = aml_opcode(0xa5 /* BreakOp */);
+    return var;
+}
+
 /* helper to call method without argument */
 Aml *aml_call0(const char *method)
 {
Signature · 1 line
2.27.0
#5 lore raw

PATCH v5 5/10 tests: acpi: mark to be changed tables in bios-tables-test-allowed-diff

In reply to Igor Mammedov

... to let tests pass until binary blobs are updated with new AML

---
 tests/qtest/bios-tables-test-allowed-diff.h | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +19 -0
index dfb8523c8b..dba32d5613 100644
@@ -1 +1,20 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/pc/DSDT",
+"tests/data/acpi/q35/DSDT",
+"tests/data/acpi/q35/DSDT.tis",
+"tests/data/acpi/q35/DSDT.bridge",
+"tests/data/acpi/q35/DSDT.mmio64",
+"tests/data/acpi/q35/DSDT.ipmibt",
+"tests/data/acpi/q35/DSDT.cphp",
+"tests/data/acpi/q35/DSDT.memhp",
+"tests/data/acpi/q35/DSDT.numamem",
+"tests/data/acpi/q35/DSDT.dimmpxm",
+"tests/data/acpi/q35/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.bridge",
+"tests/data/acpi/pc/DSDT.ipmikcs",
+"tests/data/acpi/pc/DSDT.cphp",
+"tests/data/acpi/pc/DSDT.memhp",
+"tests/data/acpi/pc/DSDT.numamem",
+"tests/data/acpi/pc/DSDT.dimmpxm",
+"tests/data/acpi/pc/DSDT.acpihmat",
+"tests/data/acpi/pc/DSDT.acpihmat",
Signature · 1 line
2.27.0
#6 lore raw

PATCH v5 6/10 x86: ich9: expose "smi_negotiated_features" as a QOM property

In reply to Igor Mammedov

Expose the "smi_negotiated_features" field of ICH9LPCState as a QOM property.

---
 include/hw/i386/ich9.h | 2 ++
 hw/isa/lpc_ich9.c      | 3 +++
 2 files changed, 5 insertions(+)
include/hw/i386/ich9.h +2 -0
index d1bb3f7bf0..0f43ef2481 100644
@@ -245,6 +245,8 @@ typedef struct ICH9LPCState {
 #define ICH9_SMB_HST_D1                         0x06
 #define ICH9_SMB_HOST_BLOCK_DB                  0x07
 
+#define ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP "x-smi-negotiated-features"
+
 /* bit positions used in fw_cfg SMI feature negotiation */
 #define ICH9_LPC_SMI_F_BROADCAST_BIT            0
 #define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT          1
hw/isa/lpc_ich9.c +3 -0
index 19f32bed3e..8124d20338 100644
@@ -647,6 +647,9 @@ static void ich9_lpc_initfn(Object *obj)
                                   &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_DISABLE_CMD,
                                   &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
+    object_property_add_uint64_ptr(obj, ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
+                                   &lpc->smi_negotiated_features,
+                                   OBJ_PROP_FLAG_READ);
 
     ich9_pm_add_properties(obj, &lpc->pm);
 }
Signature · 1 line
2.27.0
Tested-by on v5 6/10
#7 lore raw

Re: [PATCH v5 06/10] x86: ich9: expose "smi_negotiated_features" as a QOM property

Quoted 29 lines · Igor Mammedov

Expose the "smi_negotiated_features" field of ICH9LPCState as a QOM property.

---
 include/hw/i386/ich9.h | 2 ++
 hw/isa/lpc_ich9.c      | 3 +++
 2 files changed, 5 insertions(+)
include/hw/i386/ich9.h +2 -0
index d1bb3f7bf0..0f43ef2481 100644
@@ -245,6 +245,8 @@ typedef struct ICH9LPCState {
 #define ICH9_SMB_HST_D1                         0x06
 #define ICH9_SMB_HOST_BLOCK_DB                  0x07
 
+#define ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP "x-smi-negotiated-features"
+
 /* bit positions used in fw_cfg SMI feature negotiation */
 #define ICH9_LPC_SMI_F_BROADCAST_BIT            0
 #define ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT          1
hw/isa/lpc_ich9.c +0 -0
index 19f32bed3e..8124d20338 100644

hw/isa/lpc_ich9.c static void ich9_lpc_initfn(Object *obj) · line 655

Quoted 9 lines
hw/isa/lpc_ich9.c +3 -0
@@ -647,6 +647,9 @@ static void ich9_lpc_initfn(Object *obj)
                                   &acpi_enable_cmd, OBJ_PROP_FLAG_READ);
     object_property_add_uint8_ptr(OBJECT(lpc), ACPI_PM_PROP_ACPI_DISABLE_CMD,
                                   &acpi_disable_cmd, OBJ_PROP_FLAG_READ);
+    object_property_add_uint64_ptr(obj, ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP,
+                                   &lpc->smi_negotiated_features,
+                                   OBJ_PROP_FLAG_READ);
 
     ich9_pm_add_properties(obj, &lpc->pm);
 }
#8 lore raw

PATCH v5 7/10 x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp

In reply to Igor Mammedov

Translate the "CPU hotplug with SMI" feature bit, from the property added in the last patch, to a dedicated boolean in AcpiPmInfo.

---
 hw/i386/acpi-build.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/i386/acpi-build.c +6 -0
index 7a5a8b3521..e61c17a484 100644
@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool smi_on_cpuhp;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -194,6 +195,7 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->cpu_hp_io_base = 0;
     pm->pcihp_io_base = 0;
     pm->pcihp_io_len = 0;
+    pm->smi_on_cpuhp = false;
 
     assert(obj);
     init_common_fadt_data(machine, obj, &pm->fadt);
@@ -207,12 +209,16 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
             object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
     }
     if (lpc) {
+        uint64_t smi_features = object_property_get_uint(lpc,
+            ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP, NULL);
         struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,
             .bit_width = 8, .address = ICH9_RST_CNT_IOPORT };
         pm->fadt.reset_reg = r;
         pm->fadt.reset_val = 0xf;
         pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
         pm->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;
+        pm->smi_on_cpuhp =
+            !!(smi_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT));
     }
 
     /* The above need not be conditional on machine type because the reset port
Signature · 1 line
2.27.0
Tested-by on v5 7/10
#9 lore raw

Re: [PATCH v5 07/10] x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp

Quoted 37 lines · Igor Mammedov

Translate the "CPU hotplug with SMI" feature bit, from the property added in the last patch, to a dedicated boolean in AcpiPmInfo.

---
 hw/i386/acpi-build.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/i386/acpi-build.c +4 -0
index 7a5a8b3521..e61c17a484 100644
@@ -95,6 +95,7 @@ typedef struct AcpiPmInfo {
     bool s3_disabled;
     bool s4_disabled;
     bool pcihp_bridge_en;
+    bool smi_on_cpuhp;
     uint8_t s4_val;
     AcpiFadtData fadt;
     uint16_t cpu_hp_io_base;
@@ -194,6 +195,7 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
     pm->cpu_hp_io_base = 0;
     pm->pcihp_io_base = 0;
     pm->pcihp_io_len = 0;
+    pm->smi_on_cpuhp = false;
 
     assert(obj);
     init_common_fadt_data(machine, obj, &pm->fadt);
@@ -207,12 +209,16 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm)
             object_property_get_uint(obj, ACPI_PCIHP_IO_LEN_PROP, NULL);
     }
     if (lpc) {
+        uint64_t smi_features = object_property_get_uint(lpc,
+            ICH9_LPC_SMI_NEGOTIATED_FEAT_PROP, NULL);
         struct AcpiGenericAddress r = { .space_id = AML_AS_SYSTEM_IO,

hw/i386/acpi-build.c static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) · line 224

Quoted 10 lines
hw/i386/acpi-build.c +2 -0
             .bit_width = 8, .address = ICH9_RST_CNT_IOPORT };
         pm->fadt.reset_reg = r;
         pm->fadt.reset_val = 0xf;
         pm->fadt.flags |= 1 << ACPI_FADT_F_RESET_REG_SUP;
         pm->cpu_hp_io_base = ICH9_CPU_HOTPLUG_IO_BASE;
+        pm->smi_on_cpuhp =
+            !!(smi_features & BIT_ULL(ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT));
     }
 
     /* The above need not be conditional on machine type because the reset port
#10 lore raw

PATCH v5 8/10 x86: acpi: introduce the PCI0.SMI0 ACPI device

In reply to Igor Mammedov

When CPU hotplug with SMI has been negotiated, describe the SMI register block in the DSDT. Pass the ACPI name of the SMI control register to build_cpus_aml(), so that CPU_SCAN_METHOD can access the register in the next patch.

---
 include/hw/acpi/cpu.h |  1 +
 hw/i386/acpi-build.c  | 29 ++++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
include/hw/acpi/cpu.h +1 -0
index 62f0278ba2..0eeedaa491 100644
@@ -50,6 +50,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
 typedef struct CPUHotplugFeatures {
     bool acpi_1_compatible;
     bool has_legacy_cphp;
+    const char *smi_path;
 } CPUHotplugFeatures;
 
 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
hw/i386/acpi-build.c +28 -1
index e61c17a484..7a33ef193e 100644
@@ -1521,6 +1521,32 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dev, aml_name_decl("_UID", aml_int(0)));
         aml_append(dev, build_q35_osc_method());
         aml_append(sb_scope, dev);
+
+        if (pm->smi_on_cpuhp) {
+            /* reserve SMI block resources, IO ports 0xB2, 0xB3 */
+            dev = aml_device("PCI0.SMI0");
+            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));
+            aml_append(dev, aml_name_decl("_UID", aml_string("SMI resources")));
+            crs = aml_resource_template();
+            aml_append(crs,
+                aml_io(
+                       AML_DECODE16,
+                       ACPI_PORT_SMI_CMD,
+                       ACPI_PORT_SMI_CMD,
+                       1,
+                       2)
+            );
+            aml_append(dev, aml_name_decl("_CRS", crs));
+            aml_append(dev, aml_operation_region("SMIR", AML_SYSTEM_IO,
+                aml_int(ACPI_PORT_SMI_CMD), 2));
+            field = aml_field("SMIR", AML_BYTE_ACC, AML_NOLOCK,
+                              AML_WRITE_AS_ZEROS);
+            aml_append(field, aml_named_field("SMIC", 8));
+            aml_append(field, aml_reserved_field(8));
+            aml_append(dev, field);
+            aml_append(sb_scope, dev);
+        }
+
         aml_append(dsdt, sb_scope);
 
         build_hpet_aml(dsdt);
@@ -1536,7 +1562,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
     } else {
         CPUHotplugFeatures opts = {
-            .acpi_1_compatible = true, .has_legacy_cphp = true
+            .acpi_1_compatible = true, .has_legacy_cphp = true,
+            .smi_path = pm->smi_on_cpuhp ? "\\_SB.PCI0.SMI0.SMIC" : NULL,
         };
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
Signature · 1 line
2.27.0
Tested-by on v5 8/10
#11 lore raw

Re: [PATCH v5 08/10] x86: acpi: introduce the PCI0.SMI0 ACPI device

Quoted 63 lines · Igor Mammedov

When CPU hotplug with SMI has been negotiated, describe the SMI register block in the DSDT. Pass the ACPI name of the SMI control register to build_cpus_aml(), so that CPU_SCAN_METHOD can access the register in the next patch.

---
 include/hw/acpi/cpu.h |  1 +
 hw/i386/acpi-build.c  | 29 ++++++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)
include/hw/acpi/cpu.h +1 -0
index 62f0278ba2..0eeedaa491 100644
@@ -50,6 +50,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
 typedef struct CPUHotplugFeatures {
     bool acpi_1_compatible;
     bool has_legacy_cphp;
+    const char *smi_path;
 } CPUHotplugFeatures;
 
 void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
hw/i386/acpi-build.c +26 -0
index e61c17a484..7a33ef193e 100644
@@ -1521,6 +1521,32 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         aml_append(dev, aml_name_decl("_UID", aml_int(0)));
         aml_append(dev, build_q35_osc_method());
         aml_append(sb_scope, dev);
+
+        if (pm->smi_on_cpuhp) {
+            /* reserve SMI block resources, IO ports 0xB2, 0xB3 */
+            dev = aml_device("PCI0.SMI0");
+            aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0A06")));
+            aml_append(dev, aml_name_decl("_UID", aml_string("SMI resources")));
+            crs = aml_resource_template();
+            aml_append(crs,
+                aml_io(
+                       AML_DECODE16,
+                       ACPI_PORT_SMI_CMD,
+                       ACPI_PORT_SMI_CMD,
+                       1,
+                       2)
+            );
+            aml_append(dev, aml_name_decl("_CRS", crs));
+            aml_append(dev, aml_operation_region("SMIR", AML_SYSTEM_IO,
+                aml_int(ACPI_PORT_SMI_CMD), 2));
+            field = aml_field("SMIR", AML_BYTE_ACC, AML_NOLOCK,
+                              AML_WRITE_AS_ZEROS);
+            aml_append(field, aml_named_field("SMIC", 8));
+            aml_append(field, aml_reserved_field(8));
+            aml_append(dev, field);
+            aml_append(sb_scope, dev);
+        }
+
         aml_append(dsdt, sb_scope);
 
         build_hpet_aml(dsdt);

hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1569

Quoted 9 lines
hw/i386/acpi-build.c +2 -1
@@ -1536,7 +1562,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_legacy_cpu_hotplug_aml(dsdt, machine, pm->cpu_hp_io_base);
     } else {
         CPUHotplugFeatures opts = {
-            .acpi_1_compatible = true, .has_legacy_cphp = true
+            .acpi_1_compatible = true, .has_legacy_cphp = true,
+            .smi_path = pm->smi_on_cpuhp ? "\\_SB.PCI0.SMI0.SMIC" : NULL,
         };
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
#12 lore raw

PATCH v5 9/10 x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

In reply to Igor Mammedov

In case firmware has negotiated CPU hotplug SMI feature, generate AML to describe SMI IO port region and send SMI to firmware on each CPU hotplug SCI in case new CPUs were hotplugged.

Since new CPUs can be hotplugged while CPU_SCAN_METHOD is running we can't send SMI before new CPUs are fetched from QEMU as it could cause sending Notify to a CPU that firmware hasn't seen yet. So fetch new CPUs into local cache first, then send SMI and after that send Notify events to cached CPUs. This should ensure that Notify is sent only to CPUs which were processed by firmware first.
Any CPUs that were hotplugged after caching will be processed by the next CPU_SCAN_METHOD, when pending SCI is handled.

---
v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- (Laszlo Ersek <[email protected]>)
- fix off-by-one in package length
- fix not selecting CPU before clearing insert event
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero)
- split off in separate patches:
- making smi_negotiated_features a property
- introduction of AcpiPmInfo.smi_on_cpuhp
- introduction of PCI0.SMI0 ACPI device
v2:
- clear insert event after firmware has returned
control from SMI. (Laszlo Ersek <[email protected]>)
v1:
- make sure that Notify is sent only to CPUs seen by FW
- (Laszlo Ersek <[email protected]>)
- use macro instead of x-smi-negotiated-features
- style fixes
- reserve whole SMI block (0xB2, 0xB3)
v0:
- s/aml_string/aml_eisaid/
/fixes Windows BSOD, on nonsense value/ (Laszlo Ersek <[email protected]>)
- put SMI device under PCI0 like the rest of hotplug IO port
- do not generate SMI AML if CPU hotplug SMI feature hasn't been negotiated

---
 hw/acpi/cpu.c | 156 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 129 insertions(+), 27 deletions(-)
hw/acpi/cpu.c +129 -27
index 3d6a500fb7..1283972001 100644
@@ -14,6 +14,8 @@
 #define ACPI_CPU_CMD_DATA_OFFSET_RW 8
 #define ACPI_CPU_CMD_DATA2_OFFSET_R 0
 
+#define OVMF_CPUHP_SMI_CMD 4
+
 enum {
     CPHP_GET_NEXT_CPU_WITH_EVENT_CMD = 0,
     CPHP_OST_EVENT_CMD = 1,
@@ -321,6 +323,7 @@ const VMStateDescription vmstate_cpu_hotplug = {
 #define CPU_NOTIFY_METHOD "CTFY"
 #define CPU_EJECT_METHOD  "CEJ0"
 #define CPU_OST_METHOD    "COST"
+#define CPU_ADDED_LIST    "CNEW"
 
 #define CPU_ENABLED       "CPEN"
 #define CPU_SELECTOR      "CSEL"
@@ -465,42 +468,141 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
 
         method = aml_method(CPU_SCAN_METHOD, 0, AML_SERIALIZED);
         {
+            const uint8_t max_cpus_per_pass = 255;
             Aml *else_ctx;
-            Aml *while_ctx;
+            Aml *while_ctx, *while_ctx2;
             Aml *has_event = aml_local(0);
             Aml *dev_chk = aml_int(1);
             Aml *eject_req = aml_int(3);
             Aml *next_cpu_cmd = aml_int(CPHP_GET_NEXT_CPU_WITH_EVENT_CMD);
+            Aml *num_added_cpus = aml_local(1);
+            Aml *cpu_idx = aml_local(2);
+            Aml *uid = aml_local(3);
+            Aml *has_job = aml_local(4);
+            Aml *new_cpus = aml_name(CPU_ADDED_LIST);
 
             aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(one, has_event));
-            while_ctx = aml_while(aml_equal(has_event, one));
+
+            /*
+             * Windows versions newer than XP (including Windows 10/Windows
+             * Server 2019), do support* VarPackageOp but, it is cripled to hold
+             * the same elements number as old PackageOp.
+             * For compatibility with Windows XP (so it won't crash) use ACPI1.0
+             * PackageOp which can hold max 255 elements.
+             *
+             * use named package as old Windows don't support it in local var
+             */
+            aml_append(method, aml_name_decl(CPU_ADDED_LIST,
+                                             aml_package(max_cpus_per_pass)));
+
+            aml_append(method, aml_store(zero, uid));
+            aml_append(method, aml_store(one, has_job));
+            /*
+             * CPU_ADDED_LIST can hold limited number of elements, outer loop
+             * allows to process CPUs in batches which let us to handle more
+             * CPUs than CPU_ADDED_LIST can hold.
+             */
+            while_ctx2 = aml_while(aml_equal(has_job, one));
             {
-                 /* clear loop exit condition, ins_evt/rm_evt checks
-                  * will set it to 1 while next_cpu_cmd returns a CPU
-                  * with events */
-                 aml_append(while_ctx, aml_store(zero, has_event));
-                 aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
-                 ifctx = aml_if(aml_equal(ins_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, dev_chk));
-                     aml_append(ifctx, aml_store(one, ins_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(while_ctx, ifctx);
-                 else_ctx = aml_else();
-                 ifctx = aml_if(aml_equal(rm_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, eject_req));
-                     aml_append(ifctx, aml_store(one, rm_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(else_ctx, ifctx);
-                 aml_append(while_ctx, else_ctx);
+                aml_append(while_ctx2, aml_store(zero, has_job));
+
+                aml_append(while_ctx2, aml_store(one, has_event));
+                aml_append(while_ctx2, aml_store(zero, num_added_cpus));
+
+                /*
+                 * Scan CPUs, till there are CPUs with events or
+                 * CPU_ADDED_LIST capacity is exhausted
+                 */
+                while_ctx = aml_while(aml_land(aml_equal(has_event, one),
+                                      aml_lless(uid, aml_int(arch_ids->len))));
+                {
+                     /*
+                      * clear loop exit condition, ins_evt/rm_evt checks will
+                      * set it to 1 while next_cpu_cmd returns a CPU with events
+                      */
+                     aml_append(while_ctx, aml_store(zero, has_event));
+
+                     aml_append(while_ctx, aml_store(uid, cpu_selector));
+                     aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
+
+                     /*
+                      * wrap around case, scan is complete, exit loop.
+                      * It happens since events are not cleared in scan loop,
+                      * so next_cpu_cmd continues to find already processed CPUs
+                      */
+                     ifctx = aml_if(aml_lless(cpu_data, uid));
+                     {
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     /*
+                      * if CPU_ADDED_LIST is full, exit inner loop and process
+                      * collected CPUs
+                      */
+                     ifctx = aml_if(
+                         aml_equal(num_added_cpus, aml_int(max_cpus_per_pass)));
+                     {
+                         aml_append(ifctx, aml_store(one, has_job));
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     aml_append(while_ctx, aml_store(cpu_data, uid));
+                     ifctx = aml_if(aml_equal(ins_evt, one));
+                     {
+                         /* cache added CPUs to Notify/Wakeup later */
+                         aml_append(ifctx, aml_store(uid,
+                             aml_index(new_cpus, num_added_cpus)));
+                         aml_append(ifctx, aml_increment(num_added_cpus));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(while_ctx, ifctx);
+                     else_ctx = aml_else();
+                     ifctx = aml_if(aml_equal(rm_evt, one));
+                     {
+                         aml_append(ifctx,
+                             aml_call2(CPU_NOTIFY_METHOD, uid, eject_req));
+                         aml_append(ifctx, aml_store(one, rm_evt));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(else_ctx, ifctx);
+                     aml_append(while_ctx, else_ctx);
+                     aml_append(while_ctx, aml_increment(uid));
+                }
+                aml_append(while_ctx2, while_ctx);
+
+                /*
+                 * in case FW negotiated ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT,
+                 * make upcall to FW, so it can pull in new CPUs before
+                 * OS is notified and wakes them up
+                 */
+                if (opts.smi_path) {
+                    ifctx = aml_if(aml_lgreater(num_added_cpus, zero));
+                    {
+                        aml_append(ifctx, aml_store(aml_int(OVMF_CPUHP_SMI_CMD),
+                            aml_name("%s", opts.smi_path)));
+                    }
+                    aml_append(while_ctx2, ifctx);
+                }
+
+                /* Notify OSPM about new CPUs and clear insert events */
+                aml_append(while_ctx2, aml_store(zero, cpu_idx));
+                while_ctx = aml_while(aml_lless(cpu_idx, num_added_cpus));
+                {
+                    aml_append(while_ctx,
+                        aml_store(aml_derefof(aml_index(new_cpus, cpu_idx)),
+                                  uid));
+                    aml_append(while_ctx,
+                        aml_call2(CPU_NOTIFY_METHOD, uid, dev_chk));
+                    aml_append(while_ctx, aml_store(uid, aml_debug()));
+                    aml_append(while_ctx, aml_store(uid, cpu_selector));
+                    aml_append(while_ctx, aml_store(one, ins_evt));
+                    aml_append(while_ctx, aml_increment(cpu_idx));
+                }
+                aml_append(while_ctx2, while_ctx);
             }
-            aml_append(method, while_ctx);
+            aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));
         }
         aml_append(cpus_dev, method);
Signature · 1 line
2.27.0
#13 lore raw

Re: [PATCH v5 09/10] x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

Hi Igor,

Quoted 230 lines · Igor Mammedov

In case firmware has negotiated CPU hotplug SMI feature, generate AML to describe SMI IO port region and send SMI to firmware on each CPU hotplug SCI in case new CPUs were hotplugged.

Since new CPUs can be hotplugged while CPU_SCAN_METHOD is running we can't send SMI before new CPUs are fetched from QEMU as it could cause sending Notify to a CPU that firmware hasn't seen yet. So fetch new CPUs into local cache first, then send SMI and after that send Notify events to cached CPUs. This should ensure that Notify is sent only to CPUs which were processed by firmware first.
Any CPUs that were hotplugged after caching will be processed by the next CPU_SCAN_METHOD, when pending SCI is handled.

---
v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements so process CPUs in batches)
- (Laszlo Ersek <[email protected]>)
- fix off-by-one in package length
- fix not selecting CPU before clearing insert event
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero)
- split off in separate patches:
- making smi_negotiated_features a property
- introduction of AcpiPmInfo.smi_on_cpuhp
- introduction of PCI0.SMI0 ACPI device
v2:
- clear insert event after firmware has returned
control from SMI. (Laszlo Ersek <[email protected]>)
v1:
- make sure that Notify is sent only to CPUs seen by FW
- (Laszlo Ersek <[email protected]>)
- use macro instead of x-smi-negotiated-features
- style fixes
- reserve whole SMI block (0xB2, 0xB3)
v0:
- s/aml_string/aml_eisaid/
/fixes Windows BSOD, on nonsense value/ (Laszlo Ersek <[email protected]>)
- put SMI device under PCI0 like the rest of hotplug IO port
- do not generate SMI AML if CPU hotplug SMI feature hasn't been negotiated

---
 hw/acpi/cpu.c | 156 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 129 insertions(+), 27 deletions(-)
hw/acpi/cpu.c +124 -26
index 3d6a500fb7..1283972001 100644
@@ -14,6 +14,8 @@
 #define ACPI_CPU_CMD_DATA_OFFSET_RW 8
 #define ACPI_CPU_CMD_DATA2_OFFSET_R 0
 
+#define OVMF_CPUHP_SMI_CMD 4
+
 enum {
     CPHP_GET_NEXT_CPU_WITH_EVENT_CMD = 0,
     CPHP_OST_EVENT_CMD = 1,
@@ -321,6 +323,7 @@ const VMStateDescription vmstate_cpu_hotplug = {
 #define CPU_NOTIFY_METHOD "CTFY"
 #define CPU_EJECT_METHOD  "CEJ0"
 #define CPU_OST_METHOD    "COST"
+#define CPU_ADDED_LIST    "CNEW"
 
 #define CPU_ENABLED       "CPEN"
 #define CPU_SELECTOR      "CSEL"
@@ -465,42 +468,141 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
 
         method = aml_method(CPU_SCAN_METHOD, 0, AML_SERIALIZED);
         {
+            const uint8_t max_cpus_per_pass = 255;
             Aml *else_ctx;
-            Aml *while_ctx;
+            Aml *while_ctx, *while_ctx2;
             Aml *has_event = aml_local(0);
             Aml *dev_chk = aml_int(1);
             Aml *eject_req = aml_int(3);
             Aml *next_cpu_cmd = aml_int(CPHP_GET_NEXT_CPU_WITH_EVENT_CMD);
+            Aml *num_added_cpus = aml_local(1);
+            Aml *cpu_idx = aml_local(2);
+            Aml *uid = aml_local(3);
+            Aml *has_job = aml_local(4);
+            Aml *new_cpus = aml_name(CPU_ADDED_LIST);
 
             aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(one, has_event));
-            while_ctx = aml_while(aml_equal(has_event, one));
+
+            /*
+             * Windows versions newer than XP (including Windows 10/Windows
+             * Server 2019), do support* VarPackageOp but, it is cripled to hold
+             * the same elements number as old PackageOp.
+             * For compatibility with Windows XP (so it won't crash) use ACPI1.0
+             * PackageOp which can hold max 255 elements.
+             *
+             * use named package as old Windows don't support it in local var
+             */
+            aml_append(method, aml_name_decl(CPU_ADDED_LIST,
+                                             aml_package(max_cpus_per_pass)));
+
+            aml_append(method, aml_store(zero, uid));
+            aml_append(method, aml_store(one, has_job));
+            /*
+             * CPU_ADDED_LIST can hold limited number of elements, outer loop
+             * allows to process CPUs in batches which let us to handle more
+             * CPUs than CPU_ADDED_LIST can hold.
+             */
+            while_ctx2 = aml_while(aml_equal(has_job, one));
             {
-                 /* clear loop exit condition, ins_evt/rm_evt checks
-                  * will set it to 1 while next_cpu_cmd returns a CPU
-                  * with events */
-                 aml_append(while_ctx, aml_store(zero, has_event));
-                 aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
-                 ifctx = aml_if(aml_equal(ins_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, dev_chk));
-                     aml_append(ifctx, aml_store(one, ins_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(while_ctx, ifctx);
-                 else_ctx = aml_else();
-                 ifctx = aml_if(aml_equal(rm_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, eject_req));
-                     aml_append(ifctx, aml_store(one, rm_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(else_ctx, ifctx);
-                 aml_append(while_ctx, else_ctx);
+                aml_append(while_ctx2, aml_store(zero, has_job));
+
+                aml_append(while_ctx2, aml_store(one, has_event));
+                aml_append(while_ctx2, aml_store(zero, num_added_cpus));
+
+                /*
+                 * Scan CPUs, till there are CPUs with events or
+                 * CPU_ADDED_LIST capacity is exhausted
+                 */
+                while_ctx = aml_while(aml_land(aml_equal(has_event, one),
+                                      aml_lless(uid, aml_int(arch_ids->len))));
+                {
+                     /*
+                      * clear loop exit condition, ins_evt/rm_evt checks will
+                      * set it to 1 while next_cpu_cmd returns a CPU with events
+                      */
+                     aml_append(while_ctx, aml_store(zero, has_event));
+
+                     aml_append(while_ctx, aml_store(uid, cpu_selector));
+                     aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
+
+                     /*
+                      * wrap around case, scan is complete, exit loop.
+                      * It happens since events are not cleared in scan loop,
+                      * so next_cpu_cmd continues to find already processed CPUs
+                      */
+                     ifctx = aml_if(aml_lless(cpu_data, uid));
+                     {
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     /*
+                      * if CPU_ADDED_LIST is full, exit inner loop and process
+                      * collected CPUs
+                      */
+                     ifctx = aml_if(
+                         aml_equal(num_added_cpus, aml_int(max_cpus_per_pass)));
+                     {
+                         aml_append(ifctx, aml_store(one, has_job));
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     aml_append(while_ctx, aml_store(cpu_data, uid));
+                     ifctx = aml_if(aml_equal(ins_evt, one));
+                     {
+                         /* cache added CPUs to Notify/Wakeup later */
+                         aml_append(ifctx, aml_store(uid,
+                             aml_index(new_cpus, num_added_cpus)));
+                         aml_append(ifctx, aml_increment(num_added_cpus));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(while_ctx, ifctx);
+                     else_ctx = aml_else();
+                     ifctx = aml_if(aml_equal(rm_evt, one));
+                     {
+                         aml_append(ifctx,
+                             aml_call2(CPU_NOTIFY_METHOD, uid, eject_req));
+                         aml_append(ifctx, aml_store(one, rm_evt));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(else_ctx, ifctx);
+                     aml_append(while_ctx, else_ctx);
+                     aml_append(while_ctx, aml_increment(uid));
+                }
+                aml_append(while_ctx2, while_ctx);
+
+                /*
+                 * in case FW negotiated ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT,
+                 * make upcall to FW, so it can pull in new CPUs before
+                 * OS is notified and wakes them up
+                 */
+                if (opts.smi_path) {
+                    ifctx = aml_if(aml_lgreater(num_added_cpus, zero));
+                    {
+                        aml_append(ifctx, aml_store(aml_int(OVMF_CPUHP_SMI_CMD),
+                            aml_name("%s", opts.smi_path)));
+                    }
+                    aml_append(while_ctx2, ifctx);
+                }
+
+                /* Notify OSPM about new CPUs and clear insert events */
+                aml_append(while_ctx2, aml_store(zero, cpu_idx));
+                while_ctx = aml_while(aml_lless(cpu_idx, num_added_cpus));
+                {
+                    aml_append(while_ctx,
+                        aml_store(aml_derefof(aml_index(new_cpus, cpu_idx)),
+                                  uid));
+                    aml_append(while_ctx,
+                        aml_call2(CPU_NOTIFY_METHOD, uid, dev_chk));
+                    aml_append(while_ctx, aml_store(uid, aml_debug()));
+                    aml_append(while_ctx, aml_store(uid, cpu_selector));

hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 608

Quoted 10 lines
hw/acpi/cpu.c +5 -1
+                    aml_append(while_ctx, aml_store(one, ins_evt));
+                    aml_append(while_ctx, aml_increment(cpu_idx));
+                }
+                aml_append(while_ctx2, while_ctx);
             }
-            aml_append(method, while_ctx);
+            aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));
         }
         aml_append(cpus_dev, method);

Here's the ASL decompiled, and using the meaningful local variable names (and 8 possible VCPUs):

   1              Method (CSCN, 0, Serialized)
   2              {
   3                  Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
   4                  Name (CNEW, Package (0xFF){})
   5                  Local_Uid = Zero
   6                  Local_HasJob = One
   7                  While ((Local_HasJob == One))
   8                  {
   9                      Local_HasJob = Zero
  10                      Local_HasEvent = One
  11                      Local_NumAddedCpus = Zero
  12                      While (((Local_HasEvent == One) && (Local_Uid < 0x08)))
  13                      {
  14                          Local_HasEvent = Zero
  15                          \_SB.PCI0.PRES.CSEL = Local_Uid
  16                          \_SB.PCI0.PRES.CCMD = Zero
  17                          If ((\_SB.PCI0.PRES.CDAT < Local_Uid))
  18                          {
  19                              Break
  20                          }
  21
  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
  27
  28                          Local_Uid = \_SB.PCI0.PRES.CDAT
  29                          If ((\_SB.PCI0.PRES.CINS == One))
  30                          {
  31                              CNEW [Local_NumAddedCpus] = Local_Uid
  32                              Local_NumAddedCpus++
  33                              Local_HasEvent = One
  34                          }
  35                          ElseIf ((\_SB.PCI0.PRES.CRMV == One))
  36                          {
  37                              CTFY (Local_Uid, 0x03)
  38                              \_SB.PCI0.PRES.CRMV = One
  39                              Local_HasEvent = One
  40                          }
  41
  42                          Local_Uid++
  43                      }
  44
  45                      If ((Local_NumAddedCpus > Zero))
  46                      {
  47                          \_SB.PCI0.SMI0.SMIC = 0x04
  48                      }
  49
  50                      Local_CpuIdx = Zero
  51                      While ((Local_CpuIdx < Local_NumAddedCpus))
  52                      {
  53                          Local_Uid = DerefOf (CNEW [Local_CpuIdx])
  54                          CTFY (Local_Uid, One)
  55                          Debug = Local_Uid
  56                          \_SB.PCI0.PRES.CSEL = Local_Uid
  57                          \_SB.PCI0.PRES.CINS = One
  58                          Local_CpuIdx++
  59                      }
  60                  }
  61
  62                  Release (\_SB.PCI0.PRES.CPLK)
  63              }

When we take the Break on line 25, then:

(a) on line 25, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1] + 1

(b) on line 60, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1]

This means that, when we write Local_Uid to CSEL on line 15 again, then:

- we effectively re-investigate the last-cached CPU (with selector value CNEW[Local_NumAddedCpus - 1])

- rather than resuming the scanning right after it -- that is, with selector value (CNEW[Local_NumAddedCpus - 1] + 1) --, in the spirit of line 42.

My question is: is this "rewind" intentional?

Now, I don't see a functionality problem with this, as on line 57, we clear the pending insert event for the last-cached CPU, so when we re-check it, the "get pending" command will simply seek past it.

But I'd like to understand if this is *precisely* your intent, or if it's an oversight and it just ends up working OK.

Basically my question is whether we should add, on top:

cscn.v5.incr 2020-09-07 16:52:22.133843710 +0200 line 66

Quoted 13 lines
cscn.v5.incr 2020-09-07 16:52:22.133843710 +0200 renamed from cscn.v5 2020-09-07 15:02:13.401663487 +0200 +4 -0
@@ -57,6 +57,10 @@
                         \_SB.PCI0.PRES.CINS = One
                         Local_CpuIdx++
                     }
+
+                    if ((Local_HasJob == One)) {
+                        Local_Uid++
+                    }
                 }
 
                 Release (\_SB.PCI0.PRES.CPLK)

If not -- that is, the currently proposed patch is intentional --, then I think we should add a comment, about the effective "rewind" being intentional & okay.

(Note: it's certainly valid and necessary to re-write CSEL on line 15 after raising the SMI on line 47; the question is not whether we should or should not re-write CSEL (we must!), but the specific value that we write to CSEL.)

So:

- If the outer loop body is entered only once, then the patch looks fine, from both the review side, and the testing side (I tested it with 4-8 possible VCPUs).

- If the outer loop body is entered twice or more, then from the review side, please my question above. From the testing side: do you have an environment where I could test this with OVMF?

(I expect it to work OK. Upon the first SMI, the firmware will likely pick up more VCPUs than what's in CNEW. But edk2 commit 020bb4b46d6f ("OvmfPkg/CpuHotplugSmm: fix CPU hotplug race just before SMI broadcast", 2020-08-27) should deal with that.)

Hmm, actually, there's no need for a special environment: I can patch QEMU and lower "max_cpus_per_pass" to something small, such as "3" or whatever, for testing the outer loop multiple times. But first I'd like to know your thoughts on the "rewind".

Thanks!
Laszlo

#14 lore raw

Re: [PATCH v5 09/10] x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

Quoted 330 lines · On Mon, 7 Sep 2020 17:17:52 +0200 Laszlo Ersek <[email protected]> wrote:

Hi Igor,

Quoted 230 lines · Igor Mammedov

In case firmware has negotiated CPU hotplug SMI feature, generate AML to describe SMI IO port region and send SMI to firmware on each CPU hotplug SCI in case new CPUs were hotplugged.

Since new CPUs can be hotplugged while CPU_SCAN_METHOD is running we can't send SMI before new CPUs are fetched from QEMU as it could cause sending Notify to a CPU that firmware hasn't seen yet. So fetch new CPUs into local cache first, then send SMI and after that send Notify events to cached CPUs. This should ensure that Notify is sent only to CPUs which were processed by firmware first.
Any CPUs that were hotplugged after caching will be processed by the next CPU_SCAN_METHOD, when pending SCI is handled.

---
v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements so process CPUs in batches)
- (Laszlo Ersek <[email protected]>)
- fix off-by-one in package length
- fix not selecting CPU before clearing insert event
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero)
- split off in separate patches:
- making smi_negotiated_features a property
- introduction of AcpiPmInfo.smi_on_cpuhp
- introduction of PCI0.SMI0 ACPI device
v2:
- clear insert event after firmware has returned
control from SMI. (Laszlo Ersek <[email protected]>)
v1:
- make sure that Notify is sent only to CPUs seen by FW
- (Laszlo Ersek <[email protected]>)
- use macro instead of x-smi-negotiated-features
- style fixes
- reserve whole SMI block (0xB2, 0xB3)
v0:
- s/aml_string/aml_eisaid/
/fixes Windows BSOD, on nonsense value/ (Laszlo Ersek <[email protected]>)
- put SMI device under PCI0 like the rest of hotplug IO port
- do not generate SMI AML if CPU hotplug SMI feature hasn't been negotiated

---
 hw/acpi/cpu.c | 156 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 129 insertions(+), 27 deletions(-)
hw/acpi/cpu.c +124 -26
index 3d6a500fb7..1283972001 100644
@@ -14,6 +14,8 @@
 #define ACPI_CPU_CMD_DATA_OFFSET_RW 8
 #define ACPI_CPU_CMD_DATA2_OFFSET_R 0
 
+#define OVMF_CPUHP_SMI_CMD 4
+
 enum {
     CPHP_GET_NEXT_CPU_WITH_EVENT_CMD = 0,
     CPHP_OST_EVENT_CMD = 1,
@@ -321,6 +323,7 @@ const VMStateDescription vmstate_cpu_hotplug = {
 #define CPU_NOTIFY_METHOD "CTFY"
 #define CPU_EJECT_METHOD  "CEJ0"
 #define CPU_OST_METHOD    "COST"
+#define CPU_ADDED_LIST    "CNEW"
 
 #define CPU_ENABLED       "CPEN"
 #define CPU_SELECTOR      "CSEL"
@@ -465,42 +468,141 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
 
         method = aml_method(CPU_SCAN_METHOD, 0, AML_SERIALIZED);
         {
+            const uint8_t max_cpus_per_pass = 255;
             Aml *else_ctx;
-            Aml *while_ctx;
+            Aml *while_ctx, *while_ctx2;
             Aml *has_event = aml_local(0);
             Aml *dev_chk = aml_int(1);
             Aml *eject_req = aml_int(3);
             Aml *next_cpu_cmd = aml_int(CPHP_GET_NEXT_CPU_WITH_EVENT_CMD);
+            Aml *num_added_cpus = aml_local(1);
+            Aml *cpu_idx = aml_local(2);
+            Aml *uid = aml_local(3);
+            Aml *has_job = aml_local(4);
+            Aml *new_cpus = aml_name(CPU_ADDED_LIST);
 
             aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
-            aml_append(method, aml_store(one, has_event));
-            while_ctx = aml_while(aml_equal(has_event, one));
+
+            /*
+             * Windows versions newer than XP (including Windows 10/Windows
+             * Server 2019), do support* VarPackageOp but, it is cripled to hold
+             * the same elements number as old PackageOp.
+             * For compatibility with Windows XP (so it won't crash) use ACPI1.0
+             * PackageOp which can hold max 255 elements.
+             *
+             * use named package as old Windows don't support it in local var
+             */
+            aml_append(method, aml_name_decl(CPU_ADDED_LIST,
+                                             aml_package(max_cpus_per_pass)));
+
+            aml_append(method, aml_store(zero, uid));
+            aml_append(method, aml_store(one, has_job));
+            /*
+             * CPU_ADDED_LIST can hold limited number of elements, outer loop
+             * allows to process CPUs in batches which let us to handle more
+             * CPUs than CPU_ADDED_LIST can hold.
+             */
+            while_ctx2 = aml_while(aml_equal(has_job, one));
             {
-                 /* clear loop exit condition, ins_evt/rm_evt checks
-                  * will set it to 1 while next_cpu_cmd returns a CPU
-                  * with events */
-                 aml_append(while_ctx, aml_store(zero, has_event));
-                 aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
-                 ifctx = aml_if(aml_equal(ins_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, dev_chk));
-                     aml_append(ifctx, aml_store(one, ins_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(while_ctx, ifctx);
-                 else_ctx = aml_else();
-                 ifctx = aml_if(aml_equal(rm_evt, one));
-                 {
-                     aml_append(ifctx,
-                         aml_call2(CPU_NOTIFY_METHOD, cpu_data, eject_req));
-                     aml_append(ifctx, aml_store(one, rm_evt));
-                     aml_append(ifctx, aml_store(one, has_event));
-                 }
-                 aml_append(else_ctx, ifctx);
-                 aml_append(while_ctx, else_ctx);
+                aml_append(while_ctx2, aml_store(zero, has_job));
+
+                aml_append(while_ctx2, aml_store(one, has_event));
+                aml_append(while_ctx2, aml_store(zero, num_added_cpus));
+
+                /*
+                 * Scan CPUs, till there are CPUs with events or
+                 * CPU_ADDED_LIST capacity is exhausted
+                 */
+                while_ctx = aml_while(aml_land(aml_equal(has_event, one),
+                                      aml_lless(uid, aml_int(arch_ids->len))));
+                {
+                     /*
+                      * clear loop exit condition, ins_evt/rm_evt checks will
+                      * set it to 1 while next_cpu_cmd returns a CPU with events
+                      */
+                     aml_append(while_ctx, aml_store(zero, has_event));
+
+                     aml_append(while_ctx, aml_store(uid, cpu_selector));
+                     aml_append(while_ctx, aml_store(next_cpu_cmd, cpu_cmd));
+
+                     /*
+                      * wrap around case, scan is complete, exit loop.
+                      * It happens since events are not cleared in scan loop,
+                      * so next_cpu_cmd continues to find already processed CPUs
+                      */
+                     ifctx = aml_if(aml_lless(cpu_data, uid));
+                     {
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     /*
+                      * if CPU_ADDED_LIST is full, exit inner loop and process
+                      * collected CPUs
+                      */
+                     ifctx = aml_if(
+                         aml_equal(num_added_cpus, aml_int(max_cpus_per_pass)));
+                     {
+                         aml_append(ifctx, aml_store(one, has_job));
+                         aml_append(ifctx, aml_break());
+                     }
+                     aml_append(while_ctx, ifctx);
+
+                     aml_append(while_ctx, aml_store(cpu_data, uid));
+                     ifctx = aml_if(aml_equal(ins_evt, one));
+                     {
+                         /* cache added CPUs to Notify/Wakeup later */
+                         aml_append(ifctx, aml_store(uid,
+                             aml_index(new_cpus, num_added_cpus)));
+                         aml_append(ifctx, aml_increment(num_added_cpus));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(while_ctx, ifctx);
+                     else_ctx = aml_else();
+                     ifctx = aml_if(aml_equal(rm_evt, one));
+                     {
+                         aml_append(ifctx,
+                             aml_call2(CPU_NOTIFY_METHOD, uid, eject_req));
+                         aml_append(ifctx, aml_store(one, rm_evt));
+                         aml_append(ifctx, aml_store(one, has_event));
+                     }
+                     aml_append(else_ctx, ifctx);
+                     aml_append(while_ctx, else_ctx);
+                     aml_append(while_ctx, aml_increment(uid));
+                }
+                aml_append(while_ctx2, while_ctx);
+
+                /*
+                 * in case FW negotiated ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT,
+                 * make upcall to FW, so it can pull in new CPUs before
+                 * OS is notified and wakes them up
+                 */
+                if (opts.smi_path) {
+                    ifctx = aml_if(aml_lgreater(num_added_cpus, zero));
+                    {
+                        aml_append(ifctx, aml_store(aml_int(OVMF_CPUHP_SMI_CMD),
+                            aml_name("%s", opts.smi_path)));
+                    }
+                    aml_append(while_ctx2, ifctx);
+                }
+
+                /* Notify OSPM about new CPUs and clear insert events */
+                aml_append(while_ctx2, aml_store(zero, cpu_idx));
+                while_ctx = aml_while(aml_lless(cpu_idx, num_added_cpus));
+                {
+                    aml_append(while_ctx,
+                        aml_store(aml_derefof(aml_index(new_cpus, cpu_idx)),
+                                  uid));
+                    aml_append(while_ctx,
+                        aml_call2(CPU_NOTIFY_METHOD, uid, dev_chk));
+                    aml_append(while_ctx, aml_store(uid, aml_debug()));
+                    aml_append(while_ctx, aml_store(uid, cpu_selector));

hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 608

Quoted 10 lines
hw/acpi/cpu.c +5 -1
+                    aml_append(while_ctx, aml_store(one, ins_evt));
+                    aml_append(while_ctx, aml_increment(cpu_idx));
+                }
+                aml_append(while_ctx2, while_ctx);
             }
-            aml_append(method, while_ctx);
+            aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));
         }
         aml_append(cpus_dev, method);

Here's the ASL decompiled, and using the meaningful local variable names (and 8 possible VCPUs):

   1              Method (CSCN, 0, Serialized)
   2              {
   3                  Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
   4                  Name (CNEW, Package (0xFF){})
   5                  Local_Uid = Zero
   6                  Local_HasJob = One
   7                  While ((Local_HasJob == One))
   8                  {
   9                      Local_HasJob = Zero
  10                      Local_HasEvent = One
  11                      Local_NumAddedCpus = Zero
  12                      While (((Local_HasEvent == One) && (Local_Uid < 0x08)))
  13                      {
  14                          Local_HasEvent = Zero
  15                          \_SB.PCI0.PRES.CSEL = Local_Uid
  16                          \_SB.PCI0.PRES.CCMD = Zero
  17                          If ((\_SB.PCI0.PRES.CDAT < Local_Uid))
  18                          {
  19                              Break
  20                          }
  21
  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
  27
  28                          Local_Uid = \_SB.PCI0.PRES.CDAT
  29                          If ((\_SB.PCI0.PRES.CINS == One))
  30                          {
  31                              CNEW [Local_NumAddedCpus] = Local_Uid
  32                              Local_NumAddedCpus++
  33                              Local_HasEvent = One
  34                          }
  35                          ElseIf ((\_SB.PCI0.PRES.CRMV == One))
  36                          {
  37                              CTFY (Local_Uid, 0x03)
  38                              \_SB.PCI0.PRES.CRMV = One
  39                              Local_HasEvent = One
  40                          }
  41
  42                          Local_Uid++
  43                      }
  44
  45                      If ((Local_NumAddedCpus > Zero))
  46                      {
  47                          \_SB.PCI0.SMI0.SMIC = 0x04
  48                      }
  49
  50                      Local_CpuIdx = Zero
  51                      While ((Local_CpuIdx < Local_NumAddedCpus))
  52                      {
  53                          Local_Uid = DerefOf (CNEW [Local_CpuIdx])
  54                          CTFY (Local_Uid, One)
  55                          Debug = Local_Uid
  56                          \_SB.PCI0.PRES.CSEL = Local_Uid
  57                          \_SB.PCI0.PRES.CINS = One
  58                          Local_CpuIdx++
  59                      }
  60                  }
  61
  62                  Release (\_SB.PCI0.PRES.CPLK)
  63              }

When we take the Break on line 25, then:

(a) on line 25, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1] + 1

(b) on line 60, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1]

This means that, when we write Local_Uid to CSEL on line 15 again, then:

- we effectively re-investigate the last-cached CPU (with selector value CNEW[Local_NumAddedCpus - 1])

- rather than resuming the scanning right after it -- that is, with selector value (CNEW[Local_NumAddedCpus - 1] + 1) --, in the spirit of line 42.

Quoted 8 lines

My question is: is this "rewind" intentional?

Now, I don't see a functionality problem with this, as on line 57, we clear the pending insert event for the last-cached CPU, so when we re-check it, the "get pending" command will simply seek past it.

But I'd like to understand if this is *precisely* your intent, or if it's an oversight and it just ends up working OK.

it's the later (it should not have any adverse effects) so I didn't care much about restarting from the last processed CPU.

how about moving

  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }

right after
40 }
41
42 Local_Uid++

instead of adding extra 'if' at the end of outer loop?

Quoted 32 lines

Basically my question is whether we should add, on top:

cscn.v5.incr 2020-09-07 16:52:22.133843710 +0200 line 66

Quoted 13 lines
cscn.v5.incr 2020-09-07 16:52:22.133843710 +0200 renamed from cscn.v5 2020-09-07 15:02:13.401663487 +0200 +4 -0
@@ -57,6 +57,10 @@
                         \_SB.PCI0.PRES.CINS = One
                         Local_CpuIdx++
                     }
+
+                    if ((Local_HasJob == One)) {
+                        Local_Uid++
+                    }
                 }
 
                 Release (\_SB.PCI0.PRES.CPLK)  

If not -- that is, the currently proposed patch is intentional --, then I think we should add a comment, about the effective "rewind" being intentional & okay.

(Note: it's certainly valid and necessary to re-write CSEL on line 15 after raising the SMI on line 47; the question is not whether we should or should not re-write CSEL (we must!), but the specific value that we write to CSEL.)

So:

- If the outer loop body is entered only once, then the patch looks fine, from both the review side, and the testing side (I tested it with 4-8 possible VCPUs).

Quoted 8 lines

- If the outer loop body is entered twice or more, then from the review side, please my question above. From the testing side: do you have an environment where I could test this with OVMF?

(I expect it to work OK. Upon the first SMI, the firmware will likely pick up more VCPUs than what's in CNEW. But edk2 commit 020bb4b46d6f ("OvmfPkg/CpuHotplugSmm: fix CPU hotplug race just before SMI broadcast", 2020-08-27) should deal with that.)

it should work, as firmware doesn't have to jump over hoops to accomodate Windows quirks.

Quoted 4 lines

Hmm, actually, there's no need for a special environment: I can patch QEMU and lower "max_cpus_per_pass" to something small, such as "3" or whatever, for testing the outer loop multiple times. But first I'd like to know your thoughts on the "rewind".

modulo OVMF, I've tested both:
- hacking max_cpus_per_pass to simulate multiple passes of the outer loop
- with maxcpus=288 to cross 255 thresold (2 passes of outer loop), to check that WS2019 is still working.

Quoted 4 lines

Thanks!
Laszlo

Reviewed-by
#15 lore raw

Re: [PATCH v5 09/10] x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

Quoted 105 lines · Igor Mammedov
Quoted 83 lines · On Mon, 7 Sep 2020 17:17:52 +0200 Laszlo Ersek <[email protected]> wrote:
   1              Method (CSCN, 0, Serialized)
   2              {
   3                  Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
   4                  Name (CNEW, Package (0xFF){})
   5                  Local_Uid = Zero
   6                  Local_HasJob = One
   7                  While ((Local_HasJob == One))
   8                  {
   9                      Local_HasJob = Zero
  10                      Local_HasEvent = One
  11                      Local_NumAddedCpus = Zero
  12                      While (((Local_HasEvent == One) && (Local_Uid < 0x08)))
  13                      {
  14                          Local_HasEvent = Zero
  15                          \_SB.PCI0.PRES.CSEL = Local_Uid
  16                          \_SB.PCI0.PRES.CCMD = Zero
  17                          If ((\_SB.PCI0.PRES.CDAT < Local_Uid))
  18                          {
  19                              Break
  20                          }
  21
  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
  27
  28                          Local_Uid = \_SB.PCI0.PRES.CDAT
  29                          If ((\_SB.PCI0.PRES.CINS == One))
  30                          {
  31                              CNEW [Local_NumAddedCpus] = Local_Uid
  32                              Local_NumAddedCpus++
  33                              Local_HasEvent = One
  34                          }
  35                          ElseIf ((\_SB.PCI0.PRES.CRMV == One))
  36                          {
  37                              CTFY (Local_Uid, 0x03)
  38                              \_SB.PCI0.PRES.CRMV = One
  39                              Local_HasEvent = One
  40                          }
  41
  42                          Local_Uid++
  43                      }
  44
  45                      If ((Local_NumAddedCpus > Zero))
  46                      {
  47                          \_SB.PCI0.SMI0.SMIC = 0x04
  48                      }
  49
  50                      Local_CpuIdx = Zero
  51                      While ((Local_CpuIdx < Local_NumAddedCpus))
  52                      {
  53                          Local_Uid = DerefOf (CNEW [Local_CpuIdx])
  54                          CTFY (Local_Uid, One)
  55                          Debug = Local_Uid
  56                          \_SB.PCI0.PRES.CSEL = Local_Uid
  57                          \_SB.PCI0.PRES.CINS = One
  58                          Local_CpuIdx++
  59                      }
  60                  }
  61
  62                  Release (\_SB.PCI0.PRES.CPLK)
  63              }

When we take the Break on line 25, then:

(a) on line 25, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1] + 1

(b) on line 60, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1]

This means that, when we write Local_Uid to CSEL on line 15 again, then:

- we effectively re-investigate the last-cached CPU (with selector value CNEW[Local_NumAddedCpus - 1])

- rather than resuming the scanning right after it -- that is, with selector value (CNEW[Local_NumAddedCpus - 1] + 1) --, in the spirit of line 42.

Quoted 8 lines

My question is: is this "rewind" intentional?

Now, I don't see a functionality problem with this, as on line 57, we clear the pending insert event for the last-cached CPU, so when we re-check it, the "get pending" command will simply seek past it.

But I'd like to understand if this is *precisely* your intent, or if it's an oversight and it just ends up working OK.

it's the later (it should not have any adverse effects) so I didn't care much about restarting from the last processed CPU.

how about moving

  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
Quoted 6 lines

right after
40 }
41
42 Local_Uid++

instead of adding extra 'if' at the end of outer loop?

That only seems to save a CSEL write on line 15, during the first iteration of the outer loop. And we would still re-select the last selector from CNEW, in the second iteration of the outer loop.

But, again, there's no bug; I just wanted to understand your intent.

Can you please squash the following patch:

Quoted 10 lines
hw/acpi/cpu.c +2 -0
index 12839720018e..8dd4d8ebbf55 100644
@@ -601,6 +601,15 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
                     aml_append(while_ctx, aml_increment(cpu_idx));
                 }
                 aml_append(while_ctx2, while_ctx);
+                /*
+                 * If another batch is needed, then it will resume scanning

hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 615

Quoted 10 lines
hw/acpi/cpu.c +7 -0
+                 * exactly at -- and not after -- the last CPU that's currently
+                 * in CPU_ADDED_LIST. In other words, the last CPU in
+                 * CPU_ADDED_LIST is going to be re-checked. That's OK: we've
+                 * just cleared the insert event for *all* CPUs in
+                 * CPU_ADDED_LIST, including the last one. So the scan will
+                 * simply seek past it.
+                 */
             }
             aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));

With that:

I'll also follow up with test results for this patch (meaning a lowered "max_cpus_per_pass").

Thanks!
Laszlo

Tested-by
#16 lore raw

Re: [PATCH v5 09/10] x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

Quoted 144 lines · Laszlo Ersek
Quoted 105 lines · Igor Mammedov
Quoted 83 lines · On Mon, 7 Sep 2020 17:17:52 +0200 Laszlo Ersek <[email protected]> wrote:
   1              Method (CSCN, 0, Serialized)
   2              {
   3                  Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
   4                  Name (CNEW, Package (0xFF){})
   5                  Local_Uid = Zero
   6                  Local_HasJob = One
   7                  While ((Local_HasJob == One))
   8                  {
   9                      Local_HasJob = Zero
  10                      Local_HasEvent = One
  11                      Local_NumAddedCpus = Zero
  12                      While (((Local_HasEvent == One) && (Local_Uid < 0x08)))
  13                      {
  14                          Local_HasEvent = Zero
  15                          \_SB.PCI0.PRES.CSEL = Local_Uid
  16                          \_SB.PCI0.PRES.CCMD = Zero
  17                          If ((\_SB.PCI0.PRES.CDAT < Local_Uid))
  18                          {
  19                              Break
  20                          }
  21
  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
  27
  28                          Local_Uid = \_SB.PCI0.PRES.CDAT
  29                          If ((\_SB.PCI0.PRES.CINS == One))
  30                          {
  31                              CNEW [Local_NumAddedCpus] = Local_Uid
  32                              Local_NumAddedCpus++
  33                              Local_HasEvent = One
  34                          }
  35                          ElseIf ((\_SB.PCI0.PRES.CRMV == One))
  36                          {
  37                              CTFY (Local_Uid, 0x03)
  38                              \_SB.PCI0.PRES.CRMV = One
  39                              Local_HasEvent = One
  40                          }
  41
  42                          Local_Uid++
  43                      }
  44
  45                      If ((Local_NumAddedCpus > Zero))
  46                      {
  47                          \_SB.PCI0.SMI0.SMIC = 0x04
  48                      }
  49
  50                      Local_CpuIdx = Zero
  51                      While ((Local_CpuIdx < Local_NumAddedCpus))
  52                      {
  53                          Local_Uid = DerefOf (CNEW [Local_CpuIdx])
  54                          CTFY (Local_Uid, One)
  55                          Debug = Local_Uid
  56                          \_SB.PCI0.PRES.CSEL = Local_Uid
  57                          \_SB.PCI0.PRES.CINS = One
  58                          Local_CpuIdx++
  59                      }
  60                  }
  61
  62                  Release (\_SB.PCI0.PRES.CPLK)
  63              }

When we take the Break on line 25, then:

(a) on line 25, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1] + 1

(b) on line 60, the following equality holds:

Local_Uid == CNEW[Local_NumAddedCpus - 1]

This means that, when we write Local_Uid to CSEL on line 15 again, then:

- we effectively re-investigate the last-cached CPU (with selector value CNEW[Local_NumAddedCpus - 1])

- rather than resuming the scanning right after it -- that is, with selector value (CNEW[Local_NumAddedCpus - 1] + 1) --, in the spirit of line 42.

Quoted 8 lines

My question is: is this "rewind" intentional?

Now, I don't see a functionality problem with this, as on line 57, we clear the pending insert event for the last-cached CPU, so when we re-check it, the "get pending" command will simply seek past it.

But I'd like to understand if this is *precisely* your intent, or if it's an oversight and it just ends up working OK.

it's the later (it should not have any adverse effects) so I didn't care much about restarting from the last processed CPU.

how about moving

  22                          If ((Local_NumAddedCpus == 0xFF))
  23                          {
  24                              Local_HasJob = One
  25                              Break
  26                          }
Quoted 6 lines

right after
40 }
41
42 Local_Uid++

instead of adding extra 'if' at the end of outer loop?

That only seems to save a CSEL write on line 15, during the first iteration of the outer loop. And we would still re-select the last selector from CNEW, in the second iteration of the outer loop.

But, again, there's no bug; I just wanted to understand your intent.

Can you please squash the following patch:

Quoted 10 lines
hw/acpi/cpu.c +2 -0
index 12839720018e..8dd4d8ebbf55 100644
@@ -601,6 +601,15 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
                     aml_append(while_ctx, aml_increment(cpu_idx));
                 }
                 aml_append(while_ctx2, while_ctx);
+                /*
+                 * If another batch is needed, then it will resume scanning

hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 615

Quoted 10 lines
hw/acpi/cpu.c +7 -0
+                 * exactly at -- and not after -- the last CPU that's currently
+                 * in CPU_ADDED_LIST. In other words, the last CPU in
+                 * CPU_ADDED_LIST is going to be re-checked. That's OK: we've
+                 * just cleared the insert event for *all* CPUs in
+                 * CPU_ADDED_LIST, including the last one. So the scan will
+                 * simply seek past it.
+                 */
             }
             aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));

With that:

Quoted 4 lines

I'll also follow up with test results for this patch (meaning a lowered "max_cpus_per_pass").

#17 lore raw

PATCH v5 9/10 fixup! x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

In reply to Igor Mammedov

Add comment explaining why while_ctx2 restarts from the last processed CPU.

---
 hw/acpi/cpu.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/acpi/cpu.c +9 -0
index 1283972001..8dd4d8ebbf 100644
@@ -601,6 +601,15 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
                     aml_append(while_ctx, aml_increment(cpu_idx));
                 }
                 aml_append(while_ctx2, while_ctx);
+                /*
+                 * If another batch is needed, then it will resume scanning
+                 * exactly at -- and not after -- the last CPU that's currently
+                 * in CPU_ADDED_LIST. In other words, the last CPU in
+                 * CPU_ADDED_LIST is going to be re-checked. That's OK: we've
+                 * just cleared the insert event for *all* CPUs in
+                 * CPU_ADDED_LIST, including the last one. So the scan will
+                 * simply seek past it.
+                 */
             }
             aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));
Signature · 1 line
2.27.0
#18 lore raw

Re: [PATCH v5 9/10] fixup! x68: acpi: trigger SMI before sending hotplug Notify event to OSPM

Quoted 20 lines · Igor Mammedov

Add comment explaining why while_ctx2 restarts from the last processed CPU.

---
 hw/acpi/cpu.c | 9 +++++++++
 1 file changed, 9 insertions(+)
hw/acpi/cpu.c +2 -0
index 1283972001..8dd4d8ebbf 100644
@@ -601,6 +601,15 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
                     aml_append(while_ctx, aml_increment(cpu_idx));
                 }
                 aml_append(while_ctx2, while_ctx);
+                /*
+                 * If another batch is needed, then it will resume scanning

hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 615

Quoted 10 lines
hw/acpi/cpu.c +7 -0
+                 * exactly at -- and not after -- the last CPU that's currently
+                 * in CPU_ADDED_LIST. In other words, the last CPU in
+                 * CPU_ADDED_LIST is going to be re-checked. That's OK: we've
+                 * just cleared the insert event for *all* CPUs in
+                 * CPU_ADDED_LIST, including the last one. So the scan will
+                 * simply seek past it.
+                 */
             }
             aml_append(method, while_ctx2);
             aml_append(method, aml_release(ctrl_lock));

Thank you!
Laszlo

#19 lore raw

PATCH v5 10/10 tests: acpi: update acpi blobs with new AML

In reply to Igor Mammedov

here is diff against tests/data/acpi/q35/DSDT
for currently shipped ovmf binary.
(once firmware blob is updated, it will negotiate CPU hotplug feature which will ad extra hunk sending SMI and Q35 tests will need to be updated), but otherwise diff shows new CPU hotplug AML that is shared between q35 and pc machines.

             Method (CSCN, 0, Serialized)
             {
                 Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
-                Local0 = One
-                While ((Local0 == One))
-                {
-                    Local0 = Zero
-                    \_SB.PCI0.PRES.CCMD = Zero
-                    If ((\_SB.PCI0.PRES.CINS == One))
+                Name (CNEW, Package (0xFF){})
+                Local3 = Zero
+                Local4 = One
+                While ((Local4 == One))
+                {
+                    Local4 = Zero
+                    Local0 = One
+                    Local1 = Zero
+                    While (((Local0 == One) && (Local3 < One)))
                     {
-                        CTFY (\_SB.PCI0.PRES.CDAT, One)
-                        \_SB.PCI0.PRES.CINS = One
-                        Local0 = One
+                        Local0 = Zero
+                        \_SB.PCI0.PRES.CSEL = Local3
+                        \_SB.PCI0.PRES.CCMD = Zero
+                        If ((\_SB.PCI0.PRES.CDAT < Local3))
+                        {

+ Break
+ }
+
+ If ((Local1 == 0xFF))
+ {
+ Local4 = One
+ Break
+ }
+

+                        Local3 = \_SB.PCI0.PRES.CDAT
+                        If ((\_SB.PCI0.PRES.CINS == One))
+                        {
+                            CNEW [Local1] = Local3
+                            Local1++
+                            Local0 = One
+                        }
+                        ElseIf ((\_SB.PCI0.PRES.CRMV == One))
+                        {
+                            CTFY (Local3, 0x03)
+                            \_SB.PCI0.PRES.CRMV = One
+                            Local0 = One
+                        }
+
+                        Local3++
                     }

- ElseIf ((\_SB.PCI0.PRES.CRMV == One))
+
+ Local2 = Zero
+ While ((Local2 < Local1))

                     {
-                        CTFY (\_SB.PCI0.PRES.CDAT, 0x03)
-                        \_SB.PCI0.PRES.CRMV = One
-                        Local0 = One
+                        Local3 = DerefOf (CNEW [Local2])
+                        CTFY (Local3, One)
+                        Debug = Local3
+                        \_SB.PCI0.PRES.CSEL = Local3
+                        \_SB.PCI0.PRES.CINS = One
+                        Local2++
                     }
                 }
---
 tests/qtest/bios-tables-test-allowed-diff.h |  19 -------------------
 tests/data/acpi/pc/DSDT                     | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat            | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge              | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp                | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm             | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs             | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp               | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem             | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT                    | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat           | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge             | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp               | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm            | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt             | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp              | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64             | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem            | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis                | Bin 8283 -> 8409 bytes
 19 files changed, 19 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -19
index dba32d5613..dfb8523c8b 100644
@@ -1,20 +1 @@
 /* List of comma-separated changed AML files to ignore */
-"tests/data/acpi/pc/DSDT",
-"tests/data/acpi/q35/DSDT",
-"tests/data/acpi/q35/DSDT.tis",
-"tests/data/acpi/q35/DSDT.bridge",
-"tests/data/acpi/q35/DSDT.mmio64",
-"tests/data/acpi/q35/DSDT.ipmibt",
-"tests/data/acpi/q35/DSDT.cphp",
-"tests/data/acpi/q35/DSDT.memhp",
-"tests/data/acpi/q35/DSDT.numamem",
-"tests/data/acpi/q35/DSDT.dimmpxm",
-"tests/data/acpi/q35/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.bridge",
-"tests/data/acpi/pc/DSDT.ipmikcs",
-"tests/data/acpi/pc/DSDT.cphp",
-"tests/data/acpi/pc/DSDT.memhp",
-"tests/data/acpi/pc/DSDT.numamem",
-"tests/data/acpi/pc/DSDT.dimmpxm",
-"tests/data/acpi/pc/DSDT.acpihmat",
-"tests/data/acpi/pc/DSDT.acpihmat",
tests/data/acpi/pc/DSDT binary +0 -0
index b121bb5bc124be522e233516efb17cdc94de5a75..4ca46e5a2bdb1dfab79dd8630aeeb9a386d8b30e 100644
GIT binary patch
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
index b0dbb943f4cea83a5adde23aefa54f1678c560a1..35a74bce8cc152ecb615cb38c4b7f63c7c7d3ab3 100644
GIT binary patch
tests/data/acpi/pc/DSDT.bridge binary +0 -0
index 7b6c7a47875fc73b03fbe88807890f3867ddba1a..803d7a8e839ea8b7ac33c4490459ddaede584269 100644
GIT binary patch
tests/data/acpi/pc/DSDT.cphp binary +0 -0
index c0e8aa5b32d84f39e5d6c9a5024505f818707c12..8bab2f506409f2b025a63d8b91c7bfdaa931e626 100644
GIT binary patch
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
index 1649953b6cccb933e4a440dc56507dc9197c4a8a..e015b4594c96a6e0f34c0668e3383b9a91dff38e 100644
GIT binary patch
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
index 92748d49dcd418e4a734da47e8d5c0268aedfc29..ca6630e39f60ebd5c056f57c4c03fdb9d5467577 100644
GIT binary patch
tests/data/acpi/pc/DSDT.memhp binary +0 -0
index 4026772906e910af514beb76de6e4cca0bc2171b..43f4e114e2cc48c68c35af47303fa87c9255db40 100644
GIT binary patch
tests/data/acpi/pc/DSDT.numamem binary +0 -0
index 4d9ba337a82954af094e739b8a83467f89a37cc0..ba8f7e6c33f9eb0f7a080144fcb4a27d36aa04ae 100644
GIT binary patch
tests/data/acpi/q35/DSDT binary +0 -0
index bba8884073a27427b88ac0d733c9c87330a59366..d6c26940b1a68d4184f6f2335924099aa28b130a 100644
GIT binary patch
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
index 9cac92418b5fcc2767dc74603d599642b59623fe..2b67045d6add69574499b97d938cca01949231b4 100644
GIT binary patch
tests/data/acpi/q35/DSDT.bridge binary +0 -0
index f08b7245f59aad491fcaa60e2bab1085c369ea1c..0f6c9c68c81cddd2126eea8a7c336b8667202223 100644
GIT binary patch
tests/data/acpi/q35/DSDT.cphp binary +0 -0
index 57d859cef9fa16a8f125c4b338611c8472699f38..d7bedee7ff638f11b3bb84ef960364b409a49cce 100644
GIT binary patch
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
index 9d5bd5744e2ba2e0f6126c3aba0bb36af865e499..13e80ae2e5c7606a7260d4cb3ab776488d0697d6 100644
GIT binary patch
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
index 5cd11de6a8fe47324e5f922823a22746882f19f5..9a1b635dab776fb25e378a00e6ca0cadf9902c25 100644
GIT binary patch
tests/data/acpi/q35/DSDT.memhp binary +0 -0
index 05a7a73ec43130d5c3018bb462fd84981bfb151c..55ce4e2293624c2c0725c3bbaaa7ec29acfccfc9 100644
GIT binary patch
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
index efd3f1188f2b55da1514212d4be081a61c2a96e9..99b7b2ae4ba36b8ca7901626c1561d29100087d2 100644
GIT binary patch
tests/data/acpi/q35/DSDT.numamem binary +0 -0
index 1978b55f1255402bf9bade0b91150b5cb49789a4..2b2433cc13ec3110abbc8440a0b1ad8c487edb6c 100644
GIT binary patch
tests/data/acpi/q35/DSDT.tis binary +0 -0
index 638de3872673d17b1958497d0e62c83653de1602..dd06ee4c348930b0684827ca05747b4f65dbd6b2 100644
GIT binary patch
Signature · 1 line
2.27.0
#20 lore raw
In reply to Igor Mammedov
Quoted 30 lines · On Mon, 7 Sep 2020 07:23:38 -0400 Igor Mammedov <[email protected]> wrote:

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch
v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

Quoted 4 lines

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Michael,

Can you merge this along with Laszlo's
[PATCH 00/10] edk2: adopt the edk2-stable202008 release
via PCI tree, preferably in the same pull req.

Quoted 44 lines

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)
#21 lore raw
Quoted 38 lines · Igor Mammedov
Quoted 30 lines · On Mon, 7 Sep 2020 07:23:38 -0400 Igor Mammedov <[email protected]> wrote:

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch
v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

Quoted 4 lines

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Quoted 5 lines

Michael,

Can you merge this along with Laszlo's
[PATCH 00/10] edk2: adopt the edk2-stable202008 release
via PCI tree, preferably in the same pull req.

That would be very kind, thank you -- however, please give some time to Phil for reviewing the (rest of the) edk2 update series.

Cheers!
Laszlo

Quoted 47 lines
Quoted 46 lines

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)
#22 lore raw
In reply to Igor Mammedov
Quoted 16 lines · On Mon, 7 Sep 2020 07:23:38 -0400 Igor Mammedov <[email protected]> wrote:

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch

Quoted 8 lines

v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

Michael,

just saw your pull request which missed this series. Is there any plans to queue it for the next pull request?

Quoted 53 lines

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)
#23 lore raw
Quoted 28 lines · Igor Mammedov
Quoted 16 lines · On Mon, 7 Sep 2020 07:23:38 -0400 Igor Mammedov <[email protected]> wrote:

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch

Quoted 8 lines

v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

Quoted 4 lines

Michael,

just saw your pull request which missed this series. Is there any plans to queue it for the next pull request?

Oh.
You didn't Cc me on most patches so I assumed this is targeting some other tree. Sorry.
Will review and queue, thanks.

Quoted 55 lines
Quoted 55 lines

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)
#24 lore raw
Quoted 31 lines · On Mon, 21 Sep 2020 08:34:31 -0400 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 30 lines · Igor Mammedov
Quoted 16 lines · On Mon, 7 Sep 2020 07:23:38 -0400 Igor Mammedov <[email protected]> wrote:

v5:
- fix hotplug on Windows when there is more than 256 possible CPUs (Windows isn't able to handle VarPackage over 255 elements
so process CPUs in batches)
- fix off-by-one in package length (Laszlo)
- fix not selecting CPU before clearing insert event (Laszlo)
- use aml_lgreater() instead of aml_lnot(aml_equal(num_added_cpus, zero) (Laszlo)
- split 'x68: acpi: trigger SMI before sending hotplug Notify event to OSPM' in samller chunks (Laszlo)
- fix comment to match spec (Laszlo)
- reorder aml_lor() and aml_land() in header (Laszlo)
v4:
- fix 5.2 machine types so they won't apply pc_compat_5_1 (Laszlo)
v3:
- rebase on top of "[PATCH v2] hw: add compat machines for 5.2"
so apply that before this patch

Quoted 8 lines

v2:
- AML: clean is_inserted flag only after SMI callback
- make x-smi-cpu-hotunplug false by default
- massage error hint on not supported unplug
v1:
- fix typos and some phrases (Laszlo)
- add unplug check (Laszlo)
- redo AML scan logic to avoid race when adding multiple CPUs

Michael,

Quoted 7 lines
Quoted 2 lines

just saw your pull request which missed this series. Is there any plans to queue it for the next pull request?

Oh.
You didn't Cc me on most patches so I assumed this is targeting some other tree. Sorry.
Will review and queue, thanks.

Thanks,

Series doesn't apply anymore,
I've rebased fixing conflicts and resent it as v6.

Quoted 58 lines
Quoted 56 lines
Quoted 56 lines

CPU hotplug with Secure Boot was not really supported and firmware wasn't aware of hotplugged CPUs (which might lead to guest crashes). During 4.2 we introduced locked SMI handler RAM arrea to make sure that guest OS wasn't able to inject its own SMI handler and OVMF added initial CPU hotplug support.

This series is QEMU part of that support which lets QMVF tell QEMU that CPU hotplug with SMI broadcast enabled is supported so that QEMU would be able to prevent hotplug in case it's not supported and trigger SMI on hotplug when it's necessary.

Igor Mammedov (10):
x86: lpc9: let firmware negotiate 'CPU hotplug with SMI' features
x86: cpuhp: prevent guest crash on CPU hotplug when broadcast SMI is
in use
x86: cpuhp: refuse cpu hot-unplug request earlier if not supported
acpi: add aml_land() and aml_break() primitives
tests: acpi: mark to be changed tables in
bios-tables-test-allowed-diff
x86: ich9: expose "smi_negotiated_features" as a QOM property
x86: acpi: introduce AcpiPmInfo::smi_on_cpuhp
x86: acpi: introduce the PCI0.SMI0 ACPI device
x68: acpi: trigger SMI before sending hotplug Notify event to OSPM
tests: acpi: update acpi blobs with new AML

 include/hw/acpi/aml-build.h       |   2 +
 include/hw/acpi/cpu.h             |   1 +
 include/hw/i386/ich9.h            |   4 +
 hw/acpi/aml-build.c               |  16 +++
 hw/acpi/cpu.c                     | 156 ++++++++++++++++++++++++------
 hw/acpi/ich9.c                    |  24 ++++-
 hw/i386/acpi-build.c              |  35 ++++++-
 hw/i386/pc.c                      |  15 ++-
 hw/isa/lpc_ich9.c                 |  16 +++
 tests/data/acpi/pc/DSDT           | Bin 4934 -> 5060 bytes
 tests/data/acpi/pc/DSDT.acpihmat  | Bin 6258 -> 6385 bytes
 tests/data/acpi/pc/DSDT.bridge    | Bin 6793 -> 6919 bytes
 tests/data/acpi/pc/DSDT.cphp      | Bin 5397 -> 5524 bytes
 tests/data/acpi/pc/DSDT.dimmpxm   | Bin 6587 -> 6714 bytes
 tests/data/acpi/pc/DSDT.ipmikcs   | Bin 5006 -> 5132 bytes
 tests/data/acpi/pc/DSDT.memhp     | Bin 6293 -> 6419 bytes
 tests/data/acpi/pc/DSDT.numamem   | Bin 4940 -> 5066 bytes
 tests/data/acpi/q35/DSDT          | Bin 7678 -> 7804 bytes
 tests/data/acpi/q35/DSDT.acpihmat | Bin 9002 -> 9129 bytes
 tests/data/acpi/q35/DSDT.bridge   | Bin 7695 -> 7821 bytes
 tests/data/acpi/q35/DSDT.cphp     | Bin 8141 -> 8268 bytes
 tests/data/acpi/q35/DSDT.dimmpxm  | Bin 9331 -> 9458 bytes
 tests/data/acpi/q35/DSDT.ipmibt   | Bin 7753 -> 7879 bytes
 tests/data/acpi/q35/DSDT.memhp    | Bin 9037 -> 9163 bytes
 tests/data/acpi/q35/DSDT.mmio64   | Bin 8808 -> 8934 bytes
 tests/data/acpi/q35/DSDT.numamem  | Bin 7684 -> 7810 bytes
 tests/data/acpi/q35/DSDT.tis      | Bin 8283 -> 8409 bytes
 27 files changed, 239 insertions(+), 30 deletions(-)