All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods
@ 2016-05-02 12:33 Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 01/42] acpi: add aml_debug() Igor Mammedov
                   ` (41 more replies)
  0 siblings, 42 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

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:
    git@github.com: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

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 01/42] acpi: add aml_debug()
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 02/42] acpi: add aml_refof() Igor Mammedov
                   ` (40 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 9 +++++++++
 include/hw/acpi/aml-build.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index ab89ca6..0ecd386 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -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
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 2c994b3..c2cb3bc 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 02/42] acpi: add aml_refof()
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 01/42] acpi: add aml_debug() Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 03/42] pc: acpi: remove AML for empty/not used GPE handlers Igor Mammedov
                   ` (39 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/aml-build.c         | 8 ++++++++
 include/hw/acpi/aml-build.h | 1 +
 2 files changed, 9 insertions(+)

diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 0ecd386..6484161 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -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)
 {
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index c2cb3bc..52d6aef 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 03/42] pc: acpi: remove AML for empty/not used GPE handlers
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 01/42] acpi: add aml_debug() Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 02/42] acpi: add aml_refof() Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 04/42] pc: acpi: consolidate CPU hotplug AML Igor Mammedov
                   ` (38 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

ACPI spec requires GPE handlers only for GPE events
that hardware implements.
So remove AML for not supported by QEMU device model
events.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/acpi-build.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 6477003..c7355f1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 04/42] pc: acpi: consolidate CPU hotplug AML
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (2 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 03/42] pc: acpi: remove AML for empty/not used GPE handlers Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 05/42] pc: acpi: consolidate \GPE._E02 with the rest of " Igor Mammedov
                   ` (37 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

move the former SSDT part of CPU hoplug close to DSDT part.
AML is only moved but there isn't any functional change.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c
index 97bb109..730f44c 100644
--- a/hw/acpi/cpu_hotplug_acpi_table.c
+++ b/hw/acpi/cpu_hotplug_acpi_table.c
@@ -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);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index c7355f1..0405848 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -943,114 +943,6 @@ static Aml *build_crs(PCIHostState *host,
     return crs;
 }
 
-static void build_processor_devices(Aml *sb_scope, MachineState *machine,
-                                    AcpiPmInfo *pm)
-{
-    int i, apic_idx;
-    Aml *dev;
-    Aml *crs;
-    Aml *pkg;
-    Aml *field;
-    Aml *ifctx;
-    Aml *method;
-    MachineClass *mc = MACHINE_GET_CLASS(machine);
-    CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(machine);
-    PCMachineState *pcms = PC_MACHINE(machine);
-
-    /* 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, pm->cpu_hp_io_base, pm->cpu_hp_io_base, 1,
-               pm->cpu_hp_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(pm->cpu_hp_io_base), pm->cpu_hp_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;
-
-        ifctx = aml_if(aml_equal(aml_arg(0), aml_int(apic_id)));
-        aml_append(ifctx,
-            aml_notify(aml_name("CP%.02X", apic_id), aml_arg(1))
-        );
-        aml_append(method, ifctx);
-    }
-    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);
-}
-
 static void build_memory_devices(Aml *sb_scope, int nr_mem,
                                  uint16_t io_base, uint16_t io_len)
 {
@@ -2043,7 +1935,7 @@ build_dsdt(GArray *table_data, GArray *linker,
         build_q35_pci0_int(dsdt);
     }
 
-    build_cpu_hotplug_aml(dsdt);
+    build_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);
 
@@ -2305,8 +2197,6 @@ build_dsdt(GArray *table_data, GArray *linker,
 
     sb_scope = aml_scope("\\_SB");
     {
-        build_processor_devices(sb_scope, machine, pm);
-
         build_memory_devices(sb_scope, nr_mem, pm->mem_hp_io_base,
                              pm->mem_hp_io_len);
 
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index f22640e..9b1d0cf 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 05/42] pc: acpi: consolidate \GPE._E02 with the rest of CPU hotplug AML
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (3 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 04/42] pc: acpi: consolidate CPU hotplug AML Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 06/42] pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c Igor Mammedov
                   ` (36 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu_hotplug_acpi_table.c | 4 ++++
 hw/i386/acpi-build.c             | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c
index 730f44c..c31f346 100644
--- a/hw/acpi/cpu_hotplug_acpi_table.c
+++ b/hw/acpi/cpu_hotplug_acpi_table.c
@@ -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);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 0405848..0aa474e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 06/42] pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (4 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 05/42] pc: acpi: consolidate \GPE._E02 with the rest of " Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 07/42] pc: acpi: mark current CPU hotplug functions as legacy Igor Mammedov
                   ` (35 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

now as those defines are used only locally inside of
cpu_hotplug_acpi_table.c, move them out of header file.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu_hotplug_acpi_table.c | 7 +++++++
 include/hw/acpi/cpu_hotplug.h    | 7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c
index c31f346..9fdde6d 100644
--- a/hw/acpi/cpu_hotplug_acpi_table.c
+++ b/hw/acpi/cpu_hotplug_acpi_table.c
@@ -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)
 {
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index 9b1d0cf..565f96c 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 07/42] pc: acpi: mark current CPU hotplug functions as legacy
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (5 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 06/42] pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 08/42] pc: acpi: consolidate legacy CPU hotplug in one file Igor Mammedov
                   ` (34 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 4d86743..ba9d903 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -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;
 
diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c
index 9fdde6d..fc79c54 100644
--- a/hw/acpi/cpu_hotplug_acpi_table.c
+++ b/hw/acpi/cpu_hotplug_acpi_table.c
@@ -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;
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 27e978f..af340d0 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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)));
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 16abdf1..3e8d80b 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 0aa474e..30ee1b1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
 
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index 565f96c..241b50f 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 08/42] pc: acpi: consolidate legacy CPU hotplug in one file
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (6 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 07/42] pc: acpi: mark current CPU hotplug functions as legacy Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 09/42] pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature Igor Mammedov
                   ` (33 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Since 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

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index faee86c..66bd727 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -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
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index ba9d903..2d4e034 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -14,6 +14,14 @@
 #include "hw/acpi/cpu_hotplug.h"
 #include "qapi/error.h"
 #include "qom/cpu.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"
 
 static uint64_t cpu_status_read(void *opaque, hwaddr addr, unsigned int size)
 {
@@ -77,3 +85,227 @@ void legacy_acpi_cpu_hotplug_init(MemoryRegion *parent, Object *owner,
                           gpe_cpu, "acpi-cpu-hotplug", ACPI_GPE_PROC_LEN);
     memory_region_add_subregion(parent, base, &gpe_cpu->io);
 }
+
+void build_legacy_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);
+    Aml *cpu_on = aml_local(0);
+    Aml *madt = aml_local(1);
+    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
+     * cpu_id = Arg0 = Processor ID = Local APIC 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);
+    aml_append(method,
+        aml_store(aml_derefof(aml_index(cpus_map, cpu_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(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
+     * 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));
+    if_ctx = aml_if(cpu_on);
+    {
+        aml_append(if_ctx, aml_return(aml_int(0xF)));
+    }
+    aml_append(method, if_ctx);
+    else_ctx = aml_else();
+    {
+        aml_append(else_ctx, aml_return(zero));
+    }
+    aml_append(method, else_ctx);
+    aml_append(sb_scope, method);
+
+    method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);
+    aml_append(method, aml_sleep(200));
+    aml_append(sb_scope, method);
+
+    method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);
+    {
+        Aml *while_ctx, *if_ctx2, *else_ctx2;
+        Aml *bus_check_evt = aml_int(1);
+        Aml *remove_evt = aml_int(3);
+        Aml *status_map = aml_local(5); /* Local5 = active cpu bitmap */
+        Aml *byte = aml_local(2); /* Local2 = last read byte from bitmap */
+        Aml *idx = aml_local(0); /* Processor ID / APIC ID iterator */
+        Aml *is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */
+        Aml *status = aml_local(3); /* Local3 = active state for cpu */
+
+        aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));
+        aml_append(method, aml_store(zero, byte));
+        aml_append(method, aml_store(zero, idx));
+
+        /* While (idx < SizeOf(CPON)) */
+        while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));
+        aml_append(while_ctx,
+            aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));
+
+        if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));
+        {
+            /* Shift down previously read bitmap byte */
+            aml_append(if_ctx, aml_shiftright(byte, one, byte));
+        }
+        aml_append(while_ctx, if_ctx);
+
+        else_ctx = aml_else();
+        {
+            /* Read next byte from cpu bitmap */
+            aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,
+                       aml_shiftright(idx, aml_int(3), NULL))), byte));
+        }
+        aml_append(while_ctx, else_ctx);
+
+        aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));
+        if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));
+        {
+            /* State change - update CPON with new state */
+            aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));
+            if_ctx2 = aml_if(aml_equal(status, one));
+            {
+                aml_append(if_ctx2,
+                    aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));
+            }
+            aml_append(if_ctx, if_ctx2);
+            else_ctx2 = aml_else();
+            {
+                aml_append(else_ctx2,
+                    aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));
+            }
+        }
+        aml_append(if_ctx, else_ctx2);
+        aml_append(while_ctx, if_ctx);
+
+        aml_append(while_ctx, aml_increment(idx)); /* go to next cpu */
+        aml_append(method, while_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);
+
+    method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);
+    aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
+    aml_append(ctx, method);
+}
diff --git a/hw/acpi/cpu_hotplug_acpi_table.c b/hw/acpi/cpu_hotplug_acpi_table.c
deleted file mode 100644
index fc79c54..0000000
--- a/hw/acpi/cpu_hotplug_acpi_table.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "qemu/osdep.h"
-#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_legacy_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);
-    Aml *cpu_on = aml_local(0);
-    Aml *madt = aml_local(1);
-    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
-     * cpu_id = Arg0 = Processor ID = Local APIC 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);
-    aml_append(method,
-        aml_store(aml_derefof(aml_index(cpus_map, cpu_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(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
-     * 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));
-    if_ctx = aml_if(cpu_on);
-    {
-        aml_append(if_ctx, aml_return(aml_int(0xF)));
-    }
-    aml_append(method, if_ctx);
-    else_ctx = aml_else();
-    {
-        aml_append(else_ctx, aml_return(zero));
-    }
-    aml_append(method, else_ctx);
-    aml_append(sb_scope, method);
-
-    method = aml_method(CPU_EJECT_METHOD, 2, AML_NOTSERIALIZED);
-    aml_append(method, aml_sleep(200));
-    aml_append(sb_scope, method);
-
-    method = aml_method(CPU_SCAN_METHOD, 0, AML_NOTSERIALIZED);
-    {
-        Aml *while_ctx, *if_ctx2, *else_ctx2;
-        Aml *bus_check_evt = aml_int(1);
-        Aml *remove_evt = aml_int(3);
-        Aml *status_map = aml_local(5); /* Local5 = active cpu bitmap */
-        Aml *byte = aml_local(2); /* Local2 = last read byte from bitmap */
-        Aml *idx = aml_local(0); /* Processor ID / APIC ID iterator */
-        Aml *is_cpu_on = aml_local(1); /* Local1 = CPON flag for cpu */
-        Aml *status = aml_local(3); /* Local3 = active state for cpu */
-
-        aml_append(method, aml_store(aml_name(CPU_STATUS_MAP), status_map));
-        aml_append(method, aml_store(zero, byte));
-        aml_append(method, aml_store(zero, idx));
-
-        /* While (idx < SizeOf(CPON)) */
-        while_ctx = aml_while(aml_lless(idx, aml_sizeof(cpus_map)));
-        aml_append(while_ctx,
-            aml_store(aml_derefof(aml_index(cpus_map, idx)), is_cpu_on));
-
-        if_ctx = aml_if(aml_and(idx, aml_int(0x07), NULL));
-        {
-            /* Shift down previously read bitmap byte */
-            aml_append(if_ctx, aml_shiftright(byte, one, byte));
-        }
-        aml_append(while_ctx, if_ctx);
-
-        else_ctx = aml_else();
-        {
-            /* Read next byte from cpu bitmap */
-            aml_append(else_ctx, aml_store(aml_derefof(aml_index(status_map,
-                       aml_shiftright(idx, aml_int(3), NULL))), byte));
-        }
-        aml_append(while_ctx, else_ctx);
-
-        aml_append(while_ctx, aml_store(aml_and(byte, one, NULL), status));
-        if_ctx = aml_if(aml_lnot(aml_equal(is_cpu_on, status)));
-        {
-            /* State change - update CPON with new state */
-            aml_append(if_ctx, aml_store(status, aml_index(cpus_map, idx)));
-            if_ctx2 = aml_if(aml_equal(status, one));
-            {
-                aml_append(if_ctx2,
-                    aml_call2(AML_NOTIFY_METHOD, idx, bus_check_evt));
-            }
-            aml_append(if_ctx, if_ctx2);
-            else_ctx2 = aml_else();
-            {
-                aml_append(else_ctx2,
-                    aml_call2(AML_NOTIFY_METHOD, idx, remove_evt));
-            }
-        }
-        aml_append(if_ctx, else_ctx2);
-        aml_append(while_ctx, if_ctx);
-
-        aml_append(while_ctx, aml_increment(idx)); /* go to next cpu */
-        aml_append(method, while_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);
-
-    method = aml_method("\\_GPE._E02", 0, AML_NOTSERIALIZED);
-    aml_append(method, aml_call0("\\_SB." CPU_SCAN_METHOD));
-    aml_append(ctx, method);
-}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 09/42] pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (7 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 08/42] pc: acpi: consolidate legacy CPU hotplug in one file Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Igor Mammedov
                   ` (32 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

since 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 2d4e034..36ea6c2 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -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);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 30ee1b1..4a7eab3 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
 
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index 241b50f..6d729d8 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (8 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 09/42] pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 20:19   ` Eduardo Habkost
  2016-05-02 12:33 ` [Qemu-devel] [RFC 11/42] pc: add 2.7 machine Igor Mammedov
                   ` (31 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/ich9.c         | 19 +++++++++++++++++++
 hw/acpi/piix4.c        |  3 +++
 include/hw/acpi/ich9.h |  1 +
 3 files changed, 23 insertions(+)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index af340d0..1cfe832 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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,
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 3e8d80b..7b5c312 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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(),
 };
 
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 63fa198..942b966 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 11/42] pc: add 2.7 machine
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (9 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 20:20   ` Eduardo Habkost
  2016-05-02 12:33 ` [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types Igor Mammedov
                   ` (30 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 7f50116..cdbdd69 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -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);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 04aae89..4787df1 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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);
