ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods
cover ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods
Current ACPI interface for CPU hotplug supports hotadding only upto 255 CPUs and lacks means to convey additional information needed for _PXM and _OST methods support. Also being bitmap based with bit position specifying APIC ID it doesn't scale up for 32-bit APIC IDs that would with x2APIC support in KVM.
So factor out current CPU hotplug into legacy module, that is used by 2.6 and older machine types as we can't break ABI and build another QEMU-guest interface using as model memory-hotplug. New interface will be used since 2.7 machine types and will support:
- more thant 255 CPUs with any 32-bit APIC ID value
- a registers set to communicate PXM/OST information (extendable without breaking IO layout)
- possible to reuse for ARM's 'virt' machine type with minimal tweaks (add init for MMIO, add
ACPI hooks on CPU hotplug path)
Series consists of 2 parts:
1-14 patches: cleanup, consolidate legacy ACPI CPU hotplug,
use it only on 2.6 and older machine types + adding related ACPI tables test case
15-41 patches:
* extending AcpiDeviceIfClass to make ACPI event notification more target agnostic,
* adding explicit machine.cpu-hotplug property so that feature would be enabled only when users ask for it, saving some IO ports/memory/CPU cycles when it's not needed
(applies only to 2.7 and newer machine types,
legacy hotplug is always enabled on 2.6 and older machine types so it won't break migration).
* adding new ACPI HW and AML parts of CPU hotplug that support more than 255 CPUs. Plus some cleanups that partially remove apic_id_limit limitation. The rest of apic_id_limit cleanups will go later on top of this series as part of x2APIC series.
* implementing unplug side of ACPI HW/AML and basic unplug hooking in hot-unplug callback. TODO:For mgmt to use unplug it needs device_add/del support which is work in progress and will go on top of this series.
* adding extra _PXM/_OST method handling so that guest would actually know to which node CPU is hotplugged and report hotplug status progress to mgmt.
Tested with following guests: RHEL7, WS2003EEx64, WS2012R2x64
* unplug is tested only with RHEL7 as Windows doesn't support it.
* untested migration.
git tree for testing:
[email protected]:imammedo/qemu.git modern_cpu_hotplug_RFC
viewing:
https://github.com/imammedo/qemu/commits/modern_cpu_hotplug_RFC
Igor Mammedov (42):
acpi: add aml_debug()
acpi: add aml_refof()
pc: acpi: remove AML for empty/not used GPE handlers
pc: acpi: consolidate CPU hotplug AML
pc: acpi: consolidate \GPE._E02 with the rest of CPU hotplug AML
pc: acpi: cpu-hotplug: make AML CPU_foo defines local to
cpu_hotplug_acpi_table.c
pc: acpi: mark current CPU hotplug functions as legacy
pc: acpi: consolidate legacy CPU hotplug in one file
pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature
pc: piix4/ich9: add 'cpu-hotplug-legacy' property
pc: add 2.7 machine
pc: initialize legacy hotplug only for 2.6 and older machine types
tests: bios-tables-test: update tables with CPHP turned off by default
tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine
type
acpi: extend ACPI interface to provide send_event hook
pc: use AcpiDeviceIfClass.send_event to issue GPE events
docs: update ACPI CPU hotplug spec with new protocol
acpi: hardware side of CPU hotplug
pc: add generic CPU unplug callbacks
machine: add cpu-hotplug machine option
pc: q35: initialize new CPU hotplug hw
pc: piix4: initialize new CPU hotplug hw
tests: pc-cpu-test: turn on cpu-hotplug explicily
pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx
tests: acpi: update cphp_legacy case with new ProcessorID values
pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook
acpi: add CPU devices AML to DSDT
acpi: add CPU hotplug methods to DSDT
tests: acpi: update expected files with new CPU AML description
qdev: hotplug: Introduce HotplugHandler.pre_plug() callback
pc: numa: replace node_cpu indexing by apic_id with possible_cpus
index
pc: set X86CPU.node property if QEMU starts with numa enabled
target-i386: add X86CPU.node property
acpi: cpuhp: add command and data registers
acpi: cpuhp: provide cpu._PXM method if running in numa mode
acpi: cpuhp: add cpu._OST handling
tests: acpi: report names of expected files in verbose mode
tests: acpi: add CPU hotplug testcase
tests: acpi: add expected tables for CPU hotplug case
tests: acpi: extend CPU hotplug test with NUMA support
tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM
support
DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present
CPU
docs/specs/acpi_cpu_hotplug.txt | 88 ++++- hw/acpi/Makefile.objs | 3 +- hw/acpi/aml-build.c | 17 + hw/acpi/core.c | 2 +- hw/acpi/cpu.c | 610 +++++++++++++++++++++++++++++++ hw/acpi/cpu_hotplug.c | 246 ++++++++++++- hw/acpi/cpu_hotplug_acpi_table.c | 136 ------- hw/acpi/ich9.c | 113 +++++- hw/acpi/memory_hotplug.c | 12 +- hw/acpi/pcihp.c | 10 +- hw/acpi/piix4.c | 76 +++- hw/core/hotplug.c | 11 + hw/core/machine.c | 20 + hw/core/qdev.c | 9 +- hw/i386/acpi-build.c | 191 ++-------- hw/i386/pc.c | 126 +++++-- hw/i386/pc_piix.c | 18 +- hw/i386/pc_q35.c | 20 +- hw/isa/lpc_ich9.c | 39 +- hw/mips/mips_malta.c | 2 +- include/hw/acpi/acpi.h | 10 +- include/hw/acpi/acpi_dev_interface.h | 25 ++ include/hw/acpi/aml-build.h | 2 + include/hw/acpi/cpu.h | 63 ++++ include/hw/acpi/cpu_hotplug.h | 19 +- include/hw/acpi/ich9.h | 16 +- include/hw/acpi/memory_hotplug.h | 4 +- include/hw/acpi/pcihp.h | 5 +- include/hw/boards.h | 1 + include/hw/compat.h | 12 + include/hw/hotplug.h | 14 +- include/hw/i386/pc.h | 12 +- include/qom/cpu.h | 2 +- qapi-schema.json | 2 +- qom/cpu.c | 6 +- stubs/Makefile.objs | 1 + stubs/pc_madt_cpu_entry.c | 7 + target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 42 +++ tests/acpi-test-data/pc/APIC.cphp | Bin 0 -> 160 bytes tests/acpi-test-data/pc/DSDT | Bin 5587 -> 5147 bytes tests/acpi-test-data/pc/DSDT.bridge | Bin 7446 -> 7006 bytes tests/acpi-test-data/pc/DSDT.cphp | Bin 0 -> 6614 bytes tests/acpi-test-data/pc/DSDT.cphp_legacy | Bin 0 -> 5503 bytes tests/acpi-test-data/pc/SRAT.cphp | Bin 0 -> 304 bytes tests/acpi-test-data/q35/APIC.cphp | Bin 0 -> 160 bytes tests/acpi-test-data/q35/DSDT | Bin 8357 -> 7909 bytes tests/acpi-test-data/q35/DSDT.bridge | Bin 8374 -> 7926 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 0 -> 9376 bytes tests/acpi-test-data/q35/SRAT.cphp | Bin 0 -> 304 bytes tests/bios-tables-test.c | 67 +++- tests/pc-cpu-test.c | 2 +- trace-events | 13 + 53 files changed, 1622 insertions(+), 453 deletions(-) create mode 100644 hw/acpi/cpu.c delete mode 100644 hw/acpi/cpu_hotplug_acpi_table.c create mode 100644 include/hw/acpi/cpu.h create mode 100644 stubs/pc_madt_cpu_entry.c create mode 100644 tests/acpi-test-data/pc/APIC.cphp create mode 100644 tests/acpi-test-data/pc/DSDT.cphp create mode 100644 tests/acpi-test-data/pc/DSDT.cphp_legacy create mode 100644 tests/acpi-test-data/pc/SRAT.cphp create mode 100644 tests/acpi-test-data/q35/APIC.cphp create mode 100644 tests/acpi-test-data/q35/DSDT.cphp create mode 100644 tests/acpi-test-data/q35/SRAT.cphp
Signature · 1 line
1.8.3.1
RFC 2/42 acpi: add aml_refof()
--- hw/acpi/aml-build.c | 8 ++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 9 insertions(+)
hw/acpi/aml-build.c +8 -0
@@ -1416,6 +1416,14 @@ Aml *aml_unicode(const char *str)return var; } +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefRefOf */ +Aml *aml_refof (Aml *arg) +{ +Aml *var =aml_opcode (0x71 /* RefOfOp */ ); +aml_append (var, arg); +return var; +} +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefDerefOf */ Aml *aml_derefof (Aml *arg) {
include/hw/acpi/aml-build.h +1 -0
@@ -352,6 +352,7 @@ Aml *aml_create_qword_field(Aml *srcbuf, Aml *index, const char *name);Aml *aml_varpackage (uint32_t num_elements);Aml *aml_touuid (const char *uuid);Aml *aml_unicode (const char *str); +Aml *aml_refof (Aml *arg);Aml *aml_derefof (Aml *arg);Aml *aml_sizeof (Aml *arg);Aml *aml_concatenate (Aml *source1,Aml *source2,Aml *target);
Signature · 1 line
1.8.3.1
RFC 4/42 pc: acpi: consolidate CPU hotplug AML
In reply to Igor Mammedovmove the former SSDT part of CPU hoplug close to DSDT part. AML is only moved but there isn't any functional change.
--- hw/acpi/cpu_hotplug_acpi_table.c | 104 +++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 112 +-------------------------------------- include/hw/acpi/cpu_hotplug.h | 3 +- 3 files changed, 106 insertions(+), 113 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +103 -1
@@ -15,12 +15,19 @@#include "qemu/osdep.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/i386/pc.h" -void build_cpu_hotplug_aml (Aml *ctx) +void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine, +uint16_t io_base,uint16_t io_len) { +Aml *dev; +Aml *crs; +Aml *pkg; +Aml *field;Aml *method;Aml *if_ctx;Aml *else_ctx; +int i, apic_idx;Aml *sb_scope =aml_scope ("_SB" );uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 };Aml *cpu_id =aml_arg (0 );
@@ -29,6 +36,9 @@ void build_cpu_hotplug_aml(Aml *ctx)Aml *cpus_map =aml_name (CPU_ON_BITMAP );Aml *zero =aml_int (0 );Aml *one =aml_int (1 ); +MachineClass *mc =MACHINE_GET_CLASS (machine); +CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids (machine); +PCMachineState *pcms =PC_MACHINE (machine);/* * _MAT method - creates an madt apic buffer
@@ -132,5 +142,97 @@ void build_cpu_hotplug_aml(Aml *ctx) }aml_append (sb_scope, method); +/* The current AML generator can cover the APIC ID range [0..255], +* inclusive, for VCPU hotplug. */ +QEMU_BUILD_BUG_ON (ACPI_CPU_HOTPLUG_ID_LIMIT >256 ); +g_assert (pcms->apic_id_limit <=ACPI_CPU_HOTPLUG_ID_LIMIT ); + +/* create PCI0.PRES device and its _CRS to reserve CPU hotplug MMIO */ + dev =aml_device ("PCI0." stringify(CPU_HOTPLUG_RESOURCE_DEVICE )); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); +aml_append (dev, +aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" )) + ); +/* device present, functioning, decoding, not shown in UI */ +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_base, io_base,1 , io_len) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (sb_scope, dev); +/* declare CPU hotplug MMIO region and PRS field to access it */ +aml_append (sb_scope,aml_operation_region ( +"PRST" ,AML_SYSTEM_IO ,aml_int (io_base), io_len)); + field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE ); +aml_append (field,aml_named_field ("PRS" ,256 )); +aml_append (sb_scope, field); + +/* build Processor object for each processor */ +for (i =0 ; i < apic_ids->len; i++) { +int apic_id = apic_ids->cpus[i].arch_id; + +assert (apic_id <ACPI_CPU_HOTPLUG_ID_LIMIT ); + + dev =aml_processor (apic_id,0 ,0 ,"CP%.02X" , apic_id); + + method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (apic_id)))); +aml_append (dev, method); + + method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_STATUS_METHOD ,aml_int (apic_id)))); +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_return (aml_call2 (CPU_EJECT_METHOD ,aml_int (apic_id), +aml_arg (0 ))) + ); +aml_append (dev, method); + +aml_append (sb_scope, dev); + } + +/* build this code: +* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} +*/ +/* Arg0 = Processor ID = APIC ID */ + method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < apic_ids->len; i++) { +int apic_id = apic_ids->cpus[i].arch_id; + + if_ctx =aml_if (aml_equal (aml_arg (0 ),aml_int (apic_id))); +aml_append (if_ctx, +aml_notify (aml_name ("CP%.02X" , apic_id),aml_arg (1 )) + ); +aml_append (method, if_ctx); + } +aml_append (sb_scope, method); + +/* build "Name(CPON, Package() { One, One, ..., Zero, Zero, ... })" +* +* Note: The ability to create variable-sized packages was first +* introduced in ACPI 2.0. ACPI 1.0 only allowed fixed-size packages +* ith up to 255 elements. Windows guests up to win2k8 fail when +* VarPackageOp is used. +*/ + pkg = pcms->apic_id_limit <=255 ?aml_package (pcms->apic_id_limit) : +aml_varpackage (pcms->apic_id_limit); + +for (i =0 , apic_idx =0 ; i < apic_ids->len; i++) { +int apic_id = apic_ids->cpus[i].arch_id; + +for (; apic_idx < apic_id; apic_idx++) { +aml_append (pkg,aml_int (0 )); + } +aml_append (pkg,aml_int (apic_ids->cpus[i].cpu ?1 :0 )); + apic_idx = apic_id +1 ; + } +aml_append (sb_scope,aml_name_decl (CPU_ON_BITMAP , pkg)); +g_free (apic_ids); +aml_append (ctx, sb_scope); }
hw/i386/acpi-build.c +1 -111
130 lines not on this page · raw message
include/hw/acpi/cpu_hotplug.h +2 -1
@@ -34,5 +34,6 @@ void acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,#define CPU_STATUS_MAP "PRS"#define CPU_SCAN_METHOD "PRSC" -void build_cpu_hotplug_aml (Aml *ctx); +void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine, +uint16_t io_base,uint16_t io_len);#endif
Signature · 1 line
1.8.3.1
RFC 5/42 pc: acpi: consolidate \GPE._E02 with the rest of CPU hotplug AML
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug_acpi_table.c | 4 ++++ hw/i386/acpi-build.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +4 -0
@@ -235,4 +235,8 @@ void build_cpu_hotplug_aml(Aml *ctx, MachineState *machine,g_free (apic_ids);aml_append (ctx, sb_scope); + + method =aml_method ("\\_GPE._E02" ,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); +aml_append (ctx, method); }
hw/i386/acpi-build.c +0 -4
@@ -1952,10 +1952,6 @@ build_dsdt(GArray *table_data, GArray *linker,aml_append (scope, method); } - method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED ); -aml_append (method,aml_call0 ("\\_SB." CPU_SCAN_METHOD )); -aml_append (scope, method); - method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method);
Signature · 1 line
1.8.3.1
RFC 1/42 acpi: add aml_debug()
In reply to Igor Mammedov--- hw/acpi/aml-build.c | 9 +++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 10 insertions(+)
hw/acpi/aml-build.c +9 -0
@@ -406,6 +406,15 @@ Aml *aml_return(Aml *val)return var; } +/* ACPI 1.0b: 16.2.6.3 Debug Objects Encoding: DebugObj */ +Aml *aml_debug (void ) +{ +Aml *var =aml_alloc (); +build_append_byte (var->buf,0x5B );/* ExtOpPrefix */ +build_append_byte (var->buf,0x31 );/* DebugOp */ +return var; +} +/* * ACPI 1.0b: 16.2.3 Data Objects Encoding: * encodes: ByteConst, WordConst, DWordConst, QWordConst, ZeroOp, OneOp
include/hw/acpi/aml-build.h +1 -0
@@ -245,6 +245,7 @@ void aml_append(Aml *parent_ctx, Aml *child);/* non block AML object primitives */ Aml *aml_name (const char *name_format, ...)GCC_FMT_ATTR (1 ,2 );Aml *aml_name_decl (const char *name,Aml *val); +Aml *aml_debug (void );Aml *aml_return (Aml *val);Aml *aml_int (const uint64_t val);Aml *aml_arg (int pos);
Signature · 1 line
1.8.3.1
RFC 6/42 pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c
In reply to Igor Mammedovnow as those defines are used only locally inside of cpu_hotplug_acpi_table.c, move them out of header file.
--- hw/acpi/cpu_hotplug_acpi_table.c | 7 +++++++ include/hw/acpi/cpu_hotplug.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
hw/acpi/cpu_hotplug_acpi_table.c +7 -0
@@ -17,6 +17,13 @@#include "hw/acpi/cpu_hotplug.h" #include "hw/i386/pc.h" +#define CPU_EJECT_METHOD "CPEJ" +#define CPU_MAT_METHOD "CPMA" +#define CPU_ON_BITMAP "CPON" +#define CPU_STATUS_METHOD "CPST" +#define CPU_STATUS_MAP "PRS" +#define CPU_SCAN_METHOD "PRSC" +void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine,uint16_t io_base,uint16_t io_len) {
include/hw/acpi/cpu_hotplug.h +0 -7
@@ -27,13 +27,6 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,void acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner,AcpiCpuHotplug *gpe_cpu,uint16_t base); -#define CPU_EJECT_METHOD "CPEJ" -#define CPU_MAT_METHOD "CPMA" -#define CPU_ON_BITMAP "CPON" -#define CPU_STATUS_METHOD "CPST" -#define CPU_STATUS_MAP "PRS" -#define CPU_SCAN_METHOD "PRSC" -void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine,uint16_t io_base,uint16_t io_len);#endif
Signature · 1 line
1.8.3.1
RFC 7/42 pc: acpi: mark current CPU hotplug functions as legacy
In reply to Igor Mammedov--- hw/acpi/cpu_hotplug.c | 8 ++++---- hw/acpi/cpu_hotplug_acpi_table.c | 4 ++-- hw/acpi/ich9.c | 7 ++++--- hw/acpi/piix4.c | 6 +++--- hw/i386/acpi-build.c | 3 ++- include/hw/acpi/cpu_hotplug.h | 12 ++++++------ 6 files changed, 21 insertions(+), 19 deletions(-)
hw/acpi/cpu_hotplug.c +4 -4
@@ -54,8 +54,8 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); } -void acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, -AcpiCpuHotplug *g,DeviceState *dev,Error **errp) +void legacy_acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, +AcpiCpuHotplug *g,DeviceState *dev,Error **errp) {acpi_set_cpu_present_bit (g,CPU (dev), errp);if (*errp !=NULL ) {
@@ -65,8 +65,8 @@ void acpi_cpu_plug_cb(ACPIREGS *ar, qemu_irq irq,acpi_send_gpe_event (ar, irq,ACPI_CPU_HOTPLUG_STATUS ); } -void acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner, -AcpiCpuHotplug *gpe_cpu,uint16_t base) +void legacy_acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner, +AcpiCpuHotplug *gpe_cpu,uint16_t base) {CPUState *cpu;
hw/acpi/cpu_hotplug_acpi_table.c +2 -2
@@ -24,8 +24,8 @@#define CPU_STATUS_MAP "PRS"#define CPU_SCAN_METHOD "PRSC" -void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine, -uint16_t io_base,uint16_t io_len) +void build_legacy_cpu_hotplug_aml (Aml *ctx,MachineState *machine, +uint16_t io_base,uint16_t io_len) {Aml *dev;Aml *crs;
hw/acpi/ich9.c +4 -3
@@ -273,8 +273,8 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->powerdown_notifier.notify = pm_powerdown_req;qemu_register_powerdown_notifier (&pm->powerdown_notifier); -acpi_cpu_hotplug_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), - &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE ); +legacy_acpi_cpu_hotplug_init (pci_address_space_io (lpc_pci), +OBJECT (lpc_pci), &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE );if (pm->acpi_memory_hotplug.is_enabled) { acpi_memory_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci),
@@ -437,7 +437,8 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp)acpi_memory_plug_cb (&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -acpi_cpu_plug_cb (&pm->acpi_regs, pm->irq, &pm->gpe_cpu, dev, errp); +legacy_acpi_cpu_plug_cb (&pm->acpi_regs, pm->irq, + &pm->gpe_cpu, dev, errp); }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
hw/acpi/piix4.c +3 -3
@@ -352,7 +352,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,acpi_pcihp_device_plug_cb (&s->ar, s->irq, &s->acpi_pci_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -acpi_cpu_plug_cb (&s->ar, s->irq, &s->gpe_cpu, dev, errp); +legacy_acpi_cpu_plug_cb (&s->ar, s->irq, &s->gpe_cpu, dev, errp); }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -570,8 +570,8 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, s->use_acpi_pci_hotplug); -acpi_cpu_hotplug_init (parent,OBJECT (s), &s->gpe_cpu, -PIIX4_CPU_HOTPLUG_IO_BASE ); +legacy_acpi_cpu_hotplug_init (parent,OBJECT (s), &s->gpe_cpu, +PIIX4_CPU_HOTPLUG_IO_BASE );if (s->acpi_memory_hotplug.is_enabled) {acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug);
hw/i386/acpi-build.c +2 -1
@@ -1935,7 +1935,8 @@ build_dsdt(GArray *table_data, GArray *linker,build_q35_pci0_int (dsdt); } -build_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base, pm->cpu_hp_io_len); +build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base, + pm->cpu_hp_io_len);build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
include/hw/acpi/cpu_hotplug.h +6 -6
@@ -21,12 +21,12 @@ typedef struct AcpiCpuHotplug { uint8_t sts[ACPI_GPE_PROC_LEN]; } AcpiCpuHotplug; -void acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, -AcpiCpuHotplug *g,DeviceState *dev,Error **errp); +void legacy_acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, +AcpiCpuHotplug *g,DeviceState *dev,Error **errp); -void acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner, -AcpiCpuHotplug *gpe_cpu,uint16_t base); +void legacy_acpi_cpu_hotplug_init (MemoryRegion *parent,Object *owner, +AcpiCpuHotplug *gpe_cpu,uint16_t base); -void build_cpu_hotplug_aml (Aml *ctx,MachineState *machine, -uint16_t io_base,uint16_t io_len); +void build_legacy_cpu_hotplug_aml (Aml *ctx,MachineState *machine, +uint16_t io_base,uint16_t io_len);#endif
Signature · 1 line
1.8.3.1
RFC 9/42 pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature
In reply to Igor Mammedovsince IO block used by CPU hotplug is fixed size and initialized it the same file as build_legacy_cpu_hotplug_aml() just use ACPI_GPE_PROC_LEN directly instead of passing it around in several files.
--- hw/acpi/cpu_hotplug.c | 6 +++--- hw/i386/acpi-build.c | 5 +---- include/hw/acpi/cpu_hotplug.h | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-)
hw/acpi/cpu_hotplug.c +3 -3
@@ -87,7 +87,7 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, }void build_legacy_cpu_hotplug_aml (Aml *ctx,MachineState *machine, -uint16_t io_base,uint16_t io_len) +uint16_t io_base) {Aml *dev;Aml *crs;
@@ -226,13 +226,13 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); crs =aml_resource_template ();aml_append (crs, -aml_io (AML_DECODE16 , io_base, io_base,1 , io_len) +aml_io (AML_DECODE16 , io_base, io_base,1 ,ACPI_GPE_PROC_LEN ) );aml_append (dev,aml_name_decl ("_CRS" , crs));aml_append (sb_scope, dev);/* declare CPU hotplug MMIO region and PRS field to access it */ aml_append (sb_scope,aml_operation_region ( -"PRST" ,AML_SYSTEM_IO ,aml_int (io_base), io_len)); +"PRST" ,AML_SYSTEM_IO ,aml_int (io_base),ACPI_GPE_PROC_LEN )); field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK ,AML_PRESERVE );aml_append (field,aml_named_field ("PRS" ,256 ));aml_append (sb_scope, field);
hw/i386/acpi-build.c +1 -4
@@ -94,7 +94,6 @@ typedef struct AcpiPmInfo {uint32_t gpe0_blk_len;uint32_t io_base;uint16_t cpu_hp_io_base; -uint16_t cpu_hp_io_len;uint16_t mem_hp_io_base;uint16_t mem_hp_io_len;uint16_t pcihp_io_base;
@@ -142,7 +141,6 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) }assert (obj); - pm->cpu_hp_io_len =ACPI_GPE_PROC_LEN ; pm->mem_hp_io_base =ACPI_MEMORY_HOTPLUG_BASE ; pm->mem_hp_io_len =ACPI_MEMORY_HOTPLUG_IO_LEN ;
@@ -1935,8 +1933,7 @@ build_dsdt(GArray *table_data, GArray *linker,build_q35_pci0_int (dsdt); } -build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base, - pm->cpu_hp_io_len); +build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base);build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
include/hw/acpi/cpu_hotplug.h +1 -1
@@ -28,5 +28,5 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner, AcpiCpuHotplug *gpe_cpu, uint16_t base);void build_legacy_cpu_hotplug_aml (Aml *ctx,MachineState *machine, -uint16_t io_base,uint16_t io_len); +uint16_t io_base);#endif
Signature · 1 line
1.8.3.1
RFC 11/42 pc: add 2.7 machine
In reply to Igor Mammedov--- hw/i386/pc_piix.c | 16 +++++++++++++--- hw/i386/pc_q35.c | 13 +++++++++++-- include/hw/compat.h | 3 +++ include/hw/i386/pc.h | 4 ++++ 4 files changed, 31 insertions(+), 5 deletions(-)
hw/i386/pc_piix.c +13 -3
@@ -416,13 +416,25 @@ static void pc_i440fx_machine_options(MachineClass *m) m->default_display ="std" ; } -static void pc_i440fx_2_6_machine_options (MachineClass *m) +static void pc_i440fx_2_7_machine_options (MachineClass *m) {pc_i440fx_machine_options (m); m->alias ="pc" ; m->is_default =1 ; } +DEFINE_I440FX_MACHINE (v2_7,"pc-i440fx-2.7" ,NULL , + pc_i440fx_2_7_machine_options); + + +static void pc_i440fx_2_6_machine_options (MachineClass *m) +{ +pc_i440fx_2_7_machine_options (m); + m->is_default =0 ; + m->alias =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_6 ); +} +DEFINE_I440FX_MACHINE (v2_6,"pc-i440fx-2.6" ,NULL , pc_i440fx_2_6_machine_options);
@@ -431,8 +443,6 @@ static void pc_i440fx_2_5_machine_options(MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_i440fx_2_6_machine_options (m); - m->alias =NULL ; - m->is_default =0 ; pcmc->save_tsc_khz = false; m->legacy_fw_cfg_order =1 ;SET_MACHINE_COMPAT (m,PC_COMPAT_2_5 );
hw/i386/pc_q35.c +11 -2
@@ -283,12 +283,22 @@ static void pc_q35_machine_options(MachineClass *m) m->no_floppy =1 ; } -static void pc_q35_2_6_machine_options (MachineClass *m) +static void pc_q35_2_7_machine_options (MachineClass *m) {pc_q35_machine_options (m); m->alias ="q35" ; } +DEFINE_Q35_MACHINE (v2_7,"pc-q35-2.7" ,NULL , + pc_q35_2_7_machine_options); + +static void pc_q35_2_6_machine_options (MachineClass *m) +{ +pc_q35_2_7_machine_options (m); + m->alias =NULL ; +SET_MACHINE_COMPAT (m,PC_COMPAT_2_6 ); +} +DEFINE_Q35_MACHINE (v2_6,"pc-q35-2.6" ,NULL , pc_q35_2_6_machine_options);
@@ -296,7 +306,6 @@ static void pc_q35_2_5_machine_options(MachineClass *m) {PCMachineClass *pcmc =PC_MACHINE_CLASS (m);pc_q35_2_6_machine_options (m); - m->alias =NULL ; pcmc->save_tsc_khz = false; m->legacy_fw_cfg_order =1 ;SET_MACHINE_COMPAT (m,PC_COMPAT_2_5 );
include/hw/compat.h +3 -0
@@ -1,6 +1,9 @@#ifndef HW_COMPAT_H #define HW_COMPAT_H +#define HW_COMPAT_2_6 \ +/* empty */ +#define HW_COMPAT_2_5 \ {\ .driver = "isa-fdc",\
include/hw/i386/pc.h +4 -0
@@ -356,7 +356,11 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);int e820_get_num_entries (void );bool e820_get_entry (int ,uint32_t ,uint64_t *,uint64_t *); +#define PC_COMPAT_2_6 \ + HW_COMPAT_2_6 +#define PC_COMPAT_2_5 \ + PC_COMPAT_2_6 \ HW_COMPAT_2_5#define PC_COMPAT_2_4 \
Signature · 1 line
1.8.3.1
RFC 12/42 pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Igor Mammedovon old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
--- hw/acpi/ich9.c | 9 ++++++--- hw/acpi/piix4.c | 9 ++++++--- hw/i386/acpi-build.c | 8 +++++++- include/hw/compat.h | 11 ++++++++++- 4 files changed, 29 insertions(+), 8 deletions(-)
hw/acpi/ich9.c +6 -3
@@ -273,8 +273,10 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm, pm->powerdown_notifier.notify = pm_powerdown_req;qemu_register_powerdown_notifier (&pm->powerdown_notifier); -legacy_acpi_cpu_hotplug_init (pci_address_space_io (lpc_pci), -OBJECT (lpc_pci), &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE ); +if (pm->cpu_hotplug_legacy) { +legacy_acpi_cpu_hotplug_init (pci_address_space_io (lpc_pci), +OBJECT (lpc_pci), &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE ); + }if (pm->acpi_memory_hotplug.is_enabled) { acpi_memory_hotplug_init(pci_address_space_io(lpc_pci), OBJECT(lpc_pci),
@@ -455,7 +457,8 @@ void ich9_pm_device_plug_cb(ICH9LPCPMRegs *pm, DeviceState *dev, Error **errp) object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {acpi_memory_plug_cb (&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug, dev, errp); - } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { + } else if (pm->cpu_hotplug_legacy && +object_dynamic_cast (OBJECT (dev ),TYPE_CPU )) {legacy_acpi_cpu_plug_cb (&pm->acpi_regs, pm->irq, &pm->gpe_cpu, dev, errp); } else {
hw/acpi/piix4.c +6 -3
@@ -352,7 +352,8 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) {acpi_pcihp_device_plug_cb (&s->ar, s->irq, &s->acpi_pci_hotplug, dev, errp); - }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { + }else if (s->cpu_hotplug_legacy && +object_dynamic_cast (OBJECT (dev),TYPE_CPU )) {legacy_acpi_cpu_plug_cb (&s->ar, s->irq, &s->gpe_cpu, dev, errp); }else { error_setg(errp, "acpi: device plug request for not supported device"
@@ -571,8 +572,10 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,acpi_pcihp_init (OBJECT (s), &s->acpi_pci_hotplug, bus, parent, s->use_acpi_pci_hotplug); -legacy_acpi_cpu_hotplug_init (parent,OBJECT (s), &s->gpe_cpu, -PIIX4_CPU_HOTPLUG_IO_BASE ); +if (s->cpu_hotplug_legacy) { +legacy_acpi_cpu_hotplug_init (parent,OBJECT (s), &s->gpe_cpu, +PIIX4_CPU_HOTPLUG_IO_BASE ); + }if (s->acpi_memory_hotplug.is_enabled) {acpi_memory_hotplug_init (parent,OBJECT (s), &s->acpi_memory_hotplug);
hw/i386/acpi-build.c +7 -1
@@ -93,6 +93,7 @@ typedef struct AcpiPmInfo {uint32_t gpe0_blk;uint32_t gpe0_blk_len;uint32_t io_base; +bool legacy_cpu_hp;uint16_t cpu_hp_io_base;uint16_t mem_hp_io_base;uint16_t mem_hp_io_len;
@@ -141,6 +142,9 @@ static void acpi_get_pm_info(AcpiPmInfo *pm) }assert (obj); + pm->legacy_cpu_hp =object_property_get_bool (obj,"cpu-hotplug-legacy" , +NULL ); + pm->mem_hp_io_base =ACPI_MEMORY_HOTPLUG_BASE ; pm->mem_hp_io_len =ACPI_MEMORY_HOTPLUG_IO_LEN ;
@@ -1933,7 +1937,9 @@ build_dsdt(GArray *table_data, GArray *linker,build_q35_pci0_int (dsdt); } -build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base); +if (pm->legacy_cpu_hp) { +build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base); + }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
include/hw/compat.h +10 -1
@@ -2,7 +2,16 @@#define HW_COMPAT_H #define HW_COMPAT_2_6 \ -/* empty */ + {\ + .driver = "PIIX4_PM",\ + .property = "cpu-hotplug-legacy",\ + .value = "on",\ + },\ + {\ + .driver = "ICH9-LPC",\ + .property = "cpu-hotplug-legacy",\ + .value = "on",\ + },\#define HW_COMPAT_2_5 \ {\
Signature · 1 line
1.8.3.1
RFC 3/42 pc: acpi: remove AML for empty/not used GPE handlers
In reply to Igor MammedovACPI spec requires GPE handlers only for GPE events that hardware implements.
So remove AML for not supported by QEMU device model events.
--- hw/i386/acpi-build.c | 17 ----------------- 1 file changed, 17 deletions(-)
hw/i386/acpi-build.c +0 -17
@@ -2051,8 +2051,6 @@ build_dsdt(GArray *table_data, GArray *linker, {aml_append (scope,aml_name_decl ("_HID" ,aml_string ("ACPI0006" ))); -aml_append (scope,aml_method ("_L00" ,0 ,AML_NOTSERIALIZED )); -if (misc->is_piix4) { method =aml_method ("_E01" ,0 ,AML_NOTSERIALIZED ); aml_append(method,
@@ -2060,8 +2058,6 @@ build_dsdt(GArray *table_data, GArray *linker,aml_append (method,aml_call0 ("\\_SB.PCI0.PCNT" ));aml_append (method,aml_release (aml_name ("\\_SB.PCI0.BLCK" )));aml_append (scope, method); - }else { -aml_append (scope,aml_method ("_L01" ,0 ,AML_NOTSERIALIZED )); } method =aml_method ("_E02" ,0 ,AML_NOTSERIALIZED );
@@ -2071,19 +2067,6 @@ build_dsdt(GArray *table_data, GArray *linker, method =aml_method ("_E03" ,0 ,AML_NOTSERIALIZED );aml_append (method,aml_call0 (MEMORY_HOTPLUG_HANDLER_PATH ));aml_append (scope, method); - -aml_append (scope,aml_method ("_L04" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L05" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L06" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L07" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L08" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L09" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0A" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0B" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0C" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0D" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0E" ,0 ,AML_NOTSERIALIZED )); -aml_append (scope,aml_method ("_L0F" ,0 ,AML_NOTSERIALIZED )); }aml_append (dsdt, scope);
Signature · 1 line
1.8.3.1
RFC 13/42 tests: bios-tables-test: update tables with CPHP turned off by default
In reply to Igor Mammedov--- tests/acpi-test-data/pc/DSDT | Bin 5587 -> 5090 bytes tests/acpi-test-data/pc/DSDT.bridge | Bin 7446 -> 6949 bytes tests/acpi-test-data/q35/DSDT | Bin 8357 -> 7852 bytes tests/acpi-test-data/q35/DSDT.bridge | Bin 8374 -> 7869 bytes 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT binary +0 -0
tests/acpi-test-data/pc/DSDT.bridge binary +0 -0
tests/acpi-test-data/q35/DSDT binary +0 -0
tests/acpi-test-data/q35/DSDT.bridge binary +0 -0
Signature · 1 line
1.8.3.1
RFC 8/42 pc: acpi: consolidate legacy CPU hotplug in one file
In reply to Igor MammedovSince AML part of CPU hotplug is tightly coupled with its hardware part (IO port layout/protocol), move build_legacy_cpu_hotplug_aml() to cpu_hotplug.c and remove empty cpu_hotplug_acpi_table.c
--- hw/acpi/Makefile.objs | 2 +- hw/acpi/cpu_hotplug.c | 232 ++++++++++++++++++++++++++++++++++++ hw/acpi/cpu_hotplug_acpi_table.c | 249 --------------------------------------- 3 files changed, 233 insertions(+), 250 deletions(-) delete mode 100644 hw/acpi/cpu_hotplug_acpi_table.c
hw/acpi/Makefile.objs +1 -1
@@ -1,6 +1,6 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o -common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o cpu_hotplug_acpi_table.o +common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o
hw/acpi/cpu_hotplug.c +232 -0
241 lines not on this page · raw message
hw/acpi/cpu_hotplug_acpi_table.c deleted +0 -249
249 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC 15/42 acpi: extend ACPI interface to provide send_event hook
In reply to Igor Mammedovsend_event() hook will allow to send ACPI event in a target specific way (GPE or GPIO based impl.) it will also simplify proxy wrappers in piix4pm/ich9 that access ACPI regs and SCI which are part of piix4pm/lcp_ich9 devices and call acpi_foo() API directly.
---
Following patch will use hook to simplify hotplug callbacks in piix4pm/ich9.
--- hw/acpi/core.c | 2 +- hw/acpi/piix4.c | 8 ++++++++ hw/isa/lpc_ich9.c | 8 ++++++++ include/hw/acpi/acpi.h | 10 ++-------- include/hw/acpi/acpi_dev_interface.h | 18 ++++++++++++++++++ 5 files changed, 37 insertions(+), 9 deletions(-)
hw/acpi/core.c +1 -1
@@ -693,7 +693,7 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr) }void acpi_send_gpe_event (ACPIREGS *ar,qemu_irq irq, -AcpiGPEStatusBits status) +AcpiEventStatusBits status) { ar->gpe.sts[0 ] |= status;acpi_update_sci (ar, irq);
hw/acpi/piix4.c +8 -0
@@ -589,6 +589,13 @@ static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)acpi_memory_ospm_status (&s->acpi_memory_hotplug, list); } +static void piix4_send_gpe (AcpiDeviceIf *adev,AcpiEventStatusBits ev) +{ +PIIX4PMState *s =PIIX4_PM (adev); + +acpi_send_gpe_event (&s->ar, s->irq, ev); +} +static Property piix4_pm_properties[] = {DEFINE_PROP_UINT32 ("smb_io_base" , PIIX4PMState, smb_io_base,0 ),DEFINE_PROP_UINT8 (ACPI_PM_PROP_S3_DISABLED , PIIX4PMState, disable_s3,0 ),
@@ -629,6 +636,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) hc->unplug_request = piix4_device_unplug_request_cb; hc->unplug = piix4_device_unplug_cb; adevc->ospm_status = piix4_ospm_status; + adevc->send_event = piix4_send_gpe; }static const TypeInfo piix4_pm_info = {
hw/isa/lpc_ich9.c +8 -0
@@ -702,6 +702,13 @@ static Property ich9_lpc_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void ich9_send_gpe (AcpiDeviceIf *adev,AcpiEventStatusBits ev) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (adev); + +acpi_send_gpe_event (&s->pm.acpi_regs, s->pm.irq, ev); +} +static void ich9_lpc_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
@@ -729,6 +736,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) hc->unplug_request = ich9_device_unplug_request_cb; hc->unplug = ich9_device_unplug_cb; adevc->ospm_status = ich9_pm_ospm_status; + adevc->send_event = ich9_send_gpe; }static const TypeInfo ich9_lpc_info = {
include/hw/acpi/acpi.h +2 -8
@@ -23,6 +23,7 @@#include "qemu/option.h" #include "exec/memory.h" #include "hw/irq.h" +#include "hw/acpi/acpi_dev_interface.h" /* * current device naming scheme supports up to 256 memory devices
@@ -89,13 +90,6 @@/* PM2_CNT */ #define ACPI_BITMASK_ARB_DISABLE 0x0001 -/* These values are part of guest ABI, and can not be changed */ -typedef enum { -ACPI_PCI_HOTPLUG_STATUS =2 , -ACPI_CPU_HOTPLUG_STATUS =4 , -ACPI_MEMORY_HOTPLUG_STATUS =8 , -}AcpiGPEStatusBits ; -/* structs */ typedef struct ACPIPMTimer ACPIPMTimer ;typedef struct ACPIPM1EVT ACPIPM1EVT ;
@@ -179,7 +173,7 @@ void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val);uint32_t acpi_gpe_ioport_readb (ACPIREGS *ar,uint32_t addr);void acpi_send_gpe_event (ACPIREGS *ar,qemu_irq irq, -AcpiGPEStatusBits status); +AcpiEventStatusBits status);void acpi_update_sci (ACPIREGS *acpi_regs,qemu_irq irq);
include/hw/acpi/acpi_dev_interface.h +18 -0
@@ -4,6 +4,13 @@#include "qom/object.h" #include "qapi-types.h" +/* These values are part of guest ABI, and can not be changed */ +typedef enum { +ACPI_PCI_HOTPLUG_STATUS =2 , +ACPI_CPU_HOTPLUG_STATUS =4 , +ACPI_MEMORY_HOTPLUG_STATUS =8 , +}AcpiEventStatusBits ; +#define TYPE_ACPI_DEVICE_IF "acpi-device-interface"#define ACPI_DEVICE_IF_CLASS (klass) \
@@ -22,11 +29,21 @@ typedef struct AcpiDeviceIf {Object Parent; } AcpiDeviceIf; +#define ACPI_SEND_EVENT (dev, event) \ + do { \ + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(dev); \ + if (adevc->send_event) { \ + AcpiDeviceIf *adev = ACPI_DEVICE_IF(dev); \ + adevc->send_event(adev, event); \ + } \ + } while (0) +/** * AcpiDeviceIfClass: * * ospm_status: returns status of ACPI device objects, reported * via _OST method if device supports it. +* send_event: inject a specified event into guest * * Interface is designed for providing unified interface * to generic ACPI functionality that could be used without
@@ -39,5 +56,6 @@ typedef struct AcpiDeviceIfClass {/* <public> */ void (*ospm_status)(AcpiDeviceIf *adev,ACPIOSTInfoList ***list); + void (*send_event)(AcpiDeviceIf *adev, AcpiEventStatusBits ev); } AcpiDeviceIfClass;#endif
Signature · 1 line
1.8.3.1
RFC 16/42 pc: use AcpiDeviceIfClass.send_event to issue GPE events
In reply to Igor Mammedovit reduces number of args passed in handlers by 1 and a number of used proxy wrappers saving ~20LOC. Also it allows to make cpu/mem hotplug code more universal as it would allow ARM to reuse it without rewrite by providing its own send_event callback to trigger events usiong GPIO instead of GPE as fixed hadrware ACPI model doen't have GPE at all.
--- hw/acpi/cpu_hotplug.c | 5 ++--- hw/acpi/ich9.c | 35 +++++++++++++++++++++-------------- hw/acpi/memory_hotplug.c | 12 ++++-------- hw/acpi/pcihp.c | 10 ++++------ hw/acpi/piix4.c | 11 +++++------ hw/isa/lpc_ich9.c | 30 +++--------------------------- include/hw/acpi/cpu_hotplug.h | 3 ++- include/hw/acpi/ich9.h | 9 +++++---- include/hw/acpi/memory_hotplug.h | 4 ++-- include/hw/acpi/pcihp.h | 5 +++-- 10 files changed, 51 insertions(+), 73 deletions(-)
hw/acpi/cpu_hotplug.c +2 -3
@@ -62,15 +62,14 @@ static void acpi_set_cpu_present_bit(AcpiCpuHotplug *g, CPUState *cpu, g->sts[cpu_id /8 ] |= (1 << (cpu_id %8 )); } -void legacy_acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, +void legacy_acpi_cpu_plug_cb (HotplugHandler *hotplug_dev,AcpiCpuHotplug *g,DeviceState *dev,Error **errp) {acpi_set_cpu_present_bit (g,CPU (dev), errp);if (*errp !=NULL ) {return ; } - -acpi_send_gpe_event (ar, irq,ACPI_CPU_HOTPLUG_STATUS ); +ACPI_SEND_EVENT (hotplug_dev,ACPI_CPU_HOTPLUG_STATUS ); } void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
hw/acpi/ich9.c +21 -14
@@ -451,41 +451,48 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) NULL); } -void ich9_pm_device_plug_cb (ICH9LPCPMRegs *pm,DeviceState *dev,Error **errp) +void ich9_pm_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp) { -if (pm->acpi_memory_hotplug.is_enabled && +ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); + +if (lpc->pm.acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -acpi_memory_plug_cb (&pm->acpi_regs, pm->irq, &pm->acpi_memory_hotplug, +acpi_memory_plug_cb (hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); - }else if (pm->cpu_hotplug_legacy && + }else if (lpc->pm.cpu_hotplug_legacy &&object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -legacy_acpi_cpu_plug_cb (&pm->acpi_regs, pm->irq, - &pm->gpe_cpu, dev, errp); +legacy_acpi_cpu_plug_cb (hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev))); } } -void ich9_pm_device_unplug_request_cb (ICH9LPCPMRegs *pm,DeviceState *dev, -Error **errp) +void ich9_pm_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) { -if (pm->acpi_memory_hotplug.is_enabled && +ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); + +if (lpc->pm.acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -acpi_memory_unplug_request_cb (&pm->acpi_regs, pm->irq, - &pm->acpi_memory_hotplug, dev, errp); +acpi_memory_unplug_request_cb (hotplug_dev, + &lpc->pm.acpi_memory_hotplug, dev, + errp); }else {error_setg (errp,"acpi: device unplug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev))); } } -void ich9_pm_device_unplug_cb (ICH9LPCPMRegs *pm,DeviceState *dev, +void ich9_pm_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -if (pm->acpi_memory_hotplug.is_enabled && +ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); + +if (lpc->pm.acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -acpi_memory_unplug_cb (&pm->acpi_memory_hotplug, dev, errp); +acpi_memory_unplug_cb (&lpc->pm.acpi_memory_hotplug, dev, errp); }else {error_setg (errp,"acpi: device unplug for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
hw/acpi/memory_hotplug.c +4 -8
@@ -228,7 +228,7 @@ acpi_memory_slot_status(MemHotplugState *mem_st,return &mem_st->devs[slot]; } -void acpi_memory_plug_cb (ACPIREGS *ar,qemu_irq irq,MemHotplugState *mem_st, +void acpi_memory_plug_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp) {MemStatus *mdev;
@@ -247,13 +247,11 @@ void acpi_memory_plug_cb(ACPIREGS *ar, qemu_irq irq, MemHotplugState *mem_st, mdev->is_enabled = true;if (dev->hotplugged) { mdev->is_inserting = true; - -/* do ACPI magic */ -acpi_send_gpe_event (ar, irq,ACPI_MEMORY_HOTPLUG_STATUS ); +ACPI_SEND_EVENT (hotplug_dev,ACPI_MEMORY_HOTPLUG_STATUS ); } } -void acpi_memory_unplug_request_cb (ACPIREGS *ar,qemu_irq irq, +void acpi_memory_unplug_request_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp) {
@@ -265,9 +263,7 @@ void acpi_memory_unplug_request_cb(ACPIREGS *ar, qemu_irq irq, } mdev->is_removing = true; - -/* Do ACPI magic */ -acpi_send_gpe_event (ar, irq,ACPI_MEMORY_HOTPLUG_STATUS ); +ACPI_SEND_EVENT (hotplug_dev,ACPI_MEMORY_HOTPLUG_STATUS ); } void acpi_memory_unplug_cb(MemHotplugState *mem_st,
hw/acpi/pcihp.c +4 -6
@@ -182,7 +182,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s)acpi_pcihp_update (s); } -void acpi_pcihp_device_plug_cb (ACPIREGS *ar,qemu_irq irq,AcpiPciHpState *s, +void acpi_pcihp_device_plug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp) {PCIDevice *pdev =PCI_DEVICE (dev);
@@ -202,11 +202,10 @@ void acpi_pcihp_device_plug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, } s->acpi_pcihp_pci_status[bsel].up |= (1U << slot); - -acpi_send_gpe_event (ar, irq,ACPI_PCI_HOTPLUG_STATUS ); +ACPI_SEND_EVENT (hotplug_dev,ACPI_PCI_HOTPLUG_STATUS ); } -void acpi_pcihp_device_unplug_cb (ACPIREGS *ar,qemu_irq irq,AcpiPciHpState *s, +void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp) {PCIDevice *pdev =PCI_DEVICE (dev);
@@ -219,8 +218,7 @@ void acpi_pcihp_device_unplug_cb(ACPIREGS *ar, qemu_irq irq, AcpiPciHpState *s, } s->acpi_pcihp_pci_status[bsel].down |= (1U << slot); - -acpi_send_gpe_event (ar, irq,ACPI_PCI_HOTPLUG_STATUS ); +ACPI_SEND_EVENT (hotplug_dev,ACPI_PCI_HOTPLUG_STATUS ); }static uint64_t pci_read (void *opaque,hwaddr addr,unsigned int size)
hw/acpi/piix4.c +5 -6
@@ -348,13 +348,12 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,if (s->acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -acpi_memory_plug_cb (&s->ar, s->irq, &s->acpi_memory_hotplug, dev, errp); +acpi_memory_plug_cb (hotplug_dev, &s->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { -acpi_pcihp_device_plug_cb (&s->ar, s->irq, &s->acpi_pci_hotplug, dev, - errp); +acpi_pcihp_device_plug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, errp); }else if (s->cpu_hotplug_legacy &&object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -legacy_acpi_cpu_plug_cb (&s->ar, s->irq, &s->gpe_cpu, dev, errp); +legacy_acpi_cpu_plug_cb (hotplug_dev, &s->gpe_cpu, dev, errp); }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -368,10 +367,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev,if (s->acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) { -acpi_memory_unplug_request_cb (&s->ar, s->irq, &s->acpi_memory_hotplug, +acpi_memory_unplug_request_cb (hotplug_dev, &s->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { -acpi_pcihp_device_unplug_cb (&s->ar, s->irq, &s->acpi_pci_hotplug, dev, +acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, errp); }else { error_setg(errp, "acpi: device unplug request for not supported device"
hw/isa/lpc_ich9.c +3 -27
@@ -636,30 +636,6 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp) 1); } -static void ich9_device_plug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) -{ -ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); - -ich9_pm_device_plug_cb (&lpc->pm, dev, errp); -} - -static void ich9_device_unplug_request_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) -{ -ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); - -ich9_pm_device_unplug_request_cb (&lpc->pm, dev, errp); -} - -static void ich9_device_unplug_cb (HotplugHandler *hotplug_dev, -DeviceState *dev,Error **errp) -{ -ICH9LPCState *lpc =ICH9_LPC_DEVICE (hotplug_dev); - -ich9_pm_device_unplug_cb (&lpc->pm, dev, errp); -} -static bool ich9_rst_cnt_needed (void *opaque) {ICH9LPCState *lpc = opaque;
@@ -732,9 +708,9 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data)* pc_q35_init() */ dc->cannot_instantiate_with_device_add_yet = true; - hc->plug = ich9_device_plug_cb; - hc->unplug_request = ich9_device_unplug_request_cb; - hc->unplug = ich9_device_unplug_cb; + hc->plug = ich9_pm_device_plug_cb; + hc->unplug_request = ich9_pm_device_unplug_request_cb; + hc->unplug = ich9_pm_device_unplug_cb; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; }
include/hw/acpi/cpu_hotplug.h +2 -1
@@ -15,13 +15,14 @@#include "hw/acpi/acpi.h" #include "hw/acpi/pc-hotplug.h" #include "hw/acpi/aml-build.h" +#include "hw/hotplug.h" typedef struct AcpiCpuHotplug {MemoryRegion io;uint8_t sts[ACPI_GPE_PROC_LEN ]; }AcpiCpuHotplug ; -void legacy_acpi_cpu_plug_cb (ACPIREGS *ar,qemu_irq irq, +void legacy_acpi_cpu_plug_cb (HotplugHandler *hotplug_dev,AcpiCpuHotplug *g,DeviceState *dev,Error **errp); void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
include/hw/acpi/ich9.h +5 -4
@@ -70,10 +70,11 @@ extern const VMStateDescription vmstate_ich9_pm;void ich9_pm_add_properties (Object *obj,ICH9LPCPMRegs *pm,Error **errp); -void ich9_pm_device_plug_cb (ICH9LPCPMRegs *pm,DeviceState *dev,Error **errp); -void ich9_pm_device_unplug_request_cb (ICH9LPCPMRegs *pm,DeviceState *dev, -Error **errp); -void ich9_pm_device_unplug_cb (ICH9LPCPMRegs *pm,DeviceState *dev, +void ich9_pm_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev, +Error **errp); +void ich9_pm_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp); +void ich9_pm_device_unplug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp);void ich9_pm_ospm_status (AcpiDeviceIf *adev,ACPIOSTInfoList ***list);
include/hw/acpi/memory_hotplug.h +2 -2
@@ -32,9 +32,9 @@ typedef struct MemHotplugState {void acpi_memory_hotplug_init (MemoryRegion *as,Object *owner,MemHotplugState *state); -void acpi_memory_plug_cb (ACPIREGS *ar,qemu_irq irq,MemHotplugState *mem_st, +void acpi_memory_plug_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp); -void acpi_memory_unplug_request_cb (ACPIREGS *ar,qemu_irq irq, +void acpi_memory_unplug_request_cb (HotplugHandler *hotplug_dev,MemHotplugState *mem_st,DeviceState *dev,Error **errp); void acpi_memory_unplug_cb(MemHotplugState *mem_st,
include/hw/acpi/pcihp.h +3 -2
@@ -29,6 +29,7 @@#include "hw/acpi/acpi.h" #include "migration/vmstate.h" +#include "hw/hotplug.h" #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"#define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
@@ -56,9 +57,9 @@ typedef struct AcpiPciHpState {void acpi_pcihp_init (Object *owner,AcpiPciHpState *,PCIBus *root,MemoryRegion *address_space_io,bool bridges_enabled); -void acpi_pcihp_device_plug_cb (ACPIREGS *ar,qemu_irq irq,AcpiPciHpState *s, +void acpi_pcihp_device_plug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp); -void acpi_pcihp_device_unplug_cb (ACPIREGS *ar,qemu_irq irq,AcpiPciHpState *s, +void acpi_pcihp_device_unplug_cb (HotplugHandler *hotplug_dev,AcpiPciHpState *s,DeviceState *dev,Error **errp);/* Called on reset */
Signature · 1 line
1.8.3.1
RFC 17/42 docs: update ACPI CPU hotplug spec with new protocol
In reply to Igor Mammedov--- docs/specs/acpi_cpu_hotplug.txt | 88 +++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 12 deletions(-)
docs/specs/acpi_cpu_hotplug.txt +76 -12
@@ -4,21 +4,85 @@ QEMU<->ACPI BIOS CPU hotplug interface QEMU supports CPU hotplug via ACPI. This document describes the interface between QEMU and the ACPI BIOS. -ACPI GPE block (IO ports 0xafe0-0xafe3, byte access): ------------------------------------------ - -Generic ACPI GPE block. Bit 2 (GPE.2) used to notify CPU -hot-add/remove event to ACPI BIOS, via SCI interrupt. +ACPI BIOS GPE.2 handler is dedicated for notifying OS about CPU hot-add +and hot-remove events. +============================================ +Legacy ACPI CPU hotplug interface registers: +-------------------------------------------- CPU present bitmap for: + One bit per CPU. Bit position reflects corresponding CPU APIC ID. Read-only. ICH9-LPC (IO port 0x0cd8-0xcf7, 1-byte access) PIIX-PM (IO port 0xaf00-0xaf1f, 1-byte access) --------------------------------------------------------------- -One bit per CPU. Bit position reflects corresponding CPU APIC ID. -Read-only. +QEMU sets corresponding CPU bit on hot-add event and issues SCI +with GPE.2 event set. CPU present map read by ACPI BIOS GPE.2 handler +to notify OS about CPU hot-add events. CPU hot-remove isn't supported. + +===================================== +ACPI CPU hotplug interface registers: +------------------------------------- +Register block base address: + ICH9-LPC IO port 0x0cd8 + PIIX-PM IO port 0xaf00 +Register block size: + ACPI_CPU_HOTPLUG_REG_LEN = 12 + +read access: + offset: + [0x0-0x3] reserved + [0x4] CPU device status fields: (1 byte access) + bits: + 0: Device is enabled and may be used by guest + 1: Device insert event, used to distinguish device for which + 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 + [0x5-0x7] reserved + [0x8] Command data: (DWORD access) + in case of error or unsupported command reads is 0xFFFFFFFF + current 'Command field' value: + 0: returns PXM value corresponding to device + +write access: + offset: + [0x0-0x3] CPU selector: (DWORD access) + selects active CPU device. All following accesses to other + registers will read/store data from/to selected CPU. + [0x4] CPU device control fields: (1 byte access) + bits: + 0: reserved, OSPM must clear it before writing to register. + 1: if set to 1 clears device insert event, set by OSPM + after it has emitted device check event for the + 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 + 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 + [0x5] Command field: (1 byte access) + value: + 0: following reads from 'Command data' register returns PXM + value of device + 1: following writes to 'Command data' register set OST event + register in QEMU + 2: following writes to 'Command data' register set OST status + register in QEMU + other values: reserved + [0x6-0x7] reserved + [0x8] Command data: (DWORD access) + current 'Command field' value: + 1: stores value into OST event register + 2: stores value into OST status register, triggers + ACPI_DEVICE_OST QMP event from QEMU to external applications + with current values of OST event and status registers. + other values: reserved -CPU hot-add/remove notification: ------------------------------------------------------ -QEMU sets/clears corresponding CPU bit on hot-add/remove event. -CPU present map read by ACPI BIOS GPE.2 handler to notify OS of CPU -hot-(un)plug events. +Selecting CPU device beyond possible range has no effect on platform: + - write accesses to CPU hot-plug registers not documented above are + ignored + - read accesses to CPU hot-plug registers not documented above return + all bits set to 1.
Signature · 1 line
1.8.3.1
RFC 10/42 pc: piix4/ich9: add 'cpu-hotplug-legacy' property
In reply to Igor Mammedov--- hw/acpi/ich9.c | 19 +++++++++++++++++++ hw/acpi/piix4.c | 3 +++ include/hw/acpi/ich9.h | 1 + 3 files changed, 23 insertions(+)
hw/acpi/ich9.c +19 -0
@@ -306,6 +306,21 @@ static void ich9_pm_set_memory_hotplug_support(Object *obj, bool value, s->pm.acpi_memory_hotplug.is_enabled = value; } +static bool ich9_pm_get_cpu_hotplug_legacy (Object *obj,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +return s->pm.cpu_hotplug_legacy; +} + +static void ich9_pm_set_cpu_hotplug_legacy (Object *obj,bool value, +Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + + s->pm.cpu_hotplug_legacy = value; +} +static void ich9_pm_get_disable_s3 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {
@@ -412,6 +427,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) ich9_pm_get_memory_hotplug_support, ich9_pm_set_memory_hotplug_support, NULL); +object_property_add_bool (obj,"cpu-hotplug-legacy" , + ich9_pm_get_cpu_hotplug_legacy, + ich9_pm_set_cpu_hotplug_legacy, +NULL ); object_property_add(obj, ACPI_PM_PROP_S3_DISABLED, "uint8", ich9_pm_get_disable_s3, ich9_pm_set_disable_s3,
hw/acpi/piix4.c +3 -0
@@ -85,6 +85,7 @@ typedef struct PIIX4PMState {uint8_t disable_s4;uint8_t s4_val; +bool cpu_hotplug_legacy;AcpiCpuHotplug gpe_cpu;MemHotplugState acpi_memory_hotplug;
@@ -594,6 +595,8 @@ static Property piix4_pm_properties[] = { use_acpi_pci_hotplug, true),DEFINE_PROP_BOOL ("memory-hotplug-support" , PIIX4PMState, acpi_memory_hotplug.is_enabled, true), +DEFINE_PROP_BOOL ("cpu-hotplug-legacy" , PIIX4PMState, + cpu_hotplug_legacy, false), DEFINE_PROP_END_OF_LIST(), };
include/hw/acpi/ich9.h +1 -0
@@ -48,6 +48,7 @@ typedef struct ICH9LPCPMRegs {uint32_t pm_io_base;Notifier powerdown_notifier; +bool cpu_hotplug_legacy;AcpiCpuHotplug gpe_cpu;MemHotplugState acpi_memory_hotplug;
Signature · 1 line
1.8.3.1
RFC 18/42 acpi: hardware side of CPU hotplug
In reply to Igor Mammedov--- hw/acpi/Makefile.objs | 1 + hw/acpi/cpu.c | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/cpu.h | 53 ++++++++++++ trace-events | 9 +++ 4 files changed, 281 insertions(+) create mode 100644 hw/acpi/cpu.c create mode 100644 include/hw/acpi/cpu.h
hw/acpi/Makefile.objs +1 -0
@@ -2,6 +2,7 @@ common-obj-$(CONFIG_ACPI_X86) += core.o piix4.o pcihp.o common-obj-$(CONFIG_ACPI_X86_ICH) += ich9.o tco.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu_hotplug.o common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o memory_hotplug_acpi_table.o +common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI) += acpi_interface.o common-obj-$(CONFIG_ACPI) += bios-linker-loader.o
hw/acpi/cpu.c new file +218 -0
218 lines not on this page · raw message
include/hw/acpi/cpu.h new file +53 -0
53 lines not on this page · raw message
trace-events +9 -0
@@ -1909,3 +1909,12 @@ aspeed_vic_update_fiq(int flags) "Raising FIQ: %d" aspeed_vic_update_irq(int flags) "Raising IRQ: %d" aspeed_vic_read(uint64_t offset, unsigned size, uint32_t value) "From 0x%" PRIx64 " of size %u: 0x%" PRIx32 aspeed_vic_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 " of size %u: 0x%" PRIx32 + +# hw/acpi/cpu.c +cpuhp_acpi_invalid_idx_selected(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%"PRIx8 +cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" +cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" +cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32 +cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 +cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
Signature · 1 line
1.8.3.1
RFC 19/42 pc: add generic CPU unplug callbacks
In reply to Igor Mammedov--- hw/i386/pc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
hw/i386/pc.c +47 -0
@@ -1713,6 +1713,49 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev, out:error_propagate (errp, local_err); } +static void pc_cpu_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +HotplugHandlerClass *hhc; +Error *local_err =NULL ; +PCMachineState *pcms =PC_MACHINE (hotplug_dev); + + hhc =HOTPLUG_HANDLER_GET_CLASS (pcms->acpi_dev); + hhc->unplug_request (HOTPLUG_HANDLER (pcms->acpi_dev), dev, &local_err); + +if (local_err) { + goto out; + } + + out: +error_propagate (errp, local_err); + +} + +static void pc_cpu_unplug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +HotplugHandlerClass *hhc; +Error *local_err =NULL ; +PCMachineState *pcms =PC_MACHINE (hotplug_dev); + + hhc =HOTPLUG_HANDLER_GET_CLASS (pcms->acpi_dev); + hhc->unplug (HOTPLUG_HANDLER (pcms->acpi_dev), dev, &local_err); + +if (local_err) { + goto out; + } + +/* +* TODO: enable unplug once generic CPU remove bits land +* for now guest will be able to eject CPU ACPI wise but +* it will come back again on machine reset. +*/ +/* object_unparent(OBJECT(dev)); */ + + out: +error_propagate (errp, local_err); +}static void pc_machine_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp)
@@ -1729,6 +1772,8 @@ static void pc_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, {if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {pc_dimm_unplug_request (hotplug_dev, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { +pc_cpu_unplug_request_cb (hotplug_dev, dev, errp); }else {error_setg (errp,"acpi: device unplug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -1740,6 +1785,8 @@ static void pc_machine_device_unplug_cb(HotplugHandler *hotplug_dev, {if (object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {pc_dimm_unplug (hotplug_dev, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { +pc_cpu_unplug_cb (hotplug_dev, dev, errp); }else {error_setg (errp,"acpi: device unplug for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
Signature · 1 line
1.8.3.1
RFC 14/42 tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type
In reply to Igor Mammedovit should help to notice regression if legacy CPU hotplug unintentionally disappears in old machine types.
--- tests/acpi-test-data/pc/DSDT.cphp_legacy | Bin 0 -> 5502 bytes tests/bios-tables-test.c | 13 +++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 tests/acpi-test-data/pc/DSDT.cphp_legacy
tests/acpi-test-data/pc/DSDT.cphp_legacy new file binary +0 -0
tests/bios-tables-test.c +13 -0
@@ -781,6 +781,17 @@ static void test_acpi_q35_tcg_bridge(void)free_test_data (&data); } +static void test_acpi_piix4_tcg_cpuhp_legacy (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".cphp_legacy" ; +test_acpi_one ("-machine pc-i440fx-2.6,accel=tcg" , &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -797,6 +808,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/tcg/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35/tcg" , test_acpi_q35_tcg);qtest_add_func ("acpi/q35/tcg/bridge" , test_acpi_q35_tcg_bridge); +qtest_add_func ("acpi/piix4/tcg/cpuhp/legacy" , + test_acpi_piix4_tcg_cpuhp_legacy); } ret =g_test_run ();boot_sector_cleanup (disk);
Signature · 1 line
1.8.3.1
RFC 20/42 machine: add cpu-hotplug machine option
In reply to Igor Mammedov--- hw/core/machine.c | 20 ++++++++++++++++++++ include/hw/boards.h | 1 + 2 files changed, 21 insertions(+)
hw/core/machine.c +20 -0
@@ -329,6 +329,20 @@ static bool machine_get_enforce_config_section(Object *obj, Error **errp)return ms->enforce_config_section; } +static bool machine_get_cpu_hotplug (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->cpu_hotplug; +} + +static void machine_set_cpu_hotplug (Object *obj,bool value,Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->cpu_hotplug = value; +} +static int error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) { error_report("Option '-device %s' cannot be handled by this machine",
@@ -490,6 +504,12 @@ static void machine_initfn(Object *obj)object_property_set_description (obj,"enforce-config-section" ,"Set on to enforce configuration section migration" ,NULL ); +object_property_add_bool (obj,"cpu-hotplug" , + machine_get_cpu_hotplug, + machine_set_cpu_hotplug,NULL ); +object_property_set_description (obj,"cpu-hotplug" , +"Set on to enable CPU hotplug" , +NULL );/* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify;
include/hw/boards.h +1 -0
@@ -154,6 +154,7 @@ struct MachineState {bool iommu;bool suppress_vmdesc;bool enforce_config_section; +bool cpu_hotplug;ram_addr_t ram_size;ram_addr_t maxram_size;
Signature · 1 line
1.8.3.1
RFC 21/42 pc: q35: initialize new CPU hotplug hw
In reply to Igor Mammedovadd ICH9-LPC.cpu-hotplug property and necessary wiring to init new CPU hotplug hardware if ICH9-LPC.cpu-hotplug is "on", which is enabled if machine.cpu-hotplug is "on".
--- hw/acpi/ich9.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++---- hw/i386/pc_q35.c | 7 +++--- include/hw/acpi/ich9.h | 6 ++++- 3 files changed, 65 insertions(+), 8 deletions(-)
hw/acpi/ich9.c +56 -4
@@ -170,6 +170,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool vmstate_test_use_cpuhp (void *opaque) +{ +ICH9LPCPMRegs *s = opaque; +return !s->cpu_hotplug_legacy && s->cpuhp.state.is_enabled; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name ="ich9_pm/cpuhp" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .needed = vmstate_test_use_cpuhp, + .fields = (VMStateField []) { +VMSTATE_CPU_HOTPLUG (cpuhp.state, ICH9LPCPMRegs), +VMSTATE_END_OF_LIST () + } +}; +static bool vmstate_test_use_tco (void *opaque) {ICH9LPCPMRegs *s = opaque;
@@ -209,6 +227,7 @@ const VMStateDescription vmstate_ich9_pm = { .subsections = (const VMStateDescription*[]) { &vmstate_memhp_state, &vmstate_tco_io_state, + &vmstate_cpuhp_state,NULL } };
@@ -275,7 +294,10 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,if (pm->cpu_hotplug_legacy) {legacy_acpi_cpu_hotplug_init (pci_address_space_io (lpc_pci), -OBJECT (lpc_pci), &pm->gpe_cpu,ICH9_CPU_HOTPLUG_IO_BASE ); +OBJECT (lpc_pci), &pm->cpuhp.legacy,ICH9_CPU_HOTPLUG_IO_BASE ); + }else if (pm->cpuhp.state.is_enabled) { +cpu_hotplug_hw_init (pci_address_space_io (lpc_pci),OBJECT (lpc_pci), + &pm->cpuhp.state,ICH9_CPU_HOTPLUG_IO_BASE ); }if (pm->acpi_memory_hotplug.is_enabled) {
@@ -323,6 +345,21 @@ static void ich9_pm_set_cpu_hotplug_legacy(Object *obj, bool value, s->pm.cpu_hotplug_legacy = value; } +static bool ich9_pm_get_cpu_hotplug_support (Object *obj,Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + +return !s->pm.cpu_hotplug_legacy && s->pm.cpuhp.state.is_enabled; +} + +static void ich9_pm_set_cpu_hotplug_support (Object *obj,bool value, +Error **errp) +{ +ICH9LPCState *s =ICH9_LPC_DEVICE (obj); + + s->pm.cpuhp.state.is_enabled = value; +} +static void ich9_pm_get_disable_s3 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp) {
@@ -433,6 +470,10 @@ void ich9_pm_add_properties(Object *obj, ICH9LPCPMRegs *pm, Error **errp) ich9_pm_get_cpu_hotplug_legacy, ich9_pm_set_cpu_hotplug_legacy, NULL); +object_property_add_bool (obj,"cpu-hotplug" , + ich9_pm_get_cpu_hotplug_support, + ich9_pm_set_cpu_hotplug_support, +NULL ); object_property_add(obj, ACPI_PM_PROP_S3_DISABLED, "uint8", ich9_pm_get_disable_s3, ich9_pm_set_disable_s3,
@@ -460,9 +501,13 @@ void ich9_pm_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {acpi_memory_plug_cb (hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); - } else if (lpc->pm.cpu_hotplug_legacy && -object_dynamic_cast (OBJECT (dev ),TYPE_CPU )) { -legacy_acpi_cpu_plug_cb (hotplug_dev, &lpc->pm.gpe_cpu, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { +if (lpc->pm.cpu_hotplug_legacy) { +legacy_acpi_cpu_plug_cb (hotplug_dev, &lpc->pm.cpuhp.legacy, dev, + errp); + }else { +acpi_cpu_plug_cb (hotplug_dev, &lpc->pm.cpuhp.state, dev, errp); + } } else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -479,6 +524,10 @@ void ich9_pm_device_unplug_request_cb(HotplugHandler *hotplug_dev,acpi_memory_unplug_request_cb (hotplug_dev, &lpc->pm.acpi_memory_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && + !lpc->pm.cpu_hotplug_legacy) { +acpi_cpu_unplug_request_cb (hotplug_dev, &lpc->pm.cpuhp.state, + dev, errp); }else {error_setg (errp,"acpi: device unplug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -493,6 +542,9 @@ void ich9_pm_device_unplug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,if (lpc->pm.acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {acpi_memory_unplug_cb (&lpc->pm.acpi_memory_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && + !lpc->pm.cpu_hotplug_legacy) { +acpi_cpu_unplug_cb (&lpc->pm.cpuhp.state, dev, errp); }else {error_setg (errp,"acpi: device unplug for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
hw/i386/pc_q35.c +4 -3
@@ -171,15 +171,16 @@ static void pc_q35_init(MachineState *machine) host_bus = phb->bus; pcms->bus = phb->bus;/* create ISA bus */ - lpc =pci_create_simple_multifunction (host_bus,PCI_DEVFN (ICH9_LPC_DEV , -ICH9_LPC_FUNC ), true, -TYPE_ICH9_LPC_DEVICE ); + lpc =pci_create_multifunction (host_bus,PCI_DEVFN (ICH9_LPC_DEV , +ICH9_LPC_FUNC ), true,TYPE_ICH9_LPC_DEVICE ); +qdev_prop_set_bit (DEVICE (lpc),"cpu-hotplug" , machine->cpu_hotplug);object_property_add_link (OBJECT (machine),PC_MACHINE_ACPI_DEVICE_PROP ,TYPE_HOTPLUG_HANDLER , (Object **)&pcms->acpi_dev, object_property_allow_set_link,OBJ_PROP_LINK_UNREF_ON_RELEASE , &error_abort); +qdev_init_nofail (DEVICE (lpc));object_property_set_link (OBJECT (machine),OBJECT (lpc),PC_MACHINE_ACPI_DEVICE_PROP , &error_abort);
include/hw/acpi/ich9.h +5 -1
@@ -23,6 +23,7 @@#include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/cpu.h" #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/acpi/tco.h"
@@ -49,7 +50,10 @@ typedef struct ICH9LPCPMRegs {Notifier powerdown_notifier;bool cpu_hotplug_legacy; -AcpiCpuHotplug gpe_cpu; +union { +AcpiCpuHotplug legacy;/* used for keeping legacy state */ +CPUHotplugState state; + } cpuhp;MemHotplugState acpi_memory_hotplug;
Signature · 1 line
1.8.3.1
RFC 22/42 pc: piix4: initialize new CPU hotplug hw
In reply to Igor Mammedov--- hw/acpi/piix4.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ hw/i386/pc_piix.c | 2 +- hw/mips/mips_malta.c | 2 +- include/hw/i386/pc.h | 3 ++- 4 files changed, 49 insertions(+), 9 deletions(-)
hw/acpi/piix4.c +45 -6
@@ -34,6 +34,7 @@#include "hw/acpi/piix4.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/cpu.h" #include "hw/hotplug.h" #include "hw/mem/pc-dimm.h" #include "hw/acpi/memory_hotplug.h"
@@ -86,7 +87,10 @@ typedef struct PIIX4PMState {uint8_t s4_val;bool cpu_hotplug_legacy; -AcpiCpuHotplug gpe_cpu; +union { +AcpiCpuHotplug legacy;/* used for keeping legacy state */ +CPUHotplugState state; + } cpuhp;MemHotplugState acpi_memory_hotplug; } PIIX4PMState;
@@ -273,6 +277,24 @@ static const VMStateDescription vmstate_memhp_state = { } }; +static bool vmstate_test_use_cpuhp (void *opaque) +{ +PIIX4PMState *s = opaque; +return !s->cpu_hotplug_legacy && s->cpuhp.state.is_enabled; +} + +static const VMStateDescription vmstate_cpuhp_state = { + .name ="piix4_pm/cpuhp" , + .version_id =1 , + .minimum_version_id =1 , + .minimum_version_id_old =1 , + .needed = vmstate_test_use_cpuhp, + .fields = (VMStateField []) { +VMSTATE_CPU_HOTPLUG (cpuhp.state, PIIX4PMState), +VMSTATE_END_OF_LIST () + } +}; +/* qemu-kvm 1.2 uses version 3 but advertised as 2 * To support incoming qemu-kvm 1.2 migration, change version_id * and minimum_version_id to 2 below (which breaks migration from
@@ -307,6 +329,7 @@ static const VMStateDescription vmstate_acpi = { }, .subsections = (const VMStateDescription*[]) { &vmstate_memhp_state, + &vmstate_cpuhp_state,NULL } };
@@ -351,9 +374,12 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev,acpi_memory_plug_cb (hotplug_dev, &s->acpi_memory_hotplug, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) {acpi_pcihp_device_plug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, errp); - }else if (s->cpu_hotplug_legacy && -object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { -legacy_acpi_cpu_plug_cb (hotplug_dev, &s->gpe_cpu, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { +if (s->cpu_hotplug_legacy) { +legacy_acpi_cpu_plug_cb (hotplug_dev, &s->cpuhp.legacy, dev, errp); + }else { +acpi_cpu_plug_cb (hotplug_dev, &s->cpuhp.state, dev, errp); + } }else {error_setg (errp,"acpi: device plug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -372,6 +398,9 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) {acpi_pcihp_device_unplug_cb (hotplug_dev, &s->acpi_pci_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && + !s->cpu_hotplug_legacy) { +acpi_cpu_unplug_request_cb (hotplug_dev, &s->cpuhp.state, dev, errp); }else {error_setg (errp,"acpi: device unplug request for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -386,6 +415,9 @@ static void piix4_device_unplug_cb(HotplugHandler *hotplug_dev,if (s->acpi_memory_hotplug.is_enabled &&object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM )) {acpi_memory_unplug_cb (&s->acpi_memory_hotplug, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU ) && + !s->cpu_hotplug_legacy) { +acpi_cpu_unplug_cb (&s->cpuhp.state, dev, errp); }else {error_setg (errp,"acpi: device unplug for not supported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -507,13 +539,15 @@ Object *piix4_pm_find(void)I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int smm_enabled,DeviceState **piix4_pm) +int smm_enabled,DeviceState **piix4_pm, +bool cpuhp_enabled) {DeviceState *dev;PIIX4PMState *s; dev =DEVICE (pci_create (bus, devfn,TYPE_PIIX4_PM ));qdev_prop_set_uint32 (dev,"smb_io_base" , smb_io_base); +qdev_prop_set_bit (dev,"cpu-hotplug" , cpuhp_enabled);if (piix4_pm) { *piix4_pm = dev; }
@@ -572,8 +606,11 @@ static void piix4_acpi_system_hot_add_init(MemoryRegion *parent, s->use_acpi_pci_hotplug);if (s->cpu_hotplug_legacy) { -legacy_acpi_cpu_hotplug_init (parent,OBJECT (s), &s->gpe_cpu, +legacy_acpi_cpu_hotplug_init (parent,OBJECT (s), &s->cpuhp.legacy,PIIX4_CPU_HOTPLUG_IO_BASE ); + }else if (s->cpuhp.state.is_enabled) { +cpu_hotplug_hw_init (parent,OBJECT (s), &s->cpuhp.state, +PIIX4_CPU_HOTPLUG_IO_BASE ); }if (s->acpi_memory_hotplug.is_enabled) {
@@ -606,6 +643,8 @@ static Property piix4_pm_properties[] = { acpi_memory_hotplug.is_enabled, true),DEFINE_PROP_BOOL ("cpu-hotplug-legacy" , PIIX4PMState, cpu_hotplug_legacy, false), +DEFINE_PROP_BOOL ("cpu-hotplug" , PIIX4PMState, + cpuhp.state.is_enabled, false), DEFINE_PROP_END_OF_LIST(), };
hw/i386/pc_piix.c +1 -1
@@ -259,7 +259,7 @@ static void pc_init1(MachineState *machine, smbus =piix4_pm_init (pci_bus, piix3_devfn +3 ,0xb100 , gsi[9 ], smi_irq,pc_machine_is_smm_enabled (pcms), - &piix4_pm); + &piix4_pm, machine->cpu_hotplug);smbus_eeprom_init (smbus,8 ,NULL ,0 ); object_property_add_link(OBJECT(machine), PC_MACHINE_ACPI_DEVICE_PROP,
hw/mips/mips_malta.c +1 -1
@@ -1208,7 +1208,7 @@ void mips_malta_init(MachineState *machine)pci_piix4_ide_init (pci_bus, hd, piix4_devfn +1 );pci_create_simple (pci_bus, piix4_devfn +2 ,"piix4-usb-uhci" ); smbus =piix4_pm_init (pci_bus, piix4_devfn +3 ,0x1100 , -isa_get_irq (NULL ,9 ),NULL ,0 ,NULL ); +isa_get_irq (NULL ,9 ),NULL ,0 ,NULL ,NULL );smbus_eeprom_init (smbus,8 , smbus_eeprom_buf, smbus_eeprom_size);g_free (smbus_eeprom_buf); pit =pit_init (isa_bus,0x40 ,0 ,NULL );
include/hw/i386/pc.h +2 -1
@@ -275,7 +275,8 @@ int cmos_get_fd_drive_type(FloppyDriveType fd0);I2CBus *piix4_pm_init (PCIBus *bus,int devfn,uint32_t smb_io_base,qemu_irq sci_irq,qemu_irq smi_irq, -int smm_enabled,DeviceState **piix4_pm); +int smm_enabled,DeviceState **piix4_pm, +bool cpuhp_enabled);void piix4_smbus_register_device (SMBusDevice *dev,uint8_t addr);/* hpet.c */
Signature · 1 line
1.8.3.1
RFC 24/42 pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx
In reply to Igor MammedovIn legacy cpu-hotplug ProcessorID == APIC ID is used in MADT and cpu-hotplug AML. It was fine as both are 8bit and unique. Spec depricated Processor() with corresponding ProcessorID and advises to use Device() and UID instead of it.
However UID is just 32bit and it can't fit ARM's arch_id(MPIDR) which is 64bit. Also in case of sparse arch_id() distribution, managment/lookup of maps by arch_id(APIC ID/MPIDR) becomes complex and expensive.
In preparation to common CPU hotplug with ARM and to simplify lookup in possible_cpus[] map switch ProcessorID to possible_cpus index in MADT.
Legacy cpu-hotplug considerations:
HW interface of it is APIC ID based bitmask so it's impossible to change, also CPON package in AML also APIC ID based as well all the methods.
To avoid massive rewrite of AML keep is so and just break assumption that ProcessorID == APIC ID, ammending CPU_MAT_METHOD to accept APIC ID and possible_cpus index, it needs them both to patch MADT entry template. Also switch to possible_cpus index Processor(ProcessorID) AML.
That way changes to MADT/AML are minimal and kept inside AML/MADT not affecting external interfaces.
--- hw/acpi/cpu_hotplug.c | 23 +++++++++++++---------- hw/i386/acpi-build.c | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-)
hw/acpi/cpu_hotplug.c +13 -10
@@ -98,7 +98,8 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,int i, apic_idx;Aml *sb_scope =aml_scope ("_SB" );uint8_t madt_tmpl[8 ] = {0x00 ,0x08 ,0x00 ,0x00 ,0x00 ,0 ,0 ,0 }; -Aml *cpu_id =aml_arg (0 ); +Aml *cpu_id =aml_arg (1 ); +Aml *apic_id =aml_arg (0 );Aml *cpu_on =aml_local (0 );Aml *madt =aml_local (1 );Aml *cpus_map =aml_name (CPU_ON_BITMAP );
@@ -110,30 +111,31 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,/* * _MAT method - creates an madt apic buffer -* cpu_id = Arg0 = Processor ID = Local APIC ID +* apic_id = Arg0 = Local APIC ID +* cpu_id = Arg1 = Processor ID * cpu_on = Local0 = CPON flag for this cpu * madt = Local1 = Buffer (in madt apic form) to return */ - method =aml_method (CPU_MAT_METHOD ,1 ,AML_NOTSERIALIZED ); + method =aml_method (CPU_MAT_METHOD ,2 ,AML_NOTSERIALIZED );aml_append (method, -aml_store (aml_derefof (aml_index (cpus_map, cpu_id)), cpu_on)); +aml_store (aml_derefof (aml_index (cpus_map, apic_id)), cpu_on));aml_append (method,aml_store (aml_buffer (sizeof (madt_tmpl), madt_tmpl), madt));/* Update the processor id, lapic id, and enable/disable status */ aml_append (method,aml_store (cpu_id,aml_index (madt,aml_int (2 )))); -aml_append (method,aml_store (cpu_id,aml_index (madt,aml_int (3 )))); +aml_append (method,aml_store (apic_id,aml_index (madt,aml_int (3 ))));aml_append (method,aml_store (cpu_on,aml_index (madt,aml_int (4 ))));aml_append (method,aml_return (madt));aml_append (sb_scope, method);/* * _STA method - return ON status of cpu -* cpu_id = Arg0 = Processor ID = Local APIC ID +* apic_id = Arg0 = Local APIC ID * cpu_on = Local0 = CPON flag for this cpu */ method =aml_method (CPU_STATUS_METHOD ,1 ,AML_NOTSERIALIZED );aml_append (method, -aml_store (aml_derefof (aml_index (cpus_map, cpu_id)), cpu_on)); +aml_store (aml_derefof (aml_index (cpus_map, apic_id)), cpu_on)); if_ctx =aml_if (cpu_on); {aml_append (if_ctx,aml_return (aml_int (0xF )));
@@ -242,11 +244,12 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,assert (apic_id <ACPI_CPU_HOTPLUG_ID_LIMIT ); - dev =aml_processor (apic_id,0 ,0 ,"CP%.02X" , apic_id); + dev =aml_processor (i,0 ,0 ,"CP%.02X" , apic_id); method =aml_method ("_MAT" ,0 ,AML_NOTSERIALIZED );aml_append (method, -aml_return (aml_call1 (CPU_MAT_METHOD ,aml_int (apic_id)))); +aml_return (aml_call2 (CPU_MAT_METHOD ,aml_int (apic_id),aml_int (i)) + ));aml_append (dev, method); method =aml_method ("_STA" ,0 ,AML_NOTSERIALIZED );
@@ -267,7 +270,7 @@ void build_legacy_cpu_hotplug_aml(Aml *ctx, MachineState *machine,/* build this code: * Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...} */ -/* Arg0 = Processor ID = APIC ID */ +/* Arg0 = APIC ID */ method =aml_method (AML_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED );for (i =0 ; i < apic_ids->len; i++) {int apic_id = apic_ids->cpus[i].arch_id;
hw/i386/acpi-build.c +1 -1
@@ -358,7 +358,7 @@ build_madt(GArray *table_data, GArray *linker, PCMachineState *pcms) apic->type =ACPI_APIC_PROCESSOR ; apic->length =sizeof (*apic); - apic->processor_id = apic_id; + apic->processor_id = i; apic->local_apic_id = apic_id;if (apic_ids->cpus[i].cpu !=NULL ) { apic->flags =cpu_to_le32 (1 );
Signature · 1 line
1.8.3.1
RFC 25/42 tests: acpi: update cphp_legacy case with new ProcessorID values
In reply to Igor Mammedov--- tests/acpi-test-data/pc/DSDT.cphp_legacy | Bin 5502 -> 5503 bytes 1 file changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT.cphp_legacy binary +0 -0
Signature · 1 line
1.8.3.1
RFC 26/42 pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook
In reply to Igor MammedovAdd madt_cpu callback to AcpiDeviceIfClass and use it for generating LAPIC MADT entries for CPUs for x86 target. Later it will be used for generating x2APIC entries in case of more than 255 CPUs and also would be reused by ARM target when ACPI CPU hotplug is introduced there.
--- hw/acpi/piix4.c | 1 + hw/i386/acpi-build.c | 45 +++++++++++++++++++++--------------- hw/isa/lpc_ich9.c | 1 + include/hw/acpi/acpi_dev_interface.h | 7 ++++++ include/hw/i386/pc.h | 5 ++++ stubs/Makefile.objs | 1 + stubs/pc_madt_cpu_entry.c | 7 ++++++ 7 files changed, 49 insertions(+), 18 deletions(-) create mode 100644 stubs/pc_madt_cpu_entry.c
hw/acpi/piix4.c +1 -0
@@ -675,6 +675,7 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data) hc->unplug = piix4_device_unplug_cb; adevc->ospm_status = piix4_ospm_status; adevc->send_event = piix4_send_gpe; + adevc->madt_cpu = pc_madt_cpu_entry; }static const TypeInfo piix4_pm_info = {
hw/i386/acpi-build.c +27 -18
63 lines not on this page · raw message
hw/isa/lpc_ich9.c +1 -0
@@ -713,6 +713,7 @@ static void ich9_lpc_class_init(ObjectClass *klass, void *data) hc->unplug = ich9_pm_device_unplug_cb; adevc->ospm_status = ich9_pm_ospm_status; adevc->send_event = ich9_send_gpe; + adevc->madt_cpu = pc_madt_cpu_entry; }static const TypeInfo ich9_lpc_info = {
include/hw/acpi/acpi_dev_interface.h +7 -0
@@ -3,6 +3,7 @@#include "qom/object.h" #include "qapi-types.h" +#include "hw/boards.h" /* These values are part of guest ABI, and can not be changed */ typedef enum {
@@ -44,6 +45,10 @@ typedef struct AcpiDeviceIf {* ospm_status: returns status of ACPI device objects, reported * via _OST method if device supports it. * send_event: inject a specified event into guest +* madt_cpu: fills @entry with Interrupt Controller Structure +* for CPU indexed by @uid in @apic_ids array, +* returned structure types are: +* 0 - Local APIC, 9 - Local x2APIC, 0xB - GICC * * Interface is designed for providing unified interface * to generic ACPI functionality that could be used without
@@ -57,5 +62,7 @@ typedef struct AcpiDeviceIfClass {/* <public> */ void (*ospm_status)(AcpiDeviceIf *adev,ACPIOSTInfoList ***list);void (*send_event)(AcpiDeviceIf *adev,AcpiEventStatusBits ev); +void (*madt_cpu)(AcpiDeviceIf *adev,int uid, + CPUArchIdList *apic_ids, GArray *entry); } AcpiDeviceIfClass;#endif
include/hw/i386/pc.h +5 -0
@@ -17,6 +17,7 @@#include "hw/compat.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/acpi_dev_interface.h" #define HPET_INTCAP "hpet-intcap"
@@ -346,6 +347,10 @@ void pc_system_firmware_init(MemoryRegion *rom_memory,/* pvpanic.c */ uint16_t pvpanic_port (void ); +/* acpi-build.c */ +void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, +CPUArchIdList *apic_ids,GArray *entry); +/* e820 types */ #define E820_RAM 1#define E820_RESERVED 2
stubs/Makefile.objs +1 -0
@@ -41,3 +41,4 @@ stub-obj-y += target-monitor-defs.o stub-obj-y += target-get-monitor-def.o stub-obj-y += vhost.o stub-obj-y += iohandler.o +stub-obj-y += pc_madt_cpu_entry.o
stubs/pc_madt_cpu_entry.c new file +7 -0
@@ -0,0 +1,7 @@ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" + +void pc_madt_cpu_entry (AcpiDeviceIf *adev,int uid, +CPUArchIdList *apic_ids,GArray *entry) +{ +}
Signature · 1 line
1.8.3.1
RFC 27/42 acpi: add CPU devices AML to DSDT
In reply to Igor Mammedov--- hw/acpi/cpu.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 2 ++ include/hw/acpi/cpu.h | 3 +++ 3 files changed, 43 insertions(+)
hw/acpi/cpu.c +38 -0
@@ -216,3 +216,41 @@ const VMStateDescription vmstate_cpu_hotplug = { VMSTATE_END_OF_LIST() } }; + +#define CPU_NAME_FMT "C%.03X" + +void build_cpus_aml (Aml *table,MachineState *machine,bool acpi1_compat) +{ +Aml *cpus_dev; +Aml *sb_scope =aml_scope ("_SB" ); +MachineClass *mc =MACHINE_GET_CLASS (machine); +CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids (machine); + cpus_dev =aml_device ("\\_SB.CPUS" ); + { +int i; + +aml_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" ))); +aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" ))); + +/* build Processor object for each processor */ +for (i =0 ; i < arch_ids->len; i++) { +Aml *dev; +Aml *uid =aml_int (i); +int arch_id = arch_ids->cpus[i].arch_id; + +if (acpi1_compat && arch_id <255 ) { + dev =aml_processor (i,0 ,0 ,CPU_NAME_FMT , i); + }else { + dev =aml_device (CPU_NAME_FMT , arch_id); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("ACPI0007" ))); +aml_append (dev,aml_name_decl ("_UID" , uid)); + } + +aml_append (cpus_dev, dev); + } + } +aml_append (sb_scope, cpus_dev); +aml_append (table, sb_scope); + +g_free (arch_ids); +}
hw/i386/acpi-build.c +2 -0
@@ -1948,6 +1948,8 @@ build_dsdt(GArray *table_data, GArray *linker,if (pm->legacy_cpu_hp) {build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base); + }else { +build_cpus_aml (dsdt, machine, true); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
include/hw/acpi/cpu.h +3 -0
@@ -14,6 +14,7 @@#include "hw/qdev-core.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" #include "hw/hotplug.h" typedef struct AcpiCpuStatus {
@@ -45,6 +46,8 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,void cpu_hotplug_hw_init (MemoryRegion *as,Object *owner,CPUHotplugState *state,hwaddr base_addr); +void build_cpus_aml (Aml *table,MachineState *machine,bool apci1_compat); +extern const VMStateDescription vmstate_cpu_hotplug;#define VMSTATE_CPU_HOTPLUG (cpuhp, state) \ VMSTATE_STRUCT(cpuhp, state, 1, \
Signature · 1 line
1.8.3.1
RFC 23/42 tests: pc-cpu-test: turn on cpu-hotplug explicily
In reply to Igor MammedovMachine types before 2.7 have legacy CPU hotplug enabled by defaut to not regress existing setups where it's always enabled.
But since 2.7 CPU hotplug is disabled y default and requires explicit enabling using 'cpu-hotplug' parameter in '-machine' option.
So turn it on for cpu-hotplug testcase to allow it test 2.7 and later machine types.
Fixes following failure:
/x86_64/cpu/pc-q35-2.7/add/1x3x2&maxcpus=12: ** ERROR:tests/pc-cpu-test.c:44:test_pc_with_cpu_add:
assertion failed: (!qdict_haskey(response, "error"))
--- tests/pc-cpu-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/pc-cpu-test.c +1 -1
@@ -31,7 +31,7 @@ static void test_pc_with_cpu_add(gconstpointer data)QDict *response;unsigned int i; - args =g_strdup_printf ("-machine %s -cpu %s " + args =g_strdup_printf ("-machine %s,cpu-hotplug=on -cpu %s " "-smp sockets=%u,cores=%u,threads=%u,maxcpus=%u" , s->machine, s->cpu_model, s->sockets, s->cores, s->threads, s->maxcpus);
Signature · 1 line
1.8.3.1
RFC 28/42 acpi: add CPU hotplug methods to DSDT
In reply to Igor MammedovAdd necessary CPU hotplug methods to handle hotplug events if it's enabled.
--- hw/acpi/cpu.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 3 +- include/hw/acpi/cpu.h | 4 +- 3 files changed, 204 insertions(+), 4 deletions(-)
hw/acpi/cpu.c +199 -2
@@ -218,20 +218,177 @@ const VMStateDescription vmstate_cpu_hotplug = { };#define CPU_NAME_FMT "C%.03X" - -void build_cpus_aml (Aml *table,MachineState *machine,bool acpi1_compat) +#define CPUHP_RES_DEVICE "PRES" +#define CPU_LOCK "CPLK" +#define CPU_STS_METHOD "CSTA" +#define CPU_SCAN_METHOD "CSCN" +#define CPU_EJECT_METHOD "CEJ0" +#define CPU_NOTIFY_METHOD "CTFY" + +#define CPU_ENABLED "CPEN" +#define CPU_SELECTOR "CSEL" +#define CPU_EJECT_EVENT "CEJ0" +#define CPU_INSERT_EVENT "CINS" +#define CPU_REMOVE_EVENT "CRMV" + +void build_cpus_aml (Aml *table,MachineState *machine,bool acpi1_compat, +const char *res_root,const char *event_handler_method, +hwaddr io_base) { +Aml *ifctx; +Aml *field; +Aml *method; +Aml *cpu_ctrl_dev;Aml *cpus_dev; +Aml *zero =aml_int (0 );Aml *sb_scope =aml_scope ("_SB" );MachineClass *mc =MACHINE_GET_CLASS (machine);CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids (machine); +char *cphp_res_path =g_strdup_printf ("%s." CPUHP_RES_DEVICE , res_root); +Object *obj =object_resolve_path_type ("" ,TYPE_ACPI_DEVICE_IF ,NULL ); +AcpiDeviceIfClass *adevc =ACPI_DEVICE_IF_GET_CLASS (obj); +AcpiDeviceIf *adev =ACPI_DEVICE_IF (obj); + +if (machine->cpu_hotplug) { + cpu_ctrl_dev =aml_device ("%s" , cphp_res_path); + { +Aml *crs; + +aml_append (cpu_ctrl_dev, +aml_name_decl ("_HID" ,aml_eisaid ("PNP0A06" ))); +aml_append (cpu_ctrl_dev, +aml_name_decl ("_UID" ,aml_string ("CPU Hotplug resources" ))); +aml_append (cpu_ctrl_dev,aml_mutex (CPU_LOCK ,0 )); + + crs =aml_resource_template (); +aml_append (crs,aml_io (AML_DECODE16 , io_base, io_base,1 , +ACPI_CPU_HOTPLUG_REG_LEN )); +aml_append (cpu_ctrl_dev,aml_name_decl ("_CRS" , crs)); + +/* declare CPU hotplug MMIO region with related access fields */ +aml_append (cpu_ctrl_dev, +aml_operation_region ("PRST" ,AML_SYSTEM_IO ,aml_int (io_base), +ACPI_CPU_HOTPLUG_REG_LEN )); + + field =aml_field ("PRST" ,AML_BYTE_ACC ,AML_NOLOCK , +AML_WRITE_AS_ZEROS ); +aml_append (field,aml_reserved_field (ACPI_CPU_FLAGS_OFFSET_RW *8 )); +/* 1 if enabled, read only */ +aml_append (field,aml_named_field (CPU_ENABLED ,1 )); +/* (read) 1 if has a insert event. (write) 1 to clear event */ +aml_append (field,aml_named_field (CPU_INSERT_EVENT ,1 )); +/* (read) 1 if has a remove event. (write) 1 to clear event */ +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 (cpu_ctrl_dev, field); + + field =aml_field ("PRST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE ); +/* CPU selector, write only */ +aml_append (field,aml_named_field (CPU_SELECTOR ,32 )); +aml_append (cpu_ctrl_dev, field); + + } +aml_append (sb_scope, cpu_ctrl_dev); + } + cpus_dev =aml_device ("\\_SB.CPUS" ); {int i; +Aml *one =aml_int (1 ); +Aml *cpu_selector =aml_name ("%s.%s" , cphp_res_path,CPU_SELECTOR ); +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 *is_enabled =aml_name ("%s.%s" , cphp_res_path,CPU_ENABLED ); +Aml *ctrl_lock =aml_name ("%s.%s" , cphp_res_path,CPU_LOCK );aml_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" )));aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" ))); +if (machine->cpu_hotplug) { + method =aml_method (CPU_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED ); +for (i =0 ; i < arch_ids->len; i++) { +Aml *cpu =aml_name (CPU_NAME_FMT , i); +Aml *uid =aml_arg (0 ); +Aml *event =aml_arg (1 ); + + ifctx =aml_if (aml_equal (uid,aml_int (i))); + { +aml_append (ifctx,aml_notify (cpu, event)); + } +aml_append (method, ifctx); + } +aml_append (cpus_dev, method); + + method =aml_method (CPU_STS_METHOD ,1 ,AML_SERIALIZED ); + { +Aml *idx =aml_arg (0 ); +Aml *sta =aml_local (0 ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (idx, cpu_selector)); +aml_append (method,aml_store (zero, sta)); + ifctx =aml_if (aml_equal (is_enabled, one)); + { +aml_append (ifctx,aml_store (aml_int (0xF ), sta)); + } +aml_append (method, ifctx); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (sta)); + } +aml_append (cpus_dev, method); + + method =aml_method (CPU_EJECT_METHOD ,1 ,AML_SERIALIZED ); + { +Aml *idx =aml_arg (0 ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (idx, cpu_selector)); +aml_append (method,aml_store (one, ej_evt)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (cpus_dev, method); + + method =aml_method (CPU_SCAN_METHOD ,0 ,AML_SERIALIZED ); + { +Aml *else_ctx; +Aml *while_ctx; +Aml *idx =aml_local (0 ); +Aml *eject_req =aml_int (3 ); +Aml *dev_chk =aml_int (1 ); +Aml *cpus_count =aml_int (arch_ids->len); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (zero, idx)); + while_ctx =aml_while (aml_lless (idx, cpus_count)); + { +aml_append (while_ctx,aml_store (idx, cpu_selector)); + ifctx =aml_if (aml_equal (ins_evt, one)); + { +aml_append (ifctx, +aml_call2 (CPU_NOTIFY_METHOD , idx, dev_chk)); +aml_append (ifctx,aml_store (one, ins_evt)); + } +aml_append (while_ctx, ifctx); + else_ctx =aml_else (); + ifctx =aml_if (aml_equal (rm_evt, one)); + { +aml_append (ifctx, +aml_call2 (CPU_NOTIFY_METHOD , idx, eject_req)); +aml_append (ifctx,aml_store (one, rm_evt)); + } +aml_append (else_ctx, ifctx); +aml_append (while_ctx, else_ctx); + +aml_append (while_ctx,aml_add (idx, one, idx)); + } +aml_append (method, while_ctx); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (cpus_dev, method); + } +/* build Processor object for each processor */ for (i =0 ; i < arch_ids->len; i++) {Aml *dev;
@@ -246,11 +403,51 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat)aml_append (dev,aml_name_decl ("_UID" , uid)); } +if (machine->cpu_hotplug) { + method =aml_method ("_STA" ,0 ,AML_SERIALIZED ); +aml_append (method,aml_return (aml_call1 (CPU_STS_METHOD , uid))); +aml_append (dev, method); + + method =aml_method ("_MAT" ,0 ,AML_SERIALIZED ); + { +Aml *madt =aml_local (1 ); +GArray *buf =g_array_new (0 ,1 ,1 ); + + adevc->madt_cpu (adev, i, arch_ids, buf); +switch (buf->data[0 ]) { +case ACPI_APIC_PROCESSOR : { +AcpiMadtProcessorApic *apic = (void *)buf->data; + apic->flags =cpu_to_le32 (1 ); +break ; + } +default : +assert (0 ); + } +aml_append (method, +aml_store (aml_buffer (buf->len, (uint8_t *)buf->data), + madt)); +aml_append (method,aml_return (madt)); +g_array_free (buf, true); + } + +aml_append (dev, method); + + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call1 (CPU_EJECT_METHOD , uid)); +aml_append (dev, method); + }aml_append (cpus_dev, dev); } }aml_append (sb_scope, cpus_dev);aml_append (table, sb_scope); +if (machine->cpu_hotplug) { + method =aml_method (event_handler_method,0 ,AML_NOTSERIALIZED ); +aml_append (method,aml_call0 ("\\_SB.CPUS." CPU_SCAN_METHOD )); +aml_append (table, method); + } + +g_free (cphp_res_path);g_free (arch_ids); }
hw/i386/acpi-build.c +2 -1
@@ -1949,7 +1949,8 @@ build_dsdt(GArray *table_data, GArray *linker,if (pm->legacy_cpu_hp) {build_legacy_cpu_hotplug_aml (dsdt, machine, pm->cpu_hp_io_base); }else { -build_cpus_aml (dsdt, machine, true); +build_cpus_aml (dsdt, machine, true, +"\\_SB.PCI0" ,"\\_GPE._E02" , pm->cpu_hp_io_base); }build_memory_hotplug_aml (dsdt, nr_mem, pm->mem_hp_io_base, pm->mem_hp_io_len);
include/hw/acpi/cpu.h +3 -1
@@ -46,7 +46,9 @@ void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,void cpu_hotplug_hw_init (MemoryRegion *as,Object *owner,CPUHotplugState *state,hwaddr base_addr); -void build_cpus_aml (Aml *table,MachineState *machine,bool apci1_compat); +void build_cpus_aml (Aml *table,MachineState *machine,bool apci1_compat, +const char *res_root,const char *event_handler_method, +hwaddr io_base);extern const VMStateDescription vmstate_cpu_hotplug;#define VMSTATE_CPU_HOTPLUG (cpuhp, state) \
Signature · 1 line
1.8.3.1
RFC 29/42 tests: acpi: update expected files with new CPU AML description
In reply to Igor Mammedov--- tests/acpi-test-data/pc/DSDT | Bin 5090 -> 5147 bytes tests/acpi-test-data/pc/DSDT.bridge | Bin 6949 -> 7006 bytes tests/acpi-test-data/q35/DSDT | Bin 7852 -> 7909 bytes tests/acpi-test-data/q35/DSDT.bridge | Bin 7869 -> 7926 bytes 4 files changed, 0 insertions(+), 0 deletions(-)
tests/acpi-test-data/pc/DSDT binary +0 -0
tests/acpi-test-data/pc/DSDT.bridge binary +0 -0
tests/acpi-test-data/q35/DSDT binary +0 -0
tests/acpi-test-data/q35/DSDT.bridge binary +0 -0
Signature · 1 line
1.8.3.1
RFC 30/42 qdev: hotplug: Introduce HotplugHandler.pre_plug() callback
In reply to Igor Mammedovpre_plug callback is to be called before device.realize() is executed. This would allow to check/set device's properties from HotplugHandler.
--- hw/core/hotplug.c | 11 +++++++++++ hw/core/qdev.c | 9 ++++++++- include/hw/hotplug.h | 14 +++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-)
hw/core/hotplug.c +11 -0
@@ -13,6 +13,17 @@#include "hw/hotplug.h" #include "qemu/module.h" +void hotplug_handler_pre_plug (HotplugHandler *plug_handler, +DeviceState *plugged_dev, +Error **errp) +{ +HotplugHandlerClass *hdc =HOTPLUG_HANDLER_GET_CLASS (plug_handler); + +if (hdc->pre_plug) { + hdc->pre_plug (plug_handler, plugged_dev, errp); + } +} +void hotplug_handler_plug (HotplugHandler *plug_handler,DeviceState *plugged_dev,Error **errp)
hw/core/qdev.c +8 -1
@@ -1062,6 +1062,14 @@ static void device_set_realized(Object *obj, bool value, Error **errp)g_free (name); } + hotplug_ctrl =qdev_get_hotplug_handler (dev); +if (hotplug_ctrl) { +hotplug_handler_pre_plug (hotplug_ctrl, dev, &local_err); +if (local_err !=NULL ) { + goto fail; + } + } +if (dc->realize) { dc->realize (dev, &local_err); }
@@ -1072,7 +1080,6 @@ static void device_set_realized(Object *obj, bool value, Error **errp)DEVICE_LISTENER_CALL (realize, Forward, dev); - hotplug_ctrl =qdev_get_hotplug_handler (dev);if (hotplug_ctrl) {hotplug_handler_plug (hotplug_ctrl, dev, &local_err); }
include/hw/hotplug.h +13 -1
@@ -45,7 +45,8 @@ typedef void (*hotplug_fn)(HotplugHandler *plug_handler,* hardware (un)plug functions. * * @parent: Opaque parent interface. -* @plug: plug callback. +* @pre_plug: pre plug callback called at start of device.realize(true) +* @plug: plug callback called at end of device.realize(true). * @unplug_request: unplug request callback. * Used as a means to initiate device unplug for devices that * require asynchronous unplug handling.
@@ -58,6 +59,7 @@ typedef struct HotplugHandlerClass {InterfaceClass parent;/* <public> */ +hotplug_fn pre_plug;hotplug_fn plug;hotplug_fn unplug_request;hotplug_fn unplug;
@@ -73,6 +75,16 @@ void hotplug_handler_plug(HotplugHandler *plug_handler, Error **errp);/** +* hotplug_handler_pre_plug: +* +* Call #HotplugHandlerClass.pre_plug callback of @plug_handler. +*/ +void hotplug_handler_pre_plug (HotplugHandler *plug_handler, +DeviceState *plugged_dev, +Error **errp); + + +/** * hotplug_handler_unplug_request: * * Calls #HotplugHandlerClass.unplug_request callback of @plug_handler.
Signature · 1 line
1.8.3.1
RFC 31/42 pc: numa: replace node_cpu indexing by apic_id with possible_cpus index
In reply to Igor Mammedovthat removes dependency on apic_id_limit, reducing size of node_cpu to a number of maxcpus and allowing usage of 32bit APIC IDs without allocating a huge array.
--- hw/i386/acpi-build.c | 2 +- hw/i386/pc.c | 28 ++++++++++++---------------- 2 files changed, 13 insertions(+), 17 deletions(-)
hw/i386/acpi-build.c +1 -1
@@ -2362,7 +2362,7 @@ build_srat(GArray *table_data, GArray *linker, MachineState *machine) core->type =ACPI_SRAT_PROCESSOR ; core->length =sizeof (*core); core->local_apic_id = apic_id; - curnode = pcms->node_cpu[apic_id]; + curnode = pcms->node_cpu[i]; core->proximity_lo = curnode;memset (core->proximity_hi,0 ,3 ); core->local_sapic_eid =0 ;
hw/i386/pc.c +12 -16
@@ -1104,7 +1104,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)void pc_cpus_init (PCMachineState *pcms) { -int i; +int i, j;X86CPU *cpu =NULL ;MachineState *machine =MACHINE (pcms);
@@ -1133,9 +1133,19 @@ void pc_cpus_init(PCMachineState *pcms) pcms->possible_cpus =g_malloc0 (sizeof (CPUArchIdList) +sizeof (CPUArchId) * max_cpus); + pcms->node_cpu =g_malloc0 (max_cpus *sizeof *pcms->node_cpu); +for (i =0 ; i < max_cpus; i++) { pcms->possible_cpus->cpus[i].arch_id =x86_cpu_apic_id_from_index (i); pcms->possible_cpus->len++; + +for (j =0 ; j < nb_numa_nodes; j++) { +if (test_bit (i, numa_info[j].node_cpu)) { + pcms->node_cpu[i] = j; +break ; + } + } +if (i < smp_cpus) { cpu =pc_new_cpu (machine->cpu_model,x86_cpu_apic_id_from_index (i), &error_fatal);
@@ -1185,7 +1195,7 @@ void pc_machine_done(Notifier *notifier, void *data)void pc_guest_info_init (PCMachineState *pcms) { -int i, j; +int i; pcms->apic_xrupt_override =kvm_allows_irq0_override (); pcms->numa_nodes = nb_numa_nodes;
@@ -1195,20 +1205,6 @@ void pc_guest_info_init(PCMachineState *pcms) pcms->node_mem[i] = numa_info[i].node_mem; } - pcms->node_cpu =g_malloc0 (pcms->apic_id_limit * -sizeof *pcms->node_cpu); - -for (i =0 ; i < max_cpus; i++) { -unsigned int apic_id =x86_cpu_apic_id_from_index (i); -assert (apic_id < pcms->apic_id_limit); -for (j =0 ; j < nb_numa_nodes; j++) { -if (test_bit (i, numa_info[j].node_cpu)) { - pcms->node_cpu[apic_id] = j; -break ; - } - } - } - pcms->machine_done.notify = pc_machine_done;qemu_add_machine_init_done_notifier (&pcms->machine_done); }
Signature · 1 line
1.8.3.1
RFC 32/42 pc: set X86CPU.node property if QEMU starts with numa enabled
In reply to Igor Mammedov--- hw/i386/pc.c | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-)
hw/i386/pc.c +36 -7
@@ -1672,11 +1672,27 @@ static int pc_apic_cmp(const void *a, const void *b)return apic_a->arch_id - apic_b->arch_id; } +static +CPUArchId *pc_find_possible_cpu (PCMachineState *pcms,CPUState *cpu,int *idx) +{ +CPUClass *cc =CPU_GET_CLASS (cpu); +CPUArchId apic_id, *found_cpu; + + apic_id.arch_id = cc->get_arch_id (CPU (cpu)); + found_cpu =bsearch (&apic_id, pcms->possible_cpus->cpus, + pcms->possible_cpus->len,sizeof (*pcms->possible_cpus->cpus), + pc_apic_cmp); +assert (found_cpu); +if (idx) { + *idx = found_cpu - pcms->possible_cpus->cpus; + } +return found_cpu; +} +static void pc_cpu_plug (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) { -CPUClass *cc =CPU_GET_CLASS (dev); -CPUArchId apic_id, *found_cpu; +CPUArchId *found_cpu;HotplugHandlerClass *hhc;Error *local_err =NULL ;PCMachineState *pcms =PC_MACHINE (hotplug_dev);
@@ -1700,11 +1716,7 @@ static void pc_cpu_plug(HotplugHandler *hotplug_dev,/* increment the number of CPUs */ rtc_set_memory (pcms->rtc,0x5f ,rtc_get_memory (pcms->rtc,0x5f ) +1 ); - apic_id.arch_id = cc->get_arch_id (CPU (dev)); - found_cpu =bsearch (&apic_id, pcms->possible_cpus->cpus, - pcms->possible_cpus->len,sizeof (*pcms->possible_cpus->cpus), - pc_apic_cmp); -assert (found_cpu); + found_cpu =pc_find_possible_cpu (pcms,CPU (dev),NULL ); found_cpu->cpu =CPU (dev); out:error_propagate (errp, local_err);
@@ -1753,6 +1765,22 @@ static void pc_cpu_unplug_cb(HotplugHandler *hotplug_dev,error_propagate (errp, local_err); } +static void pc_machine_device_pre_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +PCMachineState *pcms =PC_MACHINE (hotplug_dev); + +if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) { +if (nb_numa_nodes) { +int idx; + +pc_find_possible_cpu (pcms,CPU (dev), &idx); +object_property_set_int (OBJECT (dev), pcms->node_cpu[idx],"node" , + errp); + } + } +} +static void pc_machine_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
@@ -2033,6 +2061,7 @@ static void pc_machine_class_init(ObjectClass *oc, void *data) mc->hot_add_cpu = pc_hot_add_cpu; mc->max_cpus =255 ; mc->reset = pc_machine_reset; + hc->pre_plug = pc_machine_device_pre_plug_cb; hc->plug = pc_machine_device_plug_cb; hc->unplug_request = pc_machine_device_unplug_request_cb; hc->unplug = pc_machine_device_unplug_cb;
Signature · 1 line
1.8.3.1
RFC 33/42 target-i386: add X86CPU.node property
In reply to Igor Mammedov--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+)
target-i386/cpu-qom.h +1 -0
@@ -101,6 +101,7 @@ typedef struct X86CPU {bool migratable;bool host_features;int64_t apic_id; +int64_t numa_node;/* default: -1: not configured */ /* if true the CPUID code directly forward host cache leaves to the guest */ bool cache_info_passthrough;
target-i386/cpu.c +42 -0
54 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC 34/42 acpi: cpuhp: add command and data registers
In reply to Igor MammedovCPU device has a lot of optional methods that might be needed to be added in future in QEMU, so instead of reserving/consuming IO/MMIO register for each of it introduce a generic DATA read-write register which is multiplexed by additional COMMAND write-only register.
currently that registers will be used for getting CPU's _PXM value and setting _OST.event/_OST.status values that OSPM reports to QEMU.
--- hw/acpi/cpu.c | 26 ++++++++++++++++++++++++++ include/hw/acpi/cpu.h | 1 + trace-events | 1 + 3 files changed, 28 insertions(+)
hw/acpi/cpu.c +26 -0
@@ -7,6 +7,12 @@#define ACPI_CPU_HOTPLUG_REG_LEN 12#define ACPI_CPU_SELECTOR_OFFSET_WR 0#define ACPI_CPU_FLAGS_OFFSET_RW 4 +#define ACPI_CPU_CMD_OFFSET_WR 5 +#define ACPI_CPU_CMD_DATA_OFFSET_RW 8 + +enum { +CPHP_CMD_MAX +};static uint64_t cpu_hotplug_rd (void *opaque,hwaddr addr,unsigned size) {
@@ -27,6 +33,12 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size) val |= cdev->is_removing ?4 :0 ;trace_cpuhp_acpi_read_flags (cpu_st->selector, val);break ; +case ACPI_CPU_CMD_DATA_OFFSET_RW : +switch (cpu_st->command) { +default : +break ; + } +break ;default :break ; }
@@ -80,6 +92,12 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, } }break ; +case ACPI_CPU_CMD_OFFSET_WR : +trace_cpuhp_acpi_write_cmd (cpu_st->selector, data); +if (data <CPHP_CMD_MAX ) { + cpu_st->command = data; + } +break ;default :break ; }
@@ -211,6 +229,7 @@ const VMStateDescription vmstate_cpu_hotplug = { .minimum_version_id_old = 1, .fields = (VMStateField []) {VMSTATE_UINT32 (selector, CPUHotplugState), +VMSTATE_UINT32 (command, CPUHotplugState),VMSTATE_STRUCT_VARRAY_POINTER_UINT32 (devs, CPUHotplugState, dev_count, vmstate_cpuhp_sts, AcpiCpuStatus),VMSTATE_END_OF_LIST ()
@@ -230,6 +249,8 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_EJECT_EVENT "CEJ0"#define CPU_INSERT_EVENT "CINS"#define CPU_REMOVE_EVENT "CRMV" +#define CPU_COMMAND "CCMD" +#define CPU_DATA "CDAT" void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, const char *res_root, const char *event_handler_method,
@@ -281,11 +302,16 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat,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_named_field (CPU_COMMAND ,8 ));aml_append (cpu_ctrl_dev, field); field =aml_field ("PRST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_PRESERVE );/* CPU selector, write only */ aml_append (field,aml_named_field (CPU_SELECTOR ,32 )); +/* flags + cmd + 2byte align */ +aml_append (field,aml_reserved_field (4 *8 )); +aml_append (field,aml_named_field (CPU_DATA ,32 ));aml_append (cpu_ctrl_dev, field); }
include/hw/acpi/cpu.h +1 -0
@@ -29,6 +29,7 @@ typedef struct CPUHotplugState {MemoryRegion ctrl_reg;bool is_enabled;uint32_t selector; +uint32_t command;uint32_t dev_count;AcpiCpuStatus *devs; } CPUHotplugState;
trace-events +1 -0
@@ -1916,5 +1916,6 @@ cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%" cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32 +cpuhp_acpi_write_cmd(uint32_t idx, uint8_t cmd) "idx[0x%"PRIx32"] cmd: 0x%"PRIx8 cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_cpu(uint32_t idx) "0x%"PRIx32
Signature · 1 line
1.8.3.1
RFC 35/42 acpi: cpuhp: provide cpu._PXM method if running in numa mode
In reply to Igor MammedovHaving proximity in SRAT table is not enough in case of linux guest as it discards SRAT table information after it's done with booting. So hotplugged CPUs will go to 1st node as kernel doesn't know to what node they belong to anymore.
So do the same as with hotplugged memory and provide _PXM method in CPU device context so that OSPM could assign CPU to a correct node.
--- hw/acpi/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ trace-events | 1 + 2 files changed, 49 insertions(+)
hw/acpi/cpu.c +48 -0
@@ -11,6 +11,7 @@#define ACPI_CPU_CMD_DATA_OFFSET_RW 8enum { +CPHP_PXM_CMD =0 ,CPHP_CMD_MAX };
@@ -35,6 +36,12 @@ static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size)break ;case ACPI_CPU_CMD_DATA_OFFSET_RW :switch (cpu_st->command) { +case CPHP_PXM_CMD : { +Object *o =OBJECT (CPU (cdev->cpu)); + val = o ?object_property_get_int (o,"node" ,NULL ) : ~0 ; +trace_cpuhp_acpi_read_pxm (cpu_st->selector, val); +break ; + }default :break ; }
@@ -243,6 +250,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_SCAN_METHOD "CSCN"#define CPU_EJECT_METHOD "CEJ0"#define CPU_NOTIFY_METHOD "CTFY" +#define CPU_PXM_METHOD "CPXM"#define CPU_ENABLED "CPEN"#define CPU_SELECTOR "CSEL"
@@ -321,6 +329,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, cpus_dev =aml_device ("\\_SB.CPUS" ); {int i; +bool has_pxm = true; +Error *local_err =NULL ;Aml *one =aml_int (1 );Aml *cpu_selector =aml_name ("%s.%s" , cphp_res_path,CPU_SELECTOR );Aml *ins_evt =aml_name ("%s.%s" , cphp_res_path,CPU_INSERT_EVENT );
@@ -328,11 +338,25 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat,Aml *ej_evt =aml_name ("%s.%s" , cphp_res_path,CPU_EJECT_EVENT );Aml *is_enabled =aml_name ("%s.%s" , cphp_res_path,CPU_ENABLED );Aml *ctrl_lock =aml_name ("%s.%s" , cphp_res_path,CPU_LOCK ); +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_append (cpus_dev,aml_name_decl ("_HID" ,aml_string ("ACPI0010" )));aml_append (cpus_dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A05" )));if (machine->cpu_hotplug) { + local_err =NULL ; +/* +* sample 1st VCPU (BSP) if it has support for numa and use result +* to enable _PXM method support +*/ +object_property_get_int (OBJECT (arch_ids->cpus[0 ].cpu),"node" , + &local_err); +if (local_err) { +error_free (local_err); + has_pxm = false; + } + method =aml_method (CPU_NOTIFY_METHOD ,2 ,AML_NOTSERIALIZED );for (i =0 ; i < arch_ids->len; i++) {Aml *cpu =aml_name (CPU_NAME_FMT , i);
@@ -413,6 +437,23 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat,aml_append (method,aml_release (ctrl_lock)); }aml_append (cpus_dev, method); + +if (has_pxm) { + method =aml_method (CPU_PXM_METHOD ,1 ,AML_SERIALIZED ); + { +Aml *uid =aml_arg (0 ); +Aml *pxm =aml_local (0 ); +Aml *pxm_cmd =aml_int (CPHP_PXM_CMD ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (uid, cpu_selector)); +aml_append (method,aml_store (pxm_cmd, cpu_cmd)); +aml_append (method,aml_store (cpu_data, pxm)); +aml_append (method,aml_release (ctrl_lock)); +aml_append (method,aml_return (pxm)); + } +aml_append (cpus_dev, method); + } }/* build Processor object for each processor */
@@ -461,6 +502,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED );aml_append (method,aml_call1 (CPU_EJECT_METHOD , uid));aml_append (dev, method); + +if (has_pxm) { + method =aml_method ("_PXM" ,0 ,AML_SERIALIZED ); +aml_append (method, +aml_return (aml_call1 (CPU_PXM_METHOD , uid))); +aml_append (dev, method); + } }aml_append (cpus_dev, dev); }
trace-events +1 -0
@@ -1913,6 +1913,7 @@ aspeed_vic_write(uint64_t offset, unsigned size, uint32_t data) "To 0x%" PRIx64 # hw/acpi/cpu.c cpuhp_acpi_invalid_idx_selected(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%"PRIx8 +cpuhp_acpi_read_pxm(uint32_t idx, uint32_t pxm) "idx[0x%"PRIx32"] flags: 0x%"PRIx32 cpuhp_acpi_clear_inserting_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_clear_remove_evt(uint32_t idx) "idx[0x%"PRIx32"]" cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32
Signature · 1 line
1.8.3.1
RFC 36/42 acpi: cpuhp: add cpu._OST handling
In reply to Igor Mammedov--- hw/acpi/cpu.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 3 ++ hw/acpi/piix4.c | 3 ++ include/hw/acpi/cpu.h | 4 +++ qapi-schema.json | 2 +- trace-events | 2 ++ 6 files changed, 96 insertions(+), 1 deletion(-)
hw/acpi/cpu.c +83 -0
@@ -2,6 +2,7 @@#include "hw/boards.h" #include "hw/acpi/cpu.h" #include "qapi/error.h" +#include "qapi-event.h" #include "trace.h" #define ACPI_CPU_HOTPLUG_REG_LEN 12
@@ -12,9 +13,42 @@enum {CPHP_PXM_CMD =0 , +CPHP_OST_EVENT_CMD =1 , +CPHP_OST_STATUS_CMD =2 ,CPHP_CMD_MAX }; +static ACPIOSTInfo *acpi_cpu_device_status (int idx,AcpiCpuStatus *cdev) +{ +ACPIOSTInfo *info =g_new0 (ACPIOSTInfo,1 ); + + info->slot_type =ACPI_SLOT_TYPE_CPU ; + info->slot =g_strdup_printf ("%d" , idx); + info->source = cdev->ost_event; + info->status = cdev->ost_status; +if (cdev->cpu) { +DeviceState *dev =DEVICE (cdev->cpu); +if (dev->id) { + info->device =g_strdup (dev->id); + info->has_device = true; + } + } +return info; +} + +void acpi_cpu_ospm_status (CPUHotplugState *cpu_st,ACPIOSTInfoList ***list) +{ +int i; + +for (i =0 ; i < cpu_st->dev_count; i++) { +ACPIOSTInfoList *elem =g_new0 (ACPIOSTInfoList,1 ); + elem->value =acpi_cpu_device_status (i, &cpu_st->devs[i]); + elem->next =NULL ; + **list = elem; + *list = &elem->next; + } +} +static uint64_t cpu_hotplug_rd (void *opaque,hwaddr addr,unsigned size) {uint64_t val = ~0 ;
@@ -57,6 +91,7 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, {CPUHotplugState *cpu_st = opaque;AcpiCpuStatus *cdev; +ACPIOSTInfo *info;Error *local_err =NULL ;assert (cpu_st->dev_count);
@@ -95,6 +130,7 @@ 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, &local_err);if (local_err) { +/* TODO: send error QAPI event */ break ; } }
@@ -105,6 +141,28 @@ static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data, cpu_st->command = data; }break ; +case ACPI_CPU_CMD_DATA_OFFSET_RW : +switch (cpu_st->command) { +case CPHP_OST_EVENT_CMD : { + cdev = &cpu_st->devs[cpu_st->selector]; + cdev->ost_event = data; +trace_cpuhp_acpi_write_ost_ev (cpu_st->selector, cdev->ost_event); +break ; + } +case CPHP_OST_STATUS_CMD : { + cdev = &cpu_st->devs[cpu_st->selector]; + cdev->ost_status = data; + info =acpi_cpu_device_status (cpu_st->selector, cdev); +qapi_event_send_acpi_device_ost (info, &error_abort); +qapi_free_ACPIOSTInfo (info); +trace_cpuhp_acpi_write_ost_status (cpu_st->selector, + cdev->ost_status); +break ; + } +default : +break ; + } +break ;default :break ; }
@@ -225,6 +283,8 @@ static const VMStateDescription vmstate_cpuhp_sts = {VMSTATE_BOOL (is_enabled, AcpiCpuStatus),VMSTATE_BOOL (is_inserting, AcpiCpuStatus),VMSTATE_BOOL (is_removing, AcpiCpuStatus), +VMSTATE_UINT32 (ost_event, AcpiCpuStatus), +VMSTATE_UINT32 (ost_status, AcpiCpuStatus), VMSTATE_END_OF_LIST() } };
@@ -251,6 +311,7 @@ const VMStateDescription vmstate_cpu_hotplug = {#define CPU_EJECT_METHOD "CEJ0"#define CPU_NOTIFY_METHOD "CTFY"#define CPU_PXM_METHOD "CPXM" +#define CPU_OST_METHOD "COST"#define CPU_ENABLED "CPEN"#define CPU_SELECTOR "CSEL"
@@ -454,6 +515,21 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, }aml_append (cpus_dev, method); } + method =aml_method (CPU_OST_METHOD ,4 ,AML_SERIALIZED ); + { +Aml *uid =aml_arg (0 ); +Aml *ev_cmd =aml_int (CPHP_OST_EVENT_CMD ); +Aml *st_cmd =aml_int (CPHP_OST_STATUS_CMD ); + +aml_append (method,aml_acquire (ctrl_lock,0xFFFF )); +aml_append (method,aml_store (uid, cpu_selector)); +aml_append (method,aml_store (ev_cmd, cpu_cmd)); +aml_append (method,aml_store (aml_arg (1 ), cpu_data)); +aml_append (method,aml_store (st_cmd, cpu_cmd)); +aml_append (method,aml_store (aml_arg (2 ), cpu_data)); +aml_append (method,aml_release (ctrl_lock)); + } +aml_append (cpus_dev, method); }/* build Processor object for each processor */
@@ -509,6 +585,13 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool acpi1_compat, aml_return(aml_call1(CPU_PXM_METHOD, uid)));aml_append (dev, method); } + + method =aml_method ("_OST" ,3 ,AML_SERIALIZED ); +aml_append (method, +aml_call4 (CPU_OST_METHOD , uid,aml_arg (0 ), +aml_arg (1 ),aml_arg (2 )) + ); +aml_append (dev, method); }aml_append (cpus_dev, dev); }
hw/acpi/ich9.c +3 -0
@@ -556,4 +556,7 @@ void ich9_pm_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)ICH9LPCState *s =ICH9_LPC_DEVICE (adev);acpi_memory_ospm_status (&s->pm.acpi_memory_hotplug, list); +if (!s->pm.cpu_hotplug_legacy && s->pm.cpuhp.state.is_enabled) { +acpi_cpu_ospm_status (&s->pm.cpuhp.state, list); + } }
hw/acpi/piix4.c +3 -0
@@ -623,6 +623,9 @@ static void piix4_ospm_status(AcpiDeviceIf *adev, ACPIOSTInfoList ***list)PIIX4PMState *s =PIIX4_PM (adev);acpi_memory_ospm_status (&s->acpi_memory_hotplug, list); +if (!s->cpu_hotplug_legacy && s->cpuhp.state.is_enabled) { +acpi_cpu_ospm_status (&s->cpuhp.state, list); + } }static void piix4_send_gpe (AcpiDeviceIf *adev,AcpiEventStatusBits ev)
include/hw/acpi/cpu.h +4 -0
@@ -23,6 +23,8 @@ typedef struct AcpiCpuStatus {bool is_enabled;bool is_inserting;bool is_removing; +uint32_t ost_event; +uint32_t ost_status; } AcpiCpuStatus; typedef struct CPUHotplugState {
@@ -51,6 +53,8 @@ void build_cpus_aml(Aml *table, MachineState *machine, bool apci1_compat, const char *res_root, const char *event_handler_method, hwaddr io_base); +void acpi_cpu_ospm_status (CPUHotplugState *cpu_st,ACPIOSTInfoList ***list); +extern const VMStateDescription vmstate_cpu_hotplug;#define VMSTATE_CPU_HOTPLUG (cpuhp, state) \ VMSTATE_STRUCT(cpuhp, state, 1, \
qapi-schema.json +1 -1
@@ -4019,7 +4019,7 @@ # # @DIMM: memory slot # -{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] } +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] } ## @ACPIOSTInfo #
trace-events +2 -0
@@ -1920,3 +1920,5 @@ cpuhp_acpi_write_idx(uint32_t idx) "set active cpu idx: 0x%"PRIx32 cpuhp_acpi_write_cmd(uint32_t idx, uint8_t cmd) "idx[0x%"PRIx32"] cmd: 0x%"PRIx8 cpuhp_acpi_ejecting_invalid_cpu(uint32_t idx) "0x%"PRIx32 cpuhp_acpi_ejecting_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
1.8.3.1
RFC 37/42 tests: acpi: report names of expected files in verbose mode
In reply to Igor Mammedovprint expected file name if it doesn't exists if verbose mode is enabled*. It helps to avoid running bios-tables-test under debugger to figure out missing file name.
*)
verbose mode is enabled if "V" env. variable is set
--- tests/bios-tables-test.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
tests/bios-tables-test.c +16 -8
@@ -464,7 +464,6 @@ static GArray *load_expected_aml(test_data *data) {int i;AcpiSdtTable *sdt; -gchar *aml_file =NULL ;GError *error =NULL ;gboolean ret;
@@ -472,7 +471,9 @@ static GArray *load_expected_aml(test_data *data)for (i =0 ; i < data->tables->len; ++i) {AcpiSdtTable exp_sdt;uint32_t signature; +gchar *aml_file =NULL ;const char *ext = data->variant ? data->variant :"" ; +int j; sdt = &g_array_index (data->tables, AcpiSdtTable, i);
@@ -481,16 +482,23 @@ static GArray *load_expected_aml(test_data *data) signature =cpu_to_le32 (sdt->header.signature); -try_again: - aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, - (gchar *)&signature, ext); -if (data->variant && !g_file_test (aml_file,G_FILE_TEST_EXISTS )) { +for (j =2 ; j; j -= data->variant ?1 :2 ) {g_free (aml_file); + aml_file =g_strdup_printf ("%s/%s/%.4s%s" , data_dir, data->machine, + (gchar *)&signature, ext); +if (g_file_test (aml_file,G_FILE_TEST_EXISTS )) { + exp_sdt.aml_file = aml_file; +break ; + } +if (getenv ("V" )) { +fprintf (stderr,"\nLooking for expected file '%s'\n" , aml_file); + } ext ="" ; - goto try_again; } - exp_sdt.aml_file = aml_file; -g_assert (g_file_test (aml_file,G_FILE_TEST_EXISTS )); +g_assert (exp_sdt.aml_file); +if (getenv ("V" )) { +fprintf (stderr,"\nUsing expected file '%s'\n" , aml_file); + } ret =g_file_get_contents (aml_file, &exp_sdt.aml, &exp_sdt.aml_len, &error);g_assert (ret);
Signature · 1 line
1.8.3.1
RFC 38/42 tests: acpi: add CPU hotplug testcase
In reply to Igor MammedovTest with "-smp 2,cores=3,sockets=2,maxcpus=6"
to capture sparse APIC ID values that default
AMD CPU has in above configuration.
--- tests/bios-tables-test.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
tests/bios-tables-test.c +28 -0
@@ -800,6 +800,32 @@ static void test_acpi_piix4_tcg_cpuhp_legacy(void)free_test_data (&data); } +static void test_acpi_piix4_tcg_cphp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_PC ; + data.variant =".cphp" ; +test_acpi_one ("-machine accel=tcg,cpu-hotplug=on" +" -smp 2,cores=3,sockets=2,maxcpus=6" , + &data); +free_test_data (&data); +} + +static void test_acpi_q35_tcg_cphp (void ) +{ +test_data data; + +memset (&data,0 ,sizeof (data)); + data.machine =MACHINE_Q35 ; + data.variant =".cphp" ; +test_acpi_one ("-machine q35,accel=tcg,cpu-hotplug=on" +" -smp 2,cores=3,sockets=2,maxcpus=6" , + &data); +free_test_data (&data); +} +int main (int argc,char *argv[]) {const char *arch =qtest_get_arch ();
@@ -816,6 +842,8 @@ int main(int argc, char *argv[])qtest_add_func ("acpi/piix4/tcg/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35/tcg" , test_acpi_q35_tcg);qtest_add_func ("acpi/q35/tcg/bridge" , test_acpi_q35_tcg_bridge); +qtest_add_func ("acpi/piix4/tcg/cpuhp" , test_acpi_piix4_tcg_cphp); +qtest_add_func ("acpi/q35/tcg/cpuhp" , test_acpi_q35_tcg_cphp);qtest_add_func ("acpi/piix4/tcg/cpuhp/legacy" , test_acpi_piix4_tcg_cpuhp_legacy); }
Signature · 1 line
1.8.3.1
RFC 39/42 tests: acpi: add expected tables for CPU hotplug case
In reply to Igor Mammedov--- tests/acpi-test-data/pc/APIC.cphp | Bin 0 -> 160 bytes tests/acpi-test-data/pc/DSDT.cphp | Bin 0 -> 6415 bytes tests/acpi-test-data/q35/APIC.cphp | Bin 0 -> 160 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 0 -> 9177 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/APIC.cphp create mode 100644 tests/acpi-test-data/pc/DSDT.cphp create mode 100644 tests/acpi-test-data/q35/APIC.cphp create mode 100644 tests/acpi-test-data/q35/DSDT.cphp
tests/acpi-test-data/pc/APIC.cphp new file binary +0 -0
tests/acpi-test-data/pc/DSDT.cphp new file binary +0 -0
tests/acpi-test-data/q35/APIC.cphp new file binary +0 -0
tests/acpi-test-data/q35/DSDT.cphp new file binary +0 -0
Signature · 1 line
1.8.3.1
RFC 40/42 tests: acpi: extend CPU hotplug test with NUMA support
In reply to Igor Mammedov--- tests/bios-tables-test.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +4 -2
@@ -808,7 +808,8 @@ static void test_acpi_piix4_tcg_cphp(void) data.machine =MACHINE_PC ; data.variant =".cphp" ;test_acpi_one ("-machine accel=tcg,cpu-hotplug=on" -" -smp 2,cores=3,sockets=2,maxcpus=6" , +" -smp 2,cores=3,sockets=2,maxcpus=6" +" -numa node,cpus=0-2 -numa node,cpus=3-5" , &data);free_test_data (&data); }
@@ -821,7 +822,8 @@ static void test_acpi_q35_tcg_cphp(void) data.machine =MACHINE_Q35 ; data.variant =".cphp" ;test_acpi_one ("-machine q35,accel=tcg,cpu-hotplug=on" -" -smp 2,cores=3,sockets=2,maxcpus=6" , +" -smp 2,cores=3,sockets=2,maxcpus=6" +" -numa node,cpus=0-2 -numa node,cpus=3-5" , &data);free_test_data (&data); }
Signature · 1 line
1.8.3.1
RFC 41/42 tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM support
In reply to Igor Mammedov--- tests/acpi-test-data/pc/DSDT.cphp | Bin 6415 -> 6614 bytes tests/acpi-test-data/pc/SRAT.cphp | Bin 0 -> 304 bytes tests/acpi-test-data/q35/DSDT.cphp | Bin 9177 -> 9376 bytes tests/acpi-test-data/q35/SRAT.cphp | Bin 0 -> 304 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/SRAT.cphp create mode 100644 tests/acpi-test-data/q35/SRAT.cphp
tests/acpi-test-data/pc/DSDT.cphp binary +0 -0
tests/acpi-test-data/pc/SRAT.cphp new file binary +0 -0
tests/acpi-test-data/q35/DSDT.cphp binary +0 -0
tests/acpi-test-data/q35/SRAT.cphp new file binary +0 -0
Signature · 1 line
1.8.3.1
RFC 42/42 DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU
In reply to Igor Mammedov--- hw/i386/pc.c | 8 ++++++++ include/qom/cpu.h | 2 +- qom/cpu.c | 6 +++--- 3 files changed, 12 insertions(+), 4 deletions(-)
hw/i386/pc.c +8 -0
@@ -1063,6 +1063,9 @@ out:return cpu; } +static void pc_machine_device_unplug_request_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp); +void pc_hot_add_cpu (const int64_t id,Error **errp) {X86CPU *cpu;
@@ -1076,6 +1079,11 @@ void pc_hot_add_cpu(const int64_t id, Error **errp) }if (cpu_exists (apic_id)) { +DeviceState *dev =DEVICE (cpu_exists (apic_id)); +pc_machine_device_unplug_request_cb ( +qdev_get_hotplug_handler (dev), + dev, + &local_err);error_setg (errp,"Unable to add CPU: %" PRIi64", it already exists" , id);return ;
include/qom/cpu.h +1 -1
@@ -629,7 +629,7 @@ CPUState *qemu_get_cpu(int index);* * Returns: %true - CPU is found, %false - CPU isn't found. */ -bool cpu_exists (int64_t id); +CPUState *cpu_exists (int64_t id);/** * cpu_throttle_set:
qom/cpu.c +3 -3
@@ -29,7 +29,7 @@#include "qemu/error-report.h" #include "sysemu/sysemu.h" -bool cpu_exists (int64_t id) +CPUState *cpu_exists (int64_t id) {CPUState *cpu;
@@ -37,10 +37,10 @@ bool cpu_exists(int64_t id)CPUClass *cc =CPU_GET_CLASS (cpu);if (cc->get_arch_id (cpu) == id) { -return true; +return cpu; } } -return false; +return NULL ; }CPUState *cpu_generic_init (const char *typename,const char *cpu_model)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property
In reply to Igor MammedovQuoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
As the property is useless if no code is reading s->pm.cpu_hotplug_legacy. What about squashing patches 10/42 and 12/42 together?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 11/42] pc: add 2.7 machine
In reply to Igor MammedovQuoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Igor MammedovQuoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>
What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer? Should max_cpus > smp_cpus automatically set cpu-hotplug=on?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
In reply to Igor MammedovQuoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
If a machine class simply doesn't support CPU hotplug at all, is silently ignoring "cpu-hotplug=on" the right thing to do?
Shouldn't we exit with an error if the machine class doesn't support CPU hotplug and the user tries to enable it?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily
In reply to Igor MammedovQuoted 10 lines · Igor Mammedov
Machine types before 2.7 have legacy CPU hotplug enabled by defaut to not regress existing setups where it's always enabled.
But since 2.7 CPU hotplug is disabled y default and requires explicit enabling using 'cpu-hotplug' parameter in '-machine' option.
So turn it on for cpu-hotplug testcase to allow it test 2.7 and later machine types.
Quoted 5 lines
Fixes following failure:
/x86_64/cpu/pc-q35-2.7/add/1x3x2&maxcpus=12: ** ERROR:tests/pc-cpu-test.c:44:test_pc_with_cpu_add:
assertion failed: (!qdict_haskey(response, "error"))
Is this test error introduced by a patch in this series? If so, shouldn't this fix be squashed with the patch that disables CPU hotplug by default, so we get a bisectable tree?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling
In reply to Igor MammedovQuoted 12 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/cpu.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 3 ++ hw/acpi/piix4.c | 3 ++ include/hw/acpi/cpu.h | 4 +++ qapi-schema.json | 2 +- trace-events | 2 ++ 6 files changed, 96 insertions(+), 1 deletion(-)+++
b/qapi-schema.json
qapi-schema.json line 4022
Quoted 5 lines
qapi-schema.json +1
-1@@ -4019,7 +4019,7 @@ # # @DIMM: memory slot # -{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] } +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] }
Missing documentation of the new value.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property
In reply to Eduardo HabkostQuoted 6 lines · On Tue, 10 May 2016 17:19:35 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>As the property is useless if no code is reading
s->pm.cpu_hotplug_legacy. What about squashing patches 10/42 and 12/42 together?
I've thought splitting trivial boiler plate code for adding property would make it smaller/easier to review.
But I'm ok with squashing it into 12/42 if it makes review easier.
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Eduardo HabkostQuoted 10 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Quoted 6 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?
Yep, I'll add it on next respin.
Would hard error better than warning?
Quoted 2 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?
I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push 'device_add x86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:
SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2
vs would be device_add:
SRC-QEMU -smp 1,maxcpus=2
device_add cpu
DST-QEMU -smp 1,maxcpus=2 -device cpu
so instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.
Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
In reply to Eduardo HabkostQuoted 8 lines · On Tue, 10 May 2016 17:27:18 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>If a machine class simply doesn't support CPU hotplug at all, is silently ignoring "cpu-hotplug=on" the right thing to do?
Shouldn't we exit with an error if the machine class doesn't support CPU hotplug and the user tries to enable it?
We have a bunch of such options in generic MachineClass and it was upto concrete machine to implement such checks.
So I hadn't even considered to make such check in generic code nor think that's a right thing to do, if that's what you are asking.
But maybe I've misunderstood question.
Re: [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling
In reply to Eric BlakeQuoted 11 lines · On Tue, 10 May 2016 15:07:40 -0600 Eric Blake <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>--- hw/acpi/cpu.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ hw/acpi/ich9.c | 3 ++ hw/acpi/piix4.c | 3 ++ include/hw/acpi/cpu.h | 4 +++ qapi-schema.json | 2 +- trace-events | 2 ++ 6 files changed, 96 insertions(+), 1 deletion(-)
Quoted 9 lines
qapi-schema.json line 4022
Quoted 7 lines
+++
b/qapi-schema.jsonqapi-schema.json +1
-1@@ -4019,7 +4019,7 @@ # # @DIMM: memory slot # -{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] } +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] }Missing documentation of the new value.
Thanks, I'll fix it on respin.
Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
In reply to Igor MammedovQuoted 6 lines · Igor Mammedov
Quoted 3 lines · On Tue, 10 May 2016 17:27:18 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 1 line · Igor Mammedov
Signed-off-by Igor Mammedov <[email protected]>
Quoted 7 lines
Quoted 5 lines
If a machine class simply doesn't support CPU hotplug at all, is silently ignoring "cpu-hotplug=on" the right thing to do?
Shouldn't we exit with an error if the machine class doesn't support CPU hotplug and the user tries to enable it?
We have a bunch of such options in generic MachineClass and it was upto concrete machine to implement such checks.
Yes, and my proposal is to make this more robust from now on, and make machines stop silently ignoring unsupported options.
Quoted 3 lines
So I hadn't even considered to make such check in generic code nor think that's a right thing to do, if that's what you are asking.
If only 1 or 2 machines support CPU hotplug, I don't think it would be reasonable to have the option available at every machine class and require most classes to add an extra check like:
if (machine->cpu_hotplug)
error_setg(errp, "CPU hotplug not supported");A check like the following, in common code:
if (!machine_class->cpu_hotplug_supported && machine->cpu_hotplug)
error_setg(errp, "CPU hotplug not supported")
would avoid duplicating code in every machine class, and only require the following extra line in the machine classes that really support CPU hotplug:
machine_class->cpu_hotplug_supported = true;
Or, even better: we can avoid registering the cpu-hotplug property at all if the subclass doesn't support CPU hotplug. You can do that at machine_class_base_init, e.g.:
static void machine_class_base_init(ObjectClass *oc, void *data)
{
/* [...] */
MachineClass *mc = MACHINE_CLASS(oc);
if (mc->cpu_hotplug_supported) {
object_class_property_add_str(oc, "cpu-hotplug",
machine_get_cpu_hotplug,
machine_set_cpu_hotplug, NULL);
object_class_property_set_description(oc, "cpu-hotplug",
"Set on to enable CPU hotplug",
NULL);
}
}Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Igor MammedovQuoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?Yep, I'll add it on next respin.
Would hard error better than warning?
Most people don't need cpu hotplug, attempts
to hotplug fail, should be enough.
Quoted 25 lines
Quoted 2 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push '
device_addx86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2vs would be
device_add:SRC-QEMU -smp 1,maxcpus=2
device_addcpu
DST-QEMU -smp 1,maxcpus=2 -device cpuso instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?
Quoted 5 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Most people don't need cpu hotplug, attempts
to hotplug fail, should be enough.
People who don't need CPU hotplug shouldn't be using the max_cpus option. I believe we should at least warn people (early, during initialization) that their configuration don't make sense anymore.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Igor MammedovQuoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 9 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?Yep, I'll add it on next respin.
Would hard error better than warning?
Not sure. It would break older libvirt versions, wouldn't it?
But: isn't the new legacy-cpu-hotplug=false default going to break old libvirt versions anyway? Should we?
(CCing libvirt list)
Quoted 18 lines
Quoted 3 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push '
device_addx86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2vs would be
device_add:
Quoted 8 lines
SRC-QEMU -smp 1,maxcpus=2
device_addcpu
DST-QEMU -smp 1,maxcpus=2 -device cpuso instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.
Agreed we shouldn't encourage people to use the old option to get the new behavior.
But I am worried about breaking existing configurations on a machine-type change. Is it possible to avoid that?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 20 lines · Eduardo Habkost
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?
Quoted 8 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Not sure. It would break older libvirt versions, wouldn't it?
But: isn't the new legacy-cpu-hotplug=false default going to break old libvirt versions anyway? Should we?(CCing libvirt list)
Even if not, we should not break scripts people use. Maybe it was a mistake to enable hotplug by default but we can't just remove it now after all this time. Why not have new hotplug on by default as well? If you see value in ability to remove this feature, add an option for that.
Quoted 35 lines
Quoted 18 lines
Quoted 3 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push '
device_addx86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2vs would be
device_add:Quoted 8 lines
SRC-QEMU -smp 1,maxcpus=2
device_addcpu
DST-QEMU -smp 1,maxcpus=2 -device cpuso instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.
Agreed we shouldn't encourage people to use the old option to get the new behavior.
But I am worried about breaking existing configurations on a machine-type change. Is it possible to avoid that?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Eduardo HabkostQuoted 21 lines · Eduardo Habkost
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Most people don't need cpu hotplug, attempts
to hotplug fail, should be enough.People who don't need CPU hotplug shouldn't be using the
max_cpusoption.
I agree.
Quoted 3 lines
I believe we should at least warn people (early, during initialization) that their configuration don't make sense anymore.
I think we should try to keep old command line working if we can.
Quoted 2 lines
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 31 lines · On Thu, 12 May 2016 10:07:03 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 21 lines · Eduardo Habkost
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Most people don't need cpu hotplug, attempts
to hotplug fail, should be enough.People who don't need CPU hotplug shouldn't be using the
max_cpusoption.
Quoted 8 lines
I agree.
Quoted 3 lines
I believe we should at least warn people (early, during initialization) that their configuration don't make sense anymore.
I think we should try to keep old command line working if we can.
this patch won't break old command line for old machine types, but for new machine type users would need to fix it and be explicit if they want cpu-hotplug.
Quoted 3 lines
Quoted 3 lines
Signature · 2 lines
-- Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Michael S. TsirkinQuoted 21 lines · On Thu, 12 May 2016 10:05:54 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 20 lines · Eduardo Habkost
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Not sure. It would break older libvirt versions, wouldn't it?
But: isn't the new legacy-cpu-hotplug=false default going to break old libvirt versions anyway? Should we?
if older libvirt are running older machine version, it won't break it. but it would break old libvirt for new machine types.
Quoted 7 lines
Quoted 2 lines
(CCing libvirt list)
Even if not, we should not break scripts people use. Maybe it was a mistake to enable hotplug by default but we can't just remove it now after all this time. Why not have new hotplug on by default as well? If you see value in ability to remove this feature, add an option for that.
It would save us some space in ACPI tables and IO ports as by default it's not used feature.
But if it's preferred to keep cpu-hotplug always on, I'm ok with it too, it's even better as I would be able to drop 3-4 patches from this series.
Quoted 35 lines
Quoted 35 lines
Quoted 18 lines
Quoted 3 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push '
device_addx86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2vs would be
device_add:Quoted 8 lines
SRC-QEMU -smp 1,maxcpus=2
device_addcpu
DST-QEMU -smp 1,maxcpus=2 -device cpuso instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.
Agreed we shouldn't encourage people to use the old option to get the new behavior.
But I am worried about breaking existing configurations on a machine-type change. Is it possible to avoid that?
Signature · 1 line
Eduardo
Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
In reply to Igor MammedovQuoted 40 lines · Igor Mammedov
Quoted 37 lines · On Thu, 12 May 2016 10:07:03 +0300 "Michael S. Tsirkin" <[email protected]> wrote:
Quoted 21 lines · Eduardo Habkost
Quoted 20 lines · Michael S. Tsirkin
Quoted 19 lines · Igor Mammedov
Quoted 16 lines · On Tue, 10 May 2016 17:24:14 -0300 Eduardo Habkost <[email protected]> wrote:
Quoted 10 lines · Igor Mammedov
on old machine types CPU hotplug was uncondtionally enabled since it was introduced, consuming IO ports and providing AML regardles of whether it was actually in use or not. Keep it so for 2.6 and older machines.
New machine types will have an option to turn CPU hotplug on if it's needed while by default it stays disabled not consuming extra RAM/IO resources.
Signed-off-by Igor Mammedov <[email protected]>What if people are using "-machine pc -smp N,max_cpus=M"? Shouldn't we at least warning about missing CPU hotplug support when using just "
max_cpus" with no "cpu-hotplug=on" with pc-2.7 and newer?Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Yep, I'll add it on next respin.
Would hard error better than warning?Most people don't need cpu hotplug, attempts
to hotplug fail, should be enough.People who don't need CPU hotplug shouldn't be using the
max_cpusoption.I agree.
Quoted 3 lines
I believe we should at least warn people (early, during initialization) that their configuration don't make sense anymore.
Quoted 5 lines
Quoted 2 lines
I think we should try to keep old command line working if we can.
this patch won't break old command line for old machine types, but for new machine type users would need to fix it and be explicit if they want cpu-hotplug.
I don't think we should do that, unless users already had time to update their scripts and libvirt had time to implement code supporting the new method.
I believe libvirt (and people's scripts) use maxcpus only when they want CPU hotplug, so making max_cpus > smp_cpus enable CPU hotplug implicitly would probably solve the compatibility issue.
If we want to deprecate the use of maxcpus to enable CPU hotplug, then we can make it print a warning for a few releases, so people have time to update their code.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 7 lines · Eduardo Habkost
I don't think we should do that, unless users already had time to update their scripts and libvirt had time to implement code supporting the new method.
I believe libvirt (and people's scripts) use maxcpus only when they want CPU hotplug, so making
max_cpus>smp_cpusenable CPU hotplug implicitly would probably solve the compatibility issue.
Libvirt uses maxcpus only if the configuration explicitly has less active cpus than the maximum number. This option would be the best IMO.
Quoted 3 lines
If we want to deprecate the use of maxcpus to enable CPU hotplug, then we can make it print a warning for a few releases, so people have time to update their code.
At that point libvirt also needs a way to detect that the new argument is supported by qemu, so we can start passing it on the command line basically every time we now pass 'maxcpus'.
The warning will get most probably ignored by people using libvirt as the stdout/err of qemu is not visible to them.
Peter
Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 16 lines · On Thu, 12 May 2016 13:04:23 +0200 Peter Krempa <[email protected]> wrote:
Quoted 7 lines · Eduardo Habkost
I don't think we should do that, unless users already had time to update their scripts and libvirt had time to implement code supporting the new method.
I believe libvirt (and people's scripts) use maxcpus only when they want CPU hotplug, so making
max_cpus>smp_cpusenable CPU hotplug implicitly would probably solve the compatibility issue.Libvirt uses maxcpus only if the configuration explicitly has less active cpus than the maximum number. This option would be the best IMO.
Quoted 3 lines
If we want to deprecate the use of maxcpus to enable CPU hotplug, then we can make it print a warning for a few releases, so people have time to update their code.
Quoted 6 lines
At that point libvirt also needs a way to detect that the new argument is supported by qemu, so we can start passing it on the command line basically every time we now pass 'maxcpus'.
The warning will get most probably ignored by people using libvirt as the stdout/err of qemu is not visible to them.
Ok, to make things less complicated I'll drop machine.cpu-hotplug and leave it always enabled as it used to be and as Michael suggested.
I'll drop following patches: 12, 13, 14, 20, 23 and respin series
Quoted 2 lines
Peter
Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 23 lines · Igor Mammedov
Quoted 20 lines · On Thu, 12 May 2016 13:04:23 +0200 Peter Krempa <[email protected]> wrote:
Quoted 7 lines · Eduardo Habkost
I don't think we should do that, unless users already had time to update their scripts and libvirt had time to implement code supporting the new method.
I believe libvirt (and people's scripts) use maxcpus only when they want CPU hotplug, so making
max_cpus>smp_cpusenable CPU hotplug implicitly would probably solve the compatibility issue.Libvirt uses maxcpus only if the configuration explicitly has less active cpus than the maximum number. This option would be the best IMO.
Quoted 3 lines
If we want to deprecate the use of maxcpus to enable CPU hotplug, then we can make it print a warning for a few releases, so people have time to update their code.
At that point libvirt also needs a way to detect that the new argument is supported by qemu, so we can start passing it on the command line basically every time we now pass 'maxcpus'.
Quoted 6 lines
Quoted 2 lines
The warning will get most probably ignored by people using libvirt as the stdout/err of qemu is not visible to them.
Ok, to make things less complicated I'll drop machine.cpu-hotplug and leave it always enabled as it used to be and as Michael suggested.
I'll drop following patches: 12, 13, 14, 20, 23 and respin series
I actually don't mind disabling it. But I'd be glad if it was based on the max_cpus value as Eduardo suggested.
Peter
Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
Quoted 26 lines · On Thu, 12 May 2016 15:27:04 +0200 Peter Krempa <[email protected]> wrote:
Quoted 25 lines · Igor Mammedov
Quoted 22 lines · On Thu, 12 May 2016 13:04:23 +0200 Peter Krempa <[email protected]> wrote:
Quoted 7 lines · Eduardo Habkost
I don't think we should do that, unless users already had time to update their scripts and libvirt had time to implement code supporting the new method.
I believe libvirt (and people's scripts) use maxcpus only when they want CPU hotplug, so making
max_cpus>smp_cpusenable CPU hotplug implicitly would probably solve the compatibility issue.Libvirt uses maxcpus only if the configuration explicitly has less active cpus than the maximum number. This option would be the best IMO.
Quoted 3 lines
If we want to deprecate the use of maxcpus to enable CPU hotplug, then we can make it print a warning for a few releases, so people have time to update their code.
At that point libvirt also needs a way to detect that the new argument is supported by qemu, so we can start passing it on the command line basically every time we now pass 'maxcpus'.
The warning will get most probably ignored by people using libvirt as the stdout/err of qemu is not visible to them.
Quoted 7 lines
Quoted 4 lines
Ok, to make things less complicated I'll drop machine.cpu-hotplug and leave it always enabled as it used to be and as Michael suggested.
I'll drop following patches: 12, 13, 14, 20, 23 and respin series
I actually don't mind disabling it. But I'd be glad if it was based on the
max_cpusvalue as Eduardo suggested.
I've already dropped it, and simplifies series quite a bit.
So lets continue without disabling for now.
Later we can consider disabling it if we agree on conditions when it should happen.
smp_cpus < max_cpus is not a good enough I think:
Quoted 31 lines
Quoted 2 lines · On Wed, 11 May 2016 15:50:39 +0200 Igor Mammedov <[email protected]> wrote:
On Tue, 10 May 2016 17:24:14 -0300
Eduardo Habkost <[email protected]> wrote:[...]
Quoted 25 lines
Quoted 2 lines
Should
max_cpus>smp_cpusautomatically set
cpu-hotplug=on?I'd prefer dumb explicit feature enablement, as it doesn't put any assumptions on other options and QEMU + mgmt don't have to maintain logic for implicit rules that might enable it.
and if I didn't manage to push '
device_addx86cpu' in 2.7 time frame, guess work gets a bit confusing with current cpu-add semantic, consider current:SRC-QEMU -smp 1,maxcpus=2
cpu-add 1
DST-QEMU -smp 2,maxcpus=2vs would be
device_add:SRC-QEMU -smp 1,maxcpus=2
device_addcpu
DST-QEMU -smp 1,maxcpus=2 -device cpuso instead of qemu/users guessing, I suggest to make it explictly enabled to get feature (which is mostly optional) or cleanly fail qemu start if confusing options are specified with a clear error message.