add support for cpu hot-unplug with SMI broadcast enabled
cover add support for cpu hot-unplug with SMI broadcast enabled
Changelog:
since RFC:
- split one big patch on smaller chunks
- clear bit #4 in CPU eject
- drop bit #4 toggle semantics and let it set only to 1 from guest side
- do not allow unplug without hotplug
- update expected ACPI tables to let CI pass
It's QEMU side to support CPU hot-unplug when using OVMF as firmware with SMI broadcast enabled (default). It adds new bit in CPU hotplug hw, to mark CPU as pending for removal by firmware and passes control to it to perform CPU eject once it's ready (i.e. forgot and no longer uses that CPU).
Patches 2-7 are preparatory, adding neccesary HW and ACPI bits for the feature and the last patch enables feature by default since 6.0 machine type.
Cornelia Huck (1):
hw: add compat machines for 6.0
Igor Mammedov (7):
acpi: cpuhp: introduce 'firmware performs eject' status/control bits
x86: acpi: introduce AcpiPmInfo::smi_on_cpu_unplug tests/acpi: allow expected files change
x86: acpi: let the firmware handle pending "CPU remove" events in SMM tests/acpi: update expected files
x86: ich9: factor out "guest_cpu_hotplug_features"
x86: ich9: let firmware negotiate 'CPU hot-unplug with SMI' feature
include/hw/acpi/cpu.h | 2 ++ include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ docs/specs/acpi_cpu_hotplug.txt | 19 ++++++++++++++----- hw/acpi/cpu.c | 24 ++++++++++++++++++++++-- hw/acpi/trace-events | 2 ++ hw/arm/virt.c | 9 ++++++++- hw/core/machine.c | 3 +++ hw/i386/acpi-build.c | 5 +++++ hw/i386/pc.c | 5 +++++ hw/i386/pc_piix.c | 14 +++++++++++++- hw/i386/pc_q35.c | 13 ++++++++++++- hw/isa/lpc_ich9.c | 16 +++++++++++++--- hw/ppc/spapr.c | 15 +++++++++++++-- hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- tests/data/acpi/pc/DSDT | Bin 5060 -> 5067 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6385 -> 6392 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6919 -> 6926 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5524 -> 5531 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6714 -> 6721 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5021 -> 5028 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3079 -> 3086 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5132 -> 5139 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6419 -> 6426 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5066 -> 5073 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5256 -> 5263 bytes tests/data/acpi/q35/DSDT | Bin 7796 -> 7803 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9121 -> 9128 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7814 -> 7821 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8260 -> 8267 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9450 -> 9457 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7871 -> 7878 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9155 -> 9162 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8927 -> 8934 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7802 -> 7809 bytes tests/data/acpi/q35/DSDT.tis | Bin 8402 -> 8409 bytes 36 files changed, 131 insertions(+), 16 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/8 hw: add compat machines for 6.0
From: Cornelia Huck <[email protected]>
Add 6.0 machine types for arm/i440fx/q35/s390x/spapr.
--- include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ hw/arm/virt.c | 9 ++++++++- hw/core/machine.c | 3 +++ hw/i386/pc.c | 3 +++ hw/i386/pc_piix.c | 14 +++++++++++++- hw/i386/pc_q35.c | 13 ++++++++++++- hw/ppc/spapr.c | 15 +++++++++++++-- hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- 9 files changed, 71 insertions(+), 6 deletions(-)
include/hw/boards.h +3 -0
@@ -310,6 +310,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) +extern GlobalProperty hw_compat_5_2[]; +extern const size_t hw_compat_5_2_len; +extern GlobalProperty hw_compat_5_1[];extern const size_t hw_compat_5_1_len;
include/hw/i386/pc.h +3 -0
@@ -191,6 +191,9 @@ void pc_system_firmware_init(PCMachineState *pcms, MemoryRegion *rom_memory);void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid,const CPUArchIdList *apic_ids,GArray *entry); +extern GlobalProperty pc_compat_5_2[]; +extern const size_t pc_compat_5_2_len; +extern GlobalProperty pc_compat_5_1[];extern const size_t pc_compat_5_1_len;
hw/arm/virt.c +8 -1
@@ -2587,10 +2587,17 @@ static void machvirt_machine_init(void) }type_init (machvirt_machine_init); +static void virt_machine_6_0_options (MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(6, 0) +static void virt_machine_5_2_options (MachineClass *mc) { +virt_machine_6_0_options (mc); +compat_props_add (mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); } -DEFINE_VIRT_MACHINE_AS_LATEST(5, 2) +DEFINE_VIRT_MACHINE(5, 2)static void virt_machine_5_1_options (MachineClass *mc) {
hw/core/machine.c +3 -0
@@ -28,6 +28,9 @@#include "hw/mem/nvdimm.h" #include "migration/vmstate.h" +GlobalProperty hw_compat_5_2[] = {}; +const size_t hw_compat_5_2_len =G_N_ELEMENTS (hw_compat_5_2); +GlobalProperty hw_compat_5_1[] = { {"vhost-scsi" ,"num_queues" ,"1" }, {"vhost-user-blk" ,"num-queues" ,"1" },
hw/i386/pc.c +3 -0
@@ -97,6 +97,9 @@#include "trace.h" #include CONFIG_DEVICES +GlobalProperty pc_compat_5_2[] = {}; +const size_t pc_compat_5_2_len =G_N_ELEMENTS (pc_compat_5_2); +GlobalProperty pc_compat_5_1[] = { {"ICH9-LPC" ,"x-smi-cpu-hotplug" ,"off" }, };
hw/i386/pc_piix.c +13 -1
@@ -426,7 +426,7 @@ static void pc_i440fx_machine_options(MachineClass *m)machine_class_allow_dynamic_sysbus_dev (m,TYPE_VMBUS_BRIDGE ); } -static void pc_i440fx_5_2_machine_options (MachineClass *m) +static void pc_i440fx_6_0_machine_options (MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_machine_options (m);
@@ -435,6 +435,18 @@ static void pc_i440fx_5_2_machine_options(MachineClass *m) pcmc->default_cpu_version =1 ; } +DEFINE_I440FX_MACHINE (v6_0,"pc-i440fx-6.0" ,NULL , + pc_i440fx_6_0_machine_options); + +static void pc_i440fx_5_2_machine_options (MachineClass *m) +{ +pc_i440fx_6_0_machine_options (m); + m->alias =NULL ; + m->is_default = false; +compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len); +compat_props_add (m->compat_props, pc_compat_5_2, pc_compat_5_2_len); +} +DEFINE_I440FX_MACHINE (v5_2,"pc-i440fx-5.2" ,NULL , pc_i440fx_5_2_machine_options);
hw/i386/pc_q35.c +12 -1
@@ -344,7 +344,7 @@ static void pc_q35_machine_options(MachineClass *m) m->max_cpus =288 ; } -static void pc_q35_5_2_machine_options (MachineClass *m) +static void pc_q35_6_0_machine_options (MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_machine_options (m);
@@ -352,6 +352,17 @@ static void pc_q35_5_2_machine_options(MachineClass *m) pcmc->default_cpu_version =1 ; } +DEFINE_Q35_MACHINE (v6_0,"pc-q35-6.0" ,NULL , + pc_q35_6_0_machine_options); + +static void pc_q35_5_2_machine_options (MachineClass *m) +{ +pc_q35_6_0_machine_options (m); + m->alias =NULL ; +compat_props_add (m->compat_props, hw_compat_5_2, hw_compat_5_2_len); +compat_props_add (m->compat_props, pc_compat_5_2, pc_compat_5_2_len); +} +DEFINE_Q35_MACHINE (v5_2,"pc-q35-5.2" ,NULL , pc_q35_5_2_machine_options);
hw/ppc/spapr.c +13 -2
@@ -4509,15 +4509,26 @@ static void spapr_machine_latest_class_options(MachineClass *mc) } \ type_init(spapr_machine_register_##suffix) +/* +* pseries-6.0 +*/ +static void spapr_machine_6_0_class_options(MachineClass *mc) +{ +/* Defaults for the latest behaviour inherited from the base class */ +} + +DEFINE_SPAPR_MACHINE(6_0, "6.0", true); +/* * pseries-5.2 */ static void spapr_machine_5_2_class_options (MachineClass *mc) { -/* Defaults for the latest behaviour inherited from the base class */ +spapr_machine_6_0_class_options (mc); +compat_props_add (mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); } -DEFINE_SPAPR_MACHINE(5_2, "5.2", true); +DEFINE_SPAPR_MACHINE(5_2, "5.2", false);/* * pseries-5.1
hw/s390x/s390-virtio-ccw.c +13 -1
@@ -789,14 +789,26 @@ bool css_migration_enabled(void) } \ type_init(ccw_machine_register_##suffix) +static void ccw_machine_6_0_instance_options(MachineState *machine) +{ +} + +static void ccw_machine_6_0_class_options (MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(6_0, "6.0", true); +static void ccw_machine_5_2_instance_options (MachineState *machine) { +ccw_machine_6_0_instance_options (machine); }static void ccw_machine_5_2_class_options (MachineClass *mc) { +ccw_machine_6_0_class_options (mc); +compat_props_add (mc->compat_props, hw_compat_5_2, hw_compat_5_2_len); } -DEFINE_CCW_MACHINE(5_2, "5.2", true); +DEFINE_CCW_MACHINE(5_2, "5.2", false);static void ccw_machine_5_1_instance_options (MachineState *machine) {
Signature · 1 line
2.27.0
PATCH 2/8 acpi: cpuhp: introduce 'firmware performs eject' status/control bits
In reply to Igor MammedovAdds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls _EJ0 method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.
---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit
--- include/hw/acpi/cpu.h | 1 + docs/specs/acpi_cpu_hotplug.txt | 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-)
include/hw/acpi/cpu.h +1 -0
@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus {uint64_t arch_id;bool is_inserting;bool is_removing; +bool fw_remove;uint32_t ost_event;uint32_t ost_status; } AcpiCpuStatus;
docs/specs/acpi_cpu_hotplug.txt +14 -5
@@ -56,8 +56,11 @@ read access: no device check event to OSPM was issued. It's valid only when bit 0 is set. 2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued. - 3-7: reserved and should be ignored by OSPM + no device eject request to OSPM was issued. Firmware must + ignore this bit. + 3: reserved and should be ignored by OSPM + 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM [0x5-0x7] reserved [0x8] Command data: (DWORD access) contains 0 unless value last stored in 'Command field' is one of:
@@ -79,10 +82,16 @@ write access: selected CPU device 2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for the - selected CPU device + selected CPU device. 3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls _EJ0 method - 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls _EJ0 method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject. + 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject. + 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access) value: 0: selects a CPU device with inserting/removing events and
hw/acpi/cpu.c +9 -0
@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ?1 :0 ; val |= cdev->is_inserting ?2 :0 ; val |= cdev->is_removing ?4 :0 ; + val |= cdev->fw_remove ?16 :0 ;trace_cpuhp_acpi_read_flags (cpu_st->selector, val);break ;case ACPI_CPU_CMD_DATA_OFFSET_RW :
@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl =qdev_get_hotplug_handler (dev);hotplug_handler_unplug (hotplug_ctrl, dev,NULL );object_unparent (OBJECT (dev)); + cdev->fw_remove = false; + }else if (data &16 ) { +if (!cdev->cpu || cdev->cpu == first_cpu) { +trace_cpuhp_acpi_fw_remove_invalid_cpu (cpu_st->selector); +break ; + } +trace_cpuhp_acpi_fw_remove_cpu (cpu_st->selector); + cdev->fw_remove = true; }break ;case ACPI_CPU_CMD_OFFSET_WR :
hw/acpi/trace-events +2 -0
@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32 cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
Signature · 1 line
2.27.0
Re: [PATCH 2/8] acpi: cpuhp: introduce 'firmware performs eject' status/control bits
Quoted 88 lines · Igor Mammedov
Adds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls
_EJ0method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.Signed-off-by Igor Mammedov <[email protected]>---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit--- include/hw/acpi/cpu.h | 1 + docs/specs/acpi_cpu_hotplug.txt | 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus {uint64_t arch_id;bool is_inserting;bool is_removing; +bool fw_remove;uint32_t ost_event;uint32_t ost_status; } AcpiCpuStatus;docs/specs/acpi_cpu_hotplug.txt +14
-5@@ -56,8 +56,11 @@ read access: no device check event to OSPM was issued. It's valid only when bit 0 is set. 2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued. - 3-7: reserved and should be ignored by OSPM + no device eject request to OSPM was issued. Firmware must + ignore this bit. + 3: reserved and should be ignored by OSPM + 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM [0x5-0x7] reserved [0x8] Command data: (DWORD access) contains 0 unless value last stored in 'Command field' is one of:@@ -79,10 +82,16 @@ write access: selected CPU device 2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for the - selected CPU device + selected CPU device. 3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls _EJ0 method - 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls _EJ0 method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject. + 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject. + 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access) value: 0: selects a CPU device with inserting/removing events andhw/acpi/cpu.c +1
-0@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ?1 :0 ; val |= cdev->is_inserting ?2 :0 ; val |= cdev->is_removing ?4 :0 ; + val |= cdev->fw_remove ?16 :0 ;trace_cpuhp_acpi_read_flags (cpu_st->selector, val);break ;case ACPI_CPU_CMD_DATA_OFFSET_RW :@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl =qdev_get_hotplug_handler (dev);hotplug_handler_unplug (hotplug_ctrl, dev,NULL );object_unparent (OBJECT (dev));
hw/acpi/cpu.c static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, · line 161
Quoted 10 lines
hw/acpi/cpu.c +8
-0+ cdev->fw_remove = false; + }else if (data &16 ) { +if (!cdev->cpu || cdev->cpu == first_cpu) { +trace_cpuhp_acpi_fw_remove_invalid_cpu (cpu_st->selector); +break ; + } +trace_cpuhp_acpi_fw_remove_cpu (cpu_st->selector); + cdev->fw_remove = true; }break ;
By the time the firmware gets the MMI, cdev->is_removing == 0. So we probably need the cdev->fw_remove clause as well.
@@ -168,7 +193,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data,
do {
cdev = &cpu_st->devs[iter];
- if (cdev->is_inserting || cdev->is_removing) {
+ if (cdev->is_inserting || cdev->is_removing || cdev->fw_remove) {
cpu_st->selector = iter;
trace_cpuhp_acpi_cpu_has_events(cpu_st->selector,
cdev->is_inserting, cdev->is_removing);Ankur
Quoted 15 lines
hw/acpi/cpu.c +0
-0case ACPI_CPU_CMD_OFFSET_WR :hw/acpi/trace-events +2
-0@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32 cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
Re: [PATCH 2/8] acpi: cpuhp: introduce 'firmware performs eject' status/control bits
Quoted 57 lines · Ankur Arora
Quoted 56 lines · Igor Mammedov
Adds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls
_EJ0method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.Signed-off-by Igor Mammedov <[email protected]>---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit
---
include/hw/acpi/cpu.h | 1 +docs/specs/acpi_cpu_hotplug.txt| 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++4 files changed, 26 insertions(+), 5 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus { uint64_t arch_id; bool is_inserting; bool is_removing; + bool fw_remove; uint32_t ost_event; uint32_t ost_status; } AcpiCpuStatus;docs/specs/acpi_cpu_hotplug.txt +0
-0@@ -56,8 +56,11 @@ read access:no device check event to OSPM was issued.
It's valid only when bit 0 is set.
2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued.
- 3-7: reserved and should be ignored by OSPM
+ no device eject request to OSPM was issued. Firmware must + ignore this bit.
+ 3: reserved and should be ignored by OSPM
+ 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM
[0x5-0x7] reserved
[0x8] Command data: (DWORD access)
contains 0 unless value last stored in 'Command field' is one of:docs/specs/acpi_cpu_hotplug.txt +0
-0@@ -79,10 +82,16 @@ write access:selected CPU device
2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for the
Quoted 8 lines
Quoted 8 lines
- selected CPU device
+ selected CPU device.
3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls_EJ0method
- 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls_EJ0method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject.
So I spent some time testing my OVMF series alongside this. Just sent out the code on the EDK2 list.
To do the eject, I'm setting bit#3 after queuing up the processor for removal (via RemoveProcessor()).
This means, however, that the unplug in QEMU would happen before the real firmware unplug (which'll happen in SmmCpuUpdate()).
Clearly, the right place for eject would be either in the appropriate APHandler() or in the BSPHandler() after all the APs have been waited for but from my reading of related code I don't see any infrastructure for doing this (admittedly, I don't know the EDK2 source well enough so it's likely I missed something.)
The other possibility might be to do it in the _EJ0 method itself after we return from the SMI:
@@ -479,9 +515,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
aml_append(method, aml_store(one, fw_ej_evt));
aml_append(method, aml_store(aml_int(OVMF_CPUHP_SMI_CMD),
aml_name("%s", opts.smi_path)));- } else {
- aml_append(method, aml_store(one, ej_evt));
- }
+ }
+ aml_append(method, aml_store(one, ej_evt));
aml_append(method, aml_release(ctrl_lock));This seems to work but it is possible I'm missing something here.
Opinions?
Ankur
Quoted 65 lines
Quoted 24 lines
+ 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject.
+ 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access)
value:
0: selects a CPU device with inserting/removing events andhw/acpi/cpu.c +1
-0@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ? 1 : 0; val |= cdev->is_inserting ? 2 : 0; val |= cdev->is_removing ? 4 : 0; + val |= cdev->fw_remove ? 16 : 0; trace_cpuhp_acpi_read_flags(cpu_st->selector, val); break;case
ACPI_CPU_CMD_DATA_OFFSET_RW:hw/acpi/cpu.c +0
-0@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl = qdev_get_hotplug_handler(dev); hotplug_handler_unplug(hotplug_ctrl, dev, NULL); object_unparent(OBJECT(dev));hw/acpi/cpu.c static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, · line 161
Quoted 10 lines
hw/acpi/cpu.c +8
-0+ cdev->fw_remove = false; + } else if (data & 16) { + if (!cdev->cpu || cdev->cpu == first_cpu) { + trace_cpuhp_acpi_fw_remove_invalid_cpu(cpu_st->selector); + break; + } + trace_cpuhp_acpi_fw_remove_cpu(cpu_st->selector); + cdev->fw_remove = true; } break;By the time the firmware gets the MMI,
cdev->is_removing== 0. So we probably need thecdev->fw_removeclause as well.(quoted diff) +1
-1@@ -168,7 +193,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, do { cdev = &cpu_st->devs[iter]; - if (cdev->is_inserting || cdev->is_removing) { + if (cdev->is_inserting || cdev->is_removing || cdev->fw_remove) { cpu_st->selector = iter; trace_cpuhp_acpi_cpu_has_events(cpu_st->selector, cdev->is_inserting, cdev->is_removing);Ankur
Quoted 14 lines
case
ACPI_CPU_CMD_OFFSET_WR:hw/acpi/trace-events +0
-0@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]"
cpuhp_acpi_clear_remove_evt(uint32_t idx)"idx[0x%"PRIx32"]"cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx)"0x%"PRIx32cpuhp_acpi_ejecting_cpu(uint32_t idx)"0x%"PRIx32hw/acpi/trace-events +2
-0+cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev)"idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st)"idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
Re: [PATCH 2/8] acpi: cpuhp: introduce 'firmware performs eject' status/control bits
Quoted 96 lines · On Mon, 7 Dec 2020 00:47:13 -0800 Ankur Arora <[email protected]> wrote:
Quoted 57 lines · Ankur Arora
Quoted 56 lines · Igor Mammedov
Adds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls
_EJ0method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.Signed-off-by Igor Mammedov <[email protected]>---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit
---
include/hw/acpi/cpu.h | 1 +docs/specs/acpi_cpu_hotplug.txt| 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++4 files changed, 26 insertions(+), 5 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus { uint64_t arch_id; bool is_inserting; bool is_removing; + bool fw_remove; uint32_t ost_event; uint32_t ost_status; } AcpiCpuStatus;docs/specs/acpi_cpu_hotplug.txt +0
-0@@ -56,8 +56,11 @@ read access:no device check event to OSPM was issued.
It's valid only when bit 0 is set.
2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued.
- 3-7: reserved and should be ignored by OSPM
+ no device eject request to OSPM was issued. Firmware must + ignore this bit.
+ 3: reserved and should be ignored by OSPM
+ 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM
[0x5-0x7] reserved
[0x8] Command data: (DWORD access)
contains 0 unless value last stored in 'Command field' is one of:docs/specs/acpi_cpu_hotplug.txt +0
-0@@ -79,10 +82,16 @@ write access:selected CPU device
2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for theQuoted 8 lines
Quoted 8 lines
- selected CPU device
+ selected CPU device.
3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls_EJ0method
- 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls_EJ0method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject.So I spent some time testing my OVMF series alongside this. Just sent out the code on the EDK2 list.
To do the eject, I'm setting bit#3 after queuing up the processor for removal (via
RemoveProcessor()).This means, however, that the unplug in QEMU would happen before the real firmware unplug (which'll happen in
SmmCpuUpdate()).Clearly, the right place for eject would be either in the appropriate
APHandler()or in theBSPHandler()after all the APs have been waited for but from my reading of related code I don't see any infrastructure for doing this (admittedly, I don't know the EDK2 source well enough so it's likely I missed something.)The other possibility might be to do it in the
_EJ0method itself after we return from the SMI:(quoted diff) +2
-3@@ -479,9 +515,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(method, aml_store(one, fw_ej_evt)); aml_append(method, aml_store(aml_int(OVMF_CPUHP_SMI_CMD), aml_name("%s", opts.smi_path))); - } else { - aml_append(method, aml_store(one, ej_evt)); - } + } + aml_append(method, aml_store(one, ej_evt)); aml_append(method, aml_release(ctrl_lock));
Quoted 1 line
This seems to work but it is possible I'm missing something here.
theoretically this leaves unaccounted CPU on fw side,
what if SMM is entered again before CPU is ejected or OS doesn't eject it on purpose?
I'd prefer firmware to remove CPU before returning from SMM.
Quoted 72 lines
Opinions?
Ankur
Quoted 65 lines
Quoted 24 lines
+ 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject.
+ 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access)
value:
0: selects a CPU device with inserting/removing events andhw/acpi/cpu.c +1
-0@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ? 1 : 0; val |= cdev->is_inserting ? 2 : 0; val |= cdev->is_removing ? 4 : 0; + val |= cdev->fw_remove ? 16 : 0; trace_cpuhp_acpi_read_flags(cpu_st->selector, val); break;case
ACPI_CPU_CMD_DATA_OFFSET_RW:hw/acpi/cpu.c +0
-0@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl = qdev_get_hotplug_handler(dev); hotplug_handler_unplug(hotplug_ctrl, dev, NULL); object_unparent(OBJECT(dev));hw/acpi/cpu.c static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, · line 161
Quoted 10 lines
hw/acpi/cpu.c +8
-0+ cdev->fw_remove = false; + } else if (data & 16) { + if (!cdev->cpu || cdev->cpu == first_cpu) { + trace_cpuhp_acpi_fw_remove_invalid_cpu(cpu_st->selector); + break; + } + trace_cpuhp_acpi_fw_remove_cpu(cpu_st->selector); + cdev->fw_remove = true; } break;By the time the firmware gets the MMI,
cdev->is_removing== 0. So we probably need thecdev->fw_removeclause as well.(quoted diff) +1
-1@@ -168,7 +193,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, do { cdev = &cpu_st->devs[iter]; - if (cdev->is_inserting || cdev->is_removing) { + if (cdev->is_inserting || cdev->is_removing || cdev->fw_remove) { cpu_st->selector = iter; trace_cpuhp_acpi_cpu_has_events(cpu_st->selector, cdev->is_inserting, cdev->is_removing);Ankur
Quoted 14 lines
case
ACPI_CPU_CMD_OFFSET_WR:hw/acpi/trace-events +0
-0@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]"
cpuhp_acpi_clear_remove_evt(uint32_t idx)"idx[0x%"PRIx32"]"cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx)"0x%"PRIx32cpuhp_acpi_ejecting_cpu(uint32_t idx)"0x%"PRIx32hw/acpi/trace-events +2
-0+cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev)"idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st)"idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
Re: [PATCH 2/8] acpi: cpuhp: introduce 'firmware performs eject' status/control bits
Quoted 99 lines · Igor Mammedov
Quoted 96 lines · On Mon, 7 Dec 2020 00:47:13 -0800 Ankur Arora <[email protected]> wrote:
Quoted 57 lines · Ankur Arora
Quoted 56 lines · Igor Mammedov
Adds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls
_EJ0method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.Signed-off-by Igor Mammedov <[email protected]>---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit--- include/hw/acpi/cpu.h | 1 + docs/specs/acpi_cpu_hotplug.txt | 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus { uint64_t arch_id; bool is_inserting; bool is_removing; + bool fw_remove; uint32_t ost_event; uint32_t ost_status; } AcpiCpuStatus;docs/specs/acpi_cpu_hotplug.txt +5
-2@@ -56,8 +56,11 @@ read access: no device check event to OSPM was issued. It's valid only when bit 0 is set. 2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued. - 3-7: reserved and should be ignored by OSPM + no device eject request to OSPM was issued. Firmware must + ignore this bit. + 3: reserved and should be ignored by OSPM + 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM [0x5-0x7] reserved [0x8] Command data: (DWORD access) contains 0 unless value last stored in 'Command field' is one of:@@ -79,10 +82,16 @@ write access: selected CPU device 2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for theQuoted 8 lines
docs/specs/acpi_cpu_hotplug.txt write access: · line 89
Quoted 8 lines
docs/specs/acpi_cpu_hotplug.txt +4
-3- selected CPU device + selected CPU device. 3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls _EJ0 method - 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls _EJ0 method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject.So I spent some time testing my OVMF series alongside this. Just sent out the code on the EDK2 list.
To do the eject, I'm setting bit#3 after queuing up the processor for removal (via
RemoveProcessor()).This means, however, that the unplug in QEMU would happen before the real firmware unplug (which'll happen in
SmmCpuUpdate()).Clearly, the right place for eject would be either in the appropriate
APHandler()or in theBSPHandler()after all the APs have been waited for but from my reading of related code I don't see any infrastructure for doing this (admittedly, I don't know the EDK2 source well enough so it's likely I missed something.)The other possibility might be to do it in the
_EJ0method itself after we return from the SMI:(quoted diff) +2
-3@@ -479,9 +515,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(method, aml_store(one, fw_ej_evt)); aml_append(method, aml_store(aml_int(OVMF_CPUHP_SMI_CMD), aml_name("%s", opts.smi_path))); - } else { - aml_append(method, aml_store(one, ej_evt)); - } + } + aml_append(method, aml_store(one, ej_evt)); aml_append(method, aml_release(ctrl_lock));
Quoted 3 lines
Quoted 1 line
This seems to work but it is possible I'm missing something here.
theoretically this leaves unaccounted CPU on fw side,
On the guest side right? As in the firmware has marked it gone but it's not really gone.
Quoted 1 line
what if SMM is entered again before CPU is ejected or OS doesn't eject it on purpose?
Yeah both of those things would be a mess. I'm not even sure it would enter the SMM again -- given that the SMM has marked it gone.
Quoted 2 lines
I'd prefer firmware to remove CPU before returning from SMM.
That would be ideal though I don't yet see a mechanism for doing that. Laszlo might have better ideas though.
Another possibility that might address your concerns would be deferred removal.
Need to work out the details, but here's a sketch of what I'm thinking:
When the firmware writes to bit#3, QEMU marks the CPU for deferred removal. And, when the firmware exits from the SMI handler, we force a VMEXIT before returning to the guest. And, as part of this VMEXIT, QEMU does the actual unplug.
Ankur
Quoted 75 lines
Quoted 74 lines
Opinions?
Ankur
Quoted 65 lines
Quoted 24 lines
docs/specs/acpi_cpu_hotplug.txt +5
-0+ 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject. + 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access) value: 0: selects a CPU device with inserting/removing events andhw/acpi/cpu.c +1
-0@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ? 1 : 0; val |= cdev->is_inserting ? 2 : 0; val |= cdev->is_removing ? 4 : 0; + val |= cdev->fw_remove ? 16 : 0; trace_cpuhp_acpi_read_flags(cpu_st->selector, val); break; case ACPI_CPU_CMD_DATA_OFFSET_RW:@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl = qdev_get_hotplug_handler(dev); hotplug_handler_unplug(hotplug_ctrl, dev, NULL); object_unparent(OBJECT(dev));hw/acpi/cpu.c static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, · line 161
Quoted 10 lines
hw/acpi/cpu.c +8
-0+ cdev->fw_remove = false; + } else if (data & 16) { + if (!cdev->cpu || cdev->cpu == first_cpu) { + trace_cpuhp_acpi_fw_remove_invalid_cpu(cpu_st->selector); + break; + } + trace_cpuhp_acpi_fw_remove_cpu(cpu_st->selector); + cdev->fw_remove = true; } break;By the time the firmware gets the MMI,
cdev->is_removing== 0. So we probably need thecdev->fw_removeclause as well.(quoted diff) +1
-1@@ -168,7 +193,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, do { cdev = &cpu_st->devs[iter]; - if (cdev->is_inserting || cdev->is_removing) { + if (cdev->is_inserting || cdev->is_removing || cdev->fw_remove) { cpu_st->selector = iter; trace_cpuhp_acpi_cpu_has_events(cpu_st->selector, cdev->is_inserting, cdev->is_removing);Ankur
Quoted 14 lines
hw/acpi/cpu.c +0
-0case ACPI_CPU_CMD_OFFSET_WR:hw/acpi/trace-events +2
-0@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32 cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
Re: [PATCH 2/8] acpi: cpuhp: introduce 'firmware performs eject' status/control bits
In reply to Ankur AroraQuoted 94 lines · On Sun, 6 Dec 2020 22:31:50 -0800 Ankur Arora <[email protected]> wrote:
Quoted 93 lines · Igor Mammedov
Adds bit #4 to status/control field of CPU hotplug MMIO interface. New bit will be used OSPM to mark CPUs as pending for removal by firmware, when it calls
_EJ0method on CPU device node. Later on, when firmware sees this bit set, it will perform CPU eject which will clear bit #4 as well.Signed-off-by Igor Mammedov <[email protected]>---
v1:
- rearrange status/control bits description (Laszlo)
- add clear bit #4 on eject
- drop toggling logic from bit #4, it can be only set by guest and clear as part of cpu eject
- exclude boot CPU from remove request
- add trace events for new bit--- include/hw/acpi/cpu.h | 1 + docs/specs/acpi_cpu_hotplug.txt | 19 ++++++++++++++----- hw/acpi/cpu.c | 9 +++++++++ hw/acpi/trace-events | 2 ++ 4 files changed, 26 insertions(+), 5 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -22,6 +22,7 @@ typedef struct AcpiCpuStatus {uint64_t arch_id;bool is_inserting;bool is_removing; +bool fw_remove;uint32_t ost_event;uint32_t ost_status; } AcpiCpuStatus;docs/specs/acpi_cpu_hotplug.txt +14
-5@@ -56,8 +56,11 @@ read access: no device check event to OSPM was issued. It's valid only when bit 0 is set. 2: Device remove event, used to distinguish device for which - no device eject request to OSPM was issued. - 3-7: reserved and should be ignored by OSPM + no device eject request to OSPM was issued. Firmware must + ignore this bit. + 3: reserved and should be ignored by OSPM + 4: if set to 1, OSPM requests firmware to perform device eject. + 5-7: reserved and should be ignored by OSPM [0x5-0x7] reserved [0x8] Command data: (DWORD access) contains 0 unless value last stored in 'Command field' is one of:@@ -79,10 +82,16 @@ write access: selected CPU device 2: if set to 1 clears device remove event, set by OSPM after it has emitted device eject request for the - selected CPU device + selected CPU device. 3: if set to 1 initiates device eject, set by OSPM when it - triggers CPU device removal and calls _EJ0 method - 4-7: reserved, OSPM must clear them before writing to register + triggers CPU device removal and calls _EJ0 method or by firmware + when bit #4 is set. In case bit #4 were set, it's cleared as + part of device eject. + 4: if set to 1, OSPM hands over device eject to firmware. + Firmware shall issue device eject request as described above + (bit #3) and OSPM should not touch device eject bit (#3) in case + it's asked firmware to perform CPU device eject. + 5-7: reserved, OSPM must clear them before writing to register [0x5] Command field: (1 byte access) value: 0: selects a CPU device with inserting/removing events andhw/acpi/cpu.c +6
-0@@ -71,6 +71,7 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->cpu ?1 :0 ; val |= cdev->is_inserting ?2 :0 ; val |= cdev->is_removing ?4 :0 ; + val |= cdev->fw_remove ?16 :0 ;trace_cpuhp_acpi_read_flags (cpu_st->selector, val);break ;case ACPI_CPU_CMD_DATA_OFFSET_RW :@@ -148,6 +149,14 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, hotplug_ctrl =qdev_get_hotplug_handler (dev);hotplug_handler_unplug (hotplug_ctrl, dev,NULL );object_unparent (OBJECT (dev)); + cdev->fw_remove = false; + }else if (data &16 ) { +if (!cdev->cpu || cdev->cpu == first_cpu) { +trace_cpuhp_acpi_fw_remove_invalid_cpu (cpu_st->selector); +break ;
Quoted 8 lines
hw/acpi/cpu.c static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, · line 161
Quoted 5 lines
hw/acpi/cpu.c +3
-0+ } +trace_cpuhp_acpi_fw_remove_cpu (cpu_st->selector); + cdev->fw_remove = true; }break ;By the time the firmware gets the MMI,
cdev->is_removing== 0. So we probably need thecdev->fw_removeclause as well.
indeed, I'll fix in in v2
Quoted 30 lines
(quoted diff) +1
-1@@ -168,7 +193,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, do { cdev = &cpu_st->devs[iter]; - if (cdev->is_inserting || cdev->is_removing) { + if (cdev->is_inserting || cdev->is_removing || cdev->fw_remove) { cpu_st->selector = iter; trace_cpuhp_acpi_cpu_has_events(cpu_st->selector, cdev->is_inserting, cdev->is_removing);Ankur
Quoted 15 lines
hw/acpi/cpu.c +0
-0case ACPI_CPU_CMD_OFFSET_WR :hw/acpi/trace-events +2
-0@@ -29,6 +29,8 @@ cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_fw_remove_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_write_ost_ev(uint32_t slot, uint32_t ev) "idx[0x%"PRIx32"] OST EVENT: 0x%"PRIx32 cpuhp_acpi_write_ost_status(uint32_t slot, uint32_t st) "idx[0x%"PRIx32"] OST STATUS: 0x%"PRIx32
PATCH 3/8 x86: acpi: introduce AcpiPmInfo::smi_on_cpu_unplug
In reply to Igor Mammedov--- hw/i386/acpi-build.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/acpi-build.c +4 -0
@@ -96,6 +96,7 @@ typedef struct AcpiPmInfo {bool s4_disabled;bool pcihp_bridge_en;bool smi_on_cpuhp; +bool smi_on_cpu_unplug;bool pcihp_root_en;uint8_t s4_val;AcpiFadtData fadt;
@@ -197,6 +198,7 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) pm->pcihp_io_base =0 ; pm->pcihp_io_len =0 ; pm->smi_on_cpuhp = false; + pm->smi_on_cpu_unplug = false;assert (obj);init_common_fadt_data (machine, obj, &pm->fadt);
@@ -220,6 +222,8 @@ static void acpi_get_pm_info(MachineState *machine, AcpiPmInfo *pm) 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 )); + pm->smi_on_cpu_unplug = + !!(smi_features &BIT_ULL (ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT )); }/* The above need not be conditional on machine type because the reset port
Signature · 1 line
2.27.0
PATCH 4/8 tests/acpi: allow expected files change
In reply to Igor MammedovChange that will be introduced by following patch:
@@ -557,6 +557,8 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
CINS, 1,
CRMV, 1,
CEJ0, 1,
+ , 1,
+ CEJF, 1,
Offset (0x05),
CCMD, 8
}--- tests/qtest/bios-tables-test-allowed-diff.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +21 -0
@@ -1 +1,22 @@/* 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.roothp" , +"tests/data/acpi/pc/DSDT.hpbridge" , +"tests/data/acpi/pc/DSDT.hpbrroot",
Signature · 1 line
2.27.0
PATCH 5/8 x86: acpi: let the firmware handle pending "CPU remove" events in SMM
In reply to Igor Mammedovif firmware and QEMU negotiated CPU hotunplug support, generate _EJ0 method so that it will mark CPU for removal by firmware and pass control to it by triggering SMI.
--- include/hw/acpi/cpu.h | 1 + hw/acpi/cpu.c | 15 +++++++++++++-- hw/i386/acpi-build.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-)
include/hw/acpi/cpu.h +1 -0
@@ -51,6 +51,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,typedef struct CPUHotplugFeatures {bool acpi_1_compatible;bool has_legacy_cphp; +bool fw_unplugs_cpu;const char *smi_path; }CPUHotplugFeatures ;
hw/acpi/cpu.c +13 -2
@@ -341,6 +341,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_INSERT_EVENT "CINS"#define CPU_REMOVE_EVENT "CRMV"#define CPU_EJECT_EVENT "CEJ0" +#define CPU_FW_EJECT_EVENT "CEJF" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, hwaddr io_base,
@@ -393,7 +394,10 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (field,aml_named_field (CPU_REMOVE_EVENT ,1 ));/* initiates device eject, write only */ aml_append (field,aml_named_field (CPU_EJECT_EVENT ,1 )); -aml_append (field,aml_reserved_field (4 )); +aml_append (field,aml_reserved_field (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 (2 ));aml_append (field,aml_named_field (CPU_COMMAND ,8 ));aml_append (cpu_ctrl_dev, field);
@@ -428,6 +432,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,Aml *ins_evt =aml_name ("%s.%s" , cphp_res_path,CPU_INSERT_EVENT );Aml *rm_evt =aml_name ("%s.%s" , cphp_res_path,CPU_REMOVE_EVENT );Aml *ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_EJECT_EVENT ); +Aml *fw_ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_FW_EJECT_EVENT );aml_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" )));aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" )));
@@ -470,7 +475,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (method,aml_acquire (ctrl_lock,0xFFFF ));aml_append (method,aml_store (idx, cpu_selector)); -aml_append (method,aml_store (one, ej_evt)); +if (opts.fw_unplugs_cpu) { +aml_append (method,aml_store (one, fw_ej_evt)); +aml_append (method,aml_store (aml_int (OVMF_CPUHP_SMI_CMD ), +aml_name ("%s" , opts.smi_path))); + }else { +aml_append (method,aml_store (one, ej_evt)); + }aml_append (method,aml_release (ctrl_lock)); }aml_append (cpus_dev, method);
hw/i386/acpi-build.c +1 -0
@@ -1586,6 +1586,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,CPUHotplugFeatures opts = { .acpi_1_compatible = true, .has_legacy_cphp = true, .smi_path = pm->smi_on_cpuhp ?"\\_SB.PCI0.SMI0.SMIC" :NULL , + .fw_unplugs_cpu = pm->smi_on_cpu_unplug, };build_cpus_aml (dsdt, machine, opts, pm->cpu_hp_io_base,"\\_SB.PCI0" ,"\\_GPE._E02" );
Signature · 1 line
2.27.0
Re: [PATCH 5/8] x86: acpi: let the firmware handle pending "CPU remove" events in SMM
Quoted 36 lines · Igor Mammedov
if firmware and QEMU negotiated CPU hotunplug support, generate
_EJ0method so that it will mark CPU for removal by firmware and pass control to it by triggering SMI.Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/cpu.h | 1 + hw/acpi/cpu.c | 15 +++++++++++++-- hw/i386/acpi-build.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -51,6 +51,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,typedef struct CPUHotplugFeatures {bool acpi_1_compatible;bool has_legacy_cphp; +bool fw_unplugs_cpu;const char *smi_path; }CPUHotplugFeatures ;hw/acpi/cpu.c +1
-0@@ -341,6 +341,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_INSERT_EVENT "CINS"#define CPU_REMOVE_EVENT "CRMV"#define CPU_EJECT_EVENT "CEJ0" +#define CPU_FW_EJECT_EVENT "CEJF" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, hwaddr io_base,
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 394
Quoted 1 line
hw/acpi/cpu.c +0
-0@@ -393,7 +394,10 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (field,aml_named_field (CPU_REMOVE_EVENT ,1 ));
Bit 2: Device remove event, used to distinguish device for which
no device eject request to OSPM was issued. Firmware must ignore this bit.
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 396
Quoted 2 lines
hw/acpi/cpu.c +0
-0/* initiates device eject, write only */ aml_append (field,aml_named_field (CPU_EJECT_EVENT ,1 ));
Bit 3: reserved and should be ignored by OSPM
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 400
Quoted 5 lines
hw/acpi/cpu.c +4
-1-aml_append (field,aml_reserved_field (4 )); +aml_append (field,aml_reserved_field (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 (2 ));
Shouldn't this be instead:
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
Quoted 4 lines
hw/acpi/cpu.c +3
-1-aml_append (field,aml_reserved_field (4 )); +/* 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 ));
Bit 4: if set to 1, OSPM requests firmware to perform device eject. Bit 5-7: reserved and should be ignored by OSPM
Otherwise AFAICS CPU_FW_EJECT_EVENT would correspond to bit 5.
Ankur
Quoted 39 lines
hw/acpi/cpu.c +8
-1aml_append (field,aml_named_field (CPU_COMMAND ,8 ));aml_append (cpu_ctrl_dev, field);@@ -428,6 +432,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,Aml *ins_evt =aml_name ("%s.%s" , cphp_res_path,CPU_INSERT_EVENT );Aml *rm_evt =aml_name ("%s.%s" , cphp_res_path,CPU_REMOVE_EVENT );Aml *ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_EJECT_EVENT ); +Aml *fw_ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_FW_EJECT_EVENT );aml_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" )));aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" )));@@ -470,7 +475,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (method,aml_acquire (ctrl_lock,0xFFFF ));aml_append (method,aml_store (idx, cpu_selector)); -aml_append (method,aml_store (one, ej_evt)); +if (opts.fw_unplugs_cpu) { +aml_append (method,aml_store (one, fw_ej_evt)); +aml_append (method,aml_store (aml_int (OVMF_CPUHP_SMI_CMD ), +aml_name ("%s" , opts.smi_path))); + }else { +aml_append (method,aml_store (one, ej_evt)); + }aml_append (method,aml_release (ctrl_lock)); }aml_append (cpus_dev, method);hw/i386/acpi-build.c +1
-0@@ -1586,6 +1586,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,CPUHotplugFeatures opts = { .acpi_1_compatible = true, .has_legacy_cphp = true, .smi_path = pm->smi_on_cpuhp ?"\\_SB.PCI0.SMI0.SMIC" :NULL , + .fw_unplugs_cpu = pm->smi_on_cpu_unplug, };build_cpus_aml (dsdt, machine, opts, pm->cpu_hp_io_base,"\\_SB.PCI0" ,"\\_GPE._E02" );
Re: [PATCH 5/8] x86: acpi: let the firmware handle pending "CPU remove" events in SMM
Quoted 41 lines · Ankur Arora
Quoted 34 lines · Igor Mammedov
if firmware and QEMU negotiated CPU hotunplug support, generate
_EJ0method so that it will mark CPU for removal by firmware and pass control to it by triggering SMI.Signed-off-by Igor Mammedov <[email protected]>---
include/hw/acpi/cpu.h| 1 +
hw/acpi/cpu.c | 15 +++++++++++++--
hw/i386/acpi-build.c | 1 +3 files changed, 15 insertions(+), 2 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -51,6 +51,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner, typedef struct CPUHotplugFeatures { bool acpi_1_compatible; bool has_legacy_cphp; + bool fw_unplugs_cpu; const char *smi_path; } CPUHotplugFeatures;hw/acpi/cpu.c +1
-0@@ -341,6 +341,7 @@ const VMStateDescription vmstate_cpu_hotplug = { #define CPU_INSERT_EVENT "CINS" #define CPU_REMOVE_EVENT "CRMV" #define CPU_EJECT_EVENT "CEJ0" +#define CPU_FW_EJECT_EVENT "CEJF" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, hwaddr io_base,hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 394
Quoted 1 line
hw/acpi/cpu.c +0
-0@@ -393,7 +394,10 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(field, aml_named_field(CPU_REMOVE_EVENT, 1));Bit 2: Device remove event, used to distinguish device for which no device eject request to OSPM was issued. Firmware must ignore this bit.
Quoted 4 lines
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 396
Quoted 2 lines
hw/acpi/cpu.c +0
-0/* initiates device eject, write only */ aml_append(field, aml_named_field(CPU_EJECT_EVENT, 1));Bit 3: reserved and should be ignored by OSPM
In write-access mode:
Bit 3: if set to 1 initiates device eject, set by OSPM when it
triggers CPU device removal and calls _EJ0 method or by firmware when bit #4 is set. In case bit #4 were set, it's cleared as part of device eject.
(and so should not be a reserved_field() below)
Quoted 58 lines
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 400
Quoted 6 lines
hw/acpi/cpu.c +4
-1- aml_append(field, aml_reserved_field(4)); + aml_append(field, aml_reserved_field(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(2));Shouldn't this be instead:
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
Quoted 4 lines
hw/acpi/cpu.c +3
-1- aml_append(field, aml_reserved_field(4)); + /* 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));Bit 4: if set to 1, OSPM requests firmware to perform device eject. Bit 5-7: reserved and should be ignored by OSPM
Otherwise AFAICS
CPU_FW_EJECT_EVENTwould correspond to bit 5.Ankur
Quoted 36 lines
aml_append(field, aml_named_field(CPU_COMMAND, 8));aml_append(cpu_ctrl_dev, field);hw/acpi/cpu.c +8
-1@@ -428,6 +432,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, Aml *ins_evt = aml_name("%s.%s", cphp_res_path, CPU_INSERT_EVENT); Aml *rm_evt = aml_name("%s.%s", cphp_res_path, CPU_REMOVE_EVENT); Aml *ej_evt = aml_name("%s.%s", cphp_res_path, CPU_EJECT_EVENT); + Aml *fw_ej_evt = aml_name("%s.%s", cphp_res_path, CPU_FW_EJECT_EVENT); aml_append(cpus_dev, aml_name_decl("_HID", aml_string("ACPI0010"))); aml_append(cpus_dev, aml_name_decl("_CID", aml_eisaid("PNP0A05")));@@ -470,7 +475,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, aml_append(method, aml_acquire(ctrl_lock, 0xFFFF)); aml_append(method, aml_store(idx, cpu_selector)); - aml_append(method, aml_store(one, ej_evt)); + if (opts.fw_unplugs_cpu) { + aml_append(method, aml_store(one, fw_ej_evt)); + aml_append(method, aml_store(aml_int(OVMF_CPUHP_SMI_CMD), + aml_name("%s", opts.smi_path))); + } else { + aml_append(method, aml_store(one, ej_evt)); + } aml_append(method, aml_release(ctrl_lock)); } aml_append(cpus_dev, method);hw/i386/acpi-build.c +1
-0@@ -1586,6 +1586,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, CPUHotplugFeatures opts = { .acpi_1_compatible = true, .has_legacy_cphp = true, .smi_path = pm->smi_on_cpuhp ? "\\_SB.PCI0.SMI0.SMIC" : NULL, + .fw_unplugs_cpu = pm->smi_on_cpu_unplug, }; build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base, "\\_SB.PCI0", "\\_GPE._E02");
Re: [PATCH 5/8] x86: acpi: let the firmware handle pending "CPU remove" events in SMM
In reply to Ankur AroraQuoted 48 lines · On Sun, 6 Dec 2020 22:20:27 -0800 Ankur Arora <[email protected]> wrote:
Quoted 36 lines · Igor Mammedov
if firmware and QEMU negotiated CPU hotunplug support, generate
_EJ0method so that it will mark CPU for removal by firmware and pass control to it by triggering SMI.Signed-off-by Igor Mammedov <[email protected]>--- include/hw/acpi/cpu.h | 1 + hw/acpi/cpu.c | 15 +++++++++++++-- hw/i386/acpi-build.c | 1 + 3 files changed, 15 insertions(+), 2 deletions(-)include/hw/acpi/cpu.h +1
-0@@ -51,6 +51,7 @@ void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,typedef struct CPUHotplugFeatures {bool acpi_1_compatible;bool has_legacy_cphp; +bool fw_unplugs_cpu;const char *smi_path; }CPUHotplugFeatures ;hw/acpi/cpu.c +1
-0@@ -341,6 +341,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_INSERT_EVENT "CINS"#define CPU_REMOVE_EVENT "CRMV"#define CPU_EJECT_EVENT "CEJ0" +#define CPU_FW_EJECT_EVENT "CEJF" void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, hwaddr io_base,hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 394
Quoted 1 line
hw/acpi/cpu.c +0
-0@@ -393,7 +394,10 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (field,aml_named_field (CPU_REMOVE_EVENT ,1 ));Bit 2: Device remove event, used to distinguish device for which
no device eject request to OSPM was issued. Firmware must ignore this bit.hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 396
Quoted 2 lines
hw/acpi/cpu.c +0
-0/* initiates device eject, write only */ aml_append (field,aml_named_field (CPU_EJECT_EVENT ,1 ));Bit 3: reserved and should be ignored by OSPM
Quoted 13 lines
hw/acpi/cpu.c void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts, · line 400
Quoted 5 lines
hw/acpi/cpu.c +4
-1-aml_append (field,aml_reserved_field (4 )); +aml_append (field,aml_reserved_field (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 (2 ));Shouldn't this be instead:
Quoted 4 lines
hw/acpi/cpu.c +3
-1-aml_append (field,aml_reserved_field (4 )); +/* 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 ));
yes, it should be this way,
I'll fix in v2
Quoted 48 lines
Bit 4: if set to 1, OSPM requests firmware to perform device eject. Bit 5-7: reserved and should be ignored by OSPM
Otherwise AFAICS
CPU_FW_EJECT_EVENTwould correspond to bit 5.Ankur
Quoted 39 lines
hw/acpi/cpu.c +8
-1aml_append (field,aml_named_field (CPU_COMMAND ,8 ));aml_append (cpu_ctrl_dev, field);@@ -428,6 +432,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,Aml *ins_evt =aml_name ("%s.%s" , cphp_res_path,CPU_INSERT_EVENT );Aml *rm_evt =aml_name ("%s.%s" , cphp_res_path,CPU_REMOVE_EVENT );Aml *ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_EJECT_EVENT ); +Aml *fw_ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_FW_EJECT_EVENT );aml_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" )));aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" )));@@ -470,7 +475,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,aml_append (method,aml_acquire (ctrl_lock,0xFFFF ));aml_append (method,aml_store (idx, cpu_selector)); -aml_append (method,aml_store (one, ej_evt)); +if (opts.fw_unplugs_cpu) { +aml_append (method,aml_store (one, fw_ej_evt)); +aml_append (method,aml_store (aml_int (OVMF_CPUHP_SMI_CMD ), +aml_name ("%s" , opts.smi_path))); + }else { +aml_append (method,aml_store (one, ej_evt)); + }aml_append (method,aml_release (ctrl_lock)); }aml_append (cpus_dev, method);hw/i386/acpi-build.c +1
-0@@ -1586,6 +1586,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,CPUHotplugFeatures opts = { .acpi_1_compatible = true, .has_legacy_cphp = true, .smi_path = pm->smi_on_cpuhp ?"\\_SB.PCI0.SMI0.SMIC" :NULL , + .fw_unplugs_cpu = pm->smi_on_cpu_unplug, };build_cpus_aml (dsdt, machine, opts, pm->cpu_hp_io_base,"\\_SB.PCI0" ,"\\_GPE._E02" );
PATCH 6/8 tests/acpi: update expected files
In reply to Igor Mammedov--- tests/qtest/bios-tables-test-allowed-diff.h | 21 -------------------- tests/data/acpi/pc/DSDT | Bin 5060 -> 5067 bytes tests/data/acpi/pc/DSDT.acpihmat | Bin 6385 -> 6392 bytes tests/data/acpi/pc/DSDT.bridge | Bin 6919 -> 6926 bytes tests/data/acpi/pc/DSDT.cphp | Bin 5524 -> 5531 bytes tests/data/acpi/pc/DSDT.dimmpxm | Bin 6714 -> 6721 bytes tests/data/acpi/pc/DSDT.hpbridge | Bin 5021 -> 5028 bytes tests/data/acpi/pc/DSDT.hpbrroot | Bin 3079 -> 3086 bytes tests/data/acpi/pc/DSDT.ipmikcs | Bin 5132 -> 5139 bytes tests/data/acpi/pc/DSDT.memhp | Bin 6419 -> 6426 bytes tests/data/acpi/pc/DSDT.numamem | Bin 5066 -> 5073 bytes tests/data/acpi/pc/DSDT.roothp | Bin 5256 -> 5263 bytes tests/data/acpi/q35/DSDT | Bin 7796 -> 7803 bytes tests/data/acpi/q35/DSDT.acpihmat | Bin 9121 -> 9128 bytes tests/data/acpi/q35/DSDT.bridge | Bin 7814 -> 7821 bytes tests/data/acpi/q35/DSDT.cphp | Bin 8260 -> 8267 bytes tests/data/acpi/q35/DSDT.dimmpxm | Bin 9450 -> 9457 bytes tests/data/acpi/q35/DSDT.ipmibt | Bin 7871 -> 7878 bytes tests/data/acpi/q35/DSDT.memhp | Bin 9155 -> 9162 bytes tests/data/acpi/q35/DSDT.mmio64 | Bin 8927 -> 8934 bytes tests/data/acpi/q35/DSDT.numamem | Bin 7802 -> 7809 bytes tests/data/acpi/q35/DSDT.tis | Bin 8402 -> 8409 bytes 22 files changed, 21 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -21
@@ -1,22 +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.roothp" , -"tests/data/acpi/pc/DSDT.hpbridge" , -"tests/data/acpi/pc/DSDT.hpbrroot",
tests/data/acpi/pc/DSDT binary +0 -0
tests/data/acpi/pc/DSDT.acpihmat binary +0 -0
tests/data/acpi/pc/DSDT.bridge binary +0 -0
tests/data/acpi/pc/DSDT.cphp binary +0 -0
tests/data/acpi/pc/DSDT.dimmpxm binary +0 -0
tests/data/acpi/pc/DSDT.hpbridge binary +0 -0
tests/data/acpi/pc/DSDT.hpbrroot binary +0 -0
tests/data/acpi/pc/DSDT.ipmikcs binary +0 -0
tests/data/acpi/pc/DSDT.memhp binary +0 -0
tests/data/acpi/pc/DSDT.numamem binary +0 -0
tests/data/acpi/pc/DSDT.roothp binary +0 -0
tests/data/acpi/q35/DSDT binary +0 -0
tests/data/acpi/q35/DSDT.acpihmat binary +0 -0
tests/data/acpi/q35/DSDT.bridge binary +0 -0
tests/data/acpi/q35/DSDT.cphp binary +0 -0
tests/data/acpi/q35/DSDT.dimmpxm binary +0 -0
tests/data/acpi/q35/DSDT.ipmibt binary +0 -0
tests/data/acpi/q35/DSDT.memhp binary +0 -0
tests/data/acpi/q35/DSDT.mmio64 binary +0 -0
tests/data/acpi/q35/DSDT.numamem binary +0 -0
tests/data/acpi/q35/DSDT.tis binary +0 -0
Signature · 1 line
2.27.0
PATCH 7/8 x86: ich9: factor out "guest_cpu_hotplug_features"
In reply to Igor Mammedovit will be reused by next patch to check validity of unplug feature.
--- hw/isa/lpc_ich9.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
hw/isa/lpc_ich9.c +6 -2
@@ -366,6 +366,7 @@ static void smi_features_ok_callback(void *opaque) {ICH9LPCState *lpc = opaque;uint64_t guest_features; +uint64_t guest_cpu_hotplug_features;if (lpc->smi_features_ok) {/* negotiation already complete, features locked */
@@ -378,9 +379,12 @@ static void smi_features_ok_callback(void *opaque)/* guest requests invalid features, leave @features_ok at zero */ return ; } + + guest_cpu_hotplug_features = guest_features & + (BIT_ULL (ICH9_LPC_SMI_F_CPU_HOTPLUG_BIT ) | +BIT_ULL (ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT ));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 ))) { + guest_cpu_hotplug_features) {/* * cpu hot-[un]plug with SMI requires SMI broadcast, * leave @features_ok at zero
Signature · 1 line
2.27.0
PATCH 8/8 x86: ich9: let firmware negotiate 'CPU hot-unplug with SMI' feature
In reply to Igor MammedovKeep CPU hotunplug with SMI disabled on 5.2 and older and enable it by default on newer machine types.
---
v1:
- ensure that unplug can't be enabled without hotplug (Laszlo)
--- hw/i386/pc.c | 4 +++- hw/isa/lpc_ich9.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-)
hw/i386/pc.c +3 -1
@@ -97,7 +97,9 @@#include "trace.h" #include CONFIG_DEVICES -GlobalProperty pc_compat_5_2[] = {}; +GlobalProperty pc_compat_5_2[] = { + {"ICH9-LPC" ,"x-smi-cpu-hotunplug" ,"off" }, +};const size_t pc_compat_5_2_len =G_N_ELEMENTS (pc_compat_5_2);GlobalProperty pc_compat_5_1[] = {
hw/isa/lpc_ich9.c +7 -1
@@ -392,6 +392,12 @@ static void smi_features_ok_callback(void *opaque)return ; } +if (guest_cpu_hotplug_features == +BIT_ULL (ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT )) { +/* cpu hot-unplug is unsupported without cpu-hotplug */ +return ; + } +/* valid feature subset requested, lock it down, report success */ lpc->smi_negotiated_features = guest_features; lpc->smi_features_ok =1 ;
@@ -774,7 +780,7 @@ static Property ich9_lpc_properties[] = {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), +ICH9_LPC_SMI_F_CPU_HOT_UNPLUG_BIT , true), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
2.27.0