diff --git a/include/hw/compat.h b/include/hw/compat.h
index a5dbbf8..636befe 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -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",\
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 96f0b66..f1e40ae 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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 \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (10 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 11/42] pc: add 2.7 machine Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 20:24   ` Eduardo Habkost
  2016-05-02 12:33 ` [Qemu-devel] [RFC 13/42] tests: bios-tables-test: update tables with CPHP turned off by default Igor Mammedov
                   ` (29 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

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 <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 1cfe832..b5481d4 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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 {
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 7b5c312..86d68dd 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4a7eab3..502f1a7 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
 
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 636befe..f8c662d 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -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 \
     {\
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 13/42] tests: bios-tables-test: update tables with CPHP turned off by default
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (11 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 14/42] tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type Igor Mammedov
                   ` (28 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/tests/acpi-test-data/pc/DSDT b/tests/acpi-test-data/pc/DSDT
index 9d1274d3c2e2b7a316d5133d013b0550024ee413..f0ebda75d233de1e5b22dbedf2cbf41b88a06f21 100644
GIT binary patch
delta 93
zcmcbt{Yah5CD<k8kuU=T<D89LmF$}XIqoxwc(TR22e@*?dw9C=Iywh<8W<RuP4?!t
vk(7*gH85s~(PxPdc8U*h_B8PI2ypQYcJ|xM%2Uh8?o}BBlGyCPH<=v()$JL<

delta 559
zcmYk3K}#D!6vy9WHCbLZG|Kj3DFiP)6m)2{TIiwcWTQ!&ba2;0*}%*uNFxZ&K?^Fy
zR;l&erT0W~50WoY@FMsHN<T?wc06<r^W#4=kN2Pd`}^$vIo6|keE%4Ltli*o>8$OE
zXhZm`jJE@#F0L5=&>4VKb7geFg?y!IaFt>KayX!*Rx>b8{RPIO_`j;*tQ_N`kuwG#
z84p{9WD$S+ts>u!7%07qT?IV_^13nmOa3suIuAW1q(eNFSb~!t>5V*nyn7<i0sa28
zN1#7k{F$YF)z2MD7-H5Zow)H)l98Jeog+CtFa0Sz2`gfghpyOa)++(yO-ku2@QdO-
zrP*hEQ>}`SzJTtM`MI%{-QYr;->=wbs}>JMYgVmWytW7|HY}J$-6FJT!1NZskmcZe
z*K|tG-_0y>)}(wpjB;~caEC=#>}Z>e@6@&q4%PnAr%aWfp1}krq;?F+S8XsRWtd<s
z`R3)q<oLFlT)bqQQad5v6YU^|v6&)h5ygQKQ4D@Xge^+62wO1l=S)-u9o_&gP5GW{
WhA{6CQf<54Whak>HK$$gvh)vxjE=Mb

diff --git a/tests/acpi-test-data/pc/DSDT.bridge b/tests/acpi-test-data/pc/DSDT.bridge
index cf48c62aa71a7dd7d816fd4ef8ad626e39d4965c..f9353b9b5689d750d3623811abda707727a11e1c 100644
GIT binary patch
delta 93
zcmbPcwbYEuCD<iIRhof;@ySN6O7_ix9QT<-JlW#i16(=cJv?1_9i0O_4Gav-CVO++
vNJ_@L8W=Og=(EHJJH-b$dm8w91i1JHJNs>B<*8+4_k9}!lGyCPca0AKl{gu>

delta 559
zcmYk3PiqrF7{=epw#o8lqp2(&DuvJw&<<+rA3V67-PlAEhwk<u8<^RI(g=ccutHl(
zY75%4i=GpS=TPz`6fgY<{Tkk!+3CSK%#UYgUfyS(_vhyKrx?aza(4xQj4tu8GU|9D
z-V*)><DG!0^9#mbcZVR=QWafrp;(z3USwE;0uCst)dEa2f0^+(`LAlcD5rRP;!MFu
z#-nyAUBzF1yUcfD21@T@PeEUS{Lx(eCcl_o-J6~gvN0Y@tiVy9^e3J^-aC@$fPR16
zComYVe$BIi8WavCj4>aOZqj@s$;2&)&VihtRjy0-qMCTYBUfy<!dk$1i&DA?ep$St
zH2;Xt>U9y(`_Nl6KR4F$OI%Kh`-k?~hQ&?MBdZ=;Jh2EYwk()MXc1X7Vg3hC$a?s<
zXF8>4FBjH0Yf-)v#f3R9xWck4cC}5$cN^R9Kd5&H`?;#Fj9>;c(l~_lR2xi46=v8-
zKY4{PIX<ta=MNaC)K19vL?=jKYNiNU#7SU8oPb{wQJWGiqBacuB@<Oihc|@Jru?mI
XhH%Frq~39R>rN2~Yt4J!?_2)>CEAXx

diff --git a/tests/acpi-test-data/q35/DSDT b/tests/acpi-test-data/q35/DSDT
index 1c089c34b06c9f2ea9fe67abb45498021319303c..6c5310e2bc43cf850eb771200713e40aa6ba6d9d 100644
GIT binary patch
delta 66
zcmZ4LxW<;tCD<iojT{35W6wseM#;^QQumoe^y1wETsh)BJY9GlodY}#3=GT|Cg;dX
WZN4RI$jI)@7ZV@s6hHZ-{2c&_78BI~

delta 562
zcmYk3&r2IY6vy9WHC@J)#xj?Pf#4sYW2^mf5W1OcYPKdF-1Sg4FtZ8L6bhY#9#p8c
zf=Z8F3Oyzz-g+ti6TRs%7omSj=ZA;B!+iJ-@A1Cxy<eMGA#Ntk^r{Yk=x=;lJ?R7@
zX$Z2xcqc^a?2_>}-62S|Fo%8c!A7ozmpLwhg$GJ%H3O5JEHa*?|5c4<<pe(*dlMj-
z@hC23%lHq8%X}wcp!6&D6!aCypRL*N^1}4$-uIM{kMOa?58$Ye`r|-<?;T0(fzChf
zBN&X9zZLmF4Xi^6BU}tnH*LL@XzW{J??7IEt^O^oH?VlcBVTN_oAV*#ZA$4=AZ4*l
zslytOiiqfA=&hLPjlJU2(qd|J)?Lnq!+qg1r=B~!a0ne54$PtH5IMBq`p425T8*nc
z(<%G%dS->QHsw1}Vhsl2EiU_FS6gL#x4!jpUwt@uS8Ud5C(~dWp!y+XpS8gh%}oPb
z&rSm?%r0M6va=_Q>!ECrKy<<sCgzf$MUsX_Bq@-25ycc~5ydbh3uav<y}%)yoAUR*
WIm9Cmp-RW^t$KDPtX<sIZvFub_l~sy

diff --git a/tests/acpi-test-data/q35/DSDT.bridge b/tests/acpi-test-data/q35/DSDT.bridge
index b29fcda0bb1717ff708668c6e98f3ded3f34a96c..d0eec6bcd4234ebd33bd1dbf5442977619ba1516 100644
GIT binary patch
delta 66
zcmdnyxYw4;CD<iouN(sdqs~UIM#;^QQumoe^y1wETsh)BJY9GlodY}#3=GT|Cg;dX
WZN4RI$jI)(9}^$!6hHZ-{96EnClk8>

delta 562
zcmYk3&r2IY6vy9WHC@IPW0{M=K=2RH^;gw{(9L9{i6$M~^&lIV*#v0>!8zzbg<31L
z;?YIuF)8^6ir}qxj~;U=_@{J!c<4LKhwtzn@B7~Sv-uR@YE+G%$^hu)H@=>^YI;1X
zaI#8SGeGj@ma<Q+9tb%-fn9LHL@Il?Db9g`15zk82E&vTDU0I&s`}$%h^Ge55D2C$
zY~+$T{7f2owii*5>g9(LIugXM+W3R`p?kI7dJ0JU_)_3^aM3}Xfv3I?F9dc#<zIFX
zbo+DnS=yCd<4`~!XI<2aYX<@iTtn=fiO0K{*W5}4^DP#-e7jzq3@EGnzW)J8p6~j;
z#UhXb5B()*&+F;6z3j_uF*Z3XHfPo1t#Hk%b&Cy)z@lP7EvgowMGYQ*&Mu;bonl*e
zO1|xk%`;l}*<KhKgI@50^Df_4Rw>&rZ=amX<Fn7%W~p>F@<tvipF{Fh8H~}y$iwC2
z+A~7$@?#;nS*A=4WrBFT8N@KumjorEIM5=BflTtS;Ugu&2K30ZURO>num|6D`H`y+
V@!mnG&~)1ij#&w<XMant{{YlKkDCAh

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 14/42] tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (12 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 13/42] tests: bios-tables-test: update tables with CPHP turned off by default Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 15/42] acpi: extend ACPI interface to provide send_event hook Igor Mammedov
                   ` (27 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

it should help to notice regression if legacy CPU hotplug
unintentionally disappears in old machine types.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/tests/acpi-test-data/pc/DSDT.cphp_legacy b/tests/acpi-test-data/pc/DSDT.cphp_legacy
new file mode 100644
index 0000000000000000000000000000000000000000..2744030a49d16d93c9806334b84c658c8faa5435
GIT binary patch
literal 5502
zcmb7IUvCrH6+hQwC*x~787D&s1Qsj6(xnCb2Lh{BRqPojcJMfZ$Dve%I^!g$rrMTK
z7NiZ)R*6>%EN@#cRr_X;pW!34kA2*au>A^Kb>WHhoEcxo&F)mxlE>%I@1Aq+z2}^J
z$GW9A|9A|56-%pH#mbcKn3|3<1^`6UuTqWP1$$R7Ejug`i86aH;nVmi$?DJa(%Lfn
zOWXak>ppzqvX%$yFO}!(E$@q`?m7_Y(YnVu5z4${l^nY>XKK}~>{P0HviJ>`WT&V%
zKz7!uI#Ucez?9{RS#AmtLlCMljEdPbAPMlzy97k-J%#w`+vU2RF&ny*Q5PJmSp<(H
zu1BKQW0xy#FZos1g|3@8IOs!f;;U{8zHTMqpZ|{aq0c8}M{8K=G@say<BZWbL;<!z
zIe(d=p>XZa3G+^_;K!PjfMF<RuAoJLA1I5l5ttUOT16+o;ldK`YF3MImt(je{^l}S
zp^*TUD==O&%XJ1fK+=jtNLmSh6z$9vNjN5JcIQ%~siDze$r89&6z?oQw#+>6K#9x)
zTV`9Z1(C6Bushdpmh>T9lGM1rD#MBT16^=|;iyg6#NYV{&e!f-Fjm)w11G1C4wQLp
z9uxu=<t1GkZsPbLqB%ah%)XPplOVdx-bin7q2?FiV$`>tTdJ8wvDr&{bt<C(kMUKW
zW&Aad@bmbc;&c3ff5N}#lU$aaCB2+J&Q(go(N6>!yYtJM*&N0i1$8#qdRkJqH-_8Y
zhZoV|oE4s0W}iu)NwPe@>&H`$YO6+0ENYAe87R!qhJ=}UE4`IKo>zP`OJpX0#0-xN
z?ck1v+KIf4pdA_QC>8lIiFQrRYO(~p;xeW<F&gIJS_U6_#@@BcD_Dy1E6S(@F<L2G
zUO`2vZZudz2^7R=rTUtYv0166-30Z#sg+kE_F3W%4!kxgy=`_MXt;fW#C=feSVAR7
zxydQ*Rh>I#qY2(rWY_he^|BOy-r~F7;}(y=y0^2{S_dw{Mo;N(ASjMyQ>)+9VY7Fx
zyTN+tZi`2UVhc83q=sA(LFw)Wj|?THfkYZgG}!b$-(KemVBx~kO#pAFh5nvyGVnH^
zx-EFr>bv&dxhoPyOSMAP#>~d8tc;HwJ@WJ@$m(?U7OrY9zQcFhSoHBePpAvkTUsNI
zfJQbw!4qGOLEKNaZFoj99>Zs~mw4XBIk$=Kli2Rm#&MdM%t1jWv4K!~l5wr9^bDW=
zasuK~46~HuH-X=6P$z>Lq#!6fHSOqC3qB{B@A{HSs%q#{NIrkuu^JY8)()b;Zq}%h
zeBixw#5?Bidwb7~c+dIXa~R*K_ni9U-g9=xpt);Dyz|Ka;XXg&KJUBFA90@#ai1T!
z*N?i#1LD1BUl?&;@ZA@VxG#jbFW8;cD9+wG>OLB{7b!%i2yVG(y9ss7-)uDztTBa(
zBHCR=$F@~+)N7h)6d4|xnz>qUgX^UeTm~8K;HTxapHjj3KN5H@a#85F)RUTtDSbGq
z7jv=Uy^#8#a?PY-pXdKjSH{qv2ADvWa}UpF58RhavFGj+@--OjLaWDjTs{tu*V+1u
zB#Q6h$teL<`8vZ2pZ`<0wc%~}0lLuRSl{*L(yv|iLiT^T^vJb4H=~!S63s?=xJG=;
zua1;vu4O6@9(tcV`fX<G-lq>9ZEf896l(?#Y@P^Cv=ryd3|_-)mcc^?tHN)CuX)Da
zOZp5=VNtQaC}?Ij8!V2Rbc|vX`m}(644wbTSWQq<PI)EEkSVV~TTN4#5e&Qy`!xK%
zO!J?T7*l8NUUrtvvQy6H0ZBUZamAGSrNf@wDPA%vW{`I&vu<XK*#!(9%RXh?`~8Eh
z?M(Xzb5p1NXnOIkq1PLD9%0L|nc+9%;+SD+bvV@FuGnWucX06X7tdW9;kkxYuJxw7
zMzwA+!(VNW5%XfEr*@5oaXXN53B|~5xy-dMkdZ!9FB!CaBWAt7w!t@;=o)3qVIH3p
zXjd)H8d(2v5rV+VMq}Y>y1=u~ehPpWpCg}l2f;^(2kZg%Pa4Q4FxXl^P9a$d$Pa5}
zA-#y?KssX-?+mafk*s(|qg0_mMAXO-6155qAfiS_wn$6_jU~oc)99Z1oMfcmBA)re
zv@c{2hZ3S{q^tGx@h*u0r(DRV&+t=Ej*m{6rb^SKDf-hZ<T*$44$cY52^>2hXD}eg
zBhRGv$T%rIij!1>9im}Fa^b3a&M@y7?C1t~D0L3E=_kgj)r|fCbl+Gl-}ZioN-Z#{
z&KsEfc-RLSCAJgO1n&z0M5&HZ()+C}Rn*LCHj62(evDO+1N-dV!#ikjVHgpZTD@ss
z7!eRcJ%J+&aQ8}7++C?)D9e>{dQer^8iGnMjq^V|O+f^&^0cP(z`N+%<l7{ZQO<%?
zdxPq?$swQeci>;6`@(TQ=zyh91bmISEy@Q6e|r~b{{B7PS+yumH@LGNsbG@-&z|({
z>u+DPC>dFaniaDVEZTp!0qlG4*WX^jE2iR=@1wia{R+<1Sd?MVNMCiP<S1T)@q&xo
zHPX-ol%F3ipWV5<^eb&C2;f%PSi@b*6Z%LORbonvCDF^u_Fex%XUHS_<+n1wDUCK>
zj`x*WYP=PbE|S3cti5-J7>P<SLj{SC8c{W*Ff*|;pC&*N7P;S4Fy*mT`JIWbsrKHn
zU_3Um3?(T(EG?ssQ8$Yy#sfMn<PvIeZ4*{Di#K|D9ke?at=xdYB#3~DQ_ShuLy5=>
zqCkY*`N+!Mz=76UeegPoLnKhA{Qgh3UUEQcg67FALGjQ=R|v(IhY+Z+8WYf17_=a)
z;%OIH9SemDtK$MX9tOQCtm4a1U{wx<3afDejfX+639DQ{c_>s^#S=ORAQ1*#5LS}{
znhb>st0@6Zg+Z?is}lk`5egMn@j4#FIvEDNA*?C_s)Ry?)wF=7!=N7vt5X6x6$%wr
zrv-F63|bUcG4q3Isi9C|^_YMj3xk$~)foYu355!)#|89w7*rEhX9aXN6e_Hq5YQ80
zP+eF(DWE4qp~C8%fX;<M%fjj@0X-E86;@9R=;<)%lCb)LfPN4P6;{s(=$Rjbs+BqY
zcD)(tC3o8RPOwkC?!M0`$Y3`Mm<%yOvxp3Kq(HMv3~5q3?F9ZMwQpft8E_HehPo(n
z*c=8r@^x*fBWGCR108u=80yF!7V1Dp{;rd5a;J^m6_2)k3ky#0c(@^dsK+C2-@?)n
zdVJ|Y{!p(Fk3}H#8J|DYFA|UGEcClRf2j9ojEO1qc$n;4+K8TJjVU(N)4cT&J<S}G
oWvI^(KcZhm9=Cm{-z6UP>KVEx;s0~=M+<Eso^@+%K<Hfh4+O78OaK4?

literal 0
HcmV?d00001

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 0352814..191e701 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 15/42] acpi: extend ACPI interface to provide send_event hook
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (13 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 14/42] tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 16/42] pc: use AcpiDeviceIfClass.send_event to issue GPE events Igor Mammedov
                   ` (26 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

send_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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
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(-)

diff --git a/hw/acpi/core.c b/hw/acpi/core.c
index 7925a1a..350345a 100644
--- a/hw/acpi/core.c
+++ b/hw/acpi/core.c
@@ -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);
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 86d68dd..b676762 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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 = {
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 99cd3ba..305ccd6 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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 = {
diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h
index e0978c8..24dd572 100644
--- a/include/hw/acpi/acpi.h
+++ b/include/hw/acpi/acpi.h
@@ -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);
 
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index f245f8d..fdfc163 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 16/42] pc: use AcpiDeviceIfClass.send_event to issue GPE events
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (14 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 15/42] acpi: extend ACPI interface to provide send_event hook Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 17/42] docs: update ACPI CPU hotplug spec with new protocol Igor Mammedov
                   ` (25 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

it 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 36ea6c2..412714d 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -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,
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index b5481d4..6ffa9bf 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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)));
diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index f65a3a2..cde1abd 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -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,
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 71f4c4e..01fd488 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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)
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index b676762..8f53b30 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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"
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 305ccd6..86d4547 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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;
 }
diff --git a/include/hw/acpi/cpu_hotplug.h b/include/hw/acpi/cpu_hotplug.h
index 6d729d8..6fef67e 100644
--- a/include/hw/acpi/cpu_hotplug.h
+++ b/include/hw/acpi/cpu_hotplug.h
@@ -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,
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index 942b966..e29a856 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -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);
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 3a646b1..d2c7452 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -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,
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 79a4392..04528b7 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -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 */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 17/42] docs: update ACPI CPU hotplug spec with new protocol
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (15 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 16/42] pc: use AcpiDeviceIfClass.send_event to issue GPE events Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 18/42] acpi: hardware side of CPU hotplug Igor Mammedov
                   ` (24 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 docs/specs/acpi_cpu_hotplug.txt | 88 +++++++++++++++++++++++++++++++++++------
 1 file changed, 76 insertions(+), 12 deletions(-)

diff --git a/docs/specs/acpi_cpu_hotplug.txt b/docs/specs/acpi_cpu_hotplug.txt
index 340b751..c5bce6a 100644
--- a/docs/specs/acpi_cpu_hotplug.txt
+++ b/docs/specs/acpi_cpu_hotplug.txt
@@ -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.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 18/42] acpi: hardware side of CPU hotplug
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (16 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 17/42] docs: update ACPI CPU hotplug spec with new protocol Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 19/42] pc: add generic CPU unplug callbacks Igor Mammedov
                   ` (23 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 66bd727..f200419 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -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
diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
new file mode 100644
index 0000000..2b4feb0
--- /dev/null
+++ b/hw/acpi/cpu.c
@@ -0,0 +1,218 @@
+#include "qemu/osdep.h"
+#include "hw/boards.h"
+#include "hw/acpi/cpu.h"
+#include "qapi/error.h"
+#include "trace.h"
+
+#define ACPI_CPU_HOTPLUG_REG_LEN 12
+#define ACPI_CPU_SELECTOR_OFFSET_WR 0
+#define ACPI_CPU_FLAGS_OFFSET_RW 4
+
+static uint64_t cpu_hotplug_rd(void *opaque, hwaddr addr, unsigned size)
+{
+    uint64_t val = ~0;
+    CPUHotplugState *cpu_st = opaque;
+    AcpiCpuStatus *cdev;
+
+    if (cpu_st->selector >= cpu_st->dev_count) {
+        return val;
+    }
+
+    cdev = &cpu_st->devs[cpu_st->selector];
+    switch (addr) {
+    case ACPI_CPU_FLAGS_OFFSET_RW: /* pack and return is_* fields */
+        val = 0;
+        val |= cdev->is_enabled   ? 1 : 0;
+        val |= cdev->is_inserting ? 2 : 0;
+        val |= cdev->is_removing  ? 4 : 0;
+        trace_cpuhp_acpi_read_flags(cpu_st->selector, val);
+        break;
+    default:
+        break;
+    }
+    return val;
+}
+
+static void cpu_hotplug_wr(void *opaque, hwaddr addr, uint64_t data,
+                           unsigned int size)
+{
+    CPUHotplugState *cpu_st = opaque;
+    AcpiCpuStatus *cdev;
+    Error *local_err = NULL;
+
+    assert(cpu_st->dev_count);
+
+    if (addr) {
+        if (cpu_st->selector >= cpu_st->dev_count) {
+            trace_cpuhp_acpi_invalid_idx_selected(cpu_st->selector);
+            return;
+        }
+    }
+
+    switch (addr) {
+    case ACPI_CPU_SELECTOR_OFFSET_WR: /* current CPU selector */
+        cpu_st->selector = data;
+        trace_cpuhp_acpi_write_idx(cpu_st->selector);
+        break;
+    case ACPI_CPU_FLAGS_OFFSET_RW: /* set is_* fields  */
+        cdev = &cpu_st->devs[cpu_st->selector];
+        if (data & 2) { /* clear insert event */
+            cdev->is_inserting = false;
+            trace_cpuhp_acpi_clear_inserting_evt(cpu_st->selector);
+        } else if (data & 4) { /* clear remove event */
+            cdev->is_removing = false;
+            trace_cpuhp_acpi_clear_remove_evt(cpu_st->selector);
+        } else if (data & 8) {
+            DeviceState *dev = NULL;
+            HotplugHandler *hotplug_ctrl = NULL;
+
+            if (!cdev->is_enabled) {
+                trace_cpuhp_acpi_ejecting_invalid_cpu(cpu_st->selector);
+                break;
+            }
+
+            trace_cpuhp_acpi_ejecting_cpu(cpu_st->selector);
+            dev = DEVICE(cdev->cpu);
+            hotplug_ctrl = qdev_get_hotplug_handler(dev);
+            hotplug_handler_unplug(hotplug_ctrl, dev, &local_err);
+            if (local_err) {
+                break;
+            }
+        }
+        break;
+    default:
+        break;
+    }
+    error_free(local_err);
+}
+
+static const MemoryRegionOps cpu_hotplug_ops = {
+    .read = cpu_hotplug_rd,
+    .write = cpu_hotplug_wr,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 1,
+        .max_access_size = 4,
+    },
+};
+
+void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
+                         CPUHotplugState *state, hwaddr base_addr)
+{
+    MachineState *machine = MACHINE(qdev_get_machine());
+    MachineClass *mc = MACHINE_GET_CLASS(machine);
+    CPUArchIdList *id_list;
+    int i;
+
+    id_list = mc->possible_cpu_arch_ids(machine);
+    state->dev_count = id_list->len;
+    state->devs = g_new0(typeof(*state->devs), state->dev_count);
+    for (i = 0; i < id_list->len; i++) {
+        state->devs[i].cpu =  id_list->cpus[i].cpu;
+        state->devs[i].arch_id = id_list->cpus[i].arch_id;
+        state->devs[i].is_enabled =  id_list->cpus[i].cpu ? true : false;
+    }
+    g_free(id_list);
+    memory_region_init_io(&state->ctrl_reg, owner, &cpu_hotplug_ops, state,
+                          "acpi-mem-hotplug", ACPI_CPU_HOTPLUG_REG_LEN);
+    memory_region_add_subregion(as, base_addr, &state->ctrl_reg);
+}
+
+static AcpiCpuStatus *get_cpu_status(CPUHotplugState *cpu_st, DeviceState *dev)
+{
+    CPUClass *k = CPU_GET_CLASS(dev);
+    uint64_t cpu_arch_id = k->get_arch_id(CPU(dev));
+    int i;
+
+    for (i = 0; i < cpu_st->dev_count; i++) {
+        if (cpu_arch_id == cpu_st->devs[i].arch_id) {
+            return &cpu_st->devs[i];
+        }
+    }
+    return NULL;
+}
+
+void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+                      CPUHotplugState *cpu_st, DeviceState *dev, Error **errp)
+{
+    AcpiCpuStatus *cdev;
+
+    if (!cpu_st->is_enabled) {
+        error_setg(errp, "acpi: CPU hotplug is not enabled on: %s",
+                   object_get_typename(OBJECT(hotplug_dev)));
+        return;
+    }
+
+    cdev = get_cpu_status(cpu_st, dev);
+    if (!cdev) {
+        return;
+    }
+
+    cdev->cpu = CPU(dev);
+    cdev->is_enabled = true;
+    if (dev->hotplugged) {
+        cdev->is_inserting = true;
+        ACPI_SEND_EVENT(hotplug_dev, ACPI_CPU_HOTPLUG_STATUS);
+    }
+}
+
+void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                CPUHotplugState *cpu_st,
+                                DeviceState *dev, Error **errp)
+{
+    AcpiCpuStatus *cdev;
+
+    if (!cpu_st->is_enabled) {
+        error_setg(errp, "acpi: CPU hotplug is not enabled on: %s",
+                   object_get_typename(OBJECT(hotplug_dev)));
+        return;
+    }
+
+    cdev = get_cpu_status(cpu_st, dev);
+    if (!cdev) {
+        return;
+    }
+
+    cdev->is_removing = true;
+    ACPI_SEND_EVENT(hotplug_dev, ACPI_CPU_HOTPLUG_STATUS);
+}
+
+void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
+                        DeviceState *dev, Error **errp)
+{
+    AcpiCpuStatus *cdev;
+
+    cdev = get_cpu_status(cpu_st, dev);
+    if (!cdev) {
+        return;
+    }
+
+    cdev->cpu = NULL;
+    cdev->is_enabled = false;
+}
+
+static const VMStateDescription vmstate_cpuhp_sts = {
+    .name = "CPU hotplug device state",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_BOOL(is_enabled, AcpiCpuStatus),
+        VMSTATE_BOOL(is_inserting, AcpiCpuStatus),
+        VMSTATE_BOOL(is_removing, AcpiCpuStatus),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+const VMStateDescription vmstate_cpu_hotplug = {
+    .name = "CPU hotplug state",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_UINT32(selector, CPUHotplugState),
+        VMSTATE_STRUCT_VARRAY_POINTER_UINT32(devs, CPUHotplugState, dev_count,
+                                             vmstate_cpuhp_sts, AcpiCpuStatus),
+        VMSTATE_END_OF_LIST()
+    }
+};
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
new file mode 100644
index 0000000..c746292
--- /dev/null
+++ b/include/hw/acpi/cpu.h
@@ -0,0 +1,53 @@
+/*
+ * QEMU ACPI hotplug utilities
+ *
+ * Copyright (C) 2016 Red Hat Inc
+ *
+ * Authors:
+ *   Igor Mammedov <imammedo@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef ACPI_CPU_H
+#define ACPI_CPU_H
+
+#include "hw/qdev-core.h"
+#include "hw/acpi/acpi.h"
+#include "hw/hotplug.h"
+
+typedef struct AcpiCpuStatus {
+    struct CPUState *cpu;
+    uint64_t arch_id;
+    bool is_enabled;
+    bool is_inserting;
+    bool is_removing;
+} AcpiCpuStatus;
+
+typedef struct CPUHotplugState {
+    MemoryRegion ctrl_reg;
+    bool is_enabled;
+    uint32_t selector;
+    uint32_t dev_count;
+    AcpiCpuStatus *devs;
+} CPUHotplugState;
+
+void acpi_cpu_plug_cb(HotplugHandler *hotplug_dev,
+                      CPUHotplugState *cpu_st, DeviceState *dev, Error **errp);
+
+void acpi_cpu_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                CPUHotplugState *cpu_st,
+                                DeviceState *dev, Error **errp);
+
+void acpi_cpu_unplug_cb(CPUHotplugState *cpu_st,
+                        DeviceState *dev, Error **errp);
+
+void cpu_hotplug_hw_init(MemoryRegion *as, Object *owner,
+                         CPUHotplugState *state, hwaddr base_addr);
+
+extern const VMStateDescription vmstate_cpu_hotplug;
+#define VMSTATE_CPU_HOTPLUG(cpuhp, state) \
+    VMSTATE_STRUCT(cpuhp, state, 1, \
+                   vmstate_cpu_hotplug, CPUHotplugState)
+
+#endif
diff --git a/trace-events b/trace-events
index 8350743..9df9531 100644
--- a/trace-events
+++ b/trace-events
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 19/42] pc: add generic CPU unplug callbacks
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (17 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 18/42] acpi: hardware side of CPU hotplug Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option Igor Mammedov
                   ` (22 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..1cad132 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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)));
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (18 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 19/42] pc: add generic CPU unplug callbacks Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 20:27   ` Eduardo Habkost
  2016-05-02 12:33 ` [Qemu-devel] [RFC 21/42] pc: q35: initialize new CPU hotplug hw Igor Mammedov
                   ` (21 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/core/machine.c   | 20 ++++++++++++++++++++
 include/hw/boards.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 6dbbc85..498230a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index 8d4fe56..d388f96 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 21/42] pc: q35: initialize new CPU hotplug hw
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (19 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 22/42] pc: piix4: " Igor Mammedov
                   ` (20 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

add 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".

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/ich9.c         | 60 ++++++++++++++++++++++++++++++++++++++++++++++----
 hw/i386/pc_q35.c       |  7 +++---
 include/hw/acpi/ich9.h |  6 ++++-
 3 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 6ffa9bf..dd141eb 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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)));
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 4787df1..0dc4ed5 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -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);
 
diff --git a/include/hw/acpi/ich9.h b/include/hw/acpi/ich9.h
index e29a856..198c017 100644
--- a/include/hw/acpi/ich9.h
+++ b/include/hw/acpi/ich9.h
@@ -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;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 22/42] pc: piix4: initialize new CPU hotplug hw
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (20 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 21/42] pc: q35: initialize new CPU hotplug hw Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily Igor Mammedov
                   ` (19 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 8f53b30..2246c65 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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(),
 };
 
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index cdbdd69..860a83d 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -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,
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index fa769e5..3f61e38 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -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);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index f1e40ae..43aeebb 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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 */
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (21 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 22/42] pc: piix4: " Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 20:28   ` Eduardo Habkost
  2016-05-02 12:33 ` [Qemu-devel] [RFC 24/42] pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx Igor Mammedov
                   ` (18 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

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.

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"))

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/pc-cpu-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/pc-cpu-test.c b/tests/pc-cpu-test.c
index 6b34ca5..5c9fd1e 100644
--- a/tests/pc-cpu-test.c
+++ b/tests/pc-cpu-test.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 24/42] pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (22 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 25/42] tests: acpi: update cphp_legacy case with new ProcessorID values Igor Mammedov
                   ` (17 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

In 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu_hotplug.c | 23 +++++++++++++----------
 hw/i386/acpi-build.c  |  2 +-
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 412714d..6c0b555 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -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;
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 502f1a7..83c18a0 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 25/42] tests: acpi: update cphp_legacy case with new ProcessorID values
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (23 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 24/42] pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 26/42] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook Igor Mammedov
                   ` (16 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/acpi-test-data/pc/DSDT.cphp_legacy | Bin 5502 -> 5503 bytes
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/tests/acpi-test-data/pc/DSDT.cphp_legacy b/tests/acpi-test-data/pc/DSDT.cphp_legacy
index 2744030a49d16d93c9806334b84c658c8faa5435..8b4f1a09b87f8361fb572022f69d304ddeeace99 100644
GIT binary patch
delta 74
zcmeyT^<Rt2CD<jTUX+1>(Rw3SB|ERHM0~JQyojlDfUhId<O%GOjG3EPvGX%Zm^cR*
Z7%+f=2yeWvV+g|%kQ#=~7dY1O007fP5{m!;

delta 73
zcmeyb^-qh-CD<jTPLzRx(QzYJB|EQ+M0~JQyojlDfUhIt<O%GOj2W9(vGX&E8#@OW
Y7%+f=2v5APV+g|%kebaGIo9z20K;7pivR!s

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 26/42] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (24 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 25/42] tests: acpi: update cphp_legacy case with new ProcessorID values Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT Igor Mammedov
                   ` (15 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Add 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 2246c65..673bc44 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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 = {
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 83c18a0..f8c9a7c 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -335,12 +335,38 @@ build_fadt(GArray *table_data, GArray *linker, AcpiPmInfo *pm,
                  (void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id);
 }
 
+void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
+                       CPUArchIdList *apic_ids, GArray *entry)
+{
+    int apic_id;
+    AcpiMadtProcessorApic *apic = acpi_data_push(entry, sizeof *apic);
+
+    apic_id = apic_ids->cpus[uid].arch_id;
+    apic->type = ACPI_APIC_PROCESSOR;
+    apic->length = sizeof(*apic);
+    apic->processor_id = uid;
+    apic->local_apic_id = apic_id;
+    if (apic_ids->cpus[uid].cpu != NULL) {
+        apic->flags = cpu_to_le32(1);
+    } else {
+        /* ACPI spec says that LAPIC entry for non present
+         * CPU may be omitted from MADT or it must be marked
+         * as disabled. However omitting non present CPU from
+         * MADT breaks hotplug on linux. So possible CPUs
+         * should be put in MADT but kept disabled.
+         */
+        apic->flags = cpu_to_le32(0);
+    }
+}
+
 static void
 build_madt(GArray *table_data, GArray *linker, PCMachineState *pcms)
 {
     MachineClass *mc = MACHINE_GET_CLASS(pcms);
     CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(pcms));
     int madt_start = table_data->len;
+    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(pcms->acpi_dev);
+    AcpiDeviceIf *adev = ACPI_DEVICE_IF(pcms->acpi_dev);
 
     AcpiMultipleApicTable *madt;
     AcpiMadtIoApic *io_apic;
@@ -353,24 +379,7 @@ build_madt(GArray *table_data, GArray *linker, PCMachineState *pcms)
     madt->flags = cpu_to_le32(1);
 
     for (i = 0; i < apic_ids->len; i++) {
-        AcpiMadtProcessorApic *apic = acpi_data_push(table_data, sizeof *apic);
-        int apic_id = apic_ids->cpus[i].arch_id;
-
-        apic->type = ACPI_APIC_PROCESSOR;
-        apic->length = sizeof(*apic);
-        apic->processor_id = i;
-        apic->local_apic_id = apic_id;
-        if (apic_ids->cpus[i].cpu != NULL) {
-            apic->flags = cpu_to_le32(1);
-        } else {
-            /* ACPI spec says that LAPIC entry for non present
-             * CPU may be omitted from MADT or it must be marked
-             * as disabled. However omitting non present CPU from
-             * MADT breaks hotplug on linux. So possible CPUs
-             * should be put in MADT but kept disabled.
-             */
-            apic->flags = cpu_to_le32(0);
-        }
+        adevc->madt_cpu(adev, i, apic_ids, table_data);
     }
     g_free(apic_ids);
 
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 86d4547..0aaaad3 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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 = {
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index fdfc163..61b5505 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -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
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 43aeebb..bed2438 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -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
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 4b258a6..e8ff38d 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -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
diff --git a/stubs/pc_madt_cpu_entry.c b/stubs/pc_madt_cpu_entry.c
new file mode 100644
index 0000000..427e772
--- /dev/null
+++ b/stubs/pc_madt_cpu_entry.c
@@ -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)
+{
+}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (25 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 26/42] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 28/42] acpi: add CPU hotplug methods " Igor Mammedov
                   ` (14 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c         | 38 ++++++++++++++++++++++++++++++++++++++
 hw/i386/acpi-build.c  |  2 ++
 include/hw/acpi/cpu.h |  3 +++
 3 files changed, 43 insertions(+)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 2b4feb0..6dab4d6 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -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);
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f8c9a7c..466eebd 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index c746292..da087bf 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -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, \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 28/42] acpi: add CPU hotplug methods to DSDT
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (26 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 29/42] tests: acpi: update expected files with new CPU AML description Igor Mammedov
                   ` (13 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Add necessary CPU hotplug methods to handle hotplug
events if it's enabled.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c         | 201 +++++++++++++++++++++++++++++++++++++++++++++++++-
 hw/i386/acpi-build.c  |   3 +-
 include/hw/acpi/cpu.h |   4 +-
 3 files changed, 204 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index 6dab4d6..f61d5a8 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -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);
 }
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 466eebd..b27502a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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);
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index da087bf..829114f 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -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) \
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 29/42] tests: acpi: update expected files with new CPU AML description
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (27 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 28/42] acpi: add CPU hotplug methods " Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 30/42] qdev: hotplug: Introduce HotplugHandler.pre_plug() callback Igor Mammedov
                   ` (12 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/tests/acpi-test-data/pc/DSDT b/tests/acpi-test-data/pc/DSDT
index f0ebda75d233de1e5b22dbedf2cbf41b88a06f21..e1cfc4be4788fcfcdfbb699580f68aac1a4cb74a 100644
GIT binary patch
delta 81
zcmaE)K3jv!CD<iIT7-dtF?u6cCA)=1e6Uk|bdzC>9*E%_5E{%8@8Rjf>*yTdX<%Sz
fz`zmj?CHYec!7&Gx|!SAz`%e33^q5hC-49OW&RVR

delta 24
gcmbQO@kpJ^CD<k8kuU=T<D89LmF%1Mu*dTN0Av6Mv;Y7A

diff --git a/tests/acpi-test-data/pc/DSDT.bridge b/tests/acpi-test-data/pc/DSDT.bridge
index f9353b9b5689d750d3623811abda707727a11e1c..86a251b9e90893bcacff7e7ca06f0e8d21f700dc 100644
GIT binary patch
delta 81
zcmZ2#cF&B<CD<h-PMU#%amhxmN_Gp2_+Y2_=qAG$JrKh=AT*dG-ow*{*U>q^)4;&c
ffPo|4+0%u`@d6iXbThZJfq?-77;J80Un~p&n8OsK

delta 24
gcmca-w$zNvCD<iIRhof;@ySN6O7_ir*cS-{0AN7}v;Y7A

diff --git a/tests/acpi-test-data/q35/DSDT b/tests/acpi-test-data/q35/DSDT
index 6c5310e2bc43cf850eb771200713e40aa6ba6d9d..918e08869a7de864e8a77a1e52a9ca3b6927f879 100644
GIT binary patch
delta 81
zcmZ2u`_z`pCD<k8sT>0Xqt8aJMo9~c_+Y2_=qAG$JrKh=AT*dG-ow*{*U>q^)4;&c
ffPo|4+0%u`@d6iXbThZJfq?-77;Ns6RAL1Hw(b;`

delta 24
fcmaEAyT+EwCD<iojT{35W6wseM#;@bBo$c!XG905

diff --git a/tests/acpi-test-data/q35/DSDT.bridge b/tests/acpi-test-data/q35/DSDT.bridge
index d0eec6bcd4234ebd33bd1dbf5442977619ba1516..649c6021c1763973d7e5d6376ba3d67365e1b574 100644
GIT binary patch
delta 81
zcmdmM`^}ciCD<k8n;ZiJ<C~3Kjgl4?@xe~<(M^UidLV{#Kxi;WyoaX?ucLE-r-6Z?
f0Ru<8v!@G>;{`6(=w@zb0|NsFFxcEBY0L@$@K_ak

delta 24
fcmexnyVsV>CD<iouN(sdqs~UIM#;@bB#l@BXR`;3

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 30/42] qdev: hotplug: Introduce HotplugHandler.pre_plug() callback
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (28 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 29/42] tests: acpi: update expected files with new CPU AML description Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index Igor Mammedov
                   ` (11 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

pre_plug callback is to be called before device.realize() is executed.
This would allow to check/set device's properties from HotplugHandler.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/core/hotplug.c    | 11 +++++++++++
 hw/core/qdev.c       |  9 ++++++++-
 include/hw/hotplug.h | 14 +++++++++++++-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
index 645cfca..17ac986 100644
--- a/hw/core/hotplug.c
+++ b/hw/core/hotplug.c
@@ -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)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index db41aa1..a0b3aad 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -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);
         }
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index da1d0e4..c0db869 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -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.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (29 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 30/42] qdev: hotplug: Introduce HotplugHandler.pre_plug() callback Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 32/42] pc: set X86CPU.node property if QEMU starts with numa enabled Igor Mammedov
                   ` (10 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

that 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/acpi-build.c |  2 +-
 hw/i386/pc.c         | 28 ++++++++++++----------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index b27502a..93f7b5b 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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;
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 1cad132..2dba916 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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);
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 32/42] pc: set X86CPU.node property if QEMU starts with numa enabled
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (30 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 33/42] target-i386: add X86CPU.node property Igor Mammedov
                   ` (9 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c | 43 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2dba916..2d29b5e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 33/42] target-i386: add X86CPU.node property
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (31 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 32/42] pc: set X86CPU.node property if QEMU starts with numa enabled Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 34/42] acpi: cpuhp: add command and data registers Igor Mammedov
                   ` (8 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target-i386/cpu-qom.h |  1 +
 target-i386/cpu.c     | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
index cb75017..7b09fa5 100644
--- a/target-i386/cpu-qom.h
+++ b/target-i386/cpu-qom.h
@@ -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;
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index d0b5b69..060131a 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -1802,6 +1802,44 @@ static void x86_cpuid_set_apic_id(Object *obj, Visitor *v, const char *name,
     cpu->apic_id = value;
 }
 
+static void x86_cpu_get_numa_node(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    int64_t value = cpu->numa_node;
+
+    if (value == -1) {
+        error_setg(errp, "Attempt to get not initialized property '%s' on '%s'",
+                   name, object_get_typename(obj));
+        return;
+    }
+
+    visit_type_int(v, name, &value, errp);
+}
+
+static void x86_cpu_set_numa_node(Object *obj, Visitor *v, const char *name,
+                                  void *opaque, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    DeviceState *dev = DEVICE(obj);
+    Error *error = NULL;
+    int64_t value;
+
+    if (dev->realized) {
+        error_setg(errp, "Attempt to set property '%s' on '%s' after "
+                   "it was realized", name, object_get_typename(obj));
+        return;
+    }
+
+    visit_type_int(v, name, &value, &error);
+    if (error) {
+        error_propagate(errp, error);
+        return;
+    }
+    cpu->numa_node = value;
+}
+
+
 /* Generic getter for "feature-words" and "filtered-features" properties */
 static void x86_cpu_get_feature_words(Object *obj, Visitor *v,
                                       const char *name, void *opaque,
@@ -3133,6 +3171,10 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "filtered-features", "X86CPUFeatureWordInfo",
                         x86_cpu_get_feature_words,
                         NULL, NULL, (void *)cpu->filtered_features, NULL);
+    cpu->numa_node = -1;
+    object_property_add(obj, "node", "int",
+                        x86_cpu_get_numa_node,
+                        x86_cpu_set_numa_node, NULL, NULL, NULL);
 
     cpu->hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 34/42] acpi: cpuhp: add command and data registers
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (32 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 33/42] target-i386: add X86CPU.node property Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode Igor Mammedov
                   ` (7 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

CPU 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c         | 26 ++++++++++++++++++++++++++
 include/hw/acpi/cpu.h |  1 +
 trace-events          |  1 +
 3 files changed, 28 insertions(+)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index f61d5a8..a238ced 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -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);
 
         }
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index 829114f..6de9476 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -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;
diff --git a/trace-events b/trace-events
index 9df9531..108ae07 100644
--- a/trace-events
+++ b/trace-events
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (33 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 34/42] acpi: cpuhp: add command and data registers Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling Igor Mammedov
                   ` (6 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Having 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.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/cpu.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 trace-events  |  1 +
 2 files changed, 49 insertions(+)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index a238ced..a2a03b2 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -11,6 +11,7 @@
 #define ACPI_CPU_CMD_DATA_OFFSET_RW 8
 
 enum {
+    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);
         }
diff --git a/trace-events b/trace-events
index 108ae07..159c94d 100644
--- a/trace-events
+++ b/trace-events
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (34 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-10 21:07   ` Eric Blake
  2016-05-02 12:33 ` [Qemu-devel] [RFC 37/42] tests: acpi: report names of expected files in verbose mode Igor Mammedov
                   ` (5 subsequent siblings)
  41 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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(-)

diff --git a/hw/acpi/cpu.c b/hw/acpi/cpu.c
index a2a03b2..e10903b 100644
--- a/hw/acpi/cpu.c
+++ b/hw/acpi/cpu.c
@@ -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);
         }
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index dd141eb..3bf2171 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -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);
+    }
 }
diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 673bc44..494e54d 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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)
diff --git a/include/hw/acpi/cpu.h b/include/hw/acpi/cpu.h
index 6de9476..94d5b1d 100644
--- a/include/hw/acpi/cpu.h
+++ b/include/hw/acpi/cpu.h
@@ -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, \
diff --git a/qapi-schema.json b/qapi-schema.json
index 54634c4..b393313 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -4019,7 +4019,7 @@
 #
 # @DIMM: memory slot
 #
-{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] }
+{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] }
 
 ## @ACPIOSTInfo
 #
diff --git a/trace-events b/trace-events
index 159c94d..51bb2f0 100644
--- a/trace-events
+++ b/trace-events
@@ -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
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 37/42] tests: acpi: report names of expected files in verbose mode
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (35 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 38/42] tests: acpi: add CPU hotplug testcase Igor Mammedov
                   ` (4 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

print 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

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/bios-tables-test.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 191e701..53c0f6a 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -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);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 38/42] tests: acpi: add CPU hotplug testcase
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (36 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 37/42] tests: acpi: report names of expected files in verbose mode Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 39/42] tests: acpi: add expected tables for CPU hotplug case Igor Mammedov
                   ` (3 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Test with "-smp 2,cores=3,sockets=2,maxcpus=6"
to capture sparse APIC ID values that default
AMD CPU has in above configuration.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/bios-tables-test.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 53c0f6a..670e6a8 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -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);
     }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 39/42] tests: acpi: add expected tables for CPU hotplug case
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (37 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 38/42] tests: acpi: add CPU hotplug testcase Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 40/42] tests: acpi: extend CPU hotplug test with NUMA support Igor Mammedov
                   ` (2 subsequent siblings)
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/tests/acpi-test-data/pc/APIC.cphp b/tests/acpi-test-data/pc/APIC.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..1bf8a0a63bc1c9b716d937b96eb34b05016b9366
GIT binary patch
literal 160
zcmXwx!3}^Q3`JW6f}%UP3UJYrBwpObWgNv(oJ8%n@zB24pP!~WmxG9S&r6xsF>kdb
z$yhQtNOavFgY<9)W~DJWDKu7Tozi)bd+hVZHk}Lv=1?18ZTnj%1<hjo%=$-Oyrt<4
A0RR91

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/pc/DSDT.cphp b/tests/acpi-test-data/pc/DSDT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..35dec608a3c30695c08ec6afe9e27f9c32ea516c
GIT binary patch
literal 6415
zcmb7IZEqXL5#GH!QpY7J9i_7@TXsaqPTZt*%oka9(4r7|M~Sp})R{-QF3u>AvW!wj
zS|1b}h++hg7(j9SEnr==-)MuM?Vr&8g#3i`FQjPfPf=&?xJQc80SN(7Gds^dGqW$V
zyVNbcF?Eg*`ntHGm92E~uBqwJMhPJ(<A0?h-6QtCUR-O^xFAvcAnwWVRg~4==*7)7
z`j58rcgK1BwL@Dj*?OhC*lM|7J#)4Qf}U)-jG>?`HmzdQ?#!E7B_lV>6+Kb-j)`)!
zpx24q+^pzSF=QW8lFMeP!9f&2V1_WtX2T!}LcaScP9*z4L4D><sivpRy53By%T23M
zATG8zE;hBkaG2us65n<m(sklTM}5+p{I=U7e`_VkfBqNglRlf0n_AsUrP$<Q3^E3C
zA`!Ajl=nZzXfRy6bI!b*&3myXL_#4HGn>~0!j6=c$Ouf6DpsNC<6vMBx0KNY<}e8N
zgFk(YEZCEf@-;G1HA^*0ZW2)|pde~R_@`(K*F^3Z+3e2MdP4(Jf5_r6SQzgdJF`Yz
z;u1wzBy^4Ll3gN1_lVuOv0l^zxG1VIZ&ZRry^aoX2!&qTWE=i33XreexngW=1|6qn
z#yiR^vPcvJ7UWf33np=55YarFTcbaSKZrzHqi@BxFi?vt<Ri)B&aPI?0-x+vy)vCv
z2#c@{mZ9to6WIIkH_hhR5&M+=$flSqH&^vi>MT=n8IFDgQ0&g{t7apJRU+z~KlM1I
zPA>}6-6t=lAZLXo*XZZs=b|hx?tAf+ByGdU@<EMIe+6<HoRBb@cj7yd$cu_cvx+pi
zF&ZWWJTRl7Ji<Excx2#F%JOg#?VFm_pmFk=$*{yx(O?a3rr}FZ+xu4O7HmcNHLj>Q
zDq1m9x&?+}&8XA3;u}!WinUE6ZPQ{^TPN!KrdGNo*q2Z{I&#}+bob~E!S41IZ0-}K
z23x4uRMr_TdsSymv)&-?w6O2Er1h#8d(mS1?iVd4kS+J=ZflD$k=*Yo-TMHF!M3T^
z)^)PoyWG7`d#P@VNkOwkwqGU#tpK1@_dXMXmg1mA3|cg@?S8qp#S{V?mpt1h#C_TV
zf6ullakrm2E%Kz*ckF}9*F=mK_X_SdYSwROWcbSBR}R1OvN}__4WrtNJ!SiC*z~bJ
zi>u3(+gd#afO;l1$>QHcNz7Ypd*nH`u?T!udhr)+$hnPjADit?bpq0a#q4j$1QZY~
zPcn>^m6~NU-%OI27=cyF;4cn;dqkb`_aFv=;i;*nUa`oRD6@U9WeRsS>0?Nqezs}V
zE&9CeM*-EWUcvT(_u`m$Sie8pdv?To*7Kf)_(r{F)ziIa?T&%DYh&J-@C)4MM%?E-
z_qj3mxe)icfqQ-2Jsc1}JNx{I`@H8qKjuCk;y!P8HYCX28h0=G?)ehJQv{}*m)*D;
z^(I@5`(uouLKDuevU1x$@K$5@hDG13mjV|o>MgFMW^Sg-j~=_9KKXNc_rYh6p6uR#
z@ENhGW>(h+<u}RL8YOSY8=8O`4U5XFB5zp2KDdNRfuuD&aI{LzqFUX!L!lsKD3LVH
z(4o{!BS_S&QZ)@oz0gS8ot3qFUSR_Fen`oJW>zwpYzCeBM|eavB(1UfN1?~MZE~n(
zGMOC|DT>*hUcB380?IjG7E#XovV`)IFGo<mzN40-Q1S{f`_jE@5<drVNHA3_T;t6U
zuuGiY`R=#@lXcmYV_!L8sjl}O)rjB#{4z&$oC+9D<yVckW@$A!EDhqkT9scoEb2Pr
zl#oy_dm<Ze)?k<&>YfM!Y%iC3xf6Z7Nya`*JlP41yAC~lbW|gzZCH&&SoEh(!ilh8
zUAa5s*}=kcnK0gp(1+uV06leV?XT7)SSuOWXYf%ISX<>jt{S4wHjP3<c2jXC6B(~y
zgtYoC*n7CvalVN<*@V>Mm>+5HJRFc^{cFZ389h!$=}9s=LPkBZ8b+4GI|@XW97YCr
zf@7fx0%uDEp#f$ph>ZzDzPxynPdv^iN~iFNqkQ6!ZwXH7@%W_Ud{X2TK53Ls8uDGo
z({3!^$Z@_%^c23xC|?Bl)On~kYi6lg%H+tPBx3Est)$eh4lhZa!d0Ve`UgSMteKfY
zW*JHnoWn`u!CxNj?xou&s--&P9m2g>*U)QqxFEtEz@~<GJ1RsCa6yJPC@J<Ov>hG2
z`rQi$d$^8)TXUvs;9fKadl8kFvpuzI;BNC;akru7Z!aY2Q}wEW1$l(l{b!qagz>IX
zvYLZZ<)Iz5FlWGl47JG*fn#N(zPyymv&{2f69O-hvCmIO{)aaY)FZgiU`I9y!B%~7
z8pN_Meo!s(){j6Ow9XoZy94Zb5X-JnFP5<r3RNTmp<2ccC{&ST7n@PQzNmO+?A=pe
zU>n+ZQKw#G%4?*LgBFykXsh=0i7qx1NI9QNEwBq;pB+sZQ^hnfMK8U4jxnHbLQWt~
zLf?Tn3jsA<^o(W~$<gRyoM^JIcw>&;0&#gsy=<6w4LUvnF0?kGW)7z5R|ZrO=>%xU
z*eKm`AA(Wyq3WUmr3Y@`$EOpP30&ZPh*F8-%J=RTgHslkwE78bg)G5396SpB8~jLv
zsnxtfc?_YRgPwWVM8P478wOXoQcC%!I^LT7$7FGW{q<Rr2=KPXF~u)<9KK7uOHdiw
zslU|Tg85w{(39Q_{C9L-7|aLWc=00;&w|??Kl0Jhzkc$?fB%S&NKJxt{YT{34#xJ8
zTMqmv&?vCDAE|fC`TouKZ>WSMw<NP{*8M>{UIrk!Q*KNrxyWnsnyT;y`|utV5G&uD
zj!IbRL0)Q3%M!dxp_+qs9W9uE^4sC?*`1G9|Ddh<0o*Pbn{X`U5Iq*L5>X;}FH>&q
z-Sb{phCDKXUMcg6(nyl<d|+e_uX1G*Uv`ACIs0G%6%n^!8aE_-RZ*&f1S>ObA6!I0
zfvhmEsKAnkQsq@9d^g$$XZ-$n%fm$qUzV0uqgb~D#dzc`i6U5GY~xlY15a%Hea7y5
zWMu~mECPY3kYZMc8j3=W3wadm&WBd^CUmqmYlGi+po>V<Y44!JXDB*AGeUDni%_^l
zgDZf-Yd!?ZStA@834`W2E8L%b)@Ue{vrcg6L>P35v%;?vKC2uG<*YFdjfFw4b5_Qo
zEELLFVK?{z#KWM=oHfCriBKqKO>$^540?mJPIBmED3r6p``C|lDhzs)vnm{_ghDxM
zibGRj&`&t)G>1-yLOJUUht7mS3!D{JzMqyF3gxV4IP^>yw8&X!IdnD@%305H=-Du+
z##!e$bS@OiS<i9kxiF~CS<iFm`A{flo#)W`FldRhUf|FRp-|3xkwY(rL038JdmQ>+
zD3r4<aOlEmP_;a-->Ef(UgBvR-WZ2i>vlXv0R^g=ucT4omK9K-BKekmRM3)q+K$5m
z<<Nq%GSCFn0-FRH6o-KgeO(W1=nS^_z=qzI0~@-7jXJQQzZ+<qdfJBS3P;<a1sjg*
zaJYd!w8Ig1Xu;Ouc6daAKC~;S!zSSNw5Jd4E2zVA=JtJ0AKJZ)VPSGR943dBHe$!D
zVTlEH%v&F^W9G0}0(%<u5&H`0FztbTA9b*+3wTe0AI$NWPn<$H>o(~?(3$vusm>r<

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/APIC.cphp b/tests/acpi-test-data/q35/APIC.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..1bf8a0a63bc1c9b716d937b96eb34b05016b9366
GIT binary patch
literal 160
zcmXwx!3}^Q3`JW6f}%UP3UJYrBwpObWgNv(oJ8%n@zB24pP!~WmxG9S&r6xsF>kdb
z$yhQtNOavFgY<9)W~DJWDKu7Tozi)bd+hVZHk}Lv=1?18ZTnj%1<hjo%=$-Oyrt<4
A0RR91

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/DSDT.cphp b/tests/acpi-test-data/q35/DSDT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..98f2aa3e0888f3e923fbc1dfaf4c3f23e59636df
GIT binary patch
literal 9177
zcmb7KTW{mW868TLOjEK=*|gVti-p~yY0_>YU$QNF305L?t3_Luw7EbFNZux`owN<%
zY=ERe0NVj_*@ps&x<UJ<UHCbFq4^1UYl=SgwXa2yeTsX&8IC+d$v{>Q)O^EpzHiQu
zoI{cF+kWSt*BLWdY1^x{^QBjso{v6*F-C3rcIxIG);;t~)t-?_m`3*~!`s-DEcYjV
z>2}rl>t6qhe*fObePcIdcON+q?(T*ke$v0o2=va~(6*`JJkx8JdfmgO*X|e@_NATW
z?UIqneo1N3U%J)w>LttB&T{B+HH)}l^=frLTm0I#tez)YNvl`%Tg>X+uKR}7zTIpx
z%j>in%=M>x+ilOh|0eVNmsf|Csli@u!FIaAzt+E9xpM1^m+uw7`qe*vd;d+_1Yix{
z7QWX*3MdaX)+yEdw6U+!cIbRQ*f&1Fo>h)s9WH%7kT}up(9V#+)c-Imda1<f$(v4K
z2|Z=2)+~3V9s?>ce#~yI*$G&dv9G_&FtdB)P`vO`dCSi?TYfL^-t4tIMHW&|KcueR
zKlN>=Kg@nM=(9mTb9#EhhO?gycG+Kcv+UphOP#P2dk(YJYUgtH>_^i$kVwu<#@=Jj
zt*Pf|I5f50V=rBA7khj<F@O~erde<8B<wyNo(9f`gneiyx<?nO&AjcPm}CaNO89Ct
zJAQ(r$_e|JP>Vp7nO7`t8D0sSMiU$7)`jPjvLaRM9^YtnJQNkjHG|_wBVD!^t47E|
z<|M8$qiP(m1C~g?$GXQq-7NVdcrxiu^Z6J_<itMfGXt#G*lYN{mVnak@zcTf?GbTq
zAx^aH)HUW1@I`1D0ZryEiy5c!_lIfB@(FurjtV;VOx1Wd`EJs(t{w71WfOC<Dix&+
zac0UiG$H4ud7ONlWY#r@r>RhywOATEG0KBEJvUF{aRPZP<guD{ufp7H58p<(N0IaA
zR}DG@j`tsaNi|!Y=KSW{hw~W|XAf&^ZI+p68)#S9e3ts{1cIszk_c*Se#Xq6o?>Yb
zxF{kPfU{yB=K(51Vj@4sCO8w=C?ckWCKzV|%9#j>iP3Ouk~8H9==|eZIW#GlfXa}V
zvI@?7f#rEj&XiD7Fy-J8syb7e&J<@#Xi6~U;1Q}i)0)mSXG&;V*NIToIi=~G(sWMg
zIuWWmElsDT>9lm62vwa}A(WY()^twmIuWWmZB3`G>9lp72vwaKO=m{anbCD3RCQvd
zQjTX<)0x$EB2;zGXgX&!oin;lgsRS2P3Nqpb5_@hP}Mo7>73Ja&gnW4syZD_r=#g~
zbe#xQojFZsPScswbs|)C&TBg7HJ$UiPK2t?1x@FIrgK5piBQ$)YC2s_r>pBksOntQ
zbS`Q-7j>NoRh>(k&LvIflCBe>s`G-T^Ma=Hg02&xs&iS>xvc42)^#FObzbDmVzd%o
z<jhjE*j*G%?<^#yA7L+P%u5>clFme^GB0b)%Np~t&P1p(uV~CG8uN<IM5r>aYRsz|
z^Qz87s4}18OzARDai(13pAt;Da3dt9bdnXV=89HxMX!la)U;rrMa4j??fS?-(MI9O
zKoOv<2$Be7Q5dMeaZ56Azr%sjF%tqRLt;v4Fi?S&2C6{GKn0XD$v_ceG}1r?Hj1dG
z^jb1d0Ua4ALJXZ_VW0vVMZ}boO9m>SoJj_XQ0jz%3M^;BKouw%sDN@N87M-j69y`<
zoCyO}pk$x|%9&)K2&GOKsK9b23{-)VfeI*Rl7S+WI$@v!%b74x1xf}gpqxnticso=
zfeI{V!ax-$8K{7ACK)I~sS^e&u$&14RiI>`0?L_Wpa`W-7^uK<CJa=8l7R{+XOe*;
zlsaLc0?U~&Pz6c`DxjQ628vMXgn<eyXTm@gC>f}LawZulLa7r5DzKah16818paRO7
zWS|J8P8g`bawZH^fs%m=C})y^B9uB|paRR8Fi-_b1}dPONd}5g>V$y`EN8+%6(|{~
zfN~}oC_<?d1}d<e2?JH2WS|1dnPi{{rA`>Az;Y%GRDqI#3Mglifg+STVW0xbnJ`cV
zN(L&RoJj_XQ0jz%3M^;BKouw%sDN@N87M-j69y`<oCyO}pk$x|%9&)K2&GOKsK9b2
z3{-)VfeI*Rl7S+WI$@v!%b74x1xf}gpqxnticso=fg(~26p?D62vq|`s2Hfign=qd
zGEjv{2C6V&pb8TPsxZkw6($*|!i0e;Oc<!bBm-5LWS|NY2C6V&pbC==RAG{VDohwC
zB6)OSponn9_+*lSBE(^kAu;9L!axzpxrKoul5<N2icroi87M-ZxtDsdP&UjC_>a{S
z`a$|IO<%?C(a)bx(yvr{RzOc9jAm=62*=$i(Z-{VZ!tU@*(p=ILYpdWYL>fD-@)Uh
z;q?3V;T|4>OrO{pccZ@JwWa}R6>_t7=F>Errbk=&rF@_I>=d^3@clh|j!_GPXyM67
zV+!{OMfqDii^nPSu*Sl$+qors;nP_*orJqFtltbPF|xUH;<*G30i!9pxt?Edvk$0k
zAM&0#deXs8Xh1x^&}+Ba#{Io$3{;-_qw1wtbv#!1-qlM=^%AdM!uZtcC3kZ5QujC@
z?Ov?9op^%so>Jc9<-J&W@0{{pRNjx5$K$f^t=?D4`@Fm#EAO9E-jB+c<K@jKC|_2}
zmwEYetbF;L^5v*}C0;)D1m!DA`3f&ziIuOMQ@#?Fug1%#pP+nIDPQH~tFiLcbIMnv
z^0j#RsV693Q_9zP`C6=e?VR#8ls9Q9i<fsqdAWGtwt^nB@u!x0pPS~FJih3<j?%?1
zV>_p(!@b5>I?*>V-Pm<GucyNe$XGhjH!<DVb+(|V!(GW(I?*>V-Pm>G>gjN+GL}yC
zO-wg-9W3hUaQ`xvPV`MoH+Ehx>FID&GnP*DO-wg-o?g(?;ZA2Po#@lkIk$Gi8-mL8
zowH}<%~rWB&qNy+ApB>>Yu?V+-ntk5{+-|D4_<%!t#=N7^ZMJYYk1AZW^_i**ml+U
zCi_j+$l}p9e23n*e3Qik{iEv?6j|P*=ki{Ct8I9#;3dN=|GHo>)AIt~>K@G#DCxD!
zjXaQkv6Jr}->Tl>FAY#$3~8q5HS2}KYJrN1moh0gFuhLY)x^*q?6Hr$LZPrvO@o@N
z`@_s&&rVQ#O|+BLUKeeX+8d&sqV@~>ZY_;BMaAjv^*hg-^7R2t2}wOY4fo>R7;wn?
z!%Kts4iX#MbN%kqV|yB#Cw(_a(F8nMAtRm&87Ag;gN)bqwyg7Hu>PZp^`LL3!+ty^
z1Pxcm)bOK*Y3>{0*dVa);l^-njKdEyaqQ$c2|Ew^#^l*?gK2NO-N~Le`iTc&Y*;w2
z!u_~9oLHfqi1!lojd&-Z6X&-3;iidmrGTppAH49u`C^^WS;O3=UQp~<VJ>4^3_t7X
zhHv*|*Uj|kT&LsB+*!OT>|{tE+uMI5O18>x4Yg#3p3E@DlNm}fgD2afk*(oj4UKH(
zY-D(wqYW*QklC`Mp#d{D8k?Os%eRhqAn|-jJzvtCkT0p`OP=N1z=NH5K2y(UrY7Vw
z)qLhzz8C0*IHotH=S!t0<V&gfQpo3C#(Gn2mV4#G8jF@hT6^eHa<*<LFEEQYf?88}
z*i3V)Stu56Vo9Q<GI;$DZymgs-y2&k-35N1KAau|{#FaG_V6R2YXl8%lexuofD-I%
zAC{Evb=r4&`skMr`oswP0bQC4gMhBZAi5SQc(^ol2LWAeyqB&vip1qbNlpy+MnDU)
zk~aL?9^(l!gP`2*MN1V&_ub-hfO~eVO=1WVYXz;F8@YA6aR0}QWyM*+r(SHnI~5<<
z6@{nx#Y04U7K3ew<~*7;(fnbfEPJ0tGwNLmimyc2OK8@@pjE07i5d+`ghr!A1Zp%W
z$pLj!gSZs%-NYWc52%m!A5d)Y&K&PF?u~k=)u4Tip+7aCZU)KgYq=Hs%ExffGsz^C
zWRgTKZ+*?Sk-i5_XwHHgHJ31;UPzT`cSy-;XGr6uUEQbooD*%-yt(22AZWf481VxT
zqPK@NGdfH^3b2ZpW1#(DyZlo426lP^>Rt=5^d!cB2D+mGIQ+!tz8{$^&S>`{u7q`5
z2_q+@vz|^>r=AtoEdDA%FVag>_8&i)VF^6tqluvnUW`A^KF%5z`VBF8-(vUU>?oe$
z)A(O?a&1g1{j#M`g7H0c?b7F~)6>6y7d2m`7wDdet5y6}BX${5zjCXBze041c1GMh
z^IMgCI-fT17T$U04zAqxdT%~$(h`gIMsMCS?SzeG6wwQ`hl)DCIFsBxey;MeCvFpG
zcFMtR_`w>XV^y4#lcF0U$D6&w--HL2a;wGH5WX5H1H(^yn=R8lRIM4b@ShdiUhW>P
zP>`f^KTlTzHVtYu(84K^?;c$xK#|?D`PGbb4Qm8n5^#v|N0&vxr`sz!JFsbcc{fc9
yM#8C>;%^z5cA<d(Bha5*y2sD93qKP94w=DlL)~8Wv20OeO*YnfBi;12I_&>n-<Wv-

literal 0
HcmV?d00001

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 40/42] tests: acpi: extend CPU hotplug test with NUMA support
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (38 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 39/42] tests: acpi: add expected tables for CPU hotplug case Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 41/42] tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM support Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 42/42] DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU Igor Mammedov
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 tests/bios-tables-test.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 670e6a8..1cf6a07 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -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);
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 41/42] tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM support
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (39 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 40/42] tests: acpi: extend CPU hotplug test with NUMA support Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  2016-05-02 12:33 ` [Qemu-devel] [RFC 42/42] DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU Igor Mammedov
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 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

diff --git a/tests/acpi-test-data/pc/DSDT.cphp b/tests/acpi-test-data/pc/DSDT.cphp
index 35dec608a3c30695c08ec6afe9e27f9c32ea516c..948a5ecaeffe7a7c971453e9e158519116d28cbd 100644
GIT binary patch
delta 247
zcmeA-x@OGf66_LkO_G6u(QhMHB|DRQ?BrJVc}(uXn^if!GqSm`I|oGgPM*u5KRJ*~
zWb#BVVTpuj^%#AY_+Y2_0B28wfFRdk=Kvq?B?*(IxfU>auuk5~Wi8JW57fo61f-Wi
zgfHGdIE337NHAn%W<@sx)o^j6s9{7>!w6R6!#X*f+m@RbVb0`<+#*as;pJ$;4<W+e
U(S!|oz^dJOPz>4J$kWFI0N#Z~dH?_b

delta 167
zcmca++;7C?66_MfFUi2bxNaj?B|DQt;N({Jc}x!On^if!Gftk!HJ{0wWwH^swGdyt
ze{cx5Gmv1&$jpjv1`79}2s46({a7YH<F*y%hpXmdf{DBEpolZW#22B8vp~fs@!D?o
I=I!PI0DJ*25dZ)H

diff --git a/tests/acpi-test-data/pc/SRAT.cphp b/tests/acpi-test-data/pc/SRAT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..ff2137642f488ec70b85207ed6c20e7351d61e98
GIT binary patch
literal 304
zcmWFzattwGWME)4bMklg2v%^42yhMtiUEZfKx_~V!f+sf!DmF1XF}yOvY_!<(fDl0
pd`1npO;83GTmZW|po75R12aq^syaB21u74tQT&BzFU&Ml8UVWm2>}2A

literal 0
HcmV?d00001

diff --git a/tests/acpi-test-data/q35/DSDT.cphp b/tests/acpi-test-data/q35/DSDT.cphp
index 98f2aa3e0888f3e923fbc1dfaf4c3f23e59636df..0d89375c616e22f7f7ba2b9650a7b2c7aca06c96 100644
GIT binary patch
delta 315
zcmccVzQB{qCD<iofeHfy<NS?Wjgn06v6Fix=P|hlZ`PIi&dBD%?i>)|JDE>fPlF*w
zpCvxnDL%m2(;y(oHQ3qN*QEem%*8Qe@_Q*MHcn^%;1Hh4{L*%lGi9QfJXj|mm9duR
zi3b|Su>@o!g9u+dPzg6k9YaQDR&+B^jgTyg8b%~Fj9@iBtdrwqZ54SD=5R5I@WTz_
mVuGn!kEV(lSrs!()qgZqEXb-@V5<D(Y`Kwa+}tS_zzP5~eODI%

delta 168
zcmZ4BdDETCCD<k8rZNKqBg00nMoA`zz{$Om^OzjmH|t7$XPi7!W<HZQ%VaBAYazaP
z|KJdAXCT3lk(m|U3>2P%BFqRD_G6j+PS#eKAFi5<2`26%ha%1l6JLcY&H@wXkhk3&
IEbq$-08V-^Pyhe`

diff --git a/tests/acpi-test-data/q35/SRAT.cphp b/tests/acpi-test-data/q35/SRAT.cphp
new file mode 100644
index 0000000000000000000000000000000000000000..ff2137642f488ec70b85207ed6c20e7351d61e98
GIT binary patch
literal 304
zcmWFzattwGWME)4bMklg2v%^42yhMtiUEZfKx_~V!f+sf!DmF1XF}yOvY_!<(fDl0
pd`1npO;83GTmZW|po75R12aq^syaB21u74tQT&BzFU&Ml8UVWm2>}2A

literal 0
HcmV?d00001

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 66+ messages in thread

* [Qemu-devel] [RFC 42/42] DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU
  2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
                   ` (40 preceding siblings ...)
  2016-05-02 12:33 ` [Qemu-devel] [RFC 41/42] tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM support Igor Mammedov
@ 2016-05-02 12:33 ` Igor Mammedov
  41 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-02 12:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: mst, ehabkost, marcel, eblake, armbru, drjones

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/pc.c      | 8 ++++++++
 include/qom/cpu.h | 2 +-
 qom/cpu.c         | 6 +++---
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2d29b5e..7072fb5 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -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;
diff --git a/include/qom/cpu.h b/include/qom/cpu.h
index b7a10f7..da55899 100644
--- a/include/qom/cpu.h
+++ b/include/qom/cpu.h
@@ -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:
diff --git a/qom/cpu.c b/qom/cpu.c
index c9007d3..f3210a2 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property
  2016-05-02 12:33 ` [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Igor Mammedov
@ 2016-05-10 20:19   ` Eduardo Habkost
  2016-05-11 13:33     ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-10 20:19 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Mon, May 02, 2016 at 02:33:19PM +0200, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

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?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 11/42] pc: add 2.7 machine
  2016-05-02 12:33 ` [Qemu-devel] [RFC 11/42] pc: add 2.7 machine Igor Mammedov
@ 2016-05-10 20:20   ` Eduardo Habkost
  0 siblings, 0 replies; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-10 20:20 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Mon, May 02, 2016 at 02:33:20PM +0200, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-02 12:33 ` [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types Igor Mammedov
@ 2016-05-10 20:24   ` Eduardo Habkost
  2016-05-11 13:50     ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-10 20:24 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> 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 <imammedo@redhat.com>

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?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
  2016-05-02 12:33 ` [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option Igor Mammedov
@ 2016-05-10 20:27   ` Eduardo Habkost
  2016-05-11 14:00     ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-10 20:27 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Mon, May 02, 2016 at 02:33:29PM +0200, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>

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?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily
  2016-05-02 12:33 ` [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily Igor Mammedov
@ 2016-05-10 20:28   ` Eduardo Habkost
  0 siblings, 0 replies; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-10 20:28 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Mon, May 02, 2016 at 02:33:32PM +0200, Igor Mammedov wrote:
> 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.
> 
> 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?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling
  2016-05-02 12:33 ` [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling Igor Mammedov
@ 2016-05-10 21:07   ` Eric Blake
  2016-05-11 14:02     ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Eric Blake @ 2016-05-10 21:07 UTC (permalink / raw)
  To: Igor Mammedov, qemu-devel; +Cc: mst, ehabkost, marcel, armbru, drjones

[-- Attachment #1: Type: text/plain, Size: 767 bytes --]

On 05/02/2016 06:33 AM, Igor Mammedov wrote:
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  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
> @@ -4019,7 +4019,7 @@
>  #
>  # @DIMM: memory slot
>  #
> -{ 'enum': 'ACPISlotType', 'data': [ 'DIMM' ] }
> +{ 'enum': 'ACPISlotType', 'data': [ 'DIMM', 'CPU' ] }

Missing documentation of the new value.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property
  2016-05-10 20:19   ` Eduardo Habkost
@ 2016-05-11 13:33     ` Igor Mammedov
  0 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-11 13:33 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Tue, 10 May 2016 17:19:35 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, May 02, 2016 at 02:33:19PM +0200, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>  
> 
> 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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-10 20:24   ` Eduardo Habkost
@ 2016-05-11 13:50     ` Igor Mammedov
  2016-05-11 21:51       ` Michael S. Tsirkin
  2016-05-11 23:36       ` [Qemu-devel] " Eduardo Habkost
  0 siblings, 2 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-11 13:50 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Tue, 10 May 2016 17:24:14 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > 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 <imammedo@redhat.com>  
> 
> 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?

> Should max_cpus > smp_cpus automatically 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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
  2016-05-10 20:27   ` Eduardo Habkost
@ 2016-05-11 14:00     ` Igor Mammedov
  2016-05-11 15:00       ` Eduardo Habkost
  0 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-11 14:00 UTC (permalink / raw)
  To: Eduardo Habkost; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Tue, 10 May 2016 17:27:18 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, May 02, 2016 at 02:33:29PM +0200, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>  
> 
> 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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling
  2016-05-10 21:07   ` Eric Blake
@ 2016-05-11 14:02     ` Igor Mammedov
  0 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-11 14:02 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, mst, ehabkost, marcel, armbru, drjones

On Tue, 10 May 2016 15:07:40 -0600
Eric Blake <eblake@redhat.com> wrote:

> On 05/02/2016 06:33 AM, Igor Mammedov wrote:
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> >  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
> > @@ -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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option
  2016-05-11 14:00     ` Igor Mammedov
@ 2016-05-11 15:00       ` Eduardo Habkost
  0 siblings, 0 replies; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-11 15:00 UTC (permalink / raw)
  To: Igor Mammedov; +Cc: qemu-devel, mst, marcel, eblake, armbru, drjones

On Wed, May 11, 2016 at 04:00:19PM +0200, Igor Mammedov wrote:
> On Tue, 10 May 2016 17:27:18 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Mon, May 02, 2016 at 02:33:29PM +0200, Igor Mammedov wrote:
> > > Signed-off-by: Igor Mammedov <imammedo@redhat.com>  
> > 
> > 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.

> 
> 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);
        }
    }


-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-11 13:50     ` Igor Mammedov
@ 2016-05-11 21:51       ` Michael S. Tsirkin
  2016-05-11 23:28         ` Eduardo Habkost
  2016-05-11 23:36       ` [Qemu-devel] " Eduardo Habkost
  1 sibling, 1 reply; 66+ messages in thread
From: Michael S. Tsirkin @ 2016-05-11 21:51 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, qemu-devel, marcel, eblake, armbru, drjones

On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:
> On Tue, 10 May 2016 17:24:14 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > > 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 <imammedo@redhat.com>  
> > 
> > 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.


> > Should max_cpus > smp_cpus automatically 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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-11 21:51       ` Michael S. Tsirkin
@ 2016-05-11 23:28         ` Eduardo Habkost
  2016-05-12  7:07           ` Michael S. Tsirkin
  0 siblings, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-11 23:28 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Igor Mammedov, qemu-devel, marcel, eblake, armbru, drjones

On Thu, May 12, 2016 at 12:51:55AM +0300, Michael S. Tsirkin wrote:
> On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:
> > On Tue, 10 May 2016 17:24:14 -0300
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > 
> > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > > > 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 <imammedo@redhat.com>  
> > > 
> > > 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.

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.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-11 13:50     ` Igor Mammedov
  2016-05-11 21:51       ` Michael S. Tsirkin
@ 2016-05-11 23:36       ` Eduardo Habkost
  2016-05-12  7:05         ` Michael S. Tsirkin
  1 sibling, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-11 23:36 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: qemu-devel, mst, marcel, eblake, armbru, drjones, libvir-list

On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:
> On Tue, 10 May 2016 17:24:14 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > > 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 <imammedo@redhat.com>  
> > 
> > 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)

> 
> > Should max_cpus > smp_cpus automatically 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.

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?

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-11 23:36       ` [Qemu-devel] " Eduardo Habkost
@ 2016-05-12  7:05         ` Michael S. Tsirkin
  2016-05-12 10:39           ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Michael S. Tsirkin @ 2016-05-12  7:05 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Igor Mammedov, qemu-devel, marcel, eblake, armbru, drjones, libvir-list

On Wed, May 11, 2016 at 08:36:00PM -0300, Eduardo Habkost wrote:
> On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:
> > On Tue, 10 May 2016 17:24:14 -0300
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > 
> > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > > > 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 <imammedo@redhat.com>  
> > > 
> > > 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)

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.
 
> > 
> > > Should max_cpus > smp_cpus automatically 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.
> 
> 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?
> 
> -- 
> Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-11 23:28         ` Eduardo Habkost
@ 2016-05-12  7:07           ` Michael S. Tsirkin
  2016-05-12 10:29             ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Michael S. Tsirkin @ 2016-05-12  7:07 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Igor Mammedov, qemu-devel, marcel, eblake, armbru, drjones

On Wed, May 11, 2016 at 08:28:59PM -0300, Eduardo Habkost wrote:
> On Thu, May 12, 2016 at 12:51:55AM +0300, Michael S. Tsirkin wrote:
> > On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:
> > > On Tue, 10 May 2016 17:24:14 -0300
> > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > 
> > > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:
> > > > > 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 <imammedo@redhat.com>  
> > > > 
> > > > 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.
> 
> People who don't need CPU hotplug shouldn't be using the max_cpus
> option.

I agree.

> 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.

> -- 
> Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12  7:07           ` Michael S. Tsirkin
@ 2016-05-12 10:29             ` Igor Mammedov
  2016-05-12 10:52               ` Eduardo Habkost
  0 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-12 10:29 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Eduardo Habkost, qemu-devel, marcel, eblake, armbru, drjones

On Thu, 12 May 2016 10:07:03 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Wed, May 11, 2016 at 08:28:59PM -0300, Eduardo Habkost wrote:
> > On Thu, May 12, 2016 at 12:51:55AM +0300, Michael S. Tsirkin wrote:  
> > > On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:  
> > > > On Tue, 10 May 2016 17:24:14 -0300
> > > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > >   
> > > > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:  
> > > > > > 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 <imammedo@redhat.com>    
> > > > > 
> > > > > 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.  
> > 
> > People who don't need CPU hotplug shouldn't be using the max_cpus
> > option.  
> 
> I agree.
> 
> > 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.

> 
> > -- 
> > Eduardo  

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12  7:05         ` Michael S. Tsirkin
@ 2016-05-12 10:39           ` Igor Mammedov
  0 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-12 10:39 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Eduardo Habkost, qemu-devel, marcel, eblake, armbru, drjones,
	libvir-list

On Thu, 12 May 2016 10:05:54 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> On Wed, May 11, 2016 at 08:36:00PM -0300, Eduardo Habkost wrote:
> > On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:  
> > > On Tue, 10 May 2016 17:24:14 -0300
> > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >   
> > > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:  
> > > > > 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 <imammedo@redhat.com>    
> > > > 
> > > > 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?
if older libvirt are running older machine version, it won't break it.
but it would break old libvirt for new machine types.

> > 
> > (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.


> > >   
> > > > Should max_cpus > smp_cpus automatically 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.  
> > 
> > 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?
> > 
> > -- 
> > Eduardo  

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12 10:29             ` Igor Mammedov
@ 2016-05-12 10:52               ` Eduardo Habkost
  2016-05-12 11:04                 ` [Qemu-devel] [libvirt] " Peter Krempa
  0 siblings, 1 reply; 66+ messages in thread
From: Eduardo Habkost @ 2016-05-12 10:52 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Michael S. Tsirkin, qemu-devel, marcel, eblake, armbru, drjones,
	libvir-list

On Thu, May 12, 2016 at 12:29:55PM +0200, Igor Mammedov wrote:
> On Thu, 12 May 2016 10:07:03 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > On Wed, May 11, 2016 at 08:28:59PM -0300, Eduardo Habkost wrote:
> > > On Thu, May 12, 2016 at 12:51:55AM +0300, Michael S. Tsirkin wrote:  
> > > > On Wed, May 11, 2016 at 03:50:39PM +0200, Igor Mammedov wrote:  
> > > > > On Tue, 10 May 2016 17:24:14 -0300
> > > > > Eduardo Habkost <ehabkost@redhat.com> wrote:
> > > > >   
> > > > > > On Mon, May 02, 2016 at 02:33:21PM +0200, Igor Mammedov wrote:  
> > > > > > > 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 <imammedo@redhat.com>    
> > > > > > 
> > > > > > 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.  
> > > 
> > > People who don't need CPU hotplug shouldn't be using the max_cpus
> > > option.  
> > 
> > I agree.
> > 
> > > 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.

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.

-- 
Eduardo

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12 10:52               ` Eduardo Habkost
@ 2016-05-12 11:04                 ` Peter Krempa
  2016-05-12 13:20                   ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Peter Krempa @ 2016-05-12 11:04 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Igor Mammedov, drjones, Michael S. Tsirkin, libvir-list,
	qemu-devel, marcel

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

On Thu, May 12, 2016 at 07:52:23 -0300, Eduardo Habkost wrote:
> 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.

Libvirt uses maxcpus only if the configuration explicitly has less
active cpus than the maximum number. This option would be the best IMO.

> 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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12 11:04                 ` [Qemu-devel] [libvirt] " Peter Krempa
@ 2016-05-12 13:20                   ` Igor Mammedov
  2016-05-12 13:27                     ` Peter Krempa
  0 siblings, 1 reply; 66+ messages in thread
From: Igor Mammedov @ 2016-05-12 13:20 UTC (permalink / raw)
  To: Peter Krempa
  Cc: Eduardo Habkost, drjones, Michael S. Tsirkin, libvir-list,
	qemu-devel, marcel

On Thu, 12 May 2016 13:04:23 +0200
Peter Krempa <pkrempa@redhat.com> wrote:

> On Thu, May 12, 2016 at 07:52:23 -0300, Eduardo Habkost wrote:
> > 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.  
> 
> Libvirt uses maxcpus only if the configuration explicitly has less
> active cpus than the maximum number. This option would be the best IMO.
> 
> > 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.
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


> 
> Peter

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12 13:20                   ` Igor Mammedov
@ 2016-05-12 13:27                     ` Peter Krempa
  2016-05-12 14:30                       ` Igor Mammedov
  0 siblings, 1 reply; 66+ messages in thread
From: Peter Krempa @ 2016-05-12 13:27 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Eduardo Habkost, drjones, Michael S. Tsirkin, libvir-list,
	qemu-devel, marcel

[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

On Thu, May 12, 2016 at 15:20:51 +0200, Igor Mammedov wrote:
> On Thu, 12 May 2016 13:04:23 +0200
> Peter Krempa <pkrempa@redhat.com> wrote:
> 
> > On Thu, May 12, 2016 at 07:52:23 -0300, Eduardo Habkost wrote:
> > > 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.  
> > 
> > Libvirt uses maxcpus only if the configuration explicitly has less
> > active cpus than the maximum number. This option would be the best IMO.
> > 
> > > 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.
> 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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 66+ messages in thread

* Re: [Qemu-devel] [libvirt] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types
  2016-05-12 13:27                     ` Peter Krempa
@ 2016-05-12 14:30                       ` Igor Mammedov
  0 siblings, 0 replies; 66+ messages in thread
From: Igor Mammedov @ 2016-05-12 14:30 UTC (permalink / raw)
  To: Peter Krempa
  Cc: Eduardo Habkost, drjones, Michael S. Tsirkin, libvir-list,
	qemu-devel, marcel

On Thu, 12 May 2016 15:27:04 +0200
Peter Krempa <pkrempa@redhat.com> wrote:

> On Thu, May 12, 2016 at 15:20:51 +0200, Igor Mammedov wrote:
> > On Thu, 12 May 2016 13:04:23 +0200
> > Peter Krempa <pkrempa@redhat.com> wrote:
> >   
> > > On Thu, May 12, 2016 at 07:52:23 -0300, Eduardo Habkost wrote:  
> > > > 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.    
> > > 
> > > Libvirt uses maxcpus only if the configuration explicitly has less
> > > active cpus than the maximum number. This option would be the best IMO.
> > >   
> > > > 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.  
> > 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.
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:

> On Wed, 11 May 2016 15:50:39 +0200
> Igor Mammedov <imammedo@redhat.com> wrote:
> 
> > On Tue, 10 May 2016 17:24:14 -0300
> > Eduardo Habkost <ehabkost@redhat.com> wrote:
> [...]
> > > Should max_cpus > smp_cpus automatically 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.

^ permalink raw reply	[flat|nested] 66+ messages in thread

end of thread, other threads:[~2016-05-12 14:30 UTC | newest]

Thread overview: 66+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-02 12:33 [Qemu-devel] [RFC 00/42] ACPI CPU hotplug refactoring to support more than 255 CPUs and PXM/OST methods Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 01/42] acpi: add aml_debug() Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 02/42] acpi: add aml_refof() Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 03/42] pc: acpi: remove AML for empty/not used GPE handlers Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 04/42] pc: acpi: consolidate CPU hotplug AML Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 05/42] pc: acpi: consolidate \GPE._E02 with the rest of " Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 06/42] pc: acpi: cpu-hotplug: make AML CPU_foo defines local to cpu_hotplug_acpi_table.c Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 07/42] pc: acpi: mark current CPU hotplug functions as legacy Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 08/42] pc: acpi: consolidate legacy CPU hotplug in one file Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 09/42] pc: acpi: simplify build_legacy_cpu_hotplug_aml() signature Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 10/42] pc: piix4/ich9: add 'cpu-hotplug-legacy' property Igor Mammedov
2016-05-10 20:19   ` Eduardo Habkost
2016-05-11 13:33     ` Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 11/42] pc: add 2.7 machine Igor Mammedov
2016-05-10 20:20   ` Eduardo Habkost
2016-05-02 12:33 ` [Qemu-devel] [RFC 12/42] pc: initialize legacy hotplug only for 2.6 and older machine types Igor Mammedov
2016-05-10 20:24   ` Eduardo Habkost
2016-05-11 13:50     ` Igor Mammedov
2016-05-11 21:51       ` Michael S. Tsirkin
2016-05-11 23:28         ` Eduardo Habkost
2016-05-12  7:07           ` Michael S. Tsirkin
2016-05-12 10:29             ` Igor Mammedov
2016-05-12 10:52               ` Eduardo Habkost
2016-05-12 11:04                 ` [Qemu-devel] [libvirt] " Peter Krempa
2016-05-12 13:20                   ` Igor Mammedov
2016-05-12 13:27                     ` Peter Krempa
2016-05-12 14:30                       ` Igor Mammedov
2016-05-11 23:36       ` [Qemu-devel] " Eduardo Habkost
2016-05-12  7:05         ` Michael S. Tsirkin
2016-05-12 10:39           ` Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 13/42] tests: bios-tables-test: update tables with CPHP turned off by default Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 14/42] tests: acpi: check legacy CPU hotplug AML is present for 2.6 machine type Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 15/42] acpi: extend ACPI interface to provide send_event hook Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 16/42] pc: use AcpiDeviceIfClass.send_event to issue GPE events Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 17/42] docs: update ACPI CPU hotplug spec with new protocol Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 18/42] acpi: hardware side of CPU hotplug Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 19/42] pc: add generic CPU unplug callbacks Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 20/42] machine: add cpu-hotplug machine option Igor Mammedov
2016-05-10 20:27   ` Eduardo Habkost
2016-05-11 14:00     ` Igor Mammedov
2016-05-11 15:00       ` Eduardo Habkost
2016-05-02 12:33 ` [Qemu-devel] [RFC 21/42] pc: q35: initialize new CPU hotplug hw Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 22/42] pc: piix4: " Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 23/42] tests: pc-cpu-test: turn on cpu-hotplug explicily Igor Mammedov
2016-05-10 20:28   ` Eduardo Habkost
2016-05-02 12:33 ` [Qemu-devel] [RFC 24/42] pc: acpi: cpuhp-legacy: switch ProcessorID to possible_cpus idx Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 25/42] tests: acpi: update cphp_legacy case with new ProcessorID values Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 26/42] pc: acpi: introduce AcpiDeviceIfClass.madt_cpu hook Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 27/42] acpi: add CPU devices AML to DSDT Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 28/42] acpi: add CPU hotplug methods " Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 29/42] tests: acpi: update expected files with new CPU AML description Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 30/42] qdev: hotplug: Introduce HotplugHandler.pre_plug() callback Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 31/42] pc: numa: replace node_cpu indexing by apic_id with possible_cpus index Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 32/42] pc: set X86CPU.node property if QEMU starts with numa enabled Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 33/42] target-i386: add X86CPU.node property Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 34/42] acpi: cpuhp: add command and data registers Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 35/42] acpi: cpuhp: provide cpu._PXM method if running in numa mode Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 36/42] acpi: cpuhp: add cpu._OST handling Igor Mammedov
2016-05-10 21:07   ` Eric Blake
2016-05-11 14:02     ` Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 37/42] tests: acpi: report names of expected files in verbose mode Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 38/42] tests: acpi: add CPU hotplug testcase Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 39/42] tests: acpi: add expected tables for CPU hotplug case Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 40/42] tests: acpi: extend CPU hotplug test with NUMA support Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 41/42] tests: acpi: cpuhp: add expected SRAT tables and update DSDT with _PXM support Igor Mammedov
2016-05-02 12:33 ` [Qemu-devel] [RFC 42/42] DO NOT APPLY: simulate CPU unplug when executin cpu-add on a present CPU Igor Mammedov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.