diff mbox series

[RFC,5/7] DO NOT MERGE: acpi: cpuhp: add option to AML genrator to opt-in to always present vCPUs

Message ID 20241112170258.2996640-6-imammedo@redhat.com (mailing list archive)
State New
Headers show
Series Fix broken cpu hotplug after migration | expand

Commit Message

Igor Mammedov Nov. 12, 2024, 5:02 p.m. UTC
Looking at [1] what 'present' bit would do, it's no necessary as it's
statically defined for VM instance. So instead of introducing new ABI
in cpuhp flags register, add CPUHotplugFeatures::always_present_cpus
config option, that when set change _STA default return value to always
present but not enabled. And the interpose 'enabled' check on top of it,
which would set 'enabled' bit in return value if vCPU is enabled.

Platforms that need the feature can opt in by setting
 CPUHotplugFeatures::always_present_cpus = true
for other plaforms _STA will revert to the behavior before [1]

1)
 bf1ecc8dad606 (w/acpi: Update ACPI `_STA` method with QOM vCPU ACPI Hotplug states)
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/acpi/cpu.h | 1 +
 hw/acpi/cpu.c         | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index 32654dc274..e9e9c28359 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -56,6 +56,7 @@  typedef struct CPUHotplugFeatures {
     bool acpi_1_compatible;
     bool has_legacy_cphp;
     bool fw_unplugs_cpu;
+    bool always_present_cpus;
     const char *smi_path;
 } CPUHotplugFeatures;
 
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 5cb60ca8bc..67513450f9 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -452,15 +452,20 @@  void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
 
         method = aml_method(CPU_STS_METHOD, 1, AML_SERIALIZED);
         {
+            /*
+             * For always present CPUs set all bits except of 'enabled'
+             * ACPI 1.0b: chapter '6.3.5 _STA'
+             */
+            uint8_t default_sta = opts.always_present_cpus ? 0xd : 0;
             Aml *idx = aml_arg(0);
-            Aml *sta = aml_local(0);
+            Aml *sta = aml_local(default_sta);
 
             aml_append(method, aml_acquire(ctrl_lock, 0xFFFF));
             aml_append(method, aml_store(idx, cpu_selector));
             aml_append(method, aml_store(zero, sta));
             ifctx = aml_if(aml_equal(is_enabled, one));
             {
-                aml_append(ifctx, aml_store(aml_int(0xF), sta));
+                aml_append(ifctx, aml_or(aml_int(0xF), sta, sta));
             }
             aml_append(method, ifctx);
             aml_append(method, aml_release(ctrl_lock));