Arch agnostic ACPI changes to support vCPU Hotplug (on Archs like ARM)
v3 cover Arch agnostic ACPI changes to support vCPU Hotplug (on Archs like ARM)
Change Log
==========
Patch V2 -> V3:
1. Addressed left over issues of x86 suggested by Igor Mammedov (Redhat):
- Removed the ACPICPUstatus::is_enabled State as well as it was breaking the x86 migration
- Above is in addition to is_present state which was removed in V2
- Dropped [PATCH 1/6] of V2 patch-set
- Introduced hooks CPUClass::cpu_{persistence,enabled}_status()
2. Fixed the accidental CPUs AML break of x86 in V2 (sorry for this!).
Patch V1 -> V2:
1. Addressed Igor Mammedov's (Redhat) raised issues:
- Removed ACPICPUstatus::is_present State and its handling in the ACPI APUs AML code and now all QOM vCPUs are present.
- Dropped the concept of acpi_persistent because now QOM vCPUs states and the ACPI vCPU states are consistent.
- QOM vCPU objects are always present now (accompanying RFC V6)
- Added .needed() hook to the GED VMSD toconditionally migrate the ACPI CPU hotplug state at the source VM.
2. Addressed Zhao Liu's (Intel) reported x86 DSDT Table bios-acpi-test failure
3. Incorporated Gustavo Romero's comments and added his Tag to [Patches 1,2,4]
4. Addressed Gavin Shan's comment to reduce the inline code comments wherever possible.
Brief Recall
============
With the advent of multi-core SoCs, the concept of CPU-level hotplugging has become less distinct, often functioning as a power on/off event rather than a full hotplug operation. However, hotplug support at the die/NUMA/socket level remains meaningful and is architecture-specific. Virtual CPU hotplug can be supported regardless of architectural support for physical CPU hotplug, as it serves resource management needs—such as dynamically scaling VM compute capacity based on demand or SLAs, optimizing boot times, or reducing memory footprint. Although, its desing must be scalable and must co-exist with future die/NUMA/socket level hotplug features.
Motivation for this patch-set
=============================
In architectures that support vCPU hotplug, firmware or the VMM/QEMU typically reflects vCPU status changes to the OS via the ACPI _STA.Present bit. However, certain CPU architectures prohibit [1] modifications to CPU presence after kernel boot. This restriction [2][3] could be due to closely integrated per-CPU components—like interrupt controllers or other features— that may not support reconfiguration post-boot and are often in an always-on power domain. Consequently, specifications for these architectures require all CPUs to remain present i.e._STA.Present=True, once the system is initialized.
To be able to support vCPU Hotplug feature, as a workaround to the above limitation, ACPI method _STA.Enabled Bit could be used to reflect the plugged and unplugged states of the QOM vCPUs.
This patch set introduces the following changes:
1. IntroducesCPUClass::cpu_{persistence,enabled}_status hooks: To check if the CPU should always remain present even after unplug operation and to fetch the vCPU enabled status in case it is present. Later is used in context when Guest Kernel evaluates ACPI _STA method and the status is read from the flags stored in the Qemu ACPI code.
2. Support for Migrating ACPI CPU Hotplug State: Facilitates the migration of the ACPI CPU hotplug state in VMSD by conditonally making it part of the GED VMSD.
3. Updates the Qtest bios-acpi-tables/DSDT binaries for x86/{pc,q35}
This patch set is designed to work independently and is meant to ensure compatibility with existing hotplug support across different architectures. This patch-set has been tested alongside ARM-specific vCPU hotplug changes (included in the upcoming RFC V6 [4]), and hot(un)plug functionalities performed as expected which concerns this patch-set. Please have a look.
Thank you!
Repository of this patch-set
============================
(*) Latest Architecture Agnostic ACPI changes patch-set:
Repo: https://github.com/salil-mehta/qemu.git virt-cpuhp-armv8/rfc-v6.arch.agnostic.acpi.v3
(*) Works with upcoming ARM architecture specific patch-set RFC V6-rc5 [4]
References
==========
[1] Check comment 5 in the bugzilla entry
Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4481#c5
[2] KVMForum 2023 Presentation: Challenges Revisited in Supporting Virt CPU Hotplug on architectures that don’t Support CPU Hotplug (like ARM64)
a. Kernel Link: https://kvm-forum.qemu.org/2023/KVM-forum-cpu-hotplug_7OJ1YyJ.pdf
b. Qemu Link: https://kvm-forum.qemu.org/2023/Challenges_Revisited_in_Supporting_Virt_CPU_Hotplug_-__ii0iNb3.pdf
[3] KVMForum 2020 Presentation: Challenges in Supporting Virtual CPU Hotplug on
SoC Based Systems (like ARM64)
[4] Upcoming RFC V6, Support of Virtual CPU Hotplug for ARMv8 Arch
Salil Mehta (5):
hw/acpi: Make CPUs ACPI presence conditional during vCPU hot-unplug
qtest: allow ACPI DSDT Table changes
hw/acpi: Update ACPI _STA method with QOM vCPU ACPI Hotplug states tests/qtest/bios-tables-test: Update DSDT golden masters for
x86/{pc,q35}hw/acpi: Update GED with vCPU Hotplug VMSD for migration
hw/acpi/cpu.c | 53 ++++++++++++++++-- hw/acpi/generic_event_device.c | 19 +++++++ include/hw/core/cpu.h | 2 + tests/data/acpi/x86/pc/DSDT | Bin 8527 -> 8561 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 8438 -> 8472 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 9852 -> 9886 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 15398 -> 15432 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 8991 -> 9025 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 10181 -> 10215 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 8478 -> 8512 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 5034 -> 5068 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 8599 -> 8633 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 9886 -> 9920 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 8385 -> 8419 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 8533 -> 8567 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 12320 -> 12354 bytes tests/data/acpi/x86/q35/DSDT | Bin 8355 -> 8389 bytes tests/data/acpi/x86/q35/DSDT.acpierst | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.acpihmat | Bin 9680 -> 9714 bytes .../acpi/x86/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8668 bytes tests/data/acpi/x86/q35/DSDT.applesmc | Bin 8401 -> 8435 bytes tests/data/acpi/x86/q35/DSDT.bridge | Bin 11968 -> 12002 bytes tests/data/acpi/x86/q35/DSDT.core-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.core-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.cphp | Bin 8819 -> 8853 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 13148 -> 13182 bytes tests/data/acpi/x86/q35/DSDT.dimmpxm | Bin 10009 -> 10043 bytes tests/data/acpi/x86/q35/DSDT.ipmibt | Bin 8430 -> 8464 bytes tests/data/acpi/x86/q35/DSDT.ipmismbus | Bin 8443 -> 8477 bytes tests/data/acpi/x86/q35/DSDT.ivrs | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.memhp | Bin 9714 -> 9748 bytes tests/data/acpi/x86/q35/DSDT.mmio64 | Bin 9485 -> 9519 bytes tests/data/acpi/x86/q35/DSDT.multi-bridge | Bin 13208 -> 13242 bytes tests/data/acpi/x86/q35/DSDT.noacpihp | Bin 8235 -> 8269 bytes tests/data/acpi/x86/q35/DSDT.nohpet | Bin 8213 -> 8247 bytes tests/data/acpi/x86/q35/DSDT.numamem | Bin 8361 -> 8395 bytes tests/data/acpi/x86/q35/DSDT.pvpanic-isa | Bin 8456 -> 8490 bytes tests/data/acpi/x86/q35/DSDT.thread-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.thread-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm12 | Bin 8961 -> 8995 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm2 | Bin 8987 -> 9021 bytes tests/data/acpi/x86/q35/DSDT.type4-count | Bin 18589 -> 18623 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 14615 -> 14649 bytes tests/data/acpi/x86/q35/DSDT.xapic | Bin 35718 -> 35752 bytes 44 files changed, 69 insertions(+), 5 deletions(-)
Signature · 1 line
2.34.1
PATCH v3 1/5 hw/acpi: Make CPUs ACPI `presence` conditional during vCPU hot-unplug
On most architectures, during vCPU hot-plug and hot-unplug actions, the firmware or VMM/QEMU can update the OS on vCPU status by toggling the ACPI method _STA.Present bit. However, certain CPU architectures prohibit [1] modifications to a CPU’s presence status after the kernel has booted.
This limitation [2][3] exists because many per-CPU components, such as interrupt controllers and various per-CPU features tightly integrated with CPUs, may not support reconfiguration once the kernel is initialized. Often, these components cannot be powered down, as they may belong to an always-on power domain. As a result, some architectures require all CPUs to remain _STA.Present after system initialization.
Therefore, it is essential to mirror the exact QOM vCPU status through ACPI for the Guest kernel. For this, we should determine—via architecture-specific code[4]—whether vCPUs must always remain present and whether the associated AcpiCpuStatus::cpu object should remain valid, even following a vCPU hot-unplug operation.
References:
[1] Check comment 5 in the bugzilla entry
Link: https://bugzilla.tianocore.org/show_bug.cgi?id=4481#c5
[2] KVMForum 2023 Presentation: Challenges Revisited in Supporting Virt CPU Hotplug on architectures that don’t Support CPU Hotplug (like ARM64)
a. Kernel Link: https://kvm-forum.qemu.org/2023/KVM-forum-cpu-hotplug_7OJ1YyJ.pdf
b. Qemu Link: https://kvm-forum.qemu.org/2023/Challenges_Revisited_in_Supporting_Virt_CPU_Hotplug_-__ii0iNb3.pdf
[3] KVMForum 2020 Presentation: Challenges in Supporting Virtual CPU Hotplug on
SoC Based Systems (like ARM64)
[4] Example implementation of architecture-specific CPU persistence hook
Link: https://github.com/salil-mehta/qemu/commit/c0b416b11e5af6505e558866f0eb6c9f3709173e
--- hw/acpi/cpu.c | 15 ++++++++++++++- include/hw/core/cpu.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-)
hw/acpi/cpu.c +14 -1
@@ -233,6 +233,17 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,memory_region_add_subregion (as, base_addr, &state->ctrl_reg); } +static bool should_remain_acpi_present (DeviceState *dev) +{ +CPUClass *k =CPU_GET_CLASS (dev); +/* +* A system may contain CPUs that are always present on one die, NUMA node, +* or socket, yet may be non-present on another simultaneously. Check from +* architecture specific code. +*/ +return k->cpu_persistent_status && k->cpu_persistent_status (CPU (dev)); +} +static AcpiCpuStatus *get_cpu_status (CPUHotplugState *cpu_st,DeviceState *dev) {CPUClass *k =CPU_GET_CLASS (dev);
@@ -289,7 +300,9 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,return ; } - cdev->cpu =NULL ; +if (!should_remain_acpi_present (dev)) { + cdev->cpu =NULL ; + } }static const VMStateDescription vmstate_cpuhp_sts = {
include/hw/core/cpu.h +1 -0
@@ -158,6 +158,7 @@ struct CPUClass {void (*dump_state)(CPUState *cpu,FILE *,int flags);void (*query_cpu_fast)(CPUState *cpu,CpuInfoFast *value);int64_t (*get_arch_id)(CPUState *cpu); +bool (*cpu_persistent_status)(CPUState *cpu);void (*set_pc)(CPUState *cpu,vaddr value);vaddr (*get_pc)(CPUState *cpu);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);
Signature · 1 line
2.34.1
PATCH v3 2/5 qtest: allow ACPI DSDT Table changes
In reply to Salil Mehtalist changed files in tests/qtest/bios-tables-test-allowed-diff.h
--- tests/qtest/bios-tables-test-allowed-diff.h | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +41 -0
@@ -1 +1,42 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/x86/pc/DSDT" , +"tests/data/acpi/x86/pc/DSDT.acpierst" , +"tests/data/acpi/x86/pc/DSDT.acpihmat" , +"tests/data/acpi/x86/pc/DSDT.bridge" , +"tests/data/acpi/x86/pc/DSDT.cphp" , +"tests/data/acpi/x86/pc/DSDT.dimmpxm" , +"tests/data/acpi/x86/pc/DSDT.hpbridge" , +"tests/data/acpi/x86/pc/DSDT.hpbrroot" , +"tests/data/acpi/x86/pc/DSDT.ipmikcs" , +"tests/data/acpi/x86/pc/DSDT.memhp" , +"tests/data/acpi/x86/pc/DSDT.nohpet" , +"tests/data/acpi/x86/pc/DSDT.numamem" , +"tests/data/acpi/x86/pc/DSDT.roothp" , +"tests/data/acpi/x86/q35/DSDT" , +"tests/data/acpi/x86/q35/DSDT.acpierst" , +"tests/data/acpi/x86/q35/DSDT.acpihmat" , +"tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator" , +"tests/data/acpi/x86/q35/DSDT.applesmc" , +"tests/data/acpi/x86/q35/DSDT.bridge" , +"tests/data/acpi/x86/q35/DSDT.core-count" , +"tests/data/acpi/x86/q35/DSDT.core-count2" , +"tests/data/acpi/x86/q35/DSDT.cphp" , +"tests/data/acpi/x86/q35/DSDT.cxl" , +"tests/data/acpi/x86/q35/DSDT.dimmpxm" , +"tests/data/acpi/x86/q35/DSDT.ipmibt" , +"tests/data/acpi/x86/q35/DSDT.ipmismbus" , +"tests/data/acpi/x86/q35/DSDT.ivrs" , +"tests/data/acpi/x86/q35/DSDT.memhp" , +"tests/data/acpi/x86/q35/DSDT.mmio64" , +"tests/data/acpi/x86/q35/DSDT.multi-bridge" , +"tests/data/acpi/x86/q35/DSDT.noacpihp" , +"tests/data/acpi/x86/q35/DSDT.nohpet" , +"tests/data/acpi/x86/q35/DSDT.numamem" , +"tests/data/acpi/x86/q35/DSDT.pvpanic-isa" , +"tests/data/acpi/x86/q35/DSDT.thread-count" , +"tests/data/acpi/x86/q35/DSDT.thread-count2" , +"tests/data/acpi/x86/q35/DSDT.tis.tpm12" , +"tests/data/acpi/x86/q35/DSDT.tis.tpm2" , +"tests/data/acpi/x86/q35/DSDT.type4-count" , +"tests/data/acpi/x86/q35/DSDT.viot" , +"tests/data/acpi/x86/q35/DSDT.xapic",
Signature · 1 line
2.34.1
PATCH v3 3/5 hw/acpi: Update ACPI `_STA` method with QOM vCPU ACPI Hotplug states
In reply to Salil MehtaReflect the QOM vCPUs ACPI CPU hotplug states in the _STA.Present and and _STA.Enabled bits when the guest kernel evaluates the ACPI _STA method during initialization, as well as when vCPUs are hot-plugged or hot-unplugged. If the CPU is present then the its enabled status can be fetched using architecture-specific code [1].
Reference:
[1] Example implementation of architecture-specific hook to fetch CPU
`enabled status
Link: https://github.com/salil-mehta/qemu/commit/c0b416b11e5af6505e558866f0eb6c9f3709173e--- hw/acpi/cpu.c | 38 ++++++++++++++++++++++++++++++++++---- include/hw/core/cpu.h | 1 + 2 files changed, 35 insertions(+), 4 deletions(-)
hw/acpi/cpu.c +34 -4
@@ -50,6 +50,18 @@ void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list) } } +static bool check_cpu_enabled_status (DeviceState *dev) +{ +CPUClass *k = dev ?CPU_GET_CLASS (dev) :NULL ; +CPUState *cpu =CPU (dev); + +if (cpu && (!k->cpu_enabled_status || k->cpu_enabled_status (cpu))) { +return true; + } + +return false; +} +static uint64_t cpu_hotplug_rd (void *opaque,hwaddr addr,unsigned size) {uint64_t val =0 ;
@@ -63,10 +75,11 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) cdev = &cpu_st->devs[cpu_st->selector];switch (addr) {case ACPI_CPU_FLAGS_OFFSET_RW :/* pack and return is_* fields */ - val |= cdev->cpu ?1 :0 ; + val |=check_cpu_enabled_status (DEVICE (cdev->cpu)) ?1 :0 ; val |= cdev->is_inserting ?2 :0 ; val |= cdev->is_removing ?4 :0 ; val |= cdev->fw_remove ?16 :0 ; + val |= cdev->cpu ?32 :0 ;trace_cpuhp_acpi_read_flags (cpu_st->selector, val);break ;case ACPI_CPU_CMD_DATA_OFFSET_RW :
@@ -349,6 +362,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_REMOVE_EVENT "CRMV"#define CPU_EJECT_EVENT "CEJ0"#define CPU_FW_EJECT_EVENT "CEJF" +#define CPU_PRESENT "CPRS" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, build_madt_cpu_fn build_madt_cpu, hwaddr base_addr,
@@ -409,7 +423,9 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (field,aml_named_field (CPU_EJECT_EVENT ,1 ));/* tell firmware to do device eject, write only */ aml_append (field,aml_named_field (CPU_FW_EJECT_EVENT ,1 )); -aml_append (field,aml_reserved_field (3 )); +/* 1 if present, read only */ +aml_append (field,aml_named_field (CPU_PRESENT ,1 )); +aml_append (field,aml_reserved_field (2 ));aml_append (field,aml_named_field (CPU_COMMAND ,8 ));aml_append (cpu_ctrl_dev, field);
@@ -439,6 +455,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,Aml *ctrl_lock =aml_name ("%s.%s" , cphp_res_path,CPU_LOCK );Aml *cpu_selector =aml_name ("%s.%s" , cphp_res_path,CPU_SELECTOR );Aml *is_enabled =aml_name ("%s.%s" , cphp_res_path,CPU_ENABLED ); +Aml *is_present =aml_name ("%s.%s" , cphp_res_path,CPU_PRESENT );Aml *cpu_cmd =aml_name ("%s.%s" , cphp_res_path,CPU_COMMAND );Aml *cpu_data =aml_name ("%s.%s" , cphp_res_path,CPU_DATA );Aml *ins_evt =aml_name ("%s.%s" , cphp_res_path,CPU_INSERT_EVENT );
@@ -467,13 +484,26 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, {Aml *idx =aml_arg (0 );Aml *sta =aml_local (0 ); +Aml *ifctx2; +Aml *else_ctx;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)); + ifctx =aml_if (aml_equal (is_present, one)); { -aml_append (ifctx,aml_store (aml_int (0xF ), sta)); + ifctx2 =aml_if (aml_equal (is_enabled, one)); + { +/* cpu is present and enabled */ +aml_append (ifctx2,aml_store (aml_int (0xF ), sta)); + } +aml_append (ifctx, ifctx2); + else_ctx =aml_else (); + { +/* cpu is present but disabled */ +aml_append (else_ctx,aml_store (aml_int (0xD ), sta)); + } +aml_append (ifctx, else_ctx); }aml_append (method, ifctx);aml_append (method,aml_release (ctrl_lock));
include/hw/core/cpu.h +1 -0
@@ -159,6 +159,7 @@ struct CPUClass {void (*query_cpu_fast)(CPUState *cpu,CpuInfoFast *value);int64_t (*get_arch_id)(CPUState *cpu);bool (*cpu_persistent_status)(CPUState *cpu); +bool (*cpu_enabled_status)(CPUState *cpu);void (*set_pc)(CPUState *cpu,vaddr value);vaddr (*get_pc)(CPUState *cpu);int (*gdb_read_register)(CPUState *cpu,GByteArray *buf,int reg);
Signature · 1 line
2.34.1
PATCH v3 4/5 tests/qtest/bios-tables-test: Update DSDT golden masters for x86/{pc,q35}
In reply to Salil MehtaUpdate DSDT golden master files for x86/pc and x86/q35 platforms to accommodate changes made in the architecture-agnostic CPU AML. These updates notify the guest OS of vCPU hot-plug and hot-unplug status using the ACPI _STA.Enabled bit.
The following is a diff of the changes in the .dsl file generated with IASL:
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of tests/data/acpi/x86/pc/DSDT, Sat Nov 2 21:08:37 2024
+ * Disassembly of /tmp/aml-FSFNW2, Sat Nov 2 21:08:37 2024 *
* Original Table Header:
* Signature "DSDT"
- * Length 0x0000214F (8527)
+ * Length 0x00002171 (8561)
* Revision 0x01 **** 32-bit table (V1), no 64-bit math support
- * Checksum 0x59
+ * Checksum 0xAA
* OEM ID "BOCHS "
* OEM Table ID "BXPC "
* OEM Revision 0x00000001 (1)
@@ -1480,6 +1480,7 @@
CRMV, 1,
CEJ0, 1,
CEJF, 1,
+ CPRS, 1,
Offset (0x05),
CCMD, 8
}
@@ -1514,9 +1515,16 @@
Acquire (\_SB.PCI0.PRES.CPLK, 0xFFFF)
\_SB.PCI0.PRES.CSEL = Arg0
Local0 = Zero- If ((\_SB.PCI0.PRES.CPEN == One))
- {
- Local0 = 0x0F
+ If ((\_SB.PCI0.PRES.CPRS == One))
+ {
+ If ((\_SB.PCI0.PRES.CPEN == One))
+ {
+ Local0 = 0x0F
+ }
+ Else
+ {
+ Local0 = 0x0D
+ }
}
Release (\_SB.PCI0.PRES.CPLK)--- tests/data/acpi/x86/pc/DSDT | Bin 8527 -> 8561 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 8438 -> 8472 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 9852 -> 9886 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 15398 -> 15432 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 8991 -> 9025 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 10181 -> 10215 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 8478 -> 8512 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 5034 -> 5068 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 8599 -> 8633 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 9886 -> 9920 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 8385 -> 8419 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 8533 -> 8567 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 12320 -> 12354 bytes tests/data/acpi/x86/q35/DSDT | Bin 8355 -> 8389 bytes tests/data/acpi/x86/q35/DSDT.acpierst | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.acpihmat | Bin 9680 -> 9714 bytes .../acpi/x86/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8668 bytes tests/data/acpi/x86/q35/DSDT.applesmc | Bin 8401 -> 8435 bytes tests/data/acpi/x86/q35/DSDT.bridge | Bin 11968 -> 12002 bytes tests/data/acpi/x86/q35/DSDT.core-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.core-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.cphp | Bin 8819 -> 8853 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 13148 -> 13182 bytes tests/data/acpi/x86/q35/DSDT.dimmpxm | Bin 10009 -> 10043 bytes tests/data/acpi/x86/q35/DSDT.ipmibt | Bin 8430 -> 8464 bytes tests/data/acpi/x86/q35/DSDT.ipmismbus | Bin 8443 -> 8477 bytes tests/data/acpi/x86/q35/DSDT.ivrs | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.memhp | Bin 9714 -> 9748 bytes tests/data/acpi/x86/q35/DSDT.mmio64 | Bin 9485 -> 9519 bytes tests/data/acpi/x86/q35/DSDT.multi-bridge | Bin 13208 -> 13242 bytes tests/data/acpi/x86/q35/DSDT.noacpihp | Bin 8235 -> 8269 bytes tests/data/acpi/x86/q35/DSDT.nohpet | Bin 8213 -> 8247 bytes tests/data/acpi/x86/q35/DSDT.numamem | Bin 8361 -> 8395 bytes tests/data/acpi/x86/q35/DSDT.pvpanic-isa | Bin 8456 -> 8490 bytes tests/data/acpi/x86/q35/DSDT.thread-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.thread-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm12 | Bin 8961 -> 8995 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm2 | Bin 8987 -> 9021 bytes tests/data/acpi/x86/q35/DSDT.type4-count | Bin 18589 -> 18623 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 14615 -> 14649 bytes tests/data/acpi/x86/q35/DSDT.xapic | Bin 35718 -> 35752 bytes tests/qtest/bios-tables-test-allowed-diff.h | 41 ------------------ 42 files changed, 41 deletions(-)
tests/data/acpi/x86/pc/DSDT binary +0 -0
tests/data/acpi/x86/pc/DSDT.acpierst binary +0 -0
tests/data/acpi/x86/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/x86/pc/DSDT.bridge binary +0 -0
tests/data/acpi/x86/pc/DSDT.cphp binary +0 -0
tests/data/acpi/x86/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/x86/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/x86/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/x86/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/x86/pc/DSDT.memhp binary +0 -0
tests/data/acpi/x86/pc/DSDT.nohpet binary +0 -0
tests/data/acpi/x86/pc/DSDT.numamem binary +0 -0
tests/data/acpi/x86/pc/DSDT.roothp binary +0 -0
tests/data/acpi/x86/q35/DSDT binary +0 -0
tests/data/acpi/x86/q35/DSDT.acpierst binary +0 -0
tests/data/acpi/x86/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/x86/q35/DSDT.acpihmat-noinitiator binary +0 -0
tests/data/acpi/x86/q35/DSDT.applesmc binary +0 -0
tests/data/acpi/x86/q35/DSDT.bridge binary +0 -0
tests/data/acpi/x86/q35/DSDT.core-count binary +0 -0
tests/data/acpi/x86/q35/DSDT.core-count2 binary +0 -0
tests/data/acpi/x86/q35/DSDT.cphp binary +0 -0
tests/data/acpi/x86/q35/DSDT.cxl binary +0 -0
tests/data/acpi/x86/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/x86/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/x86/q35/DSDT.ipmismbus binary +0 -0
tests/data/acpi/x86/q35/DSDT.ivrs binary +0 -0
tests/data/acpi/x86/q35/DSDT.memhp binary +0 -0
tests/data/acpi/x86/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/x86/q35/DSDT.multi-bridge binary +0 -0
tests/data/acpi/x86/q35/DSDT.noacpihp binary +0 -0
tests/data/acpi/x86/q35/DSDT.nohpet binary +0 -0
tests/data/acpi/x86/q35/DSDT.numamem binary +0 -0
tests/data/acpi/x86/q35/DSDT.pvpanic-isa binary +0 -0
tests/data/acpi/x86/q35/DSDT.thread-count binary +0 -0
tests/data/acpi/x86/q35/DSDT.thread-count2 binary +0 -0
tests/data/acpi/x86/q35/DSDT.tis.tpm12 binary +0 -0
tests/data/acpi/x86/q35/DSDT.tis.tpm2 binary +0 -0
tests/data/acpi/x86/q35/DSDT.type4-count binary +0 -0
tests/data/acpi/x86/q35/DSDT.viot binary +0 -0
tests/data/acpi/x86/q35/DSDT.xapic binary +0 -0
tests/qtest/bios-tables-test-allowed-diff.h +0 -41
42 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v3 5/5 hw/acpi: Update GED with vCPU Hotplug VMSD for migration
In reply to Salil MehtaThe ACPI CPU hotplug states must be migrated along with other vCPU hotplug states to the destination VM. Update the GED's VM State Description (VMSD) table subsection to conditionally include the CPU Hotplug VM State Description (VMSD).
Excerpt of GED VMSD State Dump at Source:
"acpi-ged (16)": {
"ged_state": {
"sel": "0x00000000"
},
[...]
"acpi-ged/cpuhp": {
"cpuhp_state": {
"selector": "0x00000005",
"command": "0x00",
"devs": [
{
"is_inserting": false,
"is_removing": false,
"ost_event": "0x00000000",
"ost_status": "0x00000000"
},
[...]
{
"is_inserting": false,
"is_removing": false,
"ost_event": "0x00000000",
"ost_status": "0x00000000"
}
]
}
}
},--- hw/acpi/generic_event_device.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
hw/acpi/generic_event_device.c +19 -0
@@ -331,6 +331,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool cpuhp_needed (void *opaque) +{ +MachineClass *mc =MACHINE_GET_CLASS (qdev_get_machine ()); + +return mc->has_hotpluggable_cpus; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name ="acpi-ged/cpuhp" , + .version_id =1 , + .minimum_version_id =1 , + .needed = cpuhp_needed, + .fields = (VMStateField []) { +VMSTATE_CPU_HOTPLUG (cpuhp_state, AcpiGedState), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_ged_state = { .name ="acpi-ged-state" , .version_id =1 ,
@@ -379,6 +397,7 @@ static const VMStateDescription vmstate_acpi_ged = { }, .subsections = (const VMStateDescription * const []) { &vmstate_memhp_state, + &vmstate_cpuhp_state, &vmstate_ghes_state,NULL }
Signature · 1 line
2.34.1
Hi Salil,
Quoted 72 lines · Salil Mehta via
Change Log
==========Patch V2 -> V3:
1. Addressed left over issues of x86 suggested by Igor Mammedov (Redhat):
- Removed theACPICPUstatus::is_enabledState as well as it was breaking the x86 migration
- Above is in addition tois_presentstate which was removed in V2
- Dropped [PATCH 1/6] of V2 patch-set
- Introduced hooksCPUClass::cpu_{persistence,enabled}_status()
2. Fixed the accidental CPUs AML break of x86 in V2 (sorry for this!).Patch V1 -> V2:
1. Addressed Igor Mammedov's (Redhat) raised issues:
- RemovedACPICPUstatus::is_presentState and its handling in the ACPI APUs AML code and now all QOM vCPUs are present.
- Dropped the concept ofacpi_persistentbecause now QOM vCPUs states and the ACPI vCPU states are consistent.
- QOM vCPU objects are always present now (accompanying RFC V6)
- Added .needed() hook to the GED VMSD toconditionally migrate the ACPI CPU hotplug state at the source VM.
2. Addressed Zhao Liu's (Intel) reported x86 DSDT Table bios-acpi-test failure
3. Incorporated Gustavo Romero's comments and added his Tag to [Patches 1,2,4]
4. Addressed Gavin Shan's comment to reduce the inline code comments wherever possible.Brief Recall
============
With the advent of multi-core SoCs, the concept of CPU-level hotplugging has become less distinct, often functioning as a power on/off event rather than a full hotplug operation. However, hotplug support at the die/NUMA/socket level remains meaningful and is architecture-specific. Virtual CPU hotplug can be supported regardless of architectural support for physical CPU hotplug, as it serves resource management needs—such as dynamically scaling VM compute capacity based on demand or SLAs, optimizing boot times, or reducing memory footprint. Although, its desing must be scalable and must co-exist with future die/NUMA/socket level hotplug features.Motivation for this patch-set
=============================
In architectures that support vCPU hotplug, firmware or the VMM/QEMU typically reflects vCPU status changes to the OS via the ACPI_STA.Presentbit. However, certain CPU architectures prohibit [1] modifications to CPU presence after kernel boot. This restriction [2][3] could be due to closely integrated per-CPU components—like interrupt controllers or other features— that may not support reconfiguration post-boot and are often in analways-onpower domain. Consequently, specifications for these architectures require all CPUs to remain present i.e._STA.Present=True, once the system is initialized.To be able to support vCPU Hotplug feature, as a workaround to the above limitation, ACPI method
_STA.EnabledBit could be used to reflect the plugged and unplugged states of the QOM vCPUs.This patch set introduces the following changes:
1. Introduces
CPUClass::cpu_{persistence,enabled}_statushooks: To check if the CPU should always remain present even after unplug operation and to fetch the vCPUenabledstatus in case it is present. Later is used in context when Guest Kernel evaluates ACPI_STAmethod and the status is read from the flags stored in the Qemu ACPI code.2. Support for Migrating ACPI CPU Hotplug State: Facilitates the migration of the ACPI CPU hotplug state in VMSD by conditonally making it part of the GED VMSD.
Quoted 9 lines
3. Updates the Qtest bios-acpi-tables/DSDT binaries for x86/{pc,q35}
This patch set is designed to work independently and is meant to ensure compatibility with existing hotplug support across different architectures. This patch-set has been tested alongside ARM-specific vCPU hotplug changes (included in the upcoming RFC V6 [4]), and hot(un)plug functionalities performed as expected which concerns this patch-set. Please have a look.
For arm64:
I’ve ran make check and bios-tables-test passed successfully and got 0 failed tests.
After boot the number of vcpus matched what was initially requested via -smp cpus.
I’ve also tested this patchset alongside the upcoming RFC V6-rc5 and booting, basic hot-plugging/unplugging of vCPUs and live migration with an asymmetrical number of hotplugged vCPUs looked good to me.
Please, feel free to add:
Thank you.
Miguel
Quoted 83 lines
Thank you!
Repository of this patch-set
============================
(*) Latest Architecture Agnostic ACPI changes patch-set:
Repo: https://github.com/salil-mehta/qemu.git virt-cpuhp-armv8/rfc-v6.arch.agnostic.acpi.v3(*) Works with upcoming ARM architecture specific patch-set RFC V6-rc5 [4]
References
==========
[1] Check comment 5 in the bugzilla entry[2] KVMForum 2023 Presentation: Challenges Revisited in Supporting Virt CPU Hotplug on architectures that don’t Support CPU Hotplug (like ARM64)
a. Kernel Link: https://kvm-forum.qemu.org/2023/KVM-forum-cpu-hotplug_7OJ1YyJ.pdf
b. Qemu Link: https://kvm-forum.qemu.org/2023/Challenges_Revisited_in_Supporting_Virt_CPU_Hotplug_-__ii0iNb3.pdf
[3] KVMForum 2020 Presentation: Challenges in Supporting Virtual CPU Hotplug on
SoC Based Systems (like ARM64)[4] Upcoming RFC V6, Support of Virtual CPU Hotplug for ARMv8 Arch
Salil Mehta (5):
hw/acpi: Make CPUs ACPIpresenceconditional during vCPU hot-unplug
qtest: allow ACPI DSDT Table changes
hw/acpi: Update ACPI_STAmethod with QOM vCPU ACPI Hotplug states tests/qtest/bios-tables-test: Update DSDT golden masters for
x86/{pc,q35}
hw/acpi: Update GED with vCPU Hotplug VMSD for migrationhw/acpi/cpu.c | 53 ++++++++++++++++-- hw/acpi/generic_event_device.c | 19 +++++++ include/hw/core/cpu.h | 2 + tests/data/acpi/x86/pc/DSDT | Bin 8527 -> 8561 bytes tests/data/acpi/x86/pc/DSDT.acpierst | Bin 8438 -> 8472 bytes tests/data/acpi/x86/pc/DSDT.acpihmat | Bin 9852 -> 9886 bytes tests/data/acpi/x86/pc/DSDT.bridge | Bin 15398 -> 15432 bytes tests/data/acpi/x86/pc/DSDT.cphp | Bin 8991 -> 9025 bytes tests/data/acpi/x86/pc/DSDT.dimmpxm | Bin 10181 -> 10215 bytes tests/data/acpi/x86/pc/DSDT.hpbridge | Bin 8478 -> 8512 bytes tests/data/acpi/x86/pc/DSDT.hpbrroot | Bin 5034 -> 5068 bytes tests/data/acpi/x86/pc/DSDT.ipmikcs | Bin 8599 -> 8633 bytes tests/data/acpi/x86/pc/DSDT.memhp | Bin 9886 -> 9920 bytes tests/data/acpi/x86/pc/DSDT.nohpet | Bin 8385 -> 8419 bytes tests/data/acpi/x86/pc/DSDT.numamem | Bin 8533 -> 8567 bytes tests/data/acpi/x86/pc/DSDT.roothp | Bin 12320 -> 12354 bytes tests/data/acpi/x86/q35/DSDT | Bin 8355 -> 8389 bytes tests/data/acpi/x86/q35/DSDT.acpierst | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.acpihmat | Bin 9680 -> 9714 bytes .../acpi/x86/q35/DSDT.acpihmat-noinitiator | Bin 8634 -> 8668 bytes tests/data/acpi/x86/q35/DSDT.applesmc | Bin 8401 -> 8435 bytes tests/data/acpi/x86/q35/DSDT.bridge | Bin 11968 -> 12002 bytes tests/data/acpi/x86/q35/DSDT.core-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.core-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.cphp | Bin 8819 -> 8853 bytes tests/data/acpi/x86/q35/DSDT.cxl | Bin 13148 -> 13182 bytes tests/data/acpi/x86/q35/DSDT.dimmpxm | Bin 10009 -> 10043 bytes tests/data/acpi/x86/q35/DSDT.ipmibt | Bin 8430 -> 8464 bytes tests/data/acpi/x86/q35/DSDT.ipmismbus | Bin 8443 -> 8477 bytes tests/data/acpi/x86/q35/DSDT.ivrs | Bin 8372 -> 8406 bytes tests/data/acpi/x86/q35/DSDT.memhp | Bin 9714 -> 9748 bytes tests/data/acpi/x86/q35/DSDT.mmio64 | Bin 9485 -> 9519 bytes tests/data/acpi/x86/q35/DSDT.multi-bridge | Bin 13208 -> 13242 bytes tests/data/acpi/x86/q35/DSDT.noacpihp | Bin 8235 -> 8269 bytes tests/data/acpi/x86/q35/DSDT.nohpet | Bin 8213 -> 8247 bytes tests/data/acpi/x86/q35/DSDT.numamem | Bin 8361 -> 8395 bytes tests/data/acpi/x86/q35/DSDT.pvpanic-isa | Bin 8456 -> 8490 bytes tests/data/acpi/x86/q35/DSDT.thread-count | Bin 12913 -> 12947 bytes tests/data/acpi/x86/q35/DSDT.thread-count2 | Bin 33770 -> 33804 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm12 | Bin 8961 -> 8995 bytes tests/data/acpi/x86/q35/DSDT.tis.tpm2 | Bin 8987 -> 9021 bytes tests/data/acpi/x86/q35/DSDT.type4-count | Bin 18589 -> 18623 bytes tests/data/acpi/x86/q35/DSDT.viot | Bin 14615 -> 14649 bytes tests/data/acpi/x86/q35/DSDT.xapic | Bin 35718 -> 35752 bytes 44 files changed, 69 insertions(+), 5 deletions(-)Signature · 1 line
2.34.1
HI Miguel,
Quoted 103 lines
From: Miguel Luis <[email protected]>
Sent: Monday, November 4, 2024 12:55 PM
To: Salil Mehta <[email protected]>Hi Salil,
Quoted 1 line
On 3 Nov 2024, at 09:24, Salil Mehta via <[email protected]>
Quoted 6 lines · wrote:
Change Log
==========Patch V2 -> V3:
1. Addressed left over issues of x86 suggested by Igor Mammedov(Redhat):
Quoted 7 lines
- Removed the
ACPICPUstatus::is_enabledState as well as it was breaking the x86 migration
- Above is in addition tois_presentstate which was removed in V2
- Dropped [PATCH 1/6] of V2 patch-set
- Introduced hooksCPUClass::cpu_{persistence,enabled}_status()
2. Fixed the accidental CPUs AML break of x86 in V2 (sorry for this!).Quoted 12 lines
Patch V1 -> V2:
1. Addressed Igor Mammedov's (Redhat) raised issues:
- RemovedACPICPUstatus::is_presentState and its handling in the ACPI APUs AML code and now all QOM vCPUs are present.
- Dropped the concept ofacpi_persistentbecause now QOM vCPUs states and the ACPI vCPU states are consistent.
- QOM vCPU objects are always present now (accompanying RFC V6)
- Added .needed() hook to the GED VMSD toconditionally migrate the ACPI CPU hotplug state at the source VM.
2. Addressed Zhao Liu's (Intel) reported x86 DSDT Table bios-acpi-test failure 3. Incorporated Gustavo Romero's comments and added his Tag to [Patches 1,2,4] 4. Addressed Gavin Shan's comment to reduce the inlinecode comments
Quoted 9 lines
wherever possible.
Brief Recall
============
With the advent of multi-core SoCs, the concept of CPU-level hotplugging has become less distinct, often functioning as a power on/off event rather than a full hotplug operation. However, hotplug support at the die/NUMA/socket level remains meaningful and isarchitecture-specific.
Quoted 3 lines
Virtual CPU hotplug can be supported regardless of architectural support for physical CPU hotplug, as it serves resource management needs—such as dynamically scaling VM compute capacity based on
demand
Quoted 5 lines
or SLAs, optimizing boot times, or reducing memory footprint. Although, its desing must be scalable and must co-exist with future die/NUMA/socket level hotplug features.
Quoted 11 lines
Motivation for this patch-set
=============================
In architectures that support vCPU hotplug, firmware or the VMM/QEMU typically reflects vCPU status changes to the OS via the ACPI_STA.Presentbit. However, certain CPU architectures prohibit [1] modifications to CPU presence after kernel boot. This restriction [2][3] could be due to closely integrated per-CPU components—like interrupt controllers or other features— that may not support reconfiguration post-boot and are often in analways-onpower domain. Consequently, specifications for these architectures require all CPUs to remain present i.e._STA.Present=True, once the system isinitialized.
Quoted 18 lines
To be able to support vCPU Hotplug feature, as a workaround to the above limitation, ACPI method
_STA.EnabledBit could be used to reflect the plugged and unplugged states of the QOM vCPUs.This patch set introduces the following changes:
1. Introduces
CPUClass::cpu_{persistence,enabled}_statushooks: To check if the CPU should always remain present even after unplug operation and to fetch the vCPUenabledstatus in case it is present. Later is used in context when Guest Kernel evaluates ACPI_STAmethod and the status is read from the flags stored in the Qemu ACPI code.2. Support for Migrating ACPI CPU Hotplug State: Facilitates the migration of the ACPI CPU hotplug state in VMSD by conditonally making it part of the GED VMSD.
Quoted 9 lines
3. Updates the Qtest bios-acpi-tables/DSDT binaries for x86/{pc,q35}
This patch set is designed to work independently and is meant to ensure compatibility with existing hotplug support across different architectures. This patch-set has been tested alongside ARM-specific vCPU hotplug changes (included in the upcoming RFC V6 [4]), and hot(un)plug functionalities performed as expected which concerns this patch-set. Please have a look.
For arm64:
I’ve ran make check and bios-tables-test passed successfully and got 0 failed tests.
After boot the number of vcpus matched what was initially requested via - smp cpus.
I’ve also tested this patchset alongside the upcoming RFC V6-rc5 and booting, basic hot-plugging/unplugging of vCPUs and live migration with an asymmetrical number of hotplugged vCPUs looked good to me.
Quoted 2 lines
Please, feel free to add:
Tested-by Miguel Luis <[email protected]>
Many thanks for your continuous efforts and confirming this. I really appreciate this.
I would leave application of this Tag to Michael as patch-set is in his queue now. 😊
Many thanks!
Best regards
Salil.
Quoted 6 lines
Thank you.
MiguelQuoted 2 lines
Thank you!