qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support
@ 2019-08-13 21:05 Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
                   ` (12 more replies)
  0 siblings, 13 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This series is an attempt to provide device memory hotplug support 
on ARM virt platform. This is based on Eric's recent works here[1]
and carries some of the pc-dimm related patches dropped from his
series.

The kernel support for arm64 memory hot add was added recently by
Robin and hence the guest kernel should be => 5.0-rc1.

NVDIM support is not included currently as we still have an unresolved
issue while hot adding NVDIMM[2]. However NVDIMM cold plug patches
can be included, but not done for now, for keeping it simple.

This makes use of GED device to sent hotplug ACPI events to the
Guest. GED code is based on Nemu. Thanks to the efforts of Samuel and
Sebastien to add the hardware-reduced support to Nemu using GED
device[3]. (Please shout if I got the author/signed-off wrong for
those patches or missed any names).

This is sanity tested on a HiSilicon ARM64 platform and appreciate
any further testing.

Note:
Attempted adding dimm_pxm test case to bios-tables-test for arm/virt.
But noticed the issue decribed here[5]. This is under investigation 
now.

Thanks,
Shameer

[1] https://patchwork.kernel.org/cover/10837565/
[2] https://patchwork.kernel.org/cover/10783589/
[3] https://github.com/intel/nemu/blob/topic/virt-x86/hw/acpi/ged.c
[4] http://lists.infradead.org/pipermail/linux-arm-kernel/2019-May/651763.html
[5] https://www.mail-archive.com/qemu-devel@nongnu.org/msg632651.html

v8 --> v9
 -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
 -Re-arranged patches 8 and 9.
 -Added GED ABI documentation(patch #10).
 -Added numamem and memhp tests to arm/virt(#11 and #12)
 -Dropped few R-by tags as code has changed a bit.
 -Please see Individual patch history for details.
 
v7 --> v8
 -Addressed comments from Igor.Please see individual patches.
 -Updated bios-tables-test-allowed-diff.h to avoid "make check"
  failure (patch #6) and dropped patch #10
 -Added Igor's R-by to patches 4 & 5.
 -Dropped Erics's R-by from patch #9 for now.

v6 --> v7
- Added 4.2 machine support and restricted GED creation for < 4.2
  This is to address the migration test fail reported by Eric.
- Included "tests: Update DSDT ACPI table.." patch(#10) from Eric
  to fix the "make check" bios-tables-test failure.
  
v5 --> v6

-Addressed comments from Eric.
-Added R-by from Eric and Igor.

v4 --> v5
-Removed gsi/ged-irq routing in virt.
-Added Migration support.
-Dropped support for DT coldplug case based on the discussions
 here[4]
-Added system_powerdown support through GED.

v3 --> v4
Addressed comments from Igor and Eric,
-Renamed "virt-acpi" to "acpi-ged".
-Changed ged device parent to TYPE_DEVICE.
-Introduced DT memory node property "hotpluggable" to resolve device
 memory being treated as early boot memory issue(patch #7).
-Combined patches #3 and #9 from v3 into #3.

v2 --> v3

Addressed comments from Igor and Eric,
-Made virt acpi device platform independent and moved
 to hw/acpi/generic_event_device.c
-Moved ged specific code into hw/acpi/generic_event_device.c
-Introduced an opt-in feature "fdt" to resolve device-memory being
 treated as early boot memory.
-Dropped patch #1 from v2.

RFC --> v2

-Use GED device instead of GPIO for ACPI hotplug events.
-Removed NVDIMM support for now.
-Includes dropped patches from Eric's v9 series.

Eric Auger (1):
  hw/arm/virt: Add memory hotplug framework

Samuel Ortiz (2):
  hw/acpi: Do not create memory hotplug method when handler is not
    defined
  hw/acpi: Add ACPI Generic Event Device Support

Shameer Kolothum (9):
  hw/acpi: Make ACPI IO address space configurable
  hw/arm/virt: Add 4.2 machine type
  hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  hw/arm/virt-acpi-build: Add PC-DIMM in SRAT
  hw/arm: Factor out powerdown notifier from GPIO
  hw/arm: Use GED for system_powerdown event
  docs/specs: Add ACPI GED documentation
  tests: add dummy ACPI tables for arm/virt board
  tests: Add bios tests to arm/virt

 docs/specs/acpi_hw_reduced_hotplug.txt |  60 +++++
 hw/acpi/Kconfig                        |   4 +
 hw/acpi/Makefile.objs                  |   1 +
 hw/acpi/generic_event_device.c         | 324 +++++++++++++++++++++++++
 hw/acpi/memory_hotplug.c               |  39 +--
 hw/arm/Kconfig                         |   4 +
 hw/arm/virt-acpi-build.c               |  31 ++-
 hw/arm/virt.c                          | 136 ++++++++++-
 hw/core/machine.c                      |   3 +
 hw/i386/acpi-build.c                   |   4 +-
 hw/i386/pc.c                           |   3 +
 include/hw/acpi/acpi_dev_interface.h   |   1 +
 include/hw/acpi/generic_event_device.h | 103 ++++++++
 include/hw/acpi/memory_hotplug.h       |   9 +-
 include/hw/arm/virt.h                  |   5 +
 include/hw/boards.h                    |   3 +
 include/hw/i386/pc.h                   |   3 +
 tests/bios-tables-test-allowed-diff.h  |   2 +
 tests/bios-tables-test.c               |  49 ++++
 tests/data/acpi/virt/SLIT              | Bin 0 -> 48 bytes
 tests/data/acpi/virt/SRAT              | Bin 0 -> 224 bytes
 21 files changed, 746 insertions(+), 38 deletions(-)
 create mode 100644 docs/specs/acpi_hw_reduced_hotplug.txt
 create mode 100644 hw/acpi/generic_event_device.c
 create mode 100644 include/hw/acpi/generic_event_device.h
 create mode 100644 tests/data/acpi/virt/SLIT
 create mode 100644 tests/data/acpi/virt/SRAT

-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-15  8:42   ` Shameerali Kolothum Thodi
  2019-09-01 11:17   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined Shameer Kolothum
                   ` (11 subsequent siblings)
  12 siblings, 2 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This is in preparation for adding support for ARM64 platforms
where it doesn't use port mapped IO for ACPI IO space. We are
making changes so that MMIO region can be accommodated
and board can pass the base address into the aml build function.

Also move few MEMORY_* definitions to header so that other memory
hotplug event signalling mechanisms (eg. Generic Event Device on
HW-reduced acpi platforms) can use the same from their respective
event handler code.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
v8 --> v9
  -base address is an input into build_memory_hotplug_aml()
  -Removed R-by tags from Igor and Eric for now.
---
 hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
 hw/i386/acpi-build.c             |  4 +++-
 hw/i386/pc.c                     |  3 +++
 include/hw/acpi/memory_hotplug.h |  9 +++++++--
 include/hw/i386/pc.h             |  3 +++
 5 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 297812d5f7..1734d4b44f 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -29,12 +29,7 @@
 #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
 #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
 #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
-#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
 #define MEMORY_HOTPLUG_DEVICE        "MHPD"
-#define MEMORY_HOTPLUG_IO_LEN         24
-#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
-
-static uint16_t memhp_io_base;
 
 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
 {
@@ -209,7 +204,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = {
 };
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state, uint16_t io_base)
+                              MemHotplugState *state, hwaddr io_base)
 {
     MachineState *machine = MACHINE(qdev_get_machine());
 
@@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
         return;
     }
 
-    assert(!memhp_io_base);
-    memhp_io_base = io_base;
     state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
     memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,
                           "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN);
-    memory_region_add_subregion(as, memhp_io_base, &state->io);
+    memory_region_add_subregion(as, io_base, &state->io);
 }
 
 /**
@@ -342,7 +335,8 @@ const VMStateDescription vmstate_memory_hotplug = {
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               const char *res_root,
-                              const char *event_handler_method)
+                              const char *event_handler_method,
+                              AmlRegionSpace rs, hwaddr memhp_io_base)
 {
     int i;
     Aml *ifctx;
@@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
             aml_name_decl("_UID", aml_string("Memory hotplug resources")));
 
         crs = aml_resource_template();
-        aml_append(crs,
-            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
-                   MEMORY_HOTPLUG_IO_LEN)
-        );
+        if (rs == AML_SYSTEM_IO) {
+            aml_append(crs,
+                aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
+                       MEMORY_HOTPLUG_IO_LEN)
+            );
+        } else {
+            aml_append(crs, aml_memory32_fixed(memhp_io_base,
+                            MEMORY_HOTPLUG_IO_LEN, AML_READ_WRITE));
+        }
         aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
 
         aml_append(mem_ctrl_dev, aml_operation_region(
-            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
+            MEMORY_HOTPLUG_IO_REGION, rs,
             aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
         );
 
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index f3fdfefcd5..e76d6631ea 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
-    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
+    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
+                             "\\_GPE._E03", AML_SYSTEM_IO,
+                             pcms->memhp_io_base);
 
     scope =  aml_scope("_GPE");
     {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 549c437050..be973cea99 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
 
     /* Init default IOAPIC address space */
     pcms->ioapic_as = &address_space_memory;
+
+    /* Init ACPI memory hotplug IO base address */
+    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
 }
 
 /*
diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
index 77c65765d6..dfe9cf3fde 100644
--- a/include/hw/acpi/memory_hotplug.h
+++ b/include/hw/acpi/memory_hotplug.h
@@ -5,6 +5,10 @@
 #include "hw/acpi/acpi.h"
 #include "hw/acpi/aml-build.h"
 
+#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
+#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
+#define MEMORY_HOTPLUG_IO_LEN         24
+
 /**
  * MemStatus:
  * @is_removing: the memory device in slot has been requested to be ejected.
@@ -29,7 +33,7 @@ typedef struct MemHotplugState {
 } MemHotplugState;
 
 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
-                              MemHotplugState *state, uint16_t io_base);
+                              MemHotplugState *state, hwaddr io_base);
 
 void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
                          DeviceState *dev, Error **errp);
@@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
 
 void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
                               const char *res_root,
-                              const char *event_handler_method);
+                              const char *event_handler_method,
+                              AmlRegionSpace rs, hwaddr memhp_io_base);
 #endif
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 859b64c51d..49b47535cf 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -69,6 +69,9 @@ struct PCMachineState {
     /* Address space used by IOAPIC device. All IOAPIC interrupts
      * will be translated to MSI messages in the address space. */
     AddressSpace *ioapic_as;
+
+    /* ACPI Memory hotplug IO base address */
+    hwaddr memhp_io_base;
 };
 
 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support Shameer Kolothum
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

From: Samuel Ortiz <sameo@linux.intel.com>

With Hardware-reduced ACPI, the GED device will manage ACPI
hotplug entirely. As a consequence, make the memory specific
events AML generation optional. The code will only be added
when the method name is not NULL.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/acpi/memory_hotplug.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
index 1734d4b44f..552f60a716 100644
--- a/hw/acpi/memory_hotplug.c
+++ b/hw/acpi/memory_hotplug.c
@@ -715,10 +715,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
     }
     aml_append(table, dev_container);
 
-    method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
-    aml_append(method,
-        aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD));
-    aml_append(table, method);
+    if (event_handler_method) {
+        method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED);
+        aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "."
+                                     MEMORY_SLOT_SCAN_METHOD));
+        aml_append(table, method);
+    }
 
     g_free(mhp_res_path);
 }
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-09-01 11:17   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework Shameer Kolothum
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

From: Samuel Ortiz <sameo@linux.intel.com>

The ACPI Generic Event Device (GED) is a hardware-reduced specific
device[ACPI v6.1 Section 5.6.9] that handles all platform events,
including the hotplug ones. This patch generates the AML code that
defines GEDs.

Platforms need to specify their own GED Event bitmap to describe
what kind of events they want to support through GED.  Also this
uses a a single interrupt for the  GED device, relying on IO
memory region to communicate the type of device affected by the
interrupt. This way, we can support up to 32 events with a unique
interrupt.

This supports only memory hotplug for now.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
v8 --> v9
 -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
 -Removed Eric's R-by tag for now.

v7 --> v8.
 -Removed qemu_mutex_lock() across the ged state selector access.
 -Rephrased comments section in acpi_ged_send_event().
 -Moved acpi_ged_event() code into acpi_ged_send_event().
 -Added check for memhp_base and ged_base in realize().
---
 hw/acpi/Kconfig                        |   4 +
 hw/acpi/Makefile.objs                  |   1 +
 hw/acpi/generic_event_device.c         | 316 +++++++++++++++++++++++++
 include/hw/acpi/generic_event_device.h | 100 ++++++++
 4 files changed, 421 insertions(+)
 create mode 100644 hw/acpi/generic_event_device.c
 create mode 100644 include/hw/acpi/generic_event_device.h

diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
index 7c59cf900b..12e3f1e86e 100644
--- a/hw/acpi/Kconfig
+++ b/hw/acpi/Kconfig
@@ -31,3 +31,7 @@ config ACPI_VMGENID
     bool
     default y
     depends on PC
+
+config ACPI_HW_REDUCED
+    bool
+    depends on ACPI
diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
index 9bb2101e3b..655a9c1973 100644
--- a/hw/acpi/Makefile.objs
+++ b/hw/acpi/Makefile.objs
@@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
 common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
 common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
 common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
+common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o
 common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
 
 common-obj-y += acpi_interface.o
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
new file mode 100644
index 0000000000..f4c23470c2
--- /dev/null
+++ b/hw/acpi/generic_event_device.c
@@ -0,0 +1,316 @@
+/*
+ *
+ * Copyright (c) 2018 Intel Corporation
+ * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd
+ * Written by Samuel Ortiz, Shameer Kolothum
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ */
+
+#include "qemu/osdep.h"
+#include "qapi/error.h"
+#include "exec/address-spaces.h"
+#include "hw/acpi/acpi.h"
+#include "hw/acpi/generic_event_device.h"
+#include "hw/mem/pc-dimm.h"
+#include "qemu/error-report.h"
+
+static const uint32_t ged_supported_events[] = {
+    ACPI_GED_MEM_HOTPLUG_EVT,
+};
+
+/*
+ * The ACPI Generic Event Device (GED) is a hardware-reduced specific
+ * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
+ * including the hotplug ones. Platforms need to specify their own
+ * GED Event bitmap to describe what kind of events they want to support
+ * through GED. This routine uses a single interrupt for the GED device,
+ * relying on IO memory region to communicate the type of device
+ * affected by the interrupt. This way, we can support up to 32 events
+ * with a unique interrupt.
+ */
+void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
+                   uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base)
+{
+    AcpiGedState *s = ACPI_GED(hotplug_dev);
+    Aml *crs = aml_resource_template();
+    Aml *evt, *field;
+    Aml *dev = aml_device("%s", name);
+    Aml *evt_sel = aml_local(0);
+    Aml *esel = aml_name(AML_GED_EVT_SEL);
+
+    assert(ged_base);
+
+    /* _CRS interrupt */
+    aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH,
+                                  AML_EXCLUSIVE, &ged_irq, 1));
+
+    aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013")));
+    aml_append(dev, aml_name_decl("_UID", aml_string(GED_DEVICE)));
+    aml_append(dev, aml_name_decl("_CRS", crs));
+
+    /* Append IO region */
+    aml_append(dev, aml_operation_region(AML_GED_EVT_REG, rs,
+               aml_int(ged_base + ACPI_GED_EVT_SEL_OFFSET),
+               ACPI_GED_EVT_SEL_LEN));
+    field = aml_field(AML_GED_EVT_REG, AML_DWORD_ACC, AML_NOLOCK,
+                      AML_WRITE_AS_ZEROS);
+    aml_append(field, aml_named_field(AML_GED_EVT_SEL,
+                                      ACPI_GED_EVT_SEL_LEN * BITS_PER_BYTE));
+    aml_append(dev, field);
+
+    /*
+     * For each GED event we:
+     * - Add a conditional block for each event, inside a loop.
+     * - Call a method for each supported GED event type.
+     *
+     * The resulting ASL code looks like:
+     *
+     * Local0 = ESEL
+     * If ((Local0 & One) == One)
+     * {
+     *     MethodEvent0()
+     * }
+     *
+     * If ((Local0 & 0x2) == 0x2)
+     * {
+     *     MethodEvent1()
+     * }
+     * ...
+     */
+    evt = aml_method("_EVT", 1, AML_SERIALIZED);
+    {
+        Aml *if_ctx;
+        uint32_t i;
+        uint32_t ged_events = ctpop32(s->ged_event_bitmap);
+
+        /* Local0 = ESEL */
+        aml_append(evt, aml_store(esel, evt_sel));
+
+        for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) {
+            uint32_t event = s->ged_event_bitmap & ged_supported_events[i];
+
+            if (!event) {
+                continue;
+            }
+
+            if_ctx = aml_if(aml_equal(aml_and(evt_sel, aml_int(event), NULL),
+                                      aml_int(event)));
+            switch (event) {
+            case ACPI_GED_MEM_HOTPLUG_EVT:
+                aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "."
+                                             MEMORY_SLOT_SCAN_METHOD));
+                break;
+            default:
+                /*
+                 * Please make sure all the events in ged_supported_events[]
+                 * are handled above.
+                 */
+                g_assert_not_reached();
+            }
+
+            aml_append(evt, if_ctx);
+            ged_events--;
+        }
+
+        if (ged_events) {
+            error_report("Unsupported events specified");
+            abort();
+        }
+    }
+
+    /* Append _EVT method */
+    aml_append(dev, evt);
+
+    aml_append(table, dev);
+}
+
+/* Memory read by the GED _EVT AML dynamic method */
+static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size)
+{
+    uint64_t val = 0;
+    GEDState *ged_st = opaque;
+
+    switch (addr) {
+    case ACPI_GED_EVT_SEL_OFFSET:
+        /* Read the selector value and reset it */
+        val = ged_st->sel;
+        ged_st->sel = 0;
+        break;
+    default:
+        break;
+    }
+
+    return val;
+}
+
+/* Nothing is expected to be written to the GED memory region */
+static void ged_write(void *opaque, hwaddr addr, uint64_t data,
+                      unsigned int size)
+{
+}
+
+static const MemoryRegionOps ged_ops = {
+    .read = ged_read,
+    .write = ged_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
+};
+
+static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
+                                    DeviceState *dev, Error **errp)
+{
+    AcpiGedState *s = ACPI_GED(hotplug_dev);
+
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        if (s->memhp_state.is_enabled) {
+            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
+        } else {
+            error_setg(errp,
+                 "memory hotplug is not enabled: %s.memory-hotplug-support "
+                 "is not set", object_get_typename(OBJECT(s)));
+        }
+    } else {
+        error_setg(errp, "virt: device plug request for unsupported device"
+                   " type: %s", object_get_typename(OBJECT(dev)));
+    }
+}
+
+static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
+{
+    AcpiGedState *s = ACPI_GED(adev);
+    GEDState *ged_st = &s->ged_state;
+    uint32_t sel;
+
+    if (ev & ACPI_MEMORY_HOTPLUG_STATUS) {
+        sel = ACPI_GED_MEM_HOTPLUG_EVT;
+    } else {
+        /* Unknown event. Return without generating interrupt. */
+        warn_report("GED: Unsupported event %d. No irq injected", ev);
+        return;
+    }
+
+    /*
+     * Set the GED selector field to communicate the event type.
+     * This will be read by GED aml code to select the appropriate
+     * event method.
+     */
+    ged_st->sel |= sel;
+
+    /* Trigger the event by sending an interrupt to the guest. */
+    qemu_irq_pulse(s->irq);
+}
+
+static void acpi_ged_device_realize(DeviceState *dev, Error **errp)
+{
+    AcpiGedState *s = ACPI_GED(dev);
+    GEDState *ged_st = &s->ged_state;
+
+    memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st,
+                          TYPE_ACPI_GED, ACPI_GED_EVT_SEL_LEN);
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &ged_st->io);
+
+    sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
+
+    if (s->memhp_state.is_enabled) {
+        /*
+         * GED handles memory hotplug event and acpi-mem-hotplug
+         * memory region gets initialized here. Create an exclusive
+         * container for memory hotplug IO and expose it as GED sysbus
+         * MMIO so that boards can map it separately.
+         */
+        memory_region_init(&s->container_memhp, OBJECT(dev), "container",
+                           MEMORY_HOTPLUG_IO_LEN);
+        sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container_memhp);
+        acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
+                                 &s->memhp_state, 0);
+    }
+}
+
+static Property acpi_ged_properties[] = {
+    DEFINE_PROP_BOOL("memory-hotplug-support", AcpiGedState,
+                     memhp_state.is_enabled, true),
+    DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static bool vmstate_test_use_memhp(void *opaque)
+{
+    AcpiGedState *s = opaque;
+    return s->memhp_state.is_enabled;
+}
+
+static const VMStateDescription vmstate_memhp_state = {
+    .name = "acpi-ged/memhp",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = vmstate_test_use_memhp,
+    .fields      = (VMStateField[]) {
+        VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_ged_state = {
+    .name = "acpi-ged-state",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields      = (VMStateField[]) {
+        VMSTATE_UINT32(sel, GEDState),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
+static const VMStateDescription vmstate_acpi_ged = {
+    .name = "acpi-ged",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDState),
+        VMSTATE_END_OF_LIST(),
+    },
+    .subsections = (const VMStateDescription * []) {
+        &vmstate_memhp_state,
+        NULL
+    }
+};
+
+static void acpi_ged_class_init(ObjectClass *class, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(class);
+    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(class);
+    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class);
+
+    dc->desc = "ACPI Generic Event Device";
+    dc->props = acpi_ged_properties;
+    dc->realize = acpi_ged_device_realize;
+    dc->vmsd = &vmstate_acpi_ged;
+
+    hc->plug = acpi_ged_device_plug_cb;
+
+    adevc->send_event = acpi_ged_send_event;
+}
+
+static const TypeInfo acpi_ged_info = {
+    .name          = TYPE_ACPI_GED,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(AcpiGedState),
+    .class_init    = acpi_ged_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_HOTPLUG_HANDLER },
+        { TYPE_ACPI_DEVICE_IF },
+        { }
+    }
+};
+
+static void acpi_ged_register_types(void)
+{
+    type_register_static(&acpi_ged_info);
+}
+
+type_init(acpi_ged_register_types)
diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
new file mode 100644
index 0000000000..2049e8d873
--- /dev/null
+++ b/include/hw/acpi/generic_event_device.h
@@ -0,0 +1,100 @@
+/*
+ *
+ * Copyright (c) 2018 Intel Corporation
+ * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd
+ * Written by Samuel Ortiz, Shameer Kolothum
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2 or later, as published by the Free Software Foundation.
+ *
+ * The ACPI Generic Event Device (GED) is a hardware-reduced specific
+ * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
+ * including the hotplug ones. Generic Event Device allows platforms
+ * to handle interrupts in ACPI ASL statements. It follows a very
+ * similar approach like the _EVT method from GPIO events. All
+ * interrupts are listed in  _CRS and the handler is written in _EVT
+ * method. Here, we use a single interrupt for the GED device, relying
+ * on IO memory region to communicate the type of device affected by
+ * the interrupt. This way, we can support up to 32 events with a
+ * unique interrupt.
+ *
+ * Here is an example.
+ *
+ * Device (\_SB.GED)
+ * {
+ *     Name (_HID, "ACPI0013")
+ *     Name (_UID, Zero)
+ *     Name (_CRS, ResourceTemplate ()
+ *     {
+ *         Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
+ *         {
+ *              0x00000029,
+ *         }
+ *     })
+ *     OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
+ *     Field (EREG, DWordAcc, NoLock, WriteAsZeros)
+ *     {
+ *         ESEL,   32
+ *     }
+ *
+ *     Method (_EVT, 1, Serialized)  // _EVT: Event
+ *     {
+ *         Local0 = ESEL // ESEL = IO memory region which specifies the
+ *                       // device type.
+ *         If (((Local0 & One) == One))
+ *         {
+ *             MethodEvent1()
+ *         }
+ *         If ((Local0 & 0x2) == 0x2)
+ *         {
+ *             MethodEvent2()
+ *         }
+ *         ...
+ *     }
+ * }
+ *
+ */
+
+#ifndef HW_ACPI_GED_H
+#define HW_ACPI_GED_H
+
+#include "hw/sysbus.h"
+#include "hw/acpi/memory_hotplug.h"
+
+#define TYPE_ACPI_GED "acpi-ged"
+#define ACPI_GED(obj) \
+    OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
+
+#define ACPI_GED_EVT_SEL_OFFSET    0x0
+#define ACPI_GED_EVT_SEL_LEN       0x4
+
+#define GED_DEVICE      "GED"
+#define AML_GED_EVT_REG "EREG"
+#define AML_GED_EVT_SEL "ESEL"
+
+/*
+ * Platforms need to specify the GED event bitmap
+ * to describe what kind of events they want to support
+ * through GED.
+ */
+#define ACPI_GED_MEM_HOTPLUG_EVT   0x1
+
+typedef struct GEDState {
+    MemoryRegion io;
+    uint32_t     sel;
+} GEDState;
+
+typedef struct AcpiGedState {
+    SysBusDevice parent_obj;
+    MemHotplugState memhp_state;
+    MemoryRegion container_memhp;
+    GEDState ged_state;
+    uint32_t ged_event_bitmap;
+    qemu_irq irq;
+} AcpiGedState;
+
+void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_dev,
+                   uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base);
+
+#endif
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (2 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type Shameer Kolothum
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

From: Eric Auger <eric.auger@redhat.com>

This patch adds the memory hot-plug/hot-unplug infrastructure
in machvirt. The device memory is not yet exposed to the Guest
either through DT or ACPI and hence both cold/hot plug of memory
is explicitly disabled for now.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kwangwoo Lee <kwangwoo.lee@sk.com>
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v8 --> v9
 -Added error propagation.
---
 hw/arm/Kconfig |  2 ++
 hw/arm/virt.c  | 53 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index ab65ecd216..84961c17ab 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -20,6 +20,8 @@ config ARM_VIRT
     select SMBIOS
     select VIRTIO_MMIO
     select ACPI_PCI
+    select MEM_DEVICE
+    select DIMM
 
 config CHEETAH
     bool
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index d9496c9363..72cde9deba 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -64,6 +64,8 @@
 #include "hw/arm/smmuv3.h"
 #include "hw/acpi/acpi.h"
 #include "target/arm/internals.h"
+#include "hw/mem/pc-dimm.h"
+#include "hw/mem/nvdimm.h"
 
 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
     static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
@@ -1871,6 +1873,42 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
     return ms->possible_cpus;
 }
 
+static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
+                                 Error **errp)
+{
+
+    /*
+     * The device memory is not yet exposed to the Guest either through
+     * DT or ACPI and hence both cold/hot plug of memory is explicitly
+     * disabled for now.
+     */
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        error_setg(errp, "memory cold/hot plug is not yet supported");
+        return;
+    }
+
+    pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp);
+}
+
+static void virt_memory_plug(HotplugHandler *hotplug_dev,
+                             DeviceState *dev, Error **errp)
+{
+    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
+    Error *local_err = NULL;
+
+    pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
+
+    error_propagate(errp, local_err);
+}
+
+static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
+                                            DeviceState *dev, Error **errp)
+{
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        virt_memory_pre_plug(hotplug_dev, dev, errp);
+    }
+}
+
 static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
                                         DeviceState *dev, Error **errp)
 {
@@ -1882,12 +1920,23 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
                                      SYS_BUS_DEVICE(dev));
         }
     }
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+        virt_memory_plug(hotplug_dev, dev, errp);
+    }
+}
+
+static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
+                                          DeviceState *dev, Error **errp)
+{
+    error_setg(errp, "device unplug request for unsupported device"
+               " type: %s", object_get_typename(OBJECT(dev)));
 }
 
 static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
                                                         DeviceState *dev)
 {
-    if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) ||
+       (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) {
         return HOTPLUG_HANDLER(machine);
     }
 
@@ -1951,7 +2000,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     mc->kvm_type = virt_kvm_type;
     assert(!mc->get_hotplug_handler);
     mc->get_hotplug_handler = virt_machine_get_hotplug_handler;
+    hc->pre_plug = virt_machine_device_pre_plug_cb;
     hc->plug = virt_machine_device_plug_cb;
+    hc->unplug_request = virt_machine_device_unplug_request_cb;
     mc->numa_mem_supported = true;
 }
 
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (3 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot Shameer Kolothum
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This is in preparation to create ACPI GED device as we
need to disable it for <4.2 for migration to work.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/arm/virt.c       | 9 ++++++++-
 hw/core/machine.c   | 3 +++
 include/hw/boards.h | 3 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 72cde9deba..ef65e721d2 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2097,10 +2097,17 @@ static void machvirt_machine_init(void)
 }
 type_init(machvirt_machine_init);
 
+static void virt_machine_4_2_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
+
 static void virt_machine_4_1_options(MachineClass *mc)
 {
+    virt_machine_4_2_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(4, 1)
+DEFINE_VIRT_MACHINE(4, 1)
 
 static void virt_machine_4_0_options(MachineClass *mc)
 {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 32d1ca9abc..83cd1bfeec 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -27,6 +27,9 @@
 #include "hw/pci/pci.h"
 #include "hw/mem/nvdimm.h"
 
+GlobalProperty hw_compat_4_1[] = {};
+const size_t hw_compat_4_1_len = G_N_ELEMENTS(hw_compat_4_1);
+
 GlobalProperty hw_compat_4_0[] = {
     { "VGA",            "edid", "false" },
     { "secondary-vga",  "edid", "false" },
diff --git a/include/hw/boards.h b/include/hw/boards.h
index a71d1a53a5..d9ec37d807 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -317,6 +317,9 @@ struct MachineState {
     } \
     type_init(machine_initfn##_register_types)
 
+extern GlobalProperty hw_compat_4_1[];
+extern const size_t hw_compat_4_1_len;
+
 extern GlobalProperty hw_compat_4_0[];
 extern const size_t hw_compat_4_0_len;
 
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (4 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-09-01 11:18   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT Shameer Kolothum
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This initializes the GED device with base memory and irq, configures
ged memory hotplug event and builds the corresponding aml code. With
this, both hot and cold plug of device memory is enabled now for Guest
with ACPI boot.

Memory cold plug support with Guest DT boot is not yet supported.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
v8 --> v9
 -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
 -Error propagation to _plug() handler.
 -Removed R-by by Eric for now.

v7 --> v8
 -Changed no_acpi_dev to no_ged.
 -Fixed 'dev' reference leak by object_new().
 -Updated bios-tables-test-allowed-diff.h to avoid "make check"
  failure.

---
 hw/arm/Kconfig                        |  2 +
 hw/arm/virt-acpi-build.c              | 16 +++++++
 hw/arm/virt.c                         | 62 ++++++++++++++++++++++++---
 include/hw/arm/virt.h                 |  4 ++
 tests/bios-tables-test-allowed-diff.h |  1 +
 5 files changed, 78 insertions(+), 7 deletions(-)

diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 84961c17ab..ad7f7c089b 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -22,6 +22,8 @@ config ARM_VIRT
     select ACPI_PCI
     select MEM_DEVICE
     select DIMM
+    select ACPI_MEMORY_HOTPLUG
+    select ACPI_HW_REDUCED
 
 config CHEETAH
     bool
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 0afb372769..63fa845076 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -40,6 +40,8 @@
 #include "hw/acpi/aml-build.h"
 #include "hw/acpi/utils.h"
 #include "hw/acpi/pci.h"
+#include "hw/acpi/memory_hotplug.h"
+#include "hw/acpi/generic_event_device.h"
 #include "hw/pci/pcie_host.h"
 #include "hw/pci/pci.h"
 #include "hw/arm/virt.h"
@@ -705,6 +707,7 @@ static void
 build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
 {
     Aml *scope, *dsdt;
+    MachineState *ms = MACHINE(vms);
     const MemMapEntry *memmap = vms->memmap;
     const int *irqmap = vms->irqmap;
 
@@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
                       vms->highmem, vms->highmem_ecam);
     acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
                        (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
+    if (vms->acpi_dev) {
+        build_ged_aml(scope, "\\_SB."GED_DEVICE,
+                      HOTPLUG_HANDLER(vms->acpi_dev),
+                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
+                      memmap[VIRT_ACPI_GED].base);
+    }
+
+    if (vms->acpi_dev && ms->ram_slots) {
+        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL,
+                                 AML_SYSTEM_MEMORY,
+                                 memmap[VIRT_PCDIMM_ACPI].base);
+    }
+
     acpi_dsdt_add_power_button(scope);
 
     aml_append(dsdt, scope);
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index ef65e721d2..0949a227a9 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -66,6 +66,7 @@
 #include "target/arm/internals.h"
 #include "hw/mem/pc-dimm.h"
 #include "hw/mem/nvdimm.h"
+#include "hw/acpi/generic_event_device.h"
 
 #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
     static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
@@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
     [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
     [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
     [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
+    [VIRT_PCDIMM_ACPI] =        { 0x09070000, MEMORY_HOTPLUG_IO_LEN },
+    [VIRT_ACPI_GED] =           { 0x09080000, ACPI_GED_EVT_SEL_LEN },
     [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
     /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
     [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
@@ -171,6 +174,7 @@ static const int a15irqmap[] = {
     [VIRT_PCIE] = 3, /* ... to 6 */
     [VIRT_GPIO] = 7,
     [VIRT_SECURE_UART] = 8,
+    [VIRT_ACPI_GED] = 9,
     [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
     [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
     [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
@@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
     }
 }
 
+static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic)
+{
+    DeviceState *dev;
+    int irq = vms->irqmap[VIRT_ACPI_GED];
+    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
+
+    dev = qdev_create(NULL, TYPE_ACPI_GED);
+    qdev_prop_set_uint32(dev, "ged-event", event);
+    object_property_add_child(qdev_get_machine(), "acpi-ged",
+                              OBJECT(dev), NULL);
+    qdev_init_nofail(dev);
+
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
+
+    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
+
+    return dev;
+}
+
 static void create_its(VirtMachineState *vms, DeviceState *gicdev)
 {
     const char *itsclass = its_class_name();
@@ -1483,6 +1507,7 @@ static void machvirt_init(MachineState *machine)
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     bool firmware_loaded;
     bool aarch64 = true;
+    bool has_ged = !vmc->no_ged;
     unsigned int smp_cpus = machine->smp.cpus;
     unsigned int max_cpus = machine->smp.max_cpus;
 
@@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState *machine)
 
     create_gpio(vms, pic);
 
+    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
+        vms->acpi_dev = create_acpi_ged(vms, pic);
+    }
+
     /* Create mmio transports, so the user can create virtio backends
      * (which will be automatically plugged in to the transports). If
      * no backend is created the transport will just sit harmlessly idle.
@@ -1876,14 +1905,23 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
 static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
                                  Error **errp)
 {
+    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
+    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
+    Error *local_err = NULL;
 
-    /*
-     * The device memory is not yet exposed to the Guest either through
-     * DT or ACPI and hence both cold/hot plug of memory is explicitly
-     * disabled for now.
-     */
-    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
-        error_setg(errp, "memory cold/hot plug is not yet supported");
+    if (is_nvdimm) {
+        error_setg(errp, "nvdimm is not yet supported");
+        return;
+    }
+
+    if (!vms->acpi_dev) {
+        error_setg(errp, "memory hotplug is not enabled: missing acpi device");
+        return;
+    }
+
+    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
         return;
     }
 
@@ -1893,11 +1931,18 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
 static void virt_memory_plug(HotplugHandler *hotplug_dev,
                              DeviceState *dev, Error **errp)
 {
+    HotplugHandlerClass *hhc;
     VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
     Error *local_err = NULL;
 
     pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
+    if (local_err) {
+        goto out;
+    }
 
+    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
+    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
+out:
     error_propagate(errp, local_err);
 }
 
@@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
 
 static void virt_machine_4_1_options(MachineClass *mc)
 {
+    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
     virt_machine_4_2_options(mc);
     compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
+    vmc->no_ged = true;
 }
 DEFINE_VIRT_MACHINE(4, 1)
 
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index a72094204e..577ee49b4b 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -77,6 +77,8 @@ enum {
     VIRT_GPIO,
     VIRT_SECURE_UART,
     VIRT_SECURE_MEM,
+    VIRT_PCDIMM_ACPI,
+    VIRT_ACPI_GED,
     VIRT_LOWMEMMAP_LAST,
 };
 
@@ -106,6 +108,7 @@ typedef struct {
     bool claim_edge_triggered_timers;
     bool smbios_old_sys_ver;
     bool no_highmem_ecam;
+    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
 } VirtMachineClass;
 
 typedef struct {
@@ -133,6 +136,7 @@ typedef struct {
     uint32_t iommu_phandle;
     int psci_conduit;
     hwaddr highest_gpa;
+    DeviceState *acpi_dev;
 } VirtMachineState;
 
 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h
index dfb8523c8b..7b4adbc822 100644
--- a/tests/bios-tables-test-allowed-diff.h
+++ b/tests/bios-tables-test-allowed-diff.h
@@ -1 +1,2 @@
 /* List of comma-separated changed AML files to ignore */
+"tests/data/acpi/virt/DSDT",
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (5 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO Shameer Kolothum
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Generate Memory Affinity Structures for PC-DIMM ranges.

Also, Linux and Windows need ACPI SRAT table to make memory hotplug
work properly, however currently QEMU doesn't create SRAT table if
numa options aren't present on CLI. Hence add support(>=4.2) to
create numa node automatically (auto_enable_numa_with_memhp) when
QEMU is started with memory hotplug enabled but without '-numa'
options on CLI.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
v8 --> v9
 - Added auto_enable_numa_with_memhp support.

---
 hw/arm/virt-acpi-build.c | 9 +++++++++
 hw/arm/virt.c            | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 63fa845076..6d697af2df 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -518,6 +518,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
     int i, srat_start;
     uint64_t mem_base;
     MachineClass *mc = MACHINE_GET_CLASS(vms);
+    MachineState *ms = MACHINE(vms);
     const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms));
 
     srat_start = table_data->len;
@@ -543,6 +544,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
         }
     }
 
+    if (ms->device_memory) {
+        numamem = acpi_data_push(table_data, sizeof *numamem);
+        build_srat_memory(numamem, ms->device_memory->base,
+                          memory_region_size(&ms->device_memory->mr),
+                          nb_numa_nodes - 1,
+                          MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED);
+    }
+
     build_header(linker, table_data, (void *)(table_data->data + srat_start),
                  "SRAT", table_data->len - srat_start, 3, NULL, NULL);
 }
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0949a227a9..56d64fc0a9 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2049,6 +2049,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
     hc->plug = virt_machine_device_plug_cb;
     hc->unplug_request = virt_machine_device_unplug_request_cb;
     mc->numa_mem_supported = true;
+    mc->auto_enable_numa_with_memhp = true;
 }
 
 static void virt_instance_init(Object *obj)
@@ -2154,6 +2155,7 @@ static void virt_machine_4_1_options(MachineClass *mc)
     virt_machine_4_2_options(mc);
     compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
     vmc->no_ged = true;
+    mc->auto_enable_numa_with_memhp = false;
 }
 DEFINE_VIRT_MACHINE(4, 1)
 
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (6 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-09-02  7:37   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event Shameer Kolothum
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This is in preparation of using GED device for
system_powerdown event. Make the powerdown notifier
registration independent of create_gpio() fn.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
 hw/arm/virt.c         | 12 ++++--------
 include/hw/arm/virt.h |  1 +
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 56d64fc0a9..0e75213b44 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -787,10 +787,6 @@ static void virt_powerdown_req(Notifier *n, void *opaque)
     qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
 }
 
-static Notifier virt_system_powerdown_notifier = {
-    .notify = virt_powerdown_req
-};
-
 static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
 {
     char *nodename;
@@ -831,10 +827,6 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
                           KEY_POWER);
     qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
                            "gpios", phandle, 3, 0);
-
-    /* connect powerdown request */
-    qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
-
     g_free(nodename);
 }
 
@@ -1726,6 +1718,10 @@ static void machvirt_init(MachineState *machine)
         vms->acpi_dev = create_acpi_ged(vms, pic);
     }
 
+     /* connect powerdown request */
+     vms->powerdown_notifier.notify = virt_powerdown_req;
+     qemu_register_powerdown_notifier(&vms->powerdown_notifier);
+
     /* Create mmio transports, so the user can create virtio backends
      * (which will be automatically plugged in to the transports). If
      * no backend is created the transport will just sit harmlessly idle.
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 577ee49b4b..0b41083e9d 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -137,6 +137,7 @@ typedef struct {
     int psci_conduit;
     hwaddr highest_gpa;
     DeviceState *acpi_dev;
+    Notifier powerdown_notifier;
 } VirtMachineState;
 
 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (7 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-09-02  7:37   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation Shameer Kolothum
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

For machines 4.2 or higher with ACPI boot use GED for system_powerdown
event instead of GPIO. Guest boot with DT still uses GPIO.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
v8 --> v9
 -Re-arranged patches 8 & 9 from v8 based on Igor's comments.

v7 --> v8
 -Retained gpio based system_powerdown support for machines < 4.2.
 -Reuse of virt_powerdown_req() for ACPI GED use.
 -Dropped Eric's R-by for now because of above.

---
 hw/acpi/generic_event_device.c         |  8 ++++++++
 hw/arm/virt-acpi-build.c               |  6 +++---
 hw/arm/virt.c                          | 16 +++++++++++-----
 include/hw/acpi/acpi_dev_interface.h   |  1 +
 include/hw/acpi/generic_event_device.h |  3 +++
 5 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index f4c23470c2..d6d7b28cfd 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -19,6 +19,7 @@
 
 static const uint32_t ged_supported_events[] = {
     ACPI_GED_MEM_HOTPLUG_EVT,
+    ACPI_GED_PWR_DOWN_EVT,
 };
 
 /*
@@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
                 aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "."
                                              MEMORY_SLOT_SCAN_METHOD));
                 break;
+            case ACPI_GED_PWR_DOWN_EVT:
+                aml_append(if_ctx,
+                           aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
+                                      aml_int(0x80)));
+                break;
             default:
                 /*
                  * Please make sure all the events in ged_supported_events[]
@@ -189,6 +195,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
 
     if (ev & ACPI_MEMORY_HOTPLUG_STATUS) {
         sel = ACPI_GED_MEM_HOTPLUG_EVT;
+    } else if (ev & ACPI_POWER_DOWN_STATUS) {
+        sel = ACPI_GED_PWR_DOWN_EVT;
     } else {
         /* Unknown event. Return without generating interrupt. */
         warn_report("GED: Unsupported event %d. No irq injected", ev);
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 6d697af2df..61b399dc58 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -49,7 +49,6 @@
 #include "kvm_arm.h"
 
 #define ARM_SPI_BASE 32
-#define ACPI_POWER_BUTTON_DEVICE "PWRB"
 
 static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
 {
@@ -739,13 +738,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
                     (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
     acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
                       vms->highmem, vms->highmem_ecam);
-    acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
-                       (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
     if (vms->acpi_dev) {
         build_ged_aml(scope, "\\_SB."GED_DEVICE,
                       HOTPLUG_HANDLER(vms->acpi_dev),
                       irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
                       memmap[VIRT_ACPI_GED].base);
+    } else {
+        acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
+                           (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
     }
 
     if (vms->acpi_dev && ms->ram_slots) {
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0e75213b44..d49e1a583c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -528,7 +528,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic)
 {
     DeviceState *dev;
     int irq = vms->irqmap[VIRT_ACPI_GED];
-    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
+    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT;
 
     dev = qdev_create(NULL, TYPE_ACPI_GED);
     qdev_prop_set_uint32(dev, "ged-event", event);
@@ -783,8 +783,14 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic)
 static DeviceState *gpio_key_dev;
 static void virt_powerdown_req(Notifier *n, void *opaque)
 {
-    /* use gpio Pin 3 for power button event */
-    qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
+    VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier);
+
+    if (s->acpi_dev) {
+        acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS);
+    } else {
+        /* use gpio Pin 3 for power button event */
+        qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
+    }
 }
 
 static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
@@ -1712,10 +1718,10 @@ static void machvirt_init(MachineState *machine)
 
     create_pcie(vms, pic);
 
-    create_gpio(vms, pic);
-
     if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
         vms->acpi_dev = create_acpi_ged(vms, pic);
+    } else {
+        create_gpio(vms, pic);
     }
 
      /* connect powerdown request */
diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index 43ff119179..adcb3a816c 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -11,6 +11,7 @@ typedef enum {
     ACPI_MEMORY_HOTPLUG_STATUS = 8,
     ACPI_NVDIMM_HOTPLUG_STATUS = 16,
     ACPI_VMGENID_CHANGE_STATUS = 32,
+    ACPI_POWER_DOWN_STATUS = 64,
 } AcpiEventStatusBits;
 
 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
index 2049e8d873..d157eac088 100644
--- a/include/hw/acpi/generic_event_device.h
+++ b/include/hw/acpi/generic_event_device.h
@@ -62,6 +62,8 @@
 #include "hw/sysbus.h"
 #include "hw/acpi/memory_hotplug.h"
 
+#define ACPI_POWER_BUTTON_DEVICE "PWRB"
+
 #define TYPE_ACPI_GED "acpi-ged"
 #define ACPI_GED(obj) \
     OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
@@ -79,6 +81,7 @@
  * through GED.
  */
 #define ACPI_GED_MEM_HOTPLUG_EVT   0x1
+#define ACPI_GED_PWR_DOWN_EVT      0x2
 
 typedef struct GEDState {
     MemoryRegion io;
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (8 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-09-01 11:20   ` Auger Eric
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 11/12] tests: add dummy ACPI tables for arm/virt board Shameer Kolothum
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Documents basic concepts of ACPI Generic Event device(GED)
and interface between QEMU and the ACPI BIOS.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
 docs/specs/acpi_hw_reduced_hotplug.txt | 60 ++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 docs/specs/acpi_hw_reduced_hotplug.txt

diff --git a/docs/specs/acpi_hw_reduced_hotplug.txt b/docs/specs/acpi_hw_reduced_hotplug.txt
new file mode 100644
index 0000000000..46839be5ff
--- /dev/null
+++ b/docs/specs/acpi_hw_reduced_hotplug.txt
@@ -0,0 +1,60 @@
+QEMU<->ACPI BIOS Generic Event Device interface
+
+The ACPI Generic Event Device (GED) is a HW reduced platform
+specific device introduced in ACPI v6.1 that handles all platform
+events, including the hotplug ones. GED is modelled as a device
+in the namespace with a _HID defined to be ACPI0013. This document
+describes the interface between QEMU and the ACPI BIOS.
+
+GED allows HW reduced platforms to handle interrupts in ACPI ASL
+statements. It follows a very similar approach like the _EVT method
+from GPIO events. All interrupts are listed in  _CRS and the handler
+is written in _EVT method. However, Qemu implementation uses a single
+interrupt for the GED device, relying on IO memory region to communicate
+the type of device affected by the interrupt. This way, we can support
+up to 32 events with a unique interrupt.
+
+Here is an example.
+
+Device (\_SB.GED)
+{
+    Name (_HID, "ACPI0013")
+    Name (_UID, Zero)
+    Name (_CRS, ResourceTemplate ()
+    {
+        Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
+        {
+            0x00000029,
+        }
+    })
+    OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
+    Field (EREG, DWordAcc, NoLock, WriteAsZeros)
+    {
+        ESEL,   32
+    }
+    Method (_EVT, 1, Serialized)
+    {
+        Local0 = ESEL // ESEL = IO memory region which specifies the
+                      // device type.
+        If (((Local0 & One) == One))
+        {
+            MethodEvent1()
+        }
+        If ((Local0 & 0x2) == 0x2)
+        {
+            MethodEvent2()
+        }
+        ...
+    }
+}
+
+GED IO interface (4 byte access):
+read access:
+    [0x0-0x3] Event selector bit field(32 bit) set by Qemu.
+    bits:
+        1:  Memory hotplug event
+        2:  System power down event
+     3-31:  Reserved
+
+write_access:
+    Nothing is expected to be written into GED IO memory
-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 11/12] tests: add dummy ACPI tables for arm/virt board
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (9 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt Shameer Kolothum
  2019-08-14  6:46 ` [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support no-reply
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This patch is in preparation for adding numamem and memhp tests
to arm/virt board so that 'make check' is happy. This may not
be required once the scripts are run and new tables are
generated with ".numamem" and ".memhp" extensions.

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
I am not sure this is the right way to do this. But without this, when
the numamem and memhp tests are added, you will get,

Looking for expected file 'tests/data/acpi/virt/SRAT.numamem'
Looking for expected file 'tests/data/acpi/virt/SRAT'
**
ERROR:tests/bios-tables-test.c:327:load_expected_aml: assertion failed: (exp_sdt.aml_file)

---
 tests/data/acpi/virt/SLIT | Bin 0 -> 48 bytes
 tests/data/acpi/virt/SRAT | Bin 0 -> 224 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/data/acpi/virt/SLIT
 create mode 100644 tests/data/acpi/virt/SRAT

diff --git a/tests/data/acpi/virt/SLIT b/tests/data/acpi/virt/SLIT
new file mode 100644
index 0000000000000000000000000000000000000000..74ec3b4b461ffecca36d8537975c202a5f011185
GIT binary patch
literal 48
scmWIc@eDCwU|?X>aq@Te2v%^42yhMtiZKGkKx`1r1jHb~B`V4V0NaKK0RR91

literal 0
HcmV?d00001

diff --git a/tests/data/acpi/virt/SRAT b/tests/data/acpi/virt/SRAT
new file mode 100644
index 0000000000000000000000000000000000000000..119922f4973f621602047d1dc160519f810922a3
GIT binary patch
literal 224
zcmWFzatwLEz`(%x)yd!4BUr&HBEUHqD8>jB1F=Cg2*ZH@DxXmUMHZ-x3$7Gd2B8jU
X02q8=hbcr=2NT6lGiu<Mhsgo}c|r;S

literal 0
HcmV?d00001

-- 
2.17.1




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

* [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (10 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 11/12] tests: add dummy ACPI tables for arm/virt board Shameer Kolothum
@ 2019-08-13 21:05 ` Shameer Kolothum
  2019-08-14  6:46 ` [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support no-reply
  12 siblings, 0 replies; 29+ messages in thread
From: Shameer Kolothum @ 2019-08-13 21:05 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

This adds numamem and memhp tests for arm/virt platform

Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
---
 tests/bios-tables-test-allowed-diff.h |  1 +
 tests/bios-tables-test.c              | 49 +++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h
index 7b4adbc822..d181a4da4a 100644
--- a/tests/bios-tables-test-allowed-diff.h
+++ b/tests/bios-tables-test-allowed-diff.h
@@ -1,2 +1,3 @@
 /* List of comma-separated changed AML files to ignore */
 "tests/data/acpi/virt/DSDT",
+"tests/data/acpi/virt/SRAT",
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index a356ac3489..1d6f330d53 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -871,6 +871,53 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg_memhp(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .accel = "tcg",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 256ULL * 1024 * 1024,
+    };
+
+    data.variant = ".memhp";
+    test_acpi_one(" -cpu cortex-a57"
+                  " -m 256M,slots=3,maxmem=1G"
+                  " -object memory-backend-ram,id=ram0,size=128M"
+                  " -object memory-backend-ram,id=ram1,size=128M"
+                  " -numa node,memdev=ram0 -numa node,memdev=ram1"
+                  " -numa dist,src=0,dst=1,val=21",
+                  &data);
+
+    free_test_data(&data);
+
+}
+
+static void test_acpi_virt_tcg_numamem(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .accel = "tcg",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    data.variant = ".numamem";
+    test_acpi_one(" -cpu cortex-a57"
+                  " -object memory-backend-ram,id=ram0,size=128M"
+                  " -numa node,memdev=ram0",
+                  &data);
+
+    free_test_data(&data);
+
+}
+
 static void test_acpi_virt_tcg(void)
 {
     test_data data = {
@@ -917,6 +964,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
     } else if (strcmp(arch, "aarch64") == 0) {
         qtest_add_func("acpi/virt", test_acpi_virt_tcg);
+        qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
+        qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
-- 
2.17.1




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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support
  2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
                   ` (11 preceding siblings ...)
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt Shameer Kolothum
@ 2019-08-14  6:46 ` no-reply
  12 siblings, 0 replies; 29+ messages in thread
From: no-reply @ 2019-08-14  6:46 UTC (permalink / raw)
  To: shameerali.kolothum.thodi
  Cc: peter.maydell, sameo, ard.biesheuvel, shannon.zhaosl, qemu-devel,
	xuwei5, linuxarm, eric.auger, qemu-arm, imammedo,
	sebastien.boeuf, lersek

Patchew URL: https://patchew.org/QEMU/20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com/



Hi,

This series failed the asan build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-fedora V=1 NETWORK=1
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===

PASS 1 fdc-test /x86_64/fdc/cmos
PASS 2 fdc-test /x86_64/fdc/no_media_on_start
PASS 3 fdc-test /x86_64/fdc/read_without_media
==8489==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 fdc-test /x86_64/fdc/media_change
PASS 5 fdc-test /x86_64/fdc/sense_interrupt
PASS 6 fdc-test /x86_64/fdc/relative_seek
---
PASS 32 test-opts-visitor /visitor/opts/range/beyond
PASS 33 test-opts-visitor /visitor/opts/dict/unvisited
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-coroutine -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-coroutine" 
==8534==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-coroutine /basic/no-dangling-access
==8534==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffd87315000; bottom 0x7f34dbdf8000; size: 0x00c8ab51d000 (861867724800)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 2 test-coroutine /basic/lifecycle
---
PASS 12 fdc-test /x86_64/fdc/read_no_dma_19
PASS 13 fdc-test /x86_64/fdc/fuzz-registers
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/ide-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="ide-test" 
==8562==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==8553==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 14 test-aio /aio/timer/schedule
PASS 15 test-aio /aio/coroutine/queue-chaining
PASS 16 test-aio /aio-gsource/flush
---
PASS 26 test-aio /aio-gsource/event/flush
PASS 27 test-aio /aio-gsource/event/wait/no-flush-cb
PASS 1 ide-test /x86_64/ide/identify
==8568==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 ide-test /x86_64/ide/flush
PASS 28 test-aio /aio-gsource/timer/schedule
==8574==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-aio-multithread -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-aio-multithread" 
PASS 1 test-aio-multithread /aio/multi/lifecycle
==8581==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 ide-test /x86_64/ide/bmdma/simple_rw
==8595==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 test-aio-multithread /aio/multi/schedule
PASS 4 ide-test /x86_64/ide/bmdma/trim
==8606==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-aio-multithread /aio/multi/mutex/contended
PASS 5 ide-test /x86_64/ide/bmdma/short_prdt
==8617==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 ide-test /x86_64/ide/bmdma/one_sector_short_prdt
==8623==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 7 ide-test /x86_64/ide/bmdma/long_prdt
==8629==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==8629==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc91c49000; bottom 0x7f0a1d7ba000; size: 0x00f27448f000 (1041333022720)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 4 test-aio-multithread /aio/multi/mutex/handoff
PASS 8 ide-test /x86_64/ide/bmdma/no_busmaster
PASS 5 test-aio-multithread /aio/multi/mutex/mcs
PASS 9 ide-test /x86_64/ide/flush/nodev
==8650==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 test-aio-multithread /aio/multi/mutex/pthread
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-throttle -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-throttle" 
PASS 10 ide-test /x86_64/ide/flush/empty_drive
==8657==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-throttle /throttle/leak_bucket
PASS 2 test-throttle /throttle/compute_wait
PASS 3 test-throttle /throttle/init
---
PASS 14 test-throttle /throttle/config/max
PASS 15 test-throttle /throttle/config/iops_size
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-thread-pool -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-thread-pool" 
==8663==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-thread-pool /thread-pool/submit
PASS 2 test-thread-pool /thread-pool/submit-aio
PASS 3 test-thread-pool /thread-pool/submit-co
PASS 4 test-thread-pool /thread-pool/submit-many
==8659==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 11 ide-test /x86_64/ide/flush/retry_pci
==8735==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 12 ide-test /x86_64/ide/flush/retry_isa
PASS 5 test-thread-pool /thread-pool/cancel
==8742==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 13 ide-test /x86_64/ide/cdrom/pio
==8748==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 test-thread-pool /thread-pool/cancel-async
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-hbitmap -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-hbitmap" 
PASS 1 test-hbitmap /hbitmap/granularity
---
PASS 10 test-hbitmap /hbitmap/set/all
PASS 11 test-hbitmap /hbitmap/set/one
PASS 12 test-hbitmap /hbitmap/set/two-elem
==8759==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 13 test-hbitmap /hbitmap/set/general
PASS 14 test-hbitmap /hbitmap/set/twice
PASS 15 test-hbitmap /hbitmap/set/overlap
---
PASS 28 test-hbitmap /hbitmap/truncate/shrink/medium
PASS 29 test-hbitmap /hbitmap/truncate/shrink/large
PASS 30 test-hbitmap /hbitmap/meta/zero
==8773==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 ahci-test /x86_64/ahci/sanity
==8779==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 ahci-test /x86_64/ahci/pci_spec
==8785==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 ahci-test /x86_64/ahci/pci_enable
==8791==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 ahci-test /x86_64/ahci/hba_spec
==8797==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 31 test-hbitmap /hbitmap/meta/one
PASS 32 test-hbitmap /hbitmap/meta/byte
PASS 33 test-hbitmap /hbitmap/meta/word
PASS 5 ahci-test /x86_64/ahci/hba_enable
==8803==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 34 test-hbitmap /hbitmap/meta/sector
PASS 35 test-hbitmap /hbitmap/serialize/align
PASS 6 ahci-test /x86_64/ahci/identify
==8809==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 7 ahci-test /x86_64/ahci/max
==8815==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 36 test-hbitmap /hbitmap/serialize/basic
PASS 37 test-hbitmap /hbitmap/serialize/part
PASS 38 test-hbitmap /hbitmap/serialize/zeroes
---
PASS 42 test-hbitmap /hbitmap/next_dirty_area/next_dirty_area_1
PASS 43 test-hbitmap /hbitmap/next_dirty_area/next_dirty_area_4
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bdrv-drain -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bdrv-drain" 
==8822==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-bdrv-drain /bdrv-drain/nested
PASS 2 test-bdrv-drain /bdrv-drain/multiparent
PASS 3 test-bdrv-drain /bdrv-drain/set_aio_context
---
PASS 39 test-bdrv-drain /bdrv-drain/detach/driver_cb
PASS 40 test-bdrv-drain /bdrv-drain/attach/drain
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bdrv-graph-mod -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bdrv-graph-mod" 
==8857==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==8864==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-bdrv-graph-mod /bdrv-graph-mod/update-perm-tree
PASS 2 test-bdrv-graph-mod /bdrv-graph-mod/should-update-child
==8857==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffdeaa54000; bottom 0x7f1b59ffe000; size: 0x00e290a56000 (973089366016)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-blockjob -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-blockjob" 
==8873==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-blockjob /blockjob/ids
PASS 2 test-blockjob /blockjob/cancel/created
PASS 3 test-blockjob /blockjob/cancel/running
---
PASS 8 test-blockjob /blockjob/cancel/concluded
PASS 9 ahci-test /x86_64/ahci/io/pio/lba28/simple/zero
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-blockjob-txn -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-blockjob-txn" 
==8880==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-blockjob-txn /single/success
PASS 2 test-blockjob-txn /single/failure
PASS 3 test-blockjob-txn /single/cancel
---
PASS 5 test-blockjob-txn /pair/failure
PASS 6 test-blockjob-txn /pair/cancel
PASS 7 test-blockjob-txn /pair/fail-cancel-race
==8878==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-block-backend -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-block-backend" 
==8878==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffeb46b4000; bottom 0x7f6c58ffe000; size: 0x00925b6b6000 (628598988800)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
==8889==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-block-backend /block-backend/drain_aio_error
PASS 2 test-block-backend /block-backend/drain_all_aio_error
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-block-iothread -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-block-iothread" 
PASS 10 ahci-test /x86_64/ahci/io/pio/lba28/simple/low
==8895==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-block-iothread /sync-op/pread
PASS 2 test-block-iothread /sync-op/pwrite
PASS 3 test-block-iothread /sync-op/load_vmstate
---
PASS 15 test-block-iothread /propagate/diamond
PASS 16 test-block-iothread /propagate/mirror
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-image-locking -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-image-locking" 
==8897==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==8917==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-image-locking /image-locking/basic
PASS 2 test-image-locking /image-locking/set-perm-abort
==8897==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffe2ad1d000; bottom 0x7ffae45fe000; size: 0x00034671f000 (14066774016)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-x86-cpuid -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-x86-cpuid" 
---
PASS 3 test-xbzrle /xbzrle/encode_decode_unchanged
PASS 4 test-xbzrle /xbzrle/encode_decode_1_byte
PASS 5 test-xbzrle /xbzrle/encode_decode_overflow
==8933==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 test-xbzrle /xbzrle/encode_decode
==8933==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffdbfe00000; bottom 0x7f85409fe000; size: 0x00787f402000 (517530984448)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-vmstate -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-vmstate" 
---
PASS 1 test-mul64 /host-utils/mulu64
PASS 2 test-mul64 /host-utils/muls64
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-int128 -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-int128" 
==8953==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-int128 /int128/int128_and
PASS 2 test-int128 /int128/int128_add
PASS 3 test-int128 /int128/int128_sub
---
PASS 9 test-int128 /int128/int128_gt
PASS 10 test-int128 /int128/int128_rshift
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/rcutorture -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="rcutorture" 
==8953==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc98a4a000; bottom 0x7f4042bfe000; size: 0x00bc55e4c000 (808894906368)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 13 ahci-test /x86_64/ahci/io/pio/lba28/double/low
PASS 1 rcutorture /rcu/torture/1reader
==8978==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==8978==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffd835af000; bottom 0x7f56963fe000; size: 0x00a6ed1b1000 (716942544896)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 14 ahci-test /x86_64/ahci/io/pio/lba28/double/high
PASS 2 rcutorture /rcu/torture/10readers
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-list -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-list" 
==9000==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9000==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc5208e000; bottom 0x7f5ad9324000; size: 0x00a178d6a000 (693517066240)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 15 ahci-test /x86_64/ahci/io/pio/lba28/long/zero
PASS 1 test-rcu-list /rcu/qlist/single-threaded
==9013==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9013==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffe71ca7000; bottom 0x7f545abfe000; size: 0x00aa170a9000 (730531008512)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 2 test-rcu-list /rcu/qlist/short-few
PASS 16 ahci-test /x86_64/ahci/io/pio/lba28/long/low
==9046==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9046==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc0c6d0000; bottom 0x7f8bc737c000; size: 0x007045354000 (482197454848)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 17 ahci-test /x86_64/ahci/io/pio/lba28/long/high
PASS 3 test-rcu-list /rcu/qlist/long-many
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-simpleq -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-simpleq" 
==9052==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 18 ahci-test /x86_64/ahci/io/pio/lba28/short/zero
PASS 1 test-rcu-simpleq /rcu/qsimpleq/single-threaded
==9065==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 19 ahci-test /x86_64/ahci/io/pio/lba28/short/low
PASS 2 test-rcu-simpleq /rcu/qsimpleq/short-few
==9077==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 20 ahci-test /x86_64/ahci/io/pio/lba28/short/high
==9104==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9104==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffee5b97000; bottom 0x7fd37abfe000; size: 0x002b6af99000 (186478333952)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 21 ahci-test /x86_64/ahci/io/pio/lba48/simple/zero
PASS 3 test-rcu-simpleq /rcu/qsimpleq/long-many
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-rcu-tailq -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-rcu-tailq" 
==9110==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9110==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc200d3000; bottom 0x7f972dbfe000; size: 0x0064f24d5000 (433561882624)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 22 ahci-test /x86_64/ahci/io/pio/lba48/simple/low
PASS 1 test-rcu-tailq /rcu/qtailq/single-threaded
==9123==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9123==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffe16471000; bottom 0x7f132c7fe000; size: 0x00eae9c73000 (1008944492544)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 2 test-rcu-tailq /rcu/qtailq/short-few
PASS 23 ahci-test /x86_64/ahci/io/pio/lba48/simple/high
==9156==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9156==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffdd3bf5000; bottom 0x7fe93e9fe000; size: 0x0014951f7000 (88401211392)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 24 ahci-test /x86_64/ahci/io/pio/lba48/double/zero
==9162==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9162==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fff3fbc6000; bottom 0x7fb0fc9fe000; size: 0x004e431c8000 (336133390336)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 3 test-rcu-tailq /rcu/qtailq/long-many
---
PASS 8 test-qdist /qdist/binning/shrink
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qht -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qht" 
PASS 25 ahci-test /x86_64/ahci/io/pio/lba48/double/low
==9177==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9177==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffc5c005000; bottom 0x7fa1305fe000; size: 0x005b2ba07000 (391573958656)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 26 ahci-test /x86_64/ahci/io/pio/lba48/double/high
==9183==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9183==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffedd7ec000; bottom 0x7f085fd7c000; size: 0x00f67da70000 (1058670051328)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 27 ahci-test /x86_64/ahci/io/pio/lba48/long/zero
==9189==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9189==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffe02fd3000; bottom 0x7f49fa77c000; size: 0x00b408857000 (773237075968)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 28 ahci-test /x86_64/ahci/io/pio/lba48/long/low
==9195==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9195==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffe032ab000; bottom 0x7fa768bfe000; size: 0x00569a6ad000 (371957878784)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 29 ahci-test /x86_64/ahci/io/pio/lba48/long/high
==9201==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 30 ahci-test /x86_64/ahci/io/pio/lba48/short/zero
==9207==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 31 ahci-test /x86_64/ahci/io/pio/lba48/short/low
==9213==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 32 ahci-test /x86_64/ahci/io/pio/lba48/short/high
==9219==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 33 ahci-test /x86_64/ahci/io/dma/lba28/fragmented
==9225==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 34 ahci-test /x86_64/ahci/io/dma/lba28/retry
==9231==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 35 ahci-test /x86_64/ahci/io/dma/lba28/simple/zero
==9237==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 36 ahci-test /x86_64/ahci/io/dma/lba28/simple/low
==9243==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-qht /qht/mode/default
PASS 2 test-qht /qht/mode/resize
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qht-par -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qht-par" 
PASS 37 ahci-test /x86_64/ahci/io/dma/lba28/simple/high
==9259==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-qht-par /qht/parallel/2threads-0%updates-1s
PASS 38 ahci-test /x86_64/ahci/io/dma/lba28/double/zero
==9272==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 test-qht-par /qht/parallel/2threads-20%updates-1s
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bitops -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bitops" 
PASS 39 ahci-test /x86_64/ahci/io/dma/lba28/double/low
---
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qdev-global-props -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qdev-global-props" 
PASS 1 test-qdev-global-props /qdev/properties/static/default
PASS 2 test-qdev-global-props /qdev/properties/static/global
==9284==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-qdev-global-props /qdev/properties/dynamic/global
PASS 4 test-qdev-global-props /qdev/properties/global/subclass
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/check-qom-interface -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="check-qom-interface" 
---
PASS 9 test-keyval /keyval/visit/alternate
PASS 10 test-keyval /keyval/visit/any
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-write-threshold -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-write-threshold" 
==9316==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-write-threshold /write-threshold/not-set-on-init
PASS 2 test-write-threshold /write-threshold/set-get
PASS 3 test-write-threshold /write-threshold/multi-set-get
---
PASS 15 test-crypto-secret /crypto/secret/crypt/missingiv
PASS 16 test-crypto-secret /crypto/secret/crypt/badiv
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-crypto-tlscredsx509 -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-crypto-tlscredsx509" 
==9347==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 42 ahci-test /x86_64/ahci/io/dma/lba28/long/low
==9362==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 43 ahci-test /x86_64/ahci/io/dma/lba28/long/high
PASS 1 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/perfectserver
PASS 2 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/perfectclient
==9368==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca1
PASS 44 ahci-test /x86_64/ahci/io/dma/lba28/short/zero
PASS 4 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca2
==9374==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 45 ahci-test /x86_64/ahci/io/dma/lba28/short/low
==9380==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 5 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodca3
PASS 6 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca1
PASS 7 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca2
PASS 8 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/badca3
PASS 46 ahci-test /x86_64/ahci/io/dma/lba28/short/high
==9386==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 9 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver1
PASS 47 ahci-test /x86_64/ahci/io/dma/lba48/simple/zero
PASS 10 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver2
==9392==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 11 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver3
PASS 48 ahci-test /x86_64/ahci/io/dma/lba48/simple/low
PASS 12 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver4
PASS 13 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver5
==9398==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 14 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver6
PASS 49 ahci-test /x86_64/ahci/io/dma/lba48/simple/high
PASS 15 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/goodserver7
---
PASS 32 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive1
PASS 33 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive2
PASS 34 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/inactive3
==9404==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 35 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/chain1
PASS 36 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/chain2
PASS 37 test-crypto-tlscredsx509 /qcrypto/tlscredsx509/missingca
---
PASS 1 test-crypto-tlssession /qcrypto/tlssession/psk
PASS 50 ahci-test /x86_64/ahci/io/dma/lba48/double/zero
PASS 2 test-crypto-tlssession /qcrypto/tlssession/basicca
==9415==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-crypto-tlssession /qcrypto/tlssession/differentca
PASS 51 ahci-test /x86_64/ahci/io/dma/lba48/double/low
PASS 4 test-crypto-tlssession /qcrypto/tlssession/altname1
==9421==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 5 test-crypto-tlssession /qcrypto/tlssession/altname2
PASS 52 ahci-test /x86_64/ahci/io/dma/lba48/double/high
==9427==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 53 ahci-test /x86_64/ahci/io/dma/lba48/long/zero
PASS 6 test-crypto-tlssession /qcrypto/tlssession/altname3
PASS 7 test-crypto-tlssession /qcrypto/tlssession/altname4
==9433==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 8 test-crypto-tlssession /qcrypto/tlssession/altname5
PASS 54 ahci-test /x86_64/ahci/io/dma/lba48/long/low
==9439==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 9 test-crypto-tlssession /qcrypto/tlssession/altname6
PASS 55 ahci-test /x86_64/ahci/io/dma/lba48/long/high
==9445==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 56 ahci-test /x86_64/ahci/io/dma/lba48/short/zero
==9451==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 57 ahci-test /x86_64/ahci/io/dma/lba48/short/low
==9457==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 10 test-crypto-tlssession /qcrypto/tlssession/wildcard1
PASS 58 ahci-test /x86_64/ahci/io/dma/lba48/short/high
PASS 11 test-crypto-tlssession /qcrypto/tlssession/wildcard2
==9463==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 59 ahci-test /x86_64/ahci/io/ncq/simple
==9470==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 12 test-crypto-tlssession /qcrypto/tlssession/wildcard3
PASS 13 test-crypto-tlssession /qcrypto/tlssession/wildcard4
PASS 60 ahci-test /x86_64/ahci/io/ncq/retry
PASS 14 test-crypto-tlssession /qcrypto/tlssession/wildcard5
==9476==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 61 ahci-test /x86_64/ahci/flush/simple
PASS 15 test-crypto-tlssession /qcrypto/tlssession/wildcard6
==9482==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 16 test-crypto-tlssession /qcrypto/tlssession/cachain
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-qga -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-qga" 
PASS 62 ahci-test /x86_64/ahci/flush/retry
==9494==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-qga /qga/sync-delimited
PASS 2 test-qga /qga/sync
PASS 3 test-qga /qga/ping
---
PASS 15 test-qga /qga/invalid-cmd
PASS 16 test-qga /qga/invalid-args
PASS 17 test-qga /qga/fsfreeze-status
==9499==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 18 test-qga /qga/blacklist
PASS 19 test-qga /qga/config
PASS 20 test-qga /qga/guest-exec
---
PASS 23 test-qga /qga/guest-get-host-name
PASS 24 test-qga /qga/guest-get-timezone
PASS 25 test-qga /qga/guest-get-users
==9516==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-timed-average -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-timed-average" 
PASS 1 test-timed-average /timed-average/average
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-util-filemonitor -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-util-filemonitor" 
---
PASS 7 test-util-sockets /socket/fd-pass/num/bad
PASS 8 test-util-sockets /socket/fd-pass/num/nocli
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-authz-simple -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-authz-simple" 
==9535==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-authz-simple /authz/simple
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-authz-list -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-authz-list" 
PASS 1 test-authz-list /auth/list/complex
---
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-io-channel-tls -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-io-channel-tls" 
PASS 64 ahci-test /x86_64/ahci/migrate/sanity
PASS 1 test-io-channel-tls /qio/channel/tls/basic
==9624==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-io-channel-command -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-io-channel-command" 
PASS 1 test-io-channel-command /io/channel/command/fifo/sync
PASS 2 test-io-channel-command /io/channel/command/fifo/async
PASS 3 test-io-channel-command /io/channel/command/echo/sync
PASS 4 test-io-channel-command /io/channel/command/echo/async
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-io-channel-buffer -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-io-channel-buffer" 
==9639==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-io-channel-buffer /io/channel/buf
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-base64 -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-base64" 
PASS 1 test-base64 /util/base64/good
---
PASS 1 test-logging /logging/parse_range
PASS 2 test-logging /logging/parse_path
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-replication -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-replication" 
==9685==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-replication /replication/primary/read
PASS 2 test-replication /replication/primary/write
PASS 65 ahci-test /x86_64/ahci/migrate/dma/simple
==9691==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 test-replication /replication/primary/start
PASS 4 test-replication /replication/primary/stop
PASS 5 test-replication /replication/primary/do_checkpoint
PASS 6 test-replication /replication/primary/get_error_all
==9696==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 7 test-replication /replication/secondary/read
PASS 8 test-replication /replication/secondary/write
PASS 66 ahci-test /x86_64/ahci/migrate/dma/halted
==9705==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9710==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9685==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7fffcde4c000; bottom 0x7f0bb6efc000; size: 0x00f416f50000 (1048357175296)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 9 test-replication /replication/secondary/start
PASS 67 ahci-test /x86_64/ahci/migrate/ncq/simple
==9739==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9744==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 10 test-replication /replication/secondary/stop
PASS 68 ahci-test /x86_64/ahci/migrate/ncq/halted
==9754==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 69 ahci-test /x86_64/ahci/cdrom/eject
PASS 11 test-replication /replication/secondary/do_checkpoint
==9759==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 12 test-replication /replication/secondary/get_error_all
PASS 70 ahci-test /x86_64/ahci/cdrom/dma/single
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-bufferiszero -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-bufferiszero" 
==9766==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 71 ahci-test /x86_64/ahci/cdrom/dma/multi
==9775==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 72 ahci-test /x86_64/ahci/cdrom/pio/single
==9781==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
==9781==WARNING: ASan is ignoring requested __asan_handle_no_return: stack top: 0x7ffde64fa000; bottom 0x7f95085fe000; size: 0x0068ddefc000 (450400075776)
False positive error reports may follow
For details see https://github.com/google/sanitizers/issues/189
PASS 73 ahci-test /x86_64/ahci/cdrom/pio/multi
==9787==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 74 ahci-test /x86_64/ahci/cdrom/pio/bcl
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/hd-geo-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="hd-geo-test" 
PASS 1 hd-geo-test /x86_64/hd-geo/ide/none
==9801==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 2 hd-geo-test /x86_64/hd-geo/ide/drive/cd_0
==9807==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 3 hd-geo-test /x86_64/hd-geo/ide/drive/mbr/blank
==9813==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 4 hd-geo-test /x86_64/hd-geo/ide/drive/mbr/lba
==9819==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 5 hd-geo-test /x86_64/hd-geo/ide/drive/mbr/chs
==9825==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 6 hd-geo-test /x86_64/hd-geo/ide/device/mbr/blank
==9831==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 7 hd-geo-test /x86_64/hd-geo/ide/device/mbr/lba
==9837==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 8 hd-geo-test /x86_64/hd-geo/ide/device/mbr/chs
==9843==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 9 hd-geo-test /x86_64/hd-geo/ide/device/user/chs
==9848==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 10 hd-geo-test /x86_64/hd-geo/ide/device/user/chst
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 QTEST_QEMU_IMG=qemu-img tests/boot-order-test -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="boot-order-test" 
PASS 1 boot-order-test /x86_64/boot-order/pc
---
Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
==9916==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
PASS 1 test-bufferiszero /cutils/bufferiszero
MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(( ${RANDOM:-0} % 255 + 1))}  tests/test-uuid -m=quick -k --tap < /dev/null | ./scripts/tap-driver.pl --test-name="test-uuid" 
PASS 1 test-uuid /uuid/is_null
---
PASS 326 ptimer-test /ptimer/on_the_fly_freq_change policy=wrap_after_one_period,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
acpi-test: Warning! DSDT binary file mismatch. Actual [aml:/tmp/aml-AUDP6Z], Expected [aml:tests/data/acpi/pc/DSDT].
to see ASL diff between mismatched files install IASL, rebuild QEMU from scratch and re-run tests with V=1 environment variable set**
ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl: assertion failed: (all_tables_match)
PASS 327 ptimer-test /ptimer/run_with_period_0 policy=wrap_after_one_period,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
PASS 328 ptimer-test /ptimer/run_with_delta_0 policy=wrap_after_one_period,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
PASS 329 ptimer-test /ptimer/periodic_with_load_0 policy=wrap_after_one_period,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
PASS 330 ptimer-test /ptimer/oneshot_with_load_0 policy=wrap_after_one_period,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
ERROR - Bail out! ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl: assertion failed: (all_tables_match)
PASS 331 ptimer-test /ptimer/set_count policy=continuous_trigger,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
PASS 332 ptimer-test /ptimer/set_limit policy=continuous_trigger,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,
PASS 333 ptimer-test /ptimer/oneshot policy=continuous_trigger,no_immediate_trigger,no_immediate_reload,no_counter_rounddown,


The full log is available at
http://patchew.org/logs/20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
@ 2019-08-15  8:42   ` Shameerali Kolothum Thodi
  2019-08-29  8:45     ` Igor Mammedov
  2019-09-01 11:17   ` Auger Eric
  1 sibling, 1 reply; 29+ messages in thread
From: Shameerali Kolothum Thodi @ 2019-08-15  8:42 UTC (permalink / raw)
  To: qemu-devel, qemu-arm, eric.auger, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, Linuxarm, shannon.zhaosl,
	sebastien.boeuf, lersek



> -----Original Message-----
> From: Linuxarm [mailto:linuxarm-bounces@huawei.com] On Behalf Of Shameer
> Kolothum
> Sent: 13 August 2019 22:05
> To: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> eric.auger@redhat.com; imammedo@redhat.com
> Cc: peter.maydell@linaro.org; sameo@linux.intel.com;
> ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com; lersek@redhat.com
> Subject: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> configurable
> 
> This is in preparation for adding support for ARM64 platforms
> where it doesn't use port mapped IO for ACPI IO space. We are
> making changes so that MMIO region can be accommodated
> and board can pass the base address into the aml build function.

Looks like, this now breaks the "make check" on x86_64 and needs
updating bios-tables-test-allowed-diff.h with DSDT entries. But I am 
not sure what changed now compared to v8(and older ones) that makes
it to complain now!. 

Patchew URL: https://patchew.org/QEMU/20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com/

ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl: assertion failed: (all_tables_match)

Thanks,
Shameer

> Also move few MEMORY_* definitions to header so that other memory
> hotplug event signalling mechanisms (eg. Generic Event Device on
> HW-reduced acpi platforms) can use the same from their respective
> event handler code.
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> v8 --> v9
>   -base address is an input into build_memory_hotplug_aml()
>   -Removed R-by tags from Igor and Eric for now.
> ---
>  hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
>  hw/i386/acpi-build.c             |  4 +++-
>  hw/i386/pc.c                     |  3 +++
>  include/hw/acpi/memory_hotplug.h |  9 +++++++--
>  include/hw/i386/pc.h             |  3 +++
>  5 files changed, 30 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 297812d5f7..1734d4b44f 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -29,12 +29,7 @@
>  #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
>  #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
>  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> -#define MEMORY_HOTPLUG_IO_LEN         24
> -#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> -
> -static uint16_t memhp_io_base;
> 
>  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
>  {
> @@ -209,7 +204,7 @@ static const MemoryRegionOps
> acpi_memory_hotplug_ops = {
>  };
> 
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state, uint16_t
> io_base)
> +                              MemHotplugState *state, hwaddr
> io_base)
>  {
>      MachineState *machine = MACHINE(qdev_get_machine());
> 
> @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as,
> Object *owner,
>          return;
>      }
> 
> -    assert(!memhp_io_base);
> -    memhp_io_base = io_base;
>      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
>      memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops,
> state,
>                            "acpi-mem-hotplug",
> MEMORY_HOTPLUG_IO_LEN);
> -    memory_region_add_subregion(as, memhp_io_base, &state->io);
> +    memory_region_add_subregion(as, io_base, &state->io);
>  }
> 
>  /**
> @@ -342,7 +335,8 @@ const VMStateDescription vmstate_memory_hotplug
> = {
> 
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                const char *res_root,
> -                              const char *event_handler_method)
> +                              const char *event_handler_method,
> +                              AmlRegionSpace rs, hwaddr
> memhp_io_base)
>  {
>      int i;
>      Aml *ifctx;
> @@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table,
> uint32_t nr_mem,
>              aml_name_decl("_UID", aml_string("Memory hotplug
> resources")));
> 
>          crs = aml_resource_template();
> -        aml_append(crs,
> -            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> -                   MEMORY_HOTPLUG_IO_LEN)
> -        );
> +        if (rs == AML_SYSTEM_IO) {
> +            aml_append(crs,
> +                aml_io(AML_DECODE16, memhp_io_base,
> memhp_io_base, 0,
> +                       MEMORY_HOTPLUG_IO_LEN)
> +            );
> +        } else {
> +            aml_append(crs, aml_memory32_fixed(memhp_io_base,
> +                            MEMORY_HOTPLUG_IO_LEN,
> AML_READ_WRITE));
> +        }
>          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> 
>          aml_append(mem_ctrl_dev, aml_operation_region(
> -            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> +            MEMORY_HOTPLUG_IO_REGION, rs,
>              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
>          );
> 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index f3fdfefcd5..e76d6631ea 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
>                         "\\_SB.PCI0", "\\_GPE._E02");
>      }
> -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> "\\_GPE._E03");
> +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> +                             "\\_GPE._E03", AML_SYSTEM_IO,
> +                             pcms->memhp_io_base);
> 
>      scope =  aml_scope("_GPE");
>      {
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 549c437050..be973cea99 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
> 
>      /* Init default IOAPIC address space */
>      pcms->ioapic_as = &address_space_memory;
> +
> +    /* Init ACPI memory hotplug IO base address */
> +    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
>  }
> 
>  /*
> diff --git a/include/hw/acpi/memory_hotplug.h
> b/include/hw/acpi/memory_hotplug.h
> index 77c65765d6..dfe9cf3fde 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -5,6 +5,10 @@
>  #include "hw/acpi/acpi.h"
>  #include "hw/acpi/aml-build.h"
> 
> +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> +#define MEMORY_HOTPLUG_IO_LEN         24
> +
>  /**
>   * MemStatus:
>   * @is_removing: the memory device in slot has been requested to be
> ejected.
> @@ -29,7 +33,7 @@ typedef struct MemHotplugState {
>  } MemHotplugState;
> 
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state, uint16_t
> io_base);
> +                              MemHotplugState *state, hwaddr
> io_base);
> 
>  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState
> *mem_st,
>                           DeviceState *dev, Error **errp);
> @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState
> *mem_st, ACPIOSTInfoList ***list);
> 
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                const char *res_root,
> -                              const char *event_handler_method);
> +                              const char *event_handler_method,
> +                              AmlRegionSpace rs, hwaddr
> memhp_io_base);
>  #endif
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 859b64c51d..49b47535cf 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -69,6 +69,9 @@ struct PCMachineState {
>      /* Address space used by IOAPIC device. All IOAPIC interrupts
>       * will be translated to MSI messages in the address space. */
>      AddressSpace *ioapic_as;
> +
> +    /* ACPI Memory hotplug IO base address */
> +    hwaddr memhp_io_base;
>  };
> 
>  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> --
> 2.17.1
> 
> 
> _______________________________________________
> Linuxarm mailing list
> Linuxarm@huawei.com
> http://hulk.huawei.com/mailman/listinfo/linuxarm


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-15  8:42   ` Shameerali Kolothum Thodi
@ 2019-08-29  8:45     ` Igor Mammedov
  2019-08-29 11:04       ` Shameerali Kolothum Thodi
  0 siblings, 1 reply; 29+ messages in thread
From: Igor Mammedov @ 2019-08-29  8:45 UTC (permalink / raw)
  To: Shameerali Kolothum Thodi
  Cc: peter.maydell, sameo, ard.biesheuvel, shannon.zhaosl, qemu-devel,
	Linuxarm, eric.auger, qemu-arm, sebastien.boeuf, lersek

On Thu, 15 Aug 2019 08:42:48 +0000
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> wrote:

> > -----Original Message-----
> > From: Linuxarm [mailto:linuxarm-bounces@huawei.com] On Behalf Of Shameer
> > Kolothum
> > Sent: 13 August 2019 22:05
> > To: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> > eric.auger@redhat.com; imammedo@redhat.com
> > Cc: peter.maydell@linaro.org; sameo@linux.intel.com;
> > ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> > shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com; lersek@redhat.com
> > Subject: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> > configurable
> > 
> > This is in preparation for adding support for ARM64 platforms
> > where it doesn't use port mapped IO for ACPI IO space. We are
> > making changes so that MMIO region can be accommodated
> > and board can pass the base address into the aml build function.  
> 
> Looks like, this now breaks the "make check" on x86_64 and needs
> updating bios-tables-test-allowed-diff.h with DSDT entries. But I am 
> not sure what changed now compared to v8(and older ones) that makes
> it to complain now!. 

you could see diff of what's changed but running test manually with
V=1 env var if you have 'iasl' installed

V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/bios-tables-test


> Patchew URL: https://patchew.org/QEMU/20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com/
> 
> ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl: assertion failed: (all_tables_match)
> 
> Thanks,
> Shameer
> 
> > Also move few MEMORY_* definitions to header so that other memory
> > hotplug event signalling mechanisms (eg. Generic Event Device on
> > HW-reduced acpi platforms) can use the same from their respective
> > event handler code.
> > 
> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> > ---
> > v8 --> v9
> >   -base address is an input into build_memory_hotplug_aml()
> >   -Removed R-by tags from Igor and Eric for now.
> > ---
> >  hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
> >  hw/i386/acpi-build.c             |  4 +++-
> >  hw/i386/pc.c                     |  3 +++
> >  include/hw/acpi/memory_hotplug.h |  9 +++++++--
> >  include/hw/i386/pc.h             |  3 +++
> >  5 files changed, 30 insertions(+), 18 deletions(-)
> > 
> > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > index 297812d5f7..1734d4b44f 100644
> > --- a/hw/acpi/memory_hotplug.c
> > +++ b/hw/acpi/memory_hotplug.c
> > @@ -29,12 +29,7 @@
> >  #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
> >  #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
> >  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> > -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> >  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> > -#define MEMORY_HOTPLUG_IO_LEN         24
> > -#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > -
> > -static uint16_t memhp_io_base;
> > 
> >  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
> >  {
> > @@ -209,7 +204,7 @@ static const MemoryRegionOps
> > acpi_memory_hotplug_ops = {
> >  };
> > 
> >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > -                              MemHotplugState *state, uint16_t
> > io_base)
> > +                              MemHotplugState *state, hwaddr
> > io_base)
> >  {
> >      MachineState *machine = MACHINE(qdev_get_machine());
> > 
> > @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as,
> > Object *owner,
> >          return;
> >      }
> > 
> > -    assert(!memhp_io_base);
> > -    memhp_io_base = io_base;
> >      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
> >      memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops,
> > state,
> >                            "acpi-mem-hotplug",
> > MEMORY_HOTPLUG_IO_LEN);
> > -    memory_region_add_subregion(as, memhp_io_base, &state->io);
> > +    memory_region_add_subregion(as, io_base, &state->io);
> >  }
> > 
> >  /**
> > @@ -342,7 +335,8 @@ const VMStateDescription vmstate_memory_hotplug
> > = {
> > 
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                const char *res_root,
> > -                              const char *event_handler_method)
> > +                              const char *event_handler_method,
> > +                              AmlRegionSpace rs, hwaddr
> > memhp_io_base)
> >  {
> >      int i;
> >      Aml *ifctx;
> > @@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table,
> > uint32_t nr_mem,
> >              aml_name_decl("_UID", aml_string("Memory hotplug
> > resources")));
> > 
> >          crs = aml_resource_template();
> > -        aml_append(crs,
> > -            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> > -                   MEMORY_HOTPLUG_IO_LEN)
> > -        );
> > +        if (rs == AML_SYSTEM_IO) {
> > +            aml_append(crs,
> > +                aml_io(AML_DECODE16, memhp_io_base,
> > memhp_io_base, 0,
> > +                       MEMORY_HOTPLUG_IO_LEN)
> > +            );
> > +        } else {
> > +            aml_append(crs, aml_memory32_fixed(memhp_io_base,
> > +                            MEMORY_HOTPLUG_IO_LEN,
> > AML_READ_WRITE));
> > +        }
> >          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> > 
> >          aml_append(mem_ctrl_dev, aml_operation_region(
> > -            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > +            MEMORY_HOTPLUG_IO_REGION, rs,
> >              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
> >          );
> > 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index f3fdfefcd5..e76d6631ea 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> >          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
> >                         "\\_SB.PCI0", "\\_GPE._E02");
> >      }
> > -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > "\\_GPE._E03");
> > +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > +                             "\\_GPE._E03", AML_SYSTEM_IO,
> > +                             pcms->memhp_io_base);
> > 
> >      scope =  aml_scope("_GPE");
> >      {
> > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > index 549c437050..be973cea99 100644
> > --- a/hw/i386/pc.c
> > +++ b/hw/i386/pc.c
> > @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
> > 
> >      /* Init default IOAPIC address space */
> >      pcms->ioapic_as = &address_space_memory;
> > +
> > +    /* Init ACPI memory hotplug IO base address */
> > +    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
> >  }
> > 
> >  /*
> > diff --git a/include/hw/acpi/memory_hotplug.h
> > b/include/hw/acpi/memory_hotplug.h
> > index 77c65765d6..dfe9cf3fde 100644
> > --- a/include/hw/acpi/memory_hotplug.h
> > +++ b/include/hw/acpi/memory_hotplug.h
> > @@ -5,6 +5,10 @@
> >  #include "hw/acpi/acpi.h"
> >  #include "hw/acpi/aml-build.h"
> > 
> > +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > +#define MEMORY_HOTPLUG_IO_LEN         24
> > +
> >  /**
> >   * MemStatus:
> >   * @is_removing: the memory device in slot has been requested to be
> > ejected.
> > @@ -29,7 +33,7 @@ typedef struct MemHotplugState {
> >  } MemHotplugState;
> > 
> >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > -                              MemHotplugState *state, uint16_t
> > io_base);
> > +                              MemHotplugState *state, hwaddr
> > io_base);
> > 
> >  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState
> > *mem_st,
> >                           DeviceState *dev, Error **errp);
> > @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState
> > *mem_st, ACPIOSTInfoList ***list);
> > 
> >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> >                                const char *res_root,
> > -                              const char *event_handler_method);
> > +                              const char *event_handler_method,
> > +                              AmlRegionSpace rs, hwaddr
> > memhp_io_base);
> >  #endif
> > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> > index 859b64c51d..49b47535cf 100644
> > --- a/include/hw/i386/pc.h
> > +++ b/include/hw/i386/pc.h
> > @@ -69,6 +69,9 @@ struct PCMachineState {
> >      /* Address space used by IOAPIC device. All IOAPIC interrupts
> >       * will be translated to MSI messages in the address space. */
> >      AddressSpace *ioapic_as;
> > +
> > +    /* ACPI Memory hotplug IO base address */
> > +    hwaddr memhp_io_base;
> >  };
> > 
> >  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> > --
> > 2.17.1
> > 
> > 
> > _______________________________________________
> > Linuxarm mailing list
> > Linuxarm@huawei.com
> > http://hulk.huawei.com/mailman/listinfo/linuxarm  



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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-29  8:45     ` Igor Mammedov
@ 2019-08-29 11:04       ` Shameerali Kolothum Thodi
  2019-08-29 12:38         ` Igor Mammedov
  0 siblings, 1 reply; 29+ messages in thread
From: Shameerali Kolothum Thodi @ 2019-08-29 11:04 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, sameo, ard.biesheuvel, shannon.zhaosl, qemu-devel,
	Linuxarm, eric.auger, qemu-arm, sebastien.boeuf, lersek

Hi Igor,

> -----Original Message-----
> From: Igor Mammedov [mailto:imammedo@redhat.com]
> Sent: 29 August 2019 09:45
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
> Cc: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> eric.auger@redhat.com; peter.maydell@linaro.org; sameo@linux.intel.com;
> ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com; lersek@redhat.com
> Subject: Re: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> configurable
> 
> On Thu, 15 Aug 2019 08:42:48 +0000
> Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> wrote:
> 
> > > -----Original Message-----
> > > From: Linuxarm [mailto:linuxarm-bounces@huawei.com] On Behalf Of
> Shameer
> > > Kolothum
> > > Sent: 13 August 2019 22:05
> > > To: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> > > eric.auger@redhat.com; imammedo@redhat.com
> > > Cc: peter.maydell@linaro.org; sameo@linux.intel.com;
> > > ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> > > shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com;
> lersek@redhat.com
> > > Subject: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> > > configurable
> > >
> > > This is in preparation for adding support for ARM64 platforms
> > > where it doesn't use port mapped IO for ACPI IO space. We are
> > > making changes so that MMIO region can be accommodated
> > > and board can pass the base address into the aml build function.
> >
> > Looks like, this now breaks the "make check" on x86_64 and needs
> > updating bios-tables-test-allowed-diff.h with DSDT entries. But I am
> > not sure what changed now compared to v8(and older ones) that makes
> > it to complain now!.
> 
> you could see diff of what's changed but running test manually with
> V=1 env var if you have 'iasl' installed
> 
> V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64
> tests/bios-tables-test

Thanks for that tip and please find below output.

/x86_64/acpi/piix4: Could not access KVM kernel module: No such file or directory
qemu-system-x86_64: failed to initialize KVM: No such file or directory
qemu-system-x86_64: Back to tcg accelerator
acpi-test: Warning! DSDT binary file mismatch. Actual [aml:/tmp/aml-RGE76Z], Expected [aml:tests/data/acpi/pc/DSDT].
acpi-test: Warning! DSDT mismatch. Actual [asl:/tmp/asl-TAE76Z.dsl, aml:/tmp/aml-RGE76Z], Expected [asl:/tmp/asl-O6B76Z.dsl, aml:tests/data/acpi/pc/DSDT].

diff --git a/tmp/asl-O6B76Z.dsl b/tmp/asl-TAE76Z.dsl
index 823ff002ec..4de5bd3221 100644
--- a/tmp/asl-O6B76Z.dsl
+++ b/tmp/asl-TAE76Z.dsl
@@ -5,13 +5,13 @@
  *
  * Disassembling to symbolic ASL+ operators
  *
- * Disassembly of tests/data/acpi/pc/DSDT, Thu Aug 29 10:40:40 2019
+ * Disassembly of /tmp/aml-RGE76Z, Thu Aug 29 10:40:40 2019
  *
  * Original Table Header:
  *     Signature        "DSDT"
- *     Length           0x0000140B (5131)
+ *     Length           0x000017E4 (6116)
  *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
- *     Checksum         0xB1
+ *     Checksum         0x8B
  *     OEM ID           "BOCHS "
  *     OEM Table ID     "BXPCDSDT"
  *     OEM Revision     0x00000001 (1)
@@ -787,6 +787,206 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
         \_SB.CPUS.CSCN ()
     }

+    Device (\_SB.PCI0.MHPD)
+    {
+        Name (_HID, "PNP0A06" /* Generic Container Device */)  // _HID: Hardware ID
+        Name (_UID, "Memory hotplug resources")  // _UID: Unique ID
+        Name (_CRS, Reso 

I think what happens is since we are now passing the memhp_io_base directly into the 
build_memory_hotplug_aml() and removed the "static uint16_t memhp_io_base", on 
x86, memory hotplug aml code is always built by default irrespective of whether
acpi_memory_hotplug_init() is invoked or not. 

I could either reintroduce a check in build_memory_hotplug_aml() to make sure
acpi_memory_hotplug_init() is called, or could do something like below, 

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3995f9a40f..17756c2191 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1873,9 +1873,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
         build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
                        "\\_SB.PCI0", "\\_GPE._E02");
     }
-    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
-                             "\\_GPE._E03", AML_SYSTEM_IO,
-                             pcms->memhp_io_base);
+
+    if (acpi_enabled && pcms->acpi_dev && nr_mem) {
+        build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
+                                 "\\_GPE._E03", AML_SYSTEM_IO,
+                                 pcms->memhp_io_base);
+    }


I prefer the latter if there are no other issues with that. Please let me know.

Thanks,
Shameer

> 
> > Patchew URL:
> https://patchew.org/QEMU/20190813210539.31164-1-shameerali.kolothum.t
> hodi@huawei.com/
> >
> > ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl:
> assertion failed: (all_tables_match)
> >
> > Thanks,
> > Shameer
> >
> > > Also move few MEMORY_* definitions to header so that other memory
> > > hotplug event signalling mechanisms (eg. Generic Event Device on
> > > HW-reduced acpi platforms) can use the same from their respective
> > > event handler code.
> > >
> > > Signed-off-by: Shameer Kolothum
> <shameerali.kolothum.thodi@huawei.com>
> > > ---
> > > v8 --> v9
> > >   -base address is an input into build_memory_hotplug_aml()
> > >   -Removed R-by tags from Igor and Eric for now.
> > > ---
> > >  hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
> > >  hw/i386/acpi-build.c             |  4 +++-
> > >  hw/i386/pc.c                     |  3 +++
> > >  include/hw/acpi/memory_hotplug.h |  9 +++++++--
> > >  include/hw/i386/pc.h             |  3 +++
> > >  5 files changed, 30 insertions(+), 18 deletions(-)
> > >
> > > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > > index 297812d5f7..1734d4b44f 100644
> > > --- a/hw/acpi/memory_hotplug.c
> > > +++ b/hw/acpi/memory_hotplug.c
> > > @@ -29,12 +29,7 @@
> > >  #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
> > >  #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
> > >  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> > > -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > >  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> > > -#define MEMORY_HOTPLUG_IO_LEN         24
> > > -#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > > -
> > > -static uint16_t memhp_io_base;
> > >
> > >  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus
> *mdev)
> > >  {
> > > @@ -209,7 +204,7 @@ static const MemoryRegionOps
> > > acpi_memory_hotplug_ops = {
> > >  };
> > >
> > >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > > -                              MemHotplugState *state, uint16_t
> > > io_base)
> > > +                              MemHotplugState *state, hwaddr
> > > io_base)
> > >  {
> > >      MachineState *machine = MACHINE(qdev_get_machine());
> > >
> > > @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion
> *as,
> > > Object *owner,
> > >          return;
> > >      }
> > >
> > > -    assert(!memhp_io_base);
> > > -    memhp_io_base = io_base;
> > >      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
> > >      memory_region_init_io(&state->io, owner,
> &acpi_memory_hotplug_ops,
> > > state,
> > >                            "acpi-mem-hotplug",
> > > MEMORY_HOTPLUG_IO_LEN);
> > > -    memory_region_add_subregion(as, memhp_io_base, &state->io);
> > > +    memory_region_add_subregion(as, io_base, &state->io);
> > >  }
> > >
> > >  /**
> > > @@ -342,7 +335,8 @@ const VMStateDescription
> vmstate_memory_hotplug
> > > = {
> > >
> > >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > >                                const char *res_root,
> > > -                              const char *event_handler_method)
> > > +                              const char *event_handler_method,
> > > +                              AmlRegionSpace rs, hwaddr
> > > memhp_io_base)
> > >  {
> > >      int i;
> > >      Aml *ifctx;
> > > @@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table,
> > > uint32_t nr_mem,
> > >              aml_name_decl("_UID", aml_string("Memory hotplug
> > > resources")));
> > >
> > >          crs = aml_resource_template();
> > > -        aml_append(crs,
> > > -            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base,
> 0,
> > > -                   MEMORY_HOTPLUG_IO_LEN)
> > > -        );
> > > +        if (rs == AML_SYSTEM_IO) {
> > > +            aml_append(crs,
> > > +                aml_io(AML_DECODE16, memhp_io_base,
> > > memhp_io_base, 0,
> > > +                       MEMORY_HOTPLUG_IO_LEN)
> > > +            );
> > > +        } else {
> > > +            aml_append(crs, aml_memory32_fixed(memhp_io_base,
> > > +                            MEMORY_HOTPLUG_IO_LEN,
> > > AML_READ_WRITE));
> > > +        }
> > >          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> > >
> > >          aml_append(mem_ctrl_dev, aml_operation_region(
> > > -            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > > +            MEMORY_HOTPLUG_IO_REGION, rs,
> > >              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
> > >          );
> > >
> > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > index f3fdfefcd5..e76d6631ea 100644
> > > --- a/hw/i386/acpi-build.c
> > > +++ b/hw/i386/acpi-build.c
> > > @@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker
> *linker,
> > >          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
> > >                         "\\_SB.PCI0", "\\_GPE._E02");
> > >      }
> > > -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > > "\\_GPE._E03");
> > > +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > > +                             "\\_GPE._E03", AML_SYSTEM_IO,
> > > +                             pcms->memhp_io_base);
> > >
> > >      scope =  aml_scope("_GPE");
> > >      {
> > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > > index 549c437050..be973cea99 100644
> > > --- a/hw/i386/pc.c
> > > +++ b/hw/i386/pc.c
> > > @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
> > >
> > >      /* Init default IOAPIC address space */
> > >      pcms->ioapic_as = &address_space_memory;
> > > +
> > > +    /* Init ACPI memory hotplug IO base address */
> > > +    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
> > >  }
> > >
> > >  /*
> > > diff --git a/include/hw/acpi/memory_hotplug.h
> > > b/include/hw/acpi/memory_hotplug.h
> > > index 77c65765d6..dfe9cf3fde 100644
> > > --- a/include/hw/acpi/memory_hotplug.h
> > > +++ b/include/hw/acpi/memory_hotplug.h
> > > @@ -5,6 +5,10 @@
> > >  #include "hw/acpi/acpi.h"
> > >  #include "hw/acpi/aml-build.h"
> > >
> > > +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > > +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > > +#define MEMORY_HOTPLUG_IO_LEN         24
> > > +
> > >  /**
> > >   * MemStatus:
> > >   * @is_removing: the memory device in slot has been requested to be
> > > ejected.
> > > @@ -29,7 +33,7 @@ typedef struct MemHotplugState {
> > >  } MemHotplugState;
> > >
> > >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > > -                              MemHotplugState *state, uint16_t
> > > io_base);
> > > +                              MemHotplugState *state, hwaddr
> > > io_base);
> > >
> > >  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev,
> MemHotplugState
> > > *mem_st,
> > >                           DeviceState *dev, Error **errp);
> > > @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState
> > > *mem_st, ACPIOSTInfoList ***list);
> > >
> > >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > >                                const char *res_root,
> > > -                              const char *event_handler_method);
> > > +                              const char *event_handler_method,
> > > +                              AmlRegionSpace rs, hwaddr
> > > memhp_io_base);
> > >  #endif
> > > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> > > index 859b64c51d..49b47535cf 100644
> > > --- a/include/hw/i386/pc.h
> > > +++ b/include/hw/i386/pc.h
> > > @@ -69,6 +69,9 @@ struct PCMachineState {
> > >      /* Address space used by IOAPIC device. All IOAPIC interrupts
> > >       * will be translated to MSI messages in the address space. */
> > >      AddressSpace *ioapic_as;
> > > +
> > > +    /* ACPI Memory hotplug IO base address */
> > > +    hwaddr memhp_io_base;
> > >  };
> > >
> > >  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> > > --
> > > 2.17.1
> > >
> > >
> > > _______________________________________________
> > > Linuxarm mailing list
> > > Linuxarm@huawei.com
> > > http://hulk.huawei.com/mailman/listinfo/linuxarm



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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-29 11:04       ` Shameerali Kolothum Thodi
@ 2019-08-29 12:38         ` Igor Mammedov
  2019-08-29 13:45           ` Shameerali Kolothum Thodi
  0 siblings, 1 reply; 29+ messages in thread
From: Igor Mammedov @ 2019-08-29 12:38 UTC (permalink / raw)
  To: Shameerali Kolothum Thodi
  Cc: peter.maydell, sameo, ard.biesheuvel, shannon.zhaosl, qemu-devel,
	Linuxarm, eric.auger, qemu-arm, sebastien.boeuf, lersek

On Thu, 29 Aug 2019 11:04:27 +0000
Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> wrote:

> Hi Igor,
> 
> > -----Original Message-----
> > From: Igor Mammedov [mailto:imammedo@redhat.com]
> > Sent: 29 August 2019 09:45
> > To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
> > Cc: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> > eric.auger@redhat.com; peter.maydell@linaro.org; sameo@linux.intel.com;
> > ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> > shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com; lersek@redhat.com
> > Subject: Re: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> > configurable
> > 
> > On Thu, 15 Aug 2019 08:42:48 +0000
> > Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> wrote:
> >   
> > > > -----Original Message-----
> > > > From: Linuxarm [mailto:linuxarm-bounces@huawei.com] On Behalf Of  
> > Shameer  
> > > > Kolothum
> > > > Sent: 13 August 2019 22:05
> > > > To: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> > > > eric.auger@redhat.com; imammedo@redhat.com
> > > > Cc: peter.maydell@linaro.org; sameo@linux.intel.com;
> > > > ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> > > > shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com;  
> > lersek@redhat.com  
> > > > Subject: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> > > > configurable
> > > >
> > > > This is in preparation for adding support for ARM64 platforms
> > > > where it doesn't use port mapped IO for ACPI IO space. We are
> > > > making changes so that MMIO region can be accommodated
> > > > and board can pass the base address into the aml build function.  
> > >
> > > Looks like, this now breaks the "make check" on x86_64 and needs
> > > updating bios-tables-test-allowed-diff.h with DSDT entries. But I am
> > > not sure what changed now compared to v8(and older ones) that makes
> > > it to complain now!.  
> > 
> > you could see diff of what's changed but running test manually with
> > V=1 env var if you have 'iasl' installed
> > 
> > V=1 QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64
> > tests/bios-tables-test  
> 
> Thanks for that tip and please find below output.
> 
> /x86_64/acpi/piix4: Could not access KVM kernel module: No such file or directory
> qemu-system-x86_64: failed to initialize KVM: No such file or directory
> qemu-system-x86_64: Back to tcg accelerator
> acpi-test: Warning! DSDT binary file mismatch. Actual [aml:/tmp/aml-RGE76Z], Expected [aml:tests/data/acpi/pc/DSDT].
> acpi-test: Warning! DSDT mismatch. Actual [asl:/tmp/asl-TAE76Z.dsl, aml:/tmp/aml-RGE76Z], Expected [asl:/tmp/asl-O6B76Z.dsl, aml:tests/data/acpi/pc/DSDT].
> 
> diff --git a/tmp/asl-O6B76Z.dsl b/tmp/asl-TAE76Z.dsl
> index 823ff002ec..4de5bd3221 100644
> --- a/tmp/asl-O6B76Z.dsl
> +++ b/tmp/asl-TAE76Z.dsl
> @@ -5,13 +5,13 @@
>   *
>   * Disassembling to symbolic ASL+ operators
>   *
> - * Disassembly of tests/data/acpi/pc/DSDT, Thu Aug 29 10:40:40 2019
> + * Disassembly of /tmp/aml-RGE76Z, Thu Aug 29 10:40:40 2019
>   *
>   * Original Table Header:
>   *     Signature        "DSDT"
> - *     Length           0x0000140B (5131)
> + *     Length           0x000017E4 (6116)
>   *     Revision         0x01 **** 32-bit table (V1), no 64-bit math support
> - *     Checksum         0xB1
> + *     Checksum         0x8B
>   *     OEM ID           "BOCHS "
>   *     OEM Table ID     "BXPCDSDT"
>   *     OEM Revision     0x00000001 (1)
> @@ -787,6 +787,206 @@ DefinitionBlock ("", "DSDT", 1, "BOCHS ", "BXPCDSDT", 0x00000001)
>          \_SB.CPUS.CSCN ()
>      }
> 
> +    Device (\_SB.PCI0.MHPD)
> +    {
> +        Name (_HID, "PNP0A06" /* Generic Container Device */)  // _HID: Hardware ID
> +        Name (_UID, "Memory hotplug resources")  // _UID: Unique ID
> +        Name (_CRS, Reso 
> 
> I think what happens is since we are now passing the memhp_io_base directly into the 
> build_memory_hotplug_aml() and removed the "static uint16_t memhp_io_base", on 
> x86, memory hotplug aml code is always built by default irrespective of whether
> acpi_memory_hotplug_init() is invoked or not. 
> 
> I could either reintroduce a check in build_memory_hotplug_aml() to make sure
> acpi_memory_hotplug_init() is called, or could do something like below, 
fix looks fine to me, see minor comment below
 
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 3995f9a40f..17756c2191 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1873,9 +1873,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
>                         "\\_SB.PCI0", "\\_GPE._E02");
>      }
> -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> -                             "\\_GPE._E03", AML_SYSTEM_IO,
> -                             pcms->memhp_io_base);
> +
> +    if (acpi_enabled && pcms->acpi_dev && nr_mem) {
double-check call path and see if
  acpi_enabled && pcms->acpi_dev
is really necessary


> +        build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> +                                 "\\_GPE._E03", AML_SYSTEM_IO,
> +                                 pcms->memhp_io_base);
> +    }
> 
> 
> I prefer the latter if there are no other issues with that. Please let me know.
> 
> Thanks,
> Shameer
> 
> >   
> > > Patchew URL:  
> > https://patchew.org/QEMU/20190813210539.31164-1-shameerali.kolothum.t
> > hodi@huawei.com/  
> > >
> > > ERROR:/tmp/qemu-test/src/tests/bios-tables-test.c:447:test_acpi_asl:  
> > assertion failed: (all_tables_match)  
> > >
> > > Thanks,
> > > Shameer
> > >  
> > > > Also move few MEMORY_* definitions to header so that other memory
> > > > hotplug event signalling mechanisms (eg. Generic Event Device on
> > > > HW-reduced acpi platforms) can use the same from their respective
> > > > event handler code.
> > > >
> > > > Signed-off-by: Shameer Kolothum  
> > <shameerali.kolothum.thodi@huawei.com>  
> > > > ---
> > > > v8 --> v9
> > > >   -base address is an input into build_memory_hotplug_aml()
> > > >   -Removed R-by tags from Igor and Eric for now.
> > > > ---
> > > >  hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
> > > >  hw/i386/acpi-build.c             |  4 +++-
> > > >  hw/i386/pc.c                     |  3 +++
> > > >  include/hw/acpi/memory_hotplug.h |  9 +++++++--
> > > >  include/hw/i386/pc.h             |  3 +++
> > > >  5 files changed, 30 insertions(+), 18 deletions(-)
> > > >
> > > > diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> > > > index 297812d5f7..1734d4b44f 100644
> > > > --- a/hw/acpi/memory_hotplug.c
> > > > +++ b/hw/acpi/memory_hotplug.c
> > > > @@ -29,12 +29,7 @@
> > > >  #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
> > > >  #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
> > > >  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> > > > -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > > >  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> > > > -#define MEMORY_HOTPLUG_IO_LEN         24
> > > > -#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > > > -
> > > > -static uint16_t memhp_io_base;
> > > >
> > > >  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus  
> > *mdev)  
> > > >  {
> > > > @@ -209,7 +204,7 @@ static const MemoryRegionOps
> > > > acpi_memory_hotplug_ops = {
> > > >  };
> > > >
> > > >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > > > -                              MemHotplugState *state, uint16_t
> > > > io_base)
> > > > +                              MemHotplugState *state, hwaddr
> > > > io_base)
> > > >  {
> > > >      MachineState *machine = MACHINE(qdev_get_machine());
> > > >
> > > > @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion  
> > *as,  
> > > > Object *owner,
> > > >          return;
> > > >      }
> > > >
> > > > -    assert(!memhp_io_base);
> > > > -    memhp_io_base = io_base;
> > > >      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
> > > >      memory_region_init_io(&state->io, owner,  
> > &acpi_memory_hotplug_ops,  
> > > > state,
> > > >                            "acpi-mem-hotplug",
> > > > MEMORY_HOTPLUG_IO_LEN);
> > > > -    memory_region_add_subregion(as, memhp_io_base, &state->io);
> > > > +    memory_region_add_subregion(as, io_base, &state->io);
> > > >  }
> > > >
> > > >  /**
> > > > @@ -342,7 +335,8 @@ const VMStateDescription  
> > vmstate_memory_hotplug  
> > > > = {
> > > >
> > > >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > > >                                const char *res_root,
> > > > -                              const char *event_handler_method)
> > > > +                              const char *event_handler_method,
> > > > +                              AmlRegionSpace rs, hwaddr
> > > > memhp_io_base)
> > > >  {
> > > >      int i;
> > > >      Aml *ifctx;
> > > > @@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table,
> > > > uint32_t nr_mem,
> > > >              aml_name_decl("_UID", aml_string("Memory hotplug
> > > > resources")));
> > > >
> > > >          crs = aml_resource_template();
> > > > -        aml_append(crs,
> > > > -            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base,  
> > 0,  
> > > > -                   MEMORY_HOTPLUG_IO_LEN)
> > > > -        );
> > > > +        if (rs == AML_SYSTEM_IO) {
> > > > +            aml_append(crs,
> > > > +                aml_io(AML_DECODE16, memhp_io_base,
> > > > memhp_io_base, 0,
> > > > +                       MEMORY_HOTPLUG_IO_LEN)
> > > > +            );
> > > > +        } else {
> > > > +            aml_append(crs, aml_memory32_fixed(memhp_io_base,
> > > > +                            MEMORY_HOTPLUG_IO_LEN,
> > > > AML_READ_WRITE));
> > > > +        }
> > > >          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
> > > >
> > > >          aml_append(mem_ctrl_dev, aml_operation_region(
> > > > -            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> > > > +            MEMORY_HOTPLUG_IO_REGION, rs,
> > > >              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
> > > >          );
> > > >
> > > > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > > > index f3fdfefcd5..e76d6631ea 100644
> > > > --- a/hw/i386/acpi-build.c
> > > > +++ b/hw/i386/acpi-build.c
> > > > @@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker  
> > *linker,  
> > > >          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
> > > >                         "\\_SB.PCI0", "\\_GPE._E02");
> > > >      }
> > > > -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > > > "\\_GPE._E03");
> > > > +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > > > +                             "\\_GPE._E03", AML_SYSTEM_IO,
> > > > +                             pcms->memhp_io_base);
> > > >
> > > >      scope =  aml_scope("_GPE");
> > > >      {
> > > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > > > index 549c437050..be973cea99 100644
> > > > --- a/hw/i386/pc.c
> > > > +++ b/hw/i386/pc.c
> > > > @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
> > > >
> > > >      /* Init default IOAPIC address space */
> > > >      pcms->ioapic_as = &address_space_memory;
> > > > +
> > > > +    /* Init ACPI memory hotplug IO base address */
> > > > +    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
> > > >  }
> > > >
> > > >  /*
> > > > diff --git a/include/hw/acpi/memory_hotplug.h
> > > > b/include/hw/acpi/memory_hotplug.h
> > > > index 77c65765d6..dfe9cf3fde 100644
> > > > --- a/include/hw/acpi/memory_hotplug.h
> > > > +++ b/include/hw/acpi/memory_hotplug.h
> > > > @@ -5,6 +5,10 @@
> > > >  #include "hw/acpi/acpi.h"
> > > >  #include "hw/acpi/aml-build.h"
> > > >
> > > > +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> > > > +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> > > > +#define MEMORY_HOTPLUG_IO_LEN         24
> > > > +
> > > >  /**
> > > >   * MemStatus:
> > > >   * @is_removing: the memory device in slot has been requested to be
> > > > ejected.
> > > > @@ -29,7 +33,7 @@ typedef struct MemHotplugState {
> > > >  } MemHotplugState;
> > > >
> > > >  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> > > > -                              MemHotplugState *state, uint16_t
> > > > io_base);
> > > > +                              MemHotplugState *state, hwaddr
> > > > io_base);
> > > >
> > > >  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev,  
> > MemHotplugState  
> > > > *mem_st,
> > > >                           DeviceState *dev, Error **errp);
> > > > @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState
> > > > *mem_st, ACPIOSTInfoList ***list);
> > > >
> > > >  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
> > > >                                const char *res_root,
> > > > -                              const char *event_handler_method);
> > > > +                              const char *event_handler_method,
> > > > +                              AmlRegionSpace rs, hwaddr
> > > > memhp_io_base);
> > > >  #endif
> > > > diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> > > > index 859b64c51d..49b47535cf 100644
> > > > --- a/include/hw/i386/pc.h
> > > > +++ b/include/hw/i386/pc.h
> > > > @@ -69,6 +69,9 @@ struct PCMachineState {
> > > >      /* Address space used by IOAPIC device. All IOAPIC interrupts
> > > >       * will be translated to MSI messages in the address space. */
> > > >      AddressSpace *ioapic_as;
> > > > +
> > > > +    /* ACPI Memory hotplug IO base address */
> > > > +    hwaddr memhp_io_base;
> > > >  };
> > > >
> > > >  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"
> > > > --
> > > > 2.17.1
> > > >
> > > >
> > > > _______________________________________________
> > > > Linuxarm mailing list
> > > > Linuxarm@huawei.com
> > > > http://hulk.huawei.com/mailman/listinfo/linuxarm  
> 



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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-29 12:38         ` Igor Mammedov
@ 2019-08-29 13:45           ` Shameerali Kolothum Thodi
  0 siblings, 0 replies; 29+ messages in thread
From: Shameerali Kolothum Thodi @ 2019-08-29 13:45 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: peter.maydell, sameo, ard.biesheuvel, shannon.zhaosl, qemu-devel,
	Linuxarm, eric.auger, qemu-arm, sebastien.boeuf, lersek



> -----Original Message-----
> From: Igor Mammedov [mailto:imammedo@redhat.com]
> Sent: 29 August 2019 13:38
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
> Cc: qemu-devel@nongnu.org; qemu-arm@nongnu.org;
> eric.auger@redhat.com; peter.maydell@linaro.org; sameo@linux.intel.com;
> ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>;
> shannon.zhaosl@gmail.com; sebastien.boeuf@intel.com; lersek@redhat.com
> Subject: Re: [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space
> configurable
> 
> On Thu, 29 Aug 2019 11:04:27 +0000
> Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com> wrote:

[...]

> >
> > I think what happens is since we are now passing the memhp_io_base
> directly into the
> > build_memory_hotplug_aml() and removed the "static uint16_t
> memhp_io_base", on
> > x86, memory hotplug aml code is always built by default irrespective of
> whether
> > acpi_memory_hotplug_init() is invoked or not.
> >
> > I could either reintroduce a check in build_memory_hotplug_aml() to make
> sure
> > acpi_memory_hotplug_init() is called, or could do something like below,

> fix looks fine to me, see minor comment below

Ok
 
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index 3995f9a40f..17756c2191 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -1873,9 +1873,12 @@ build_dsdt(GArray *table_data, BIOSLinker
> *linker,
> >          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
> >                         "\\_SB.PCI0", "\\_GPE._E02");
> >      }
> > -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> > -                             "\\_GPE._E03", AML_SYSTEM_IO,
> > -                             pcms->memhp_io_base);
> > +
> > +    if (acpi_enabled && pcms->acpi_dev && nr_mem) {
> double-check call path and see if
>   acpi_enabled && pcms->acpi_dev
> is really necessary

Right, looks like those are always true. I will remove those.

Also appreciate if you could take a look at rest of the series and then I can
re-spin along with this.

Thanks,
Shameer
 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
  2019-08-15  8:42   ` Shameerali Kolothum Thodi
@ 2019-09-01 11:17   ` Auger Eric
  1 sibling, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-01 11:17 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,
On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> This is in preparation for adding support for ARM64 platforms
> where it doesn't use port mapped IO for ACPI IO space. We are
> making changes so that MMIO region can be accommodated
> and board can pass the base address into the aml build function.
> 
> Also move few MEMORY_* definitions to header so that other memory
> hotplug event signalling mechanisms (eg. Generic Event Device on
> HW-reduced acpi platforms) can use the same from their respective
> event handler code.
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> v8 --> v9
>   -base address is an input into build_memory_hotplug_aml()
>   -Removed R-by tags from Igor and Eric for now.
> ---
>  hw/acpi/memory_hotplug.c         | 29 ++++++++++++++---------------
>  hw/i386/acpi-build.c             |  4 +++-
>  hw/i386/pc.c                     |  3 +++
>  include/hw/acpi/memory_hotplug.h |  9 +++++++--
>  include/hw/i386/pc.h             |  3 +++
>  5 files changed, 30 insertions(+), 18 deletions(-)
> 
> diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c
> index 297812d5f7..1734d4b44f 100644
> --- a/hw/acpi/memory_hotplug.c
> +++ b/hw/acpi/memory_hotplug.c
> @@ -29,12 +29,7 @@
>  #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM"
>  #define MEMORY_SLOT_EJECT_METHOD     "MEJ0"
>  #define MEMORY_SLOT_NOTIFY_METHOD    "MTFY"
> -#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
>  #define MEMORY_HOTPLUG_DEVICE        "MHPD"
> -#define MEMORY_HOTPLUG_IO_LEN         24
> -#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> -
> -static uint16_t memhp_io_base;
>  
>  static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
>  {
> @@ -209,7 +204,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = {
>  };
>  
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state, uint16_t io_base)
> +                              MemHotplugState *state, hwaddr io_base)
>  {
>      MachineState *machine = MACHINE(qdev_get_machine());
>  
> @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
>          return;
>      }
>  
> -    assert(!memhp_io_base);
> -    memhp_io_base = io_base;
>      state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count);
>      memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state,
>                            "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN);
> -    memory_region_add_subregion(as, memhp_io_base, &state->io);
> +    memory_region_add_subregion(as, io_base, &state->io);
>  }
>  
>  /**
> @@ -342,7 +335,8 @@ const VMStateDescription vmstate_memory_hotplug = {
>  
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                const char *res_root,
> -                              const char *event_handler_method)
> +                              const char *event_handler_method,
> +                              AmlRegionSpace rs, hwaddr memhp_io_base)
>  {
>      int i;
>      Aml *ifctx;
> @@ -365,14 +359,19 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>              aml_name_decl("_UID", aml_string("Memory hotplug resources")));
do you want to keep

    if (!memhp_io_base) {
        return;
    }

at the beginning of the function? I think we should rather call the
function only if all args are resolved?
>  
>          crs = aml_resource_template();
> -        aml_append(crs,
> -            aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> -                   MEMORY_HOTPLUG_IO_LEN)
> -        );
> +        if (rs == AML_SYSTEM_IO) {
> +            aml_append(crs,
> +                aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0,
> +                       MEMORY_HOTPLUG_IO_LEN)
> +            );
> +        } else {
> +            aml_append(crs, aml_memory32_fixed(memhp_io_base,
> +                            MEMORY_HOTPLUG_IO_LEN, AML_READ_WRITE));
> +        }
>          aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs));
>  
>          aml_append(mem_ctrl_dev, aml_operation_region(
> -            MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO,
> +            MEMORY_HOTPLUG_IO_REGION, rs,
>              aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN)
>          );
>  
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index f3fdfefcd5..e76d6631ea 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -1871,7 +1871,9 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>          build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base,
>                         "\\_SB.PCI0", "\\_GPE._E02");
>      }
> -    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03");
> +    build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0",
> +                             "\\_GPE._E03", AML_SYSTEM_IO,
> +                             pcms->memhp_io_base);
>  
>      scope =  aml_scope("_GPE");
>      {
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index 549c437050..be973cea99 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -1936,6 +1936,9 @@ void pc_memory_init(PCMachineState *pcms,
>  
>      /* Init default IOAPIC address space */
>      pcms->ioapic_as = &address_space_memory;
> +
> +    /* Init ACPI memory hotplug IO base address */
> +    pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE;
>  }
>  
>  /*
> diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h
> index 77c65765d6..dfe9cf3fde 100644
> --- a/include/hw/acpi/memory_hotplug.h
> +++ b/include/hw/acpi/memory_hotplug.h
> @@ -5,6 +5,10 @@
>  #include "hw/acpi/acpi.h"
>  #include "hw/acpi/aml-build.h"
>  
> +#define MEMORY_SLOT_SCAN_METHOD      "MSCN"
> +#define MEMORY_DEVICES_CONTAINER     "\\_SB.MHPC"
> +#define MEMORY_HOTPLUG_IO_LEN         24
> +
>  /**
>   * MemStatus:
>   * @is_removing: the memory device in slot has been requested to be ejected.
> @@ -29,7 +33,7 @@ typedef struct MemHotplugState {
>  } MemHotplugState;
>  
>  void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner,
> -                              MemHotplugState *state, uint16_t io_base);
> +                              MemHotplugState *state, hwaddr io_base);
>  
>  void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st,
>                           DeviceState *dev, Error **errp);
> @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list);
>  
>  void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem,
>                                const char *res_root,
> -                              const char *event_handler_method);
> +                              const char *event_handler_method,
> +                              AmlRegionSpace rs, hwaddr memhp_io_base);
>  #endif
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 859b64c51d..49b47535cf 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -69,6 +69,9 @@ struct PCMachineState {
>      /* Address space used by IOAPIC device. All IOAPIC interrupts
>       * will be translated to MSI messages in the address space. */
>      AddressSpace *ioapic_as;
> +
> +    /* ACPI Memory hotplug IO base address */
> +    hwaddr memhp_io_base;
>  };
>  
>  #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device"

Besides
Reviewed-by: Eric Auger <eric.auger@redhat.com>
> 

Thanks

Eric


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support Shameer Kolothum
@ 2019-09-01 11:17   ` Auger Eric
  0 siblings, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-01 11:17 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,
On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> From: Samuel Ortiz <sameo@linux.intel.com>
> 
> The ACPI Generic Event Device (GED) is a hardware-reduced specific
> device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> including the hotplug ones. This patch generates the AML code that
> defines GEDs.
> 
> Platforms need to specify their own GED Event bitmap to describe
> what kind of events they want to support through GED.  Also this
> uses a a single interrupt for the  GED device, relying on IO
> memory region to communicate the type of device affected by the
> interrupt. This way, we can support up to 32 events with a unique
> interrupt.
> 
> This supports only memory hotplug for now.
> 
> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
> Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> v8 --> v9
>  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
>  -Removed Eric's R-by tag for now.
> 
> v7 --> v8.
>  -Removed qemu_mutex_lock() across the ged state selector access.
>  -Rephrased comments section in acpi_ged_send_event().
>  -Moved acpi_ged_event() code into acpi_ged_send_event().
>  -Added check for memhp_base and ged_base in realize().
> ---
>  hw/acpi/Kconfig                        |   4 +
>  hw/acpi/Makefile.objs                  |   1 +
>  hw/acpi/generic_event_device.c         | 316 +++++++++++++++++++++++++
>  include/hw/acpi/generic_event_device.h | 100 ++++++++
>  4 files changed, 421 insertions(+)
>  create mode 100644 hw/acpi/generic_event_device.c
>  create mode 100644 include/hw/acpi/generic_event_device.h
> 
> diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig
> index 7c59cf900b..12e3f1e86e 100644
> --- a/hw/acpi/Kconfig
> +++ b/hw/acpi/Kconfig
> @@ -31,3 +31,7 @@ config ACPI_VMGENID
>      bool
>      default y
>      depends on PC
> +
> +config ACPI_HW_REDUCED
> +    bool
> +    depends on ACPI
> diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs
> index 9bb2101e3b..655a9c1973 100644
> --- a/hw/acpi/Makefile.objs
> +++ b/hw/acpi/Makefile.objs
> @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o
>  common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o
>  common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o
>  common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o
> +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o
>  common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o
>  
>  common-obj-y += acpi_interface.o
> diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
> new file mode 100644
> index 0000000000..f4c23470c2
> --- /dev/null
> +++ b/hw/acpi/generic_event_device.c
> @@ -0,0 +1,316 @@
> +/*
> + *
> + * Copyright (c) 2018 Intel Corporation
> + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd
> + * Written by Samuel Ortiz, Shameer Kolothum
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qapi/error.h"
> +#include "exec/address-spaces.h"
> +#include "hw/acpi/acpi.h"
> +#include "hw/acpi/generic_event_device.h"
> +#include "hw/mem/pc-dimm.h"
> +#include "qemu/error-report.h"
you may need to include few other headers now.
> +
> +static const uint32_t ged_supported_events[] = {
> +    ACPI_GED_MEM_HOTPLUG_EVT,
> +};
> +
> +/*
> + * The ACPI Generic Event Device (GED) is a hardware-reduced specific
> + * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> + * including the hotplug ones. Platforms need to specify their own
> + * GED Event bitmap to describe what kind of events they want to support
> + * through GED. This routine uses a single interrupt for the GED device,
> + * relying on IO memory region to communicate the type of device
> + * affected by the interrupt. This way, we can support up to 32 events
> + * with a unique interrupt.
> + */
> +void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
> +                   uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base)
> +{
> +    AcpiGedState *s = ACPI_GED(hotplug_dev);
> +    Aml *crs = aml_resource_template();
> +    Aml *evt, *field;
> +    Aml *dev = aml_device("%s", name);
> +    Aml *evt_sel = aml_local(0);
> +    Aml *esel = aml_name(AML_GED_EVT_SEL);
> +
> +    assert(ged_base);
This assert may be removed?
> +
> +    /* _CRS interrupt */
> +    aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH,
> +                                  AML_EXCLUSIVE, &ged_irq, 1));
> +
> +    aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013")));
> +    aml_append(dev, aml_name_decl("_UID", aml_string(GED_DEVICE)));
> +    aml_append(dev, aml_name_decl("_CRS", crs));
> +
> +    /* Append IO region */
> +    aml_append(dev, aml_operation_region(AML_GED_EVT_REG, rs,
> +               aml_int(ged_base + ACPI_GED_EVT_SEL_OFFSET),
> +               ACPI_GED_EVT_SEL_LEN));
> +    field = aml_field(AML_GED_EVT_REG, AML_DWORD_ACC, AML_NOLOCK,
> +                      AML_WRITE_AS_ZEROS);
> +    aml_append(field, aml_named_field(AML_GED_EVT_SEL,
> +                                      ACPI_GED_EVT_SEL_LEN * BITS_PER_BYTE));
> +    aml_append(dev, field);
> +
> +    /*
> +     * For each GED event we:
> +     * - Add a conditional block for each event, inside a loop.
> +     * - Call a method for each supported GED event type.
> +     *
> +     * The resulting ASL code looks like:
> +     *
> +     * Local0 = ESEL
> +     * If ((Local0 & One) == One)
> +     * {
> +     *     MethodEvent0()
> +     * }
> +     *
> +     * If ((Local0 & 0x2) == 0x2)
> +     * {
> +     *     MethodEvent1()
> +     * }
> +     * ...
> +     */
> +    evt = aml_method("_EVT", 1, AML_SERIALIZED);
> +    {
> +        Aml *if_ctx;
> +        uint32_t i;
> +        uint32_t ged_events = ctpop32(s->ged_event_bitmap);
> +
> +        /* Local0 = ESEL */
> +        aml_append(evt, aml_store(esel, evt_sel));
> +
> +        for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) {
> +            uint32_t event = s->ged_event_bitmap & ged_supported_events[i];
> +
> +            if (!event) {
> +                continue;
> +            }
> +
> +            if_ctx = aml_if(aml_equal(aml_and(evt_sel, aml_int(event), NULL),
> +                                      aml_int(event)));
> +            switch (event) {
> +            case ACPI_GED_MEM_HOTPLUG_EVT:
> +                aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "."
> +                                             MEMORY_SLOT_SCAN_METHOD));
> +                break;
> +            default:
> +                /*
> +                 * Please make sure all the events in ged_supported_events[]
> +                 * are handled above.
> +                 */
> +                g_assert_not_reached();
> +            }
> +
> +            aml_append(evt, if_ctx);
> +            ged_events--;
> +        }
> +
> +        if (ged_events) {
> +            error_report("Unsupported events specified");
> +            abort();
> +        }
> +    }
> +
> +    /* Append _EVT method */
> +    aml_append(dev, evt);
> +
> +    aml_append(table, dev);
> +}
> +
> +/* Memory read by the GED _EVT AML dynamic method */
> +static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size)
> +{
> +    uint64_t val = 0;
> +    GEDState *ged_st = opaque;
> +
> +    switch (addr) {
> +    case ACPI_GED_EVT_SEL_OFFSET:
> +        /* Read the selector value and reset it */
> +        val = ged_st->sel;
> +        ged_st->sel = 0;
> +        break;
> +    default:
> +        break;
> +    }
> +
> +    return val;
> +}
> +
> +/* Nothing is expected to be written to the GED memory region */
> +static void ged_write(void *opaque, hwaddr addr, uint64_t data,
> +                      unsigned int size)
> +{
> +}
> +
> +static const MemoryRegionOps ged_ops = {
> +    .read = ged_read,
> +    .write = ged_write,
> +    .endianness = DEVICE_LITTLE_ENDIAN,
> +    .valid = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
> +};
> +
> +static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
> +                                    DeviceState *dev, Error **errp)
> +{
> +    AcpiGedState *s = ACPI_GED(hotplug_dev);
> +
> +    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> +        if (s->memhp_state.is_enabled) {
> +            acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp);
> +        } else {
> +            error_setg(errp,
> +                 "memory hotplug is not enabled: %s.memory-hotplug-support "
> +                 "is not set", object_get_typename(OBJECT(s)));
> +        }
> +    } else {
> +        error_setg(errp, "virt: device plug request for unsupported device"
> +                   " type: %s", object_get_typename(OBJECT(dev)));
> +    }
> +}
> +
> +static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
> +{
> +    AcpiGedState *s = ACPI_GED(adev);
> +    GEDState *ged_st = &s->ged_state;
> +    uint32_t sel;
> +
> +    if (ev & ACPI_MEMORY_HOTPLUG_STATUS) {
> +        sel = ACPI_GED_MEM_HOTPLUG_EVT;
> +    } else {
> +        /* Unknown event. Return without generating interrupt. */
> +        warn_report("GED: Unsupported event %d. No irq injected", ev);
> +        return;
> +    }
> +
> +    /*
> +     * Set the GED selector field to communicate the event type.
> +     * This will be read by GED aml code to select the appropriate
> +     * event method.
> +     */
> +    ged_st->sel |= sel;
> +
> +    /* Trigger the event by sending an interrupt to the guest. */
> +    qemu_irq_pulse(s->irq);
> +}
> +
> +static void acpi_ged_device_realize(DeviceState *dev, Error **errp)
> +{
> +    AcpiGedState *s = ACPI_GED(dev);
> +    GEDState *ged_st = &s->ged_state;
> +
> +    memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st,
> +                          TYPE_ACPI_GED, ACPI_GED_EVT_SEL_LEN);
> +    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &ged_st->io);
> +
> +    sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
> +
> +    if (s->memhp_state.is_enabled) {
> +        /*
> +         * GED handles memory hotplug event and acpi-mem-hotplug
> +         * memory region gets initialized here. Create an exclusive
> +         * container for memory hotplug IO and expose it as GED sysbus
> +         * MMIO so that boards can map it separately.
> +         */
> +        memory_region_init(&s->container_memhp, OBJECT(dev), "container",
> +                           MEMORY_HOTPLUG_IO_LEN);
> +        sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container_memhp);
> +        acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
> +                                 &s->memhp_state, 0);
> +    }
> +}
> +
> +static Property acpi_ged_properties[] = {
> +    DEFINE_PROP_BOOL("memory-hotplug-support", AcpiGedState,
> +                     memhp_state.is_enabled, true),
> +    DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static bool vmstate_test_use_memhp(void *opaque)
> +{
> +    AcpiGedState *s = opaque;
> +    return s->memhp_state.is_enabled;
> +}
> +
> +static const VMStateDescription vmstate_memhp_state = {
> +    .name = "acpi-ged/memhp",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .needed = vmstate_test_use_memhp,
> +    .fields      = (VMStateField[]) {
> +        VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
> +static const VMStateDescription vmstate_ged_state = {
> +    .name = "acpi-ged-state",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields      = (VMStateField[]) {
> +        VMSTATE_UINT32(sel, GEDState),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> +
> +static const VMStateDescription vmstate_acpi_ged = {
> +    .name = "acpi-ged",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDState),
> +        VMSTATE_END_OF_LIST(),
> +    },
> +    .subsections = (const VMStateDescription * []) {
> +        &vmstate_memhp_state,
> +        NULL
> +    }
> +};
> +
> +static void acpi_ged_class_init(ObjectClass *class, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(class);
> +    HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(class);
> +    AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class);
> +
> +    dc->desc = "ACPI Generic Event Device";
> +    dc->props = acpi_ged_properties;
> +    dc->realize = acpi_ged_device_realize;
> +    dc->vmsd = &vmstate_acpi_ged;
> +
> +    hc->plug = acpi_ged_device_plug_cb;
> +
> +    adevc->send_event = acpi_ged_send_event;
> +}
> +
> +static const TypeInfo acpi_ged_info = {
> +    .name          = TYPE_ACPI_GED,
> +    .parent        = TYPE_SYS_BUS_DEVICE,
> +    .instance_size = sizeof(AcpiGedState),
> +    .class_init    = acpi_ged_class_init,
> +    .interfaces = (InterfaceInfo[]) {
> +        { TYPE_HOTPLUG_HANDLER },
> +        { TYPE_ACPI_DEVICE_IF },
> +        { }
> +    }
> +};
> +
> +static void acpi_ged_register_types(void)
> +{
> +    type_register_static(&acpi_ged_info);
> +}
> +
> +type_init(acpi_ged_register_types)
> diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
> new file mode 100644
> index 0000000000..2049e8d873
> --- /dev/null
> +++ b/include/hw/acpi/generic_event_device.h
> @@ -0,0 +1,100 @@
> +/*
> + *
> + * Copyright (c) 2018 Intel Corporation
> + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd
> + * Written by Samuel Ortiz, Shameer Kolothum
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2 or later, as published by the Free Software Foundation.
> + *
> + * The ACPI Generic Event Device (GED) is a hardware-reduced specific
> + * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
> + * including the hotplug ones. Generic Event Device allows platforms
> + * to handle interrupts in ACPI ASL statements. It follows a very
> + * similar approach like the _EVT method from GPIO events. All
> + * interrupts are listed in  _CRS and the handler is written in _EVT
> + * method. Here, we use a single interrupt for the GED device, relying
> + * on IO memory region to communicate the type of device affected by
> + * the interrupt. This way, we can support up to 32 events with a
> + * unique interrupt.
> + *
> + * Here is an example.
> + *
> + * Device (\_SB.GED)
> + * {
> + *     Name (_HID, "ACPI0013")
> + *     Name (_UID, Zero)
> + *     Name (_CRS, ResourceTemplate ()
> + *     {
> + *         Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
> + *         {
> + *              0x00000029,
> + *         }
> + *     })
> + *     OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
> + *     Field (EREG, DWordAcc, NoLock, WriteAsZeros)
> + *     {
> + *         ESEL,   32
> + *     }
> + *
> + *     Method (_EVT, 1, Serialized)  // _EVT: Event
> + *     {
> + *         Local0 = ESEL // ESEL = IO memory region which specifies the
> + *                       // device type.
> + *         If (((Local0 & One) == One))
> + *         {
> + *             MethodEvent1()
> + *         }
> + *         If ((Local0 & 0x2) == 0x2)
> + *         {
> + *             MethodEvent2()
> + *         }
> + *         ...
> + *     }
> + * }
> + *
> + */
> +
> +#ifndef HW_ACPI_GED_H
> +#define HW_ACPI_GED_H
> +
> +#include "hw/sysbus.h"
> +#include "hw/acpi/memory_hotplug.h"
> +
> +#define TYPE_ACPI_GED "acpi-ged"
> +#define ACPI_GED(obj) \
> +    OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
> +
> +#define ACPI_GED_EVT_SEL_OFFSET    0x0
> +#define ACPI_GED_EVT_SEL_LEN       0x4
> +
> +#define GED_DEVICE      "GED"
> +#define AML_GED_EVT_REG "EREG"
> +#define AML_GED_EVT_SEL "ESEL"
> +
> +/*
> + * Platforms need to specify the GED event bitmap
> + * to describe what kind of events they want to support
> + * through GED.
> + */
> +#define ACPI_GED_MEM_HOTPLUG_EVT   0x1
> +
> +typedef struct GEDState {
> +    MemoryRegion io;
> +    uint32_t     sel;
> +} GEDState;
> +
> +typedef struct AcpiGedState {
> +    SysBusDevice parent_obj;
> +    MemHotplugState memhp_state;
> +    MemoryRegion container_memhp;
> +    GEDState ged_state;
> +    uint32_t ged_event_bitmap;
> +    qemu_irq irq;
> +} AcpiGedState;
> +
> +void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_dev,
> +                   uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base);
> +
> +#endif
> 

Looks good to me
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric



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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot Shameer Kolothum
@ 2019-09-01 11:18   ` Auger Eric
  2019-09-01 11:22     ` Auger Eric
  2019-09-02  9:21     ` Shameerali Kolothum Thodi
  0 siblings, 2 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-01 11:18 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,

On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> This initializes the GED device with base memory and irq, configures
> ged memory hotplug event and builds the corresponding aml code. With
> this, both hot and cold plug of device memory is enabled now for Guest
> with ACPI boot.
> 
> Memory cold plug support with Guest DT boot is not yet supported.

I think you should comment about bios-tables-test-allowed-diff.h update.
Can't you update the table instead of ignoring the test?

Thanks

Eric
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> v8 --> v9
>  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
>  -Error propagation to _plug() handler.
>  -Removed R-by by Eric for now.
> 
> v7 --> v8
>  -Changed no_acpi_dev to no_ged.
>  -Fixed 'dev' reference leak by object_new().
>  -Updated bios-tables-test-allowed-diff.h to avoid "make check"
>   failure.
> 
> ---
>  hw/arm/Kconfig                        |  2 +
>  hw/arm/virt-acpi-build.c              | 16 +++++++
>  hw/arm/virt.c                         | 62 ++++++++++++++++++++++++---
>  include/hw/arm/virt.h                 |  4 ++
>  tests/bios-tables-test-allowed-diff.h |  1 +
>  5 files changed, 78 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
> index 84961c17ab..ad7f7c089b 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -22,6 +22,8 @@ config ARM_VIRT
>      select ACPI_PCI
>      select MEM_DEVICE
>      select DIMM
> +    select ACPI_MEMORY_HOTPLUG
> +    select ACPI_HW_REDUCED
>  
>  config CHEETAH
>      bool
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 0afb372769..63fa845076 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -40,6 +40,8 @@
>  #include "hw/acpi/aml-build.h"
>  #include "hw/acpi/utils.h"
>  #include "hw/acpi/pci.h"
> +#include "hw/acpi/memory_hotplug.h"
> +#include "hw/acpi/generic_event_device.h"
>  #include "hw/pci/pcie_host.h"
>  #include "hw/pci/pci.h"
>  #include "hw/arm/virt.h"
> @@ -705,6 +707,7 @@ static void
>  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>  {
>      Aml *scope, *dsdt;
> +    MachineState *ms = MACHINE(vms);
>      const MemMapEntry *memmap = vms->memmap;
>      const int *irqmap = vms->irqmap;
>  
> @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>                        vms->highmem, vms->highmem_ecam);
>      acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
>                         (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
> +    if (vms->acpi_dev) {
> +        build_ged_aml(scope, "\\_SB."GED_DEVICE,
> +                      HOTPLUG_HANDLER(vms->acpi_dev),
> +                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
> +                      memmap[VIRT_ACPI_GED].base);
> +    }
> +
> +    if (vms->acpi_dev && ms->ram_slots) {
> +        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL,
> +                                 AML_SYSTEM_MEMORY,
> +                                 memmap[VIRT_PCDIMM_ACPI].base);
> +    }
> +
>      acpi_dsdt_add_power_button(scope);
>  
>      aml_append(dsdt, scope);
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index ef65e721d2..0949a227a9 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -66,6 +66,7 @@
>  #include "target/arm/internals.h"
>  #include "hw/mem/pc-dimm.h"
>  #include "hw/mem/nvdimm.h"
> +#include "hw/acpi/generic_event_device.h"
>  
>  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
>      static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
> @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
>      [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
>      [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
>      [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
> +    [VIRT_PCDIMM_ACPI] =        { 0x09070000, MEMORY_HOTPLUG_IO_LEN },
> +    [VIRT_ACPI_GED] =           { 0x09080000, ACPI_GED_EVT_SEL_LEN },
>      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
> @@ -171,6 +174,7 @@ static const int a15irqmap[] = {
>      [VIRT_PCIE] = 3, /* ... to 6 */
>      [VIRT_GPIO] = 7,
>      [VIRT_SECURE_UART] = 8,
> +    [VIRT_ACPI_GED] = 9,
>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
>      [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
> @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
>      }
>  }
>  
> +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic)
> +{
> +    DeviceState *dev;
> +    int irq = vms->irqmap[VIRT_ACPI_GED];
> +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
> +
> +    dev = qdev_create(NULL, TYPE_ACPI_GED);
> +    qdev_prop_set_uint32(dev, "ged-event", event);
> +    object_property_add_child(qdev_get_machine(), "acpi-ged",
> +                              OBJECT(dev), NULL);
> +    qdev_init_nofail(dev);
> +
> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
> +
> +    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
> +
> +    return dev;
> +}
> +
>  static void create_its(VirtMachineState *vms, DeviceState *gicdev)
>  {
>      const char *itsclass = its_class_name();
> @@ -1483,6 +1507,7 @@ static void machvirt_init(MachineState *machine)
>      MemoryRegion *ram = g_new(MemoryRegion, 1);
>      bool firmware_loaded;
>      bool aarch64 = true;
> +    bool has_ged = !vmc->no_ged;
>      unsigned int smp_cpus = machine->smp.cpus;
>      unsigned int max_cpus = machine->smp.max_cpus;
>  
> @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState *machine)
>  
>      create_gpio(vms, pic);
>  
> +    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
> +        vms->acpi_dev = create_acpi_ged(vms, pic);
> +    }
> +
>      /* Create mmio transports, so the user can create virtio backends
>       * (which will be automatically plugged in to the transports). If
>       * no backend is created the transport will just sit harmlessly idle.
> @@ -1876,14 +1905,23 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
>  static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>                                   Error **errp)
>  {
> +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> +    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
> +    Error *local_err = NULL;
>  
> -    /*
> -     * The device memory is not yet exposed to the Guest either through
> -     * DT or ACPI and hence both cold/hot plug of memory is explicitly
> -     * disabled for now.
> -     */
> -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> -        error_setg(errp, "memory cold/hot plug is not yet supported");
> +    if (is_nvdimm) {
> +        error_setg(errp, "nvdimm is not yet supported");
> +        return;
> +    }
> +
> +    if (!vms->acpi_dev) {
> +        error_setg(errp, "memory hotplug is not enabled: missing acpi device");
> +        return;
> +    }
> +
> +    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
> +    if (local_err) {
> +        error_propagate(errp, local_err);
>          return;
>      }
>  
> @@ -1893,11 +1931,18 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>  static void virt_memory_plug(HotplugHandler *hotplug_dev,
>                               DeviceState *dev, Error **errp)
>  {
> +    HotplugHandlerClass *hhc;
>      VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
>      Error *local_err = NULL;
>  
>      pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
> +    if (local_err) {
> +        goto out;
> +    }
>  
> +    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
> +    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
> +out:
>      error_propagate(errp, local_err);
>  }
>  
> @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
>  
>  static void virt_machine_4_1_options(MachineClass *mc)
>  {
> +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
> +
>      virt_machine_4_2_options(mc);
>      compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
> +    vmc->no_ged = true;
>  }
>  DEFINE_VIRT_MACHINE(4, 1)
>  
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index a72094204e..577ee49b4b 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -77,6 +77,8 @@ enum {
>      VIRT_GPIO,
>      VIRT_SECURE_UART,
>      VIRT_SECURE_MEM,
> +    VIRT_PCDIMM_ACPI,
> +    VIRT_ACPI_GED,
>      VIRT_LOWMEMMAP_LAST,
>  };
>  
> @@ -106,6 +108,7 @@ typedef struct {
>      bool claim_edge_triggered_timers;
>      bool smbios_old_sys_ver;
>      bool no_highmem_ecam;
> +    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
>  } VirtMachineClass;
>  
>  typedef struct {
> @@ -133,6 +136,7 @@ typedef struct {
>      uint32_t iommu_phandle;
>      int psci_conduit;
>      hwaddr highest_gpa;
> +    DeviceState *acpi_dev;
>  } VirtMachineState;
>  
>  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
> diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h
> index dfb8523c8b..7b4adbc822 100644
> --- a/tests/bios-tables-test-allowed-diff.h
> +++ b/tests/bios-tables-test-allowed-diff.h
> @@ -1 +1,2 @@
>  /* List of comma-separated changed AML files to ignore */
> +"tests/data/acpi/virt/DSDT",
> 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation Shameer Kolothum
@ 2019-09-01 11:20   ` Auger Eric
  0 siblings, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-01 11:20 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,
On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> Documents basic concepts of ACPI Generic Event device(GED)
> and interface between QEMU and the ACPI BIOS.
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  docs/specs/acpi_hw_reduced_hotplug.txt | 60 ++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
>  create mode 100644 docs/specs/acpi_hw_reduced_hotplug.txt
> 
> diff --git a/docs/specs/acpi_hw_reduced_hotplug.txt b/docs/specs/acpi_hw_reduced_hotplug.txt
> new file mode 100644
> index 0000000000..46839be5ff
> --- /dev/null
> +++ b/docs/specs/acpi_hw_reduced_hotplug.txt
> @@ -0,0 +1,60 @@
> +QEMU<->ACPI BIOS Generic Event Device interface
> +
> +The ACPI Generic Event Device (GED) is a HW reduced platform
> +specific device introduced in ACPI v6.1 that handles all platform
> +events, including the hotplug ones. GED is modelled as a device
> +in the namespace with a _HID defined to be ACPI0013. This document
> +describes the interface between QEMU and the ACPI BIOS.
> +
> +GED allows HW reduced platforms to handle interrupts in ACPI ASL
> +statements. It follows a very similar approach like the _EVT method
> +from GPIO events. All interrupts are listed in  _CRS and the handler
> +is written in _EVT method. However, Qemu implementation uses a single
> +interrupt for the GED device, relying on IO memory region to communicate
> +the type of device affected by the interrupt. This way, we can support
> +up to 32 events with a unique interrupt.
> +
> +Here is an example.
> +
> +Device (\_SB.GED)
> +{
> +    Name (_HID, "ACPI0013")
> +    Name (_UID, Zero)
> +    Name (_CRS, ResourceTemplate ()
> +    {
> +        Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
> +        {
> +            0x00000029,
> +        }
> +    })
> +    OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
> +    Field (EREG, DWordAcc, NoLock, WriteAsZeros)
> +    {
> +        ESEL,   32
> +    }
> +    Method (_EVT, 1, Serialized)
> +    {
> +        Local0 = ESEL // ESEL = IO memory region which specifies the
> +                      // device type.
> +        If (((Local0 & One) == One))
> +        {
> +            MethodEvent1()
> +        }
> +        If ((Local0 & 0x2) == 0x2)
> +        {
> +            MethodEvent2()
> +        }
> +        ...
> +    }
> +}
> +
> +GED IO interface (4 byte access):
> +read access:
> +    [0x0-0x3] Event selector bit field(32 bit) set by Qemu.
> +    bits:
> +        1:  Memory hotplug event
> +        2:  System power down event
> +     3-31:  Reserved
> +
> +write_access:
> +    Nothing is expected to be written into GED IO memory
> 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-09-01 11:18   ` Auger Eric
@ 2019-09-01 11:22     ` Auger Eric
  2019-09-02  9:34       ` Shameerali Kolothum Thodi
  2019-09-02  9:21     ` Shameerali Kolothum Thodi
  1 sibling, 1 reply; 29+ messages in thread
From: Auger Eric @ 2019-09-01 11:22 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,
On 9/1/19 1:18 PM, Auger Eric wrote:
> Hi Shameer,
> 
> On 8/13/19 11:05 PM, Shameer Kolothum wrote:
>> This initializes the GED device with base memory and irq, configures
>> ged memory hotplug event and builds the corresponding aml code. With
>> this, both hot and cold plug of device memory is enabled now for Guest
>> with ACPI boot.
>>
>> Memory cold plug support with Guest DT boot is not yet supported.
> 
> I think you should comment about bios-tables-test-allowed-diff.h update.
> Can't you update the table instead of ignoring the test?
> 
> Thanks
> 
> Eric
>>
>> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
>> ---
>> v8 --> v9
>>  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
>>  -Error propagation to _plug() handler.
>>  -Removed R-by by Eric for now.
>>
>> v7 --> v8
>>  -Changed no_acpi_dev to no_ged.
>>  -Fixed 'dev' reference leak by object_new().
>>  -Updated bios-tables-test-allowed-diff.h to avoid "make check"
>>   failure.
>>
>> ---
>>  hw/arm/Kconfig                        |  2 +
>>  hw/arm/virt-acpi-build.c              | 16 +++++++
>>  hw/arm/virt.c                         | 62 ++++++++++++++++++++++++---
>>  include/hw/arm/virt.h                 |  4 ++
>>  tests/bios-tables-test-allowed-diff.h |  1 +
>>  5 files changed, 78 insertions(+), 7 deletions(-)
>>
>> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
>> index 84961c17ab..ad7f7c089b 100644
>> --- a/hw/arm/Kconfig
>> +++ b/hw/arm/Kconfig
>> @@ -22,6 +22,8 @@ config ARM_VIRT
>>      select ACPI_PCI
>>      select MEM_DEVICE
>>      select DIMM
>> +    select ACPI_MEMORY_HOTPLUG
>> +    select ACPI_HW_REDUCED
>>  
>>  config CHEETAH
>>      bool
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index 0afb372769..63fa845076 100644
>> --- a/hw/arm/virt-acpi-build.c
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -40,6 +40,8 @@
>>  #include "hw/acpi/aml-build.h"
>>  #include "hw/acpi/utils.h"
>>  #include "hw/acpi/pci.h"
>> +#include "hw/acpi/memory_hotplug.h"
>> +#include "hw/acpi/generic_event_device.h"
>>  #include "hw/pci/pcie_host.h"
>>  #include "hw/pci/pci.h"
>>  #include "hw/arm/virt.h"
>> @@ -705,6 +707,7 @@ static void
>>  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>>  {
>>      Aml *scope, *dsdt;
>> +    MachineState *ms = MACHINE(vms);
>>      const MemMapEntry *memmap = vms->memmap;
>>      const int *irqmap = vms->irqmap;
>>  
>> @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>>                        vms->highmem, vms->highmem_ecam);
>>      acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
>>                         (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
>> +    if (vms->acpi_dev) {
>> +        build_ged_aml(scope, "\\_SB."GED_DEVICE,
>> +                      HOTPLUG_HANDLER(vms->acpi_dev),
>> +                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
>> +                      memmap[VIRT_ACPI_GED].base);
>> +    }
>> +
>> +    if (vms->acpi_dev && ms->ram_slots) {
>> +        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL,
>> +                                 AML_SYSTEM_MEMORY,
>> +                                 memmap[VIRT_PCDIMM_ACPI].base);
>> +    }
>> +
>>      acpi_dsdt_add_power_button(scope);
>>  
>>      aml_append(dsdt, scope);
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index ef65e721d2..0949a227a9 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -66,6 +66,7 @@
>>  #include "target/arm/internals.h"
>>  #include "hw/mem/pc-dimm.h"
>>  #include "hw/mem/nvdimm.h"
>> +#include "hw/acpi/generic_event_device.h"
>>  
>>  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
>>      static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
>> @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
>>      [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
>>      [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
>>      [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
>> +    [VIRT_PCDIMM_ACPI] =        { 0x09070000, MEMORY_HOTPLUG_IO_LEN },
>> +    [VIRT_ACPI_GED] =           { 0x09080000, ACPI_GED_EVT_SEL_LEN },
>>      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
>>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
>>      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
>> @@ -171,6 +174,7 @@ static const int a15irqmap[] = {
>>      [VIRT_PCIE] = 3, /* ... to 6 */
>>      [VIRT_GPIO] = 7,
>>      [VIRT_SECURE_UART] = 8,
>> +    [VIRT_ACPI_GED] = 9,
>>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>>      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
>>      [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
>> @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)
>>      }
>>  }
>>  
>> +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic)
>> +{
>> +    DeviceState *dev;
>> +    int irq = vms->irqmap[VIRT_ACPI_GED];
>> +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
>> +
>> +    dev = qdev_create(NULL, TYPE_ACPI_GED);
>> +    qdev_prop_set_uint32(dev, "ged-event", event);
>> +    object_property_add_child(qdev_get_machine(), "acpi-ged",
>> +                              OBJECT(dev), NULL);
Out of curiosity, what is the object_property_add_child() used for?

Thanks

Eric
>> +    qdev_init_nofail(dev);
>> +
>> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
>> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
>> +
>> +    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
>> +
>> +    return dev;
>> +}
>> +
>>  static void create_its(VirtMachineState *vms, DeviceState *gicdev)
>>  {
>>      const char *itsclass = its_class_name();
>> @@ -1483,6 +1507,7 @@ static void machvirt_init(MachineState *machine)
>>      MemoryRegion *ram = g_new(MemoryRegion, 1);
>>      bool firmware_loaded;
>>      bool aarch64 = true;
>> +    bool has_ged = !vmc->no_ged;
>>      unsigned int smp_cpus = machine->smp.cpus;
>>      unsigned int max_cpus = machine->smp.max_cpus;
>>  
>> @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState *machine)
>>  
>>      create_gpio(vms, pic);
>>  
>> +    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
>> +        vms->acpi_dev = create_acpi_ged(vms, pic);
>> +    }
>> +
>>      /* Create mmio transports, so the user can create virtio backends
>>       * (which will be automatically plugged in to the transports). If
>>       * no backend is created the transport will just sit harmlessly idle.
>> @@ -1876,14 +1905,23 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms)
>>  static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>>                                   Error **errp)
>>  {
>> +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
>> +    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM);
>> +    Error *local_err = NULL;
>>  
>> -    /*
>> -     * The device memory is not yet exposed to the Guest either through
>> -     * DT or ACPI and hence both cold/hot plug of memory is explicitly
>> -     * disabled for now.
>> -     */
>> -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
>> -        error_setg(errp, "memory cold/hot plug is not yet supported");
>> +    if (is_nvdimm) {
>> +        error_setg(errp, "nvdimm is not yet supported");
>> +        return;
>> +    }
>> +
>> +    if (!vms->acpi_dev) {
>> +        error_setg(errp, "memory hotplug is not enabled: missing acpi device");
>> +        return;
>> +    }
>> +
>> +    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
>> +    if (local_err) {
>> +        error_propagate(errp, local_err);
>>          return;
>>      }
>>  
>> @@ -1893,11 +1931,18 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>>  static void virt_memory_plug(HotplugHandler *hotplug_dev,
>>                               DeviceState *dev, Error **errp)
>>  {
>> +    HotplugHandlerClass *hhc;
>>      VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
>>      Error *local_err = NULL;
>>  
>>      pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
>> +    if (local_err) {
>> +        goto out;
>> +    }
>>  
>> +    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
>> +    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
>> +out:
>>      error_propagate(errp, local_err);
>>  }
>>  
>> @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
>>  
>>  static void virt_machine_4_1_options(MachineClass *mc)
>>  {
>> +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
>> +
>>      virt_machine_4_2_options(mc);
>>      compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
>> +    vmc->no_ged = true;
>>  }
>>  DEFINE_VIRT_MACHINE(4, 1)
>>  
>> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
>> index a72094204e..577ee49b4b 100644
>> --- a/include/hw/arm/virt.h
>> +++ b/include/hw/arm/virt.h
>> @@ -77,6 +77,8 @@ enum {
>>      VIRT_GPIO,
>>      VIRT_SECURE_UART,
>>      VIRT_SECURE_MEM,
>> +    VIRT_PCDIMM_ACPI,
>> +    VIRT_ACPI_GED,
>>      VIRT_LOWMEMMAP_LAST,
>>  };
>>  
>> @@ -106,6 +108,7 @@ typedef struct {
>>      bool claim_edge_triggered_timers;
>>      bool smbios_old_sys_ver;
>>      bool no_highmem_ecam;
>> +    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device */
>>  } VirtMachineClass;
>>  
>>  typedef struct {
>> @@ -133,6 +136,7 @@ typedef struct {
>>      uint32_t iommu_phandle;
>>      int psci_conduit;
>>      hwaddr highest_gpa;
>> +    DeviceState *acpi_dev;
>>  } VirtMachineState;
>>  
>>  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
>> diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h
>> index dfb8523c8b..7b4adbc822 100644
>> --- a/tests/bios-tables-test-allowed-diff.h
>> +++ b/tests/bios-tables-test-allowed-diff.h
>> @@ -1 +1,2 @@
>>  /* List of comma-separated changed AML files to ignore */
>> +"tests/data/acpi/virt/DSDT",
>>
> 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO Shameer Kolothum
@ 2019-09-02  7:37   ` Auger Eric
  0 siblings, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-02  7:37 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,

On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> This is in preparation of using GED device for
> system_powerdown event. Make the powerdown notifier
> registration independent of create_gpio() fn.
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  hw/arm/virt.c         | 12 ++++--------
>  include/hw/arm/virt.h |  1 +
>  2 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 56d64fc0a9..0e75213b44 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -787,10 +787,6 @@ static void virt_powerdown_req(Notifier *n, void *opaque)
>      qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
>  }
>  
> -static Notifier virt_system_powerdown_notifier = {
> -    .notify = virt_powerdown_req
> -};
> -
>  static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
>  {
>      char *nodename;
> @@ -831,10 +827,6 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
>                            KEY_POWER);
>      qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff",
>                             "gpios", phandle, 3, 0);
> -
> -    /* connect powerdown request */
> -    qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
> -
>      g_free(nodename);
>  }
>  
> @@ -1726,6 +1718,10 @@ static void machvirt_init(MachineState *machine)
>          vms->acpi_dev = create_acpi_ged(vms, pic);
>      }
>  
> +     /* connect powerdown request */
> +     vms->powerdown_notifier.notify = virt_powerdown_req;
> +     qemu_register_powerdown_notifier(&vms->powerdown_notifier);
> +
>      /* Create mmio transports, so the user can create virtio backends
>       * (which will be automatically plugged in to the transports). If
>       * no backend is created the transport will just sit harmlessly idle.
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 577ee49b4b..0b41083e9d 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -137,6 +137,7 @@ typedef struct {
>      int psci_conduit;
>      hwaddr highest_gpa;
>      DeviceState *acpi_dev;
> +    Notifier powerdown_notifier;
>  } VirtMachineState;
>  
>  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
> 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event
  2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event Shameer Kolothum
@ 2019-09-02  7:37   ` Auger Eric
  0 siblings, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-02  7:37 UTC (permalink / raw)
  To: Shameer Kolothum, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, linuxarm, xuwei5,
	shannon.zhaosl, sebastien.boeuf, lersek

Hi Shameer,

On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> For machines 4.2 or higher with ACPI boot use GED for system_powerdown
> event instead of GPIO. Guest boot with DT still uses GPIO.
> 
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric
> ---
> v8 --> v9
>  -Re-arranged patches 8 & 9 from v8 based on Igor's comments.
> 
> v7 --> v8
>  -Retained gpio based system_powerdown support for machines < 4.2.
>  -Reuse of virt_powerdown_req() for ACPI GED use.
>  -Dropped Eric's R-by for now because of above.
> 
> ---
>  hw/acpi/generic_event_device.c         |  8 ++++++++
>  hw/arm/virt-acpi-build.c               |  6 +++---
>  hw/arm/virt.c                          | 16 +++++++++++-----
>  include/hw/acpi/acpi_dev_interface.h   |  1 +
>  include/hw/acpi/generic_event_device.h |  3 +++
>  5 files changed, 26 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
> index f4c23470c2..d6d7b28cfd 100644
> --- a/hw/acpi/generic_event_device.c
> +++ b/hw/acpi/generic_event_device.c
> @@ -19,6 +19,7 @@
>  
>  static const uint32_t ged_supported_events[] = {
>      ACPI_GED_MEM_HOTPLUG_EVT,
> +    ACPI_GED_PWR_DOWN_EVT,
>  };
>  
>  /*
> @@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
>                  aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "."
>                                               MEMORY_SLOT_SCAN_METHOD));
>                  break;
> +            case ACPI_GED_PWR_DOWN_EVT:
> +                aml_append(if_ctx,
> +                           aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
> +                                      aml_int(0x80)));
> +                break;
>              default:
>                  /*
>                   * Please make sure all the events in ged_supported_events[]
> @@ -189,6 +195,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
>  
>      if (ev & ACPI_MEMORY_HOTPLUG_STATUS) {
>          sel = ACPI_GED_MEM_HOTPLUG_EVT;
> +    } else if (ev & ACPI_POWER_DOWN_STATUS) {
> +        sel = ACPI_GED_PWR_DOWN_EVT;
>      } else {
>          /* Unknown event. Return without generating interrupt. */
>          warn_report("GED: Unsupported event %d. No irq injected", ev);
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 6d697af2df..61b399dc58 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -49,7 +49,6 @@
>  #include "kvm_arm.h"
>  
>  #define ARM_SPI_BASE 32
> -#define ACPI_POWER_BUTTON_DEVICE "PWRB"
>  
>  static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
>  {
> @@ -739,13 +738,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>                      (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
>      acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
>                        vms->highmem, vms->highmem_ecam);
> -    acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
> -                       (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
>      if (vms->acpi_dev) {
>          build_ged_aml(scope, "\\_SB."GED_DEVICE,
>                        HOTPLUG_HANDLER(vms->acpi_dev),
>                        irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY,
>                        memmap[VIRT_ACPI_GED].base);
> +    } else {
> +        acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
> +                           (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
>      }
>  
>      if (vms->acpi_dev && ms->ram_slots) {
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 0e75213b44..d49e1a583c 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -528,7 +528,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic)
>  {
>      DeviceState *dev;
>      int irq = vms->irqmap[VIRT_ACPI_GED];
> -    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
> +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT;
>  
>      dev = qdev_create(NULL, TYPE_ACPI_GED);
>      qdev_prop_set_uint32(dev, "ged-event", event);
> @@ -783,8 +783,14 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic)
>  static DeviceState *gpio_key_dev;
>  static void virt_powerdown_req(Notifier *n, void *opaque)
>  {
> -    /* use gpio Pin 3 for power button event */
> -    qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
> +    VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier);
> +
> +    if (s->acpi_dev) {
> +        acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS);
> +    } else {
> +        /* use gpio Pin 3 for power button event */
> +        qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1);
> +    }
>  }
>  
>  static void create_gpio(const VirtMachineState *vms, qemu_irq *pic)
> @@ -1712,10 +1718,10 @@ static void machvirt_init(MachineState *machine)
>  
>      create_pcie(vms, pic);
>  
> -    create_gpio(vms, pic);
> -
>      if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
>          vms->acpi_dev = create_acpi_ged(vms, pic);
> +    } else {
> +        create_gpio(vms, pic);
>      }
>  
>       /* connect powerdown request */
> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> index 43ff119179..adcb3a816c 100644
> --- a/include/hw/acpi/acpi_dev_interface.h
> +++ b/include/hw/acpi/acpi_dev_interface.h
> @@ -11,6 +11,7 @@ typedef enum {
>      ACPI_MEMORY_HOTPLUG_STATUS = 8,
>      ACPI_NVDIMM_HOTPLUG_STATUS = 16,
>      ACPI_VMGENID_CHANGE_STATUS = 32,
> +    ACPI_POWER_DOWN_STATUS = 64,
>  } AcpiEventStatusBits;
>  
>  #define TYPE_ACPI_DEVICE_IF "acpi-device-interface"
> diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
> index 2049e8d873..d157eac088 100644
> --- a/include/hw/acpi/generic_event_device.h
> +++ b/include/hw/acpi/generic_event_device.h
> @@ -62,6 +62,8 @@
>  #include "hw/sysbus.h"
>  #include "hw/acpi/memory_hotplug.h"
>  
> +#define ACPI_POWER_BUTTON_DEVICE "PWRB"
> +
>  #define TYPE_ACPI_GED "acpi-ged"
>  #define ACPI_GED(obj) \
>      OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
> @@ -79,6 +81,7 @@
>   * through GED.
>   */
>  #define ACPI_GED_MEM_HOTPLUG_EVT   0x1
> +#define ACPI_GED_PWR_DOWN_EVT      0x2
>  
>  typedef struct GEDState {
>      MemoryRegion io;
> 


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-09-01 11:18   ` Auger Eric
  2019-09-01 11:22     ` Auger Eric
@ 2019-09-02  9:21     ` Shameerali Kolothum Thodi
  2019-09-02  9:32       ` Auger Eric
  1 sibling, 1 reply; 29+ messages in thread
From: Shameerali Kolothum Thodi @ 2019-09-02  9:21 UTC (permalink / raw)
  To: Auger Eric, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, Linuxarm, shannon.zhaosl,
	sebastien.boeuf, xuwei (O),
	lersek

Hi Eric,

> -----Original Message-----
> From: Auger Eric [mailto:eric.auger@redhat.com]
> Sent: 01 September 2019 12:19
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>;
> qemu-devel@nongnu.org; qemu-arm@nongnu.org; imammedo@redhat.com
> Cc: peter.maydell@linaro.org; shannon.zhaosl@gmail.com;
> sameo@linux.intel.com; sebastien.boeuf@intel.com; xuwei (O)
> <xuwei5@huawei.com>; lersek@redhat.com; ard.biesheuvel@linaro.org;
> Linuxarm <linuxarm@huawei.com>
> Subject: Re: [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory
> cold/hot plug with ACPI boot
> 
> Hi Shameer,
> 
> On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> > This initializes the GED device with base memory and irq, configures
> > ged memory hotplug event and builds the corresponding aml code. With
> > this, both hot and cold plug of device memory is enabled now for Guest
> > with ACPI boot.
> >
> > Memory cold plug support with Guest DT boot is not yet supported.
> 
> I think you should comment about bios-tables-test-allowed-diff.h update.

Ok. I will add that.

> Can't you update the table instead of ignoring the test?

I think that is not how it is handled now. The process is,

"Expected table change is then handled like this:
1. add table to diff allowed list
2. change generating code (can be combined with 1)
3. maintainer runs a script to update expected +
   blows away allowed diff list "
https://patchwork.kernel.org/patch/10967339/

Thanks,
Shameer

> 
> Thanks
> 
> Eric
> >
> > Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> > ---
> > v8 --> v9
> >  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
> >  -Error propagation to _plug() handler.
> >  -Removed R-by by Eric for now.
> >
> > v7 --> v8
> >  -Changed no_acpi_dev to no_ged.
> >  -Fixed 'dev' reference leak by object_new().
> >  -Updated bios-tables-test-allowed-diff.h to avoid "make check"
> >   failure.
> >
> > ---
> >  hw/arm/Kconfig                        |  2 +
> >  hw/arm/virt-acpi-build.c              | 16 +++++++
> >  hw/arm/virt.c                         | 62
> ++++++++++++++++++++++++---
> >  include/hw/arm/virt.h                 |  4 ++
> >  tests/bios-tables-test-allowed-diff.h |  1 +
> >  5 files changed, 78 insertions(+), 7 deletions(-)
> >
> > diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index
> > 84961c17ab..ad7f7c089b 100644
> > --- a/hw/arm/Kconfig
> > +++ b/hw/arm/Kconfig
> > @@ -22,6 +22,8 @@ config ARM_VIRT
> >      select ACPI_PCI
> >      select MEM_DEVICE
> >      select DIMM
> > +    select ACPI_MEMORY_HOTPLUG
> > +    select ACPI_HW_REDUCED
> >
> >  config CHEETAH
> >      bool
> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index
> > 0afb372769..63fa845076 100644
> > --- a/hw/arm/virt-acpi-build.c
> > +++ b/hw/arm/virt-acpi-build.c
> > @@ -40,6 +40,8 @@
> >  #include "hw/acpi/aml-build.h"
> >  #include "hw/acpi/utils.h"
> >  #include "hw/acpi/pci.h"
> > +#include "hw/acpi/memory_hotplug.h"
> > +#include "hw/acpi/generic_event_device.h"
> >  #include "hw/pci/pcie_host.h"
> >  #include "hw/pci/pci.h"
> >  #include "hw/arm/virt.h"
> > @@ -705,6 +707,7 @@ static void
> >  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState
> > *vms)  {
> >      Aml *scope, *dsdt;
> > +    MachineState *ms = MACHINE(vms);
> >      const MemMapEntry *memmap = vms->memmap;
> >      const int *irqmap = vms->irqmap;
> >
> > @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> VirtMachineState *vms)
> >                        vms->highmem, vms->highmem_ecam);
> >      acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
> >                         (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
> > +    if (vms->acpi_dev) {
> > +        build_ged_aml(scope, "\\_SB."GED_DEVICE,
> > +                      HOTPLUG_HANDLER(vms->acpi_dev),
> > +                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE,
> AML_SYSTEM_MEMORY,
> > +                      memmap[VIRT_ACPI_GED].base);
> > +    }
> > +
> > +    if (vms->acpi_dev && ms->ram_slots) {
> > +        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB",
> NULL,
> > +                                 AML_SYSTEM_MEMORY,
> > +
> memmap[VIRT_PCDIMM_ACPI].base);
> > +    }
> > +
> >      acpi_dsdt_add_power_button(scope);
> >
> >      aml_append(dsdt, scope);
> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c index
> > ef65e721d2..0949a227a9 100644
> > --- a/hw/arm/virt.c
> > +++ b/hw/arm/virt.c
> > @@ -66,6 +66,7 @@
> >  #include "target/arm/internals.h"
> >  #include "hw/mem/pc-dimm.h"
> >  #include "hw/mem/nvdimm.h"
> > +#include "hw/acpi/generic_event_device.h"
> >
> >  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
> >      static void virt_##major##_##minor##_class_init(ObjectClass *oc,
> > \ @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
> >      [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
> >      [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
> >      [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
> > +    [VIRT_PCDIMM_ACPI] =        { 0x09070000,
> MEMORY_HOTPLUG_IO_LEN },
> > +    [VIRT_ACPI_GED] =           { 0x09080000,
> ACPI_GED_EVT_SEL_LEN },
> >      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
> >      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that
> size */
> >      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
> > @@ -171,6 +174,7 @@ static const int a15irqmap[] = {
> >      [VIRT_PCIE] = 3, /* ... to 6 */
> >      [VIRT_GPIO] = 7,
> >      [VIRT_SECURE_UART] = 8,
> > +    [VIRT_ACPI_GED] = 9,
> >      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
> >      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
> >      [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
> > @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const
> VirtMachineState *vms)
> >      }
> >  }
> >
> > +static inline DeviceState *create_acpi_ged(VirtMachineState *vms,
> > +qemu_irq *pic) {
> > +    DeviceState *dev;
> > +    int irq = vms->irqmap[VIRT_ACPI_GED];
> > +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
> > +
> > +    dev = qdev_create(NULL, TYPE_ACPI_GED);
> > +    qdev_prop_set_uint32(dev, "ged-event", event);
> > +    object_property_add_child(qdev_get_machine(), "acpi-ged",
> > +                              OBJECT(dev), NULL);
> > +    qdev_init_nofail(dev);
> > +
> > +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
> vms->memmap[VIRT_ACPI_GED].base);
> > +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1,
> > + vms->memmap[VIRT_PCDIMM_ACPI].base);
> > +
> > +    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
> > +
> > +    return dev;
> > +}
> > +
> >  static void create_its(VirtMachineState *vms, DeviceState *gicdev)  {
> >      const char *itsclass = its_class_name(); @@ -1483,6 +1507,7 @@
> > static void machvirt_init(MachineState *machine)
> >      MemoryRegion *ram = g_new(MemoryRegion, 1);
> >      bool firmware_loaded;
> >      bool aarch64 = true;
> > +    bool has_ged = !vmc->no_ged;
> >      unsigned int smp_cpus = machine->smp.cpus;
> >      unsigned int max_cpus = machine->smp.max_cpus;
> >
> > @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState
> > *machine)
> >
> >      create_gpio(vms, pic);
> >
> > +    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
> > +        vms->acpi_dev = create_acpi_ged(vms, pic);
> > +    }
> > +
> >      /* Create mmio transports, so the user can create virtio backends
> >       * (which will be automatically plugged in to the transports). If
> >       * no backend is created the transport will just sit harmlessly idle.
> > @@ -1876,14 +1905,23 @@ static const CPUArchIdList
> > *virt_possible_cpu_arch_ids(MachineState *ms)  static void
> virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >                                   Error **errp)  {
> > +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> > +    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev),
> TYPE_NVDIMM);
> > +    Error *local_err = NULL;
> >
> > -    /*
> > -     * The device memory is not yet exposed to the Guest either through
> > -     * DT or ACPI and hence both cold/hot plug of memory is explicitly
> > -     * disabled for now.
> > -     */
> > -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> > -        error_setg(errp, "memory cold/hot plug is not yet supported");
> > +    if (is_nvdimm) {
> > +        error_setg(errp, "nvdimm is not yet supported");
> > +        return;
> > +    }
> > +
> > +    if (!vms->acpi_dev) {
> > +        error_setg(errp, "memory hotplug is not enabled: missing acpi
> device");
> > +        return;
> > +    }
> > +
> > +    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev,
> &local_err);
> > +    if (local_err) {
> > +        error_propagate(errp, local_err);
> >          return;
> >      }
> >
> > @@ -1893,11 +1931,18 @@ static void
> > virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> static void virt_memory_plug(HotplugHandler *hotplug_dev,
> >                               DeviceState *dev, Error **errp)  {
> > +    HotplugHandlerClass *hhc;
> >      VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> >      Error *local_err = NULL;
> >
> >      pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
> > +    if (local_err) {
> > +        goto out;
> > +    }
> >
> > +    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
> > +    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
> > +out:
> >      error_propagate(errp, local_err);  }
> >
> > @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
> >
> >  static void virt_machine_4_1_options(MachineClass *mc)  {
> > +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
> > +
> >      virt_machine_4_2_options(mc);
> >      compat_props_add(mc->compat_props, hw_compat_4_1,
> > hw_compat_4_1_len);
> > +    vmc->no_ged = true;
> >  }
> >  DEFINE_VIRT_MACHINE(4, 1)
> >
> > diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index
> > a72094204e..577ee49b4b 100644
> > --- a/include/hw/arm/virt.h
> > +++ b/include/hw/arm/virt.h
> > @@ -77,6 +77,8 @@ enum {
> >      VIRT_GPIO,
> >      VIRT_SECURE_UART,
> >      VIRT_SECURE_MEM,
> > +    VIRT_PCDIMM_ACPI,
> > +    VIRT_ACPI_GED,
> >      VIRT_LOWMEMMAP_LAST,
> >  };
> >
> > @@ -106,6 +108,7 @@ typedef struct {
> >      bool claim_edge_triggered_timers;
> >      bool smbios_old_sys_ver;
> >      bool no_highmem_ecam;
> > +    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device
> */
> >  } VirtMachineClass;
> >
> >  typedef struct {
> > @@ -133,6 +136,7 @@ typedef struct {
> >      uint32_t iommu_phandle;
> >      int psci_conduit;
> >      hwaddr highest_gpa;
> > +    DeviceState *acpi_dev;
> >  } VirtMachineState;
> >
> >  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM :
> > VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h
> > b/tests/bios-tables-test-allowed-diff.h
> > index dfb8523c8b..7b4adbc822 100644
> > --- a/tests/bios-tables-test-allowed-diff.h
> > +++ b/tests/bios-tables-test-allowed-diff.h
> > @@ -1 +1,2 @@
> >  /* List of comma-separated changed AML files to ignore */
> > +"tests/data/acpi/virt/DSDT",
> >

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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-09-02  9:21     ` Shameerali Kolothum Thodi
@ 2019-09-02  9:32       ` Auger Eric
  0 siblings, 0 replies; 29+ messages in thread
From: Auger Eric @ 2019-09-02  9:32 UTC (permalink / raw)
  To: Shameerali Kolothum Thodi, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, Linuxarm, shannon.zhaosl,
	sebastien.boeuf, xuwei (O),
	lersek

Hi Shameer,

On 9/2/19 11:21 AM, Shameerali Kolothum Thodi wrote:
> Hi Eric,
> 
>> -----Original Message-----
>> From: Auger Eric [mailto:eric.auger@redhat.com]
>> Sent: 01 September 2019 12:19
>> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>;
>> qemu-devel@nongnu.org; qemu-arm@nongnu.org; imammedo@redhat.com
>> Cc: peter.maydell@linaro.org; shannon.zhaosl@gmail.com;
>> sameo@linux.intel.com; sebastien.boeuf@intel.com; xuwei (O)
>> <xuwei5@huawei.com>; lersek@redhat.com; ard.biesheuvel@linaro.org;
>> Linuxarm <linuxarm@huawei.com>
>> Subject: Re: [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory
>> cold/hot plug with ACPI boot
>>
>> Hi Shameer,
>>
>> On 8/13/19 11:05 PM, Shameer Kolothum wrote:
>>> This initializes the GED device with base memory and irq, configures
>>> ged memory hotplug event and builds the corresponding aml code. With
>>> this, both hot and cold plug of device memory is enabled now for Guest
>>> with ACPI boot.
>>>
>>> Memory cold plug support with Guest DT boot is not yet supported.
>>
>> I think you should comment about bios-tables-test-allowed-diff.h update.
> 
> Ok. I will add that.
> 
>> Can't you update the table instead of ignoring the test?
> 
> I think that is not how it is handled now. The process is,
> 
> "Expected table change is then handled like this:
> 1. add table to diff allowed list
> 2. change generating code (can be combined with 1)
> 3. maintainer runs a script to update expected +
>    blows away allowed diff list "
> https://patchwork.kernel.org/patch/10967339/

Ok. Thanks for the link.

Best Regards

Eric
> 
> Thanks,
> Shameer
> 
>>
>> Thanks
>>
>> Eric
>>>
>>> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
>>> ---
>>> v8 --> v9
>>>  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
>>>  -Error propagation to _plug() handler.
>>>  -Removed R-by by Eric for now.
>>>
>>> v7 --> v8
>>>  -Changed no_acpi_dev to no_ged.
>>>  -Fixed 'dev' reference leak by object_new().
>>>  -Updated bios-tables-test-allowed-diff.h to avoid "make check"
>>>   failure.
>>>
>>> ---
>>>  hw/arm/Kconfig                        |  2 +
>>>  hw/arm/virt-acpi-build.c              | 16 +++++++
>>>  hw/arm/virt.c                         | 62
>> ++++++++++++++++++++++++---
>>>  include/hw/arm/virt.h                 |  4 ++
>>>  tests/bios-tables-test-allowed-diff.h |  1 +
>>>  5 files changed, 78 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index
>>> 84961c17ab..ad7f7c089b 100644
>>> --- a/hw/arm/Kconfig
>>> +++ b/hw/arm/Kconfig
>>> @@ -22,6 +22,8 @@ config ARM_VIRT
>>>      select ACPI_PCI
>>>      select MEM_DEVICE
>>>      select DIMM
>>> +    select ACPI_MEMORY_HOTPLUG
>>> +    select ACPI_HW_REDUCED
>>>
>>>  config CHEETAH
>>>      bool
>>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index
>>> 0afb372769..63fa845076 100644
>>> --- a/hw/arm/virt-acpi-build.c
>>> +++ b/hw/arm/virt-acpi-build.c
>>> @@ -40,6 +40,8 @@
>>>  #include "hw/acpi/aml-build.h"
>>>  #include "hw/acpi/utils.h"
>>>  #include "hw/acpi/pci.h"
>>> +#include "hw/acpi/memory_hotplug.h"
>>> +#include "hw/acpi/generic_event_device.h"
>>>  #include "hw/pci/pcie_host.h"
>>>  #include "hw/pci/pci.h"
>>>  #include "hw/arm/virt.h"
>>> @@ -705,6 +707,7 @@ static void
>>>  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState
>>> *vms)  {
>>>      Aml *scope, *dsdt;
>>> +    MachineState *ms = MACHINE(vms);
>>>      const MemMapEntry *memmap = vms->memmap;
>>>      const int *irqmap = vms->irqmap;
>>>
>>> @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>> VirtMachineState *vms)
>>>                        vms->highmem, vms->highmem_ecam);
>>>      acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
>>>                         (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
>>> +    if (vms->acpi_dev) {
>>> +        build_ged_aml(scope, "\\_SB."GED_DEVICE,
>>> +                      HOTPLUG_HANDLER(vms->acpi_dev),
>>> +                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE,
>> AML_SYSTEM_MEMORY,
>>> +                      memmap[VIRT_ACPI_GED].base);
>>> +    }
>>> +
>>> +    if (vms->acpi_dev && ms->ram_slots) {
>>> +        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB",
>> NULL,
>>> +                                 AML_SYSTEM_MEMORY,
>>> +
>> memmap[VIRT_PCDIMM_ACPI].base);
>>> +    }
>>> +
>>>      acpi_dsdt_add_power_button(scope);
>>>
>>>      aml_append(dsdt, scope);
>>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c index
>>> ef65e721d2..0949a227a9 100644
>>> --- a/hw/arm/virt.c
>>> +++ b/hw/arm/virt.c
>>> @@ -66,6 +66,7 @@
>>>  #include "target/arm/internals.h"
>>>  #include "hw/mem/pc-dimm.h"
>>>  #include "hw/mem/nvdimm.h"
>>> +#include "hw/acpi/generic_event_device.h"
>>>
>>>  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
>>>      static void virt_##major##_##minor##_class_init(ObjectClass *oc,
>>> \ @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
>>>      [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
>>>      [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
>>>      [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
>>> +    [VIRT_PCDIMM_ACPI] =        { 0x09070000,
>> MEMORY_HOTPLUG_IO_LEN },
>>> +    [VIRT_ACPI_GED] =           { 0x09080000,
>> ACPI_GED_EVT_SEL_LEN },
>>>      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
>>>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that
>> size */
>>>      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
>>> @@ -171,6 +174,7 @@ static const int a15irqmap[] = {
>>>      [VIRT_PCIE] = 3, /* ... to 6 */
>>>      [VIRT_GPIO] = 7,
>>>      [VIRT_SECURE_UART] = 8,
>>> +    [VIRT_ACPI_GED] = 9,
>>>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
>>>      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
>>>      [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
>>> @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const
>> VirtMachineState *vms)
>>>      }
>>>  }
>>>
>>> +static inline DeviceState *create_acpi_ged(VirtMachineState *vms,
>>> +qemu_irq *pic) {
>>> +    DeviceState *dev;
>>> +    int irq = vms->irqmap[VIRT_ACPI_GED];
>>> +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
>>> +
>>> +    dev = qdev_create(NULL, TYPE_ACPI_GED);
>>> +    qdev_prop_set_uint32(dev, "ged-event", event);
>>> +    object_property_add_child(qdev_get_machine(), "acpi-ged",
>>> +                              OBJECT(dev), NULL);
>>> +    qdev_init_nofail(dev);
>>> +
>>> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
>> vms->memmap[VIRT_ACPI_GED].base);
>>> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1,
>>> + vms->memmap[VIRT_PCDIMM_ACPI].base);
>>> +
>>> +    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
>>> +
>>> +    return dev;
>>> +}
>>> +
>>>  static void create_its(VirtMachineState *vms, DeviceState *gicdev)  {
>>>      const char *itsclass = its_class_name(); @@ -1483,6 +1507,7 @@
>>> static void machvirt_init(MachineState *machine)
>>>      MemoryRegion *ram = g_new(MemoryRegion, 1);
>>>      bool firmware_loaded;
>>>      bool aarch64 = true;
>>> +    bool has_ged = !vmc->no_ged;
>>>      unsigned int smp_cpus = machine->smp.cpus;
>>>      unsigned int max_cpus = machine->smp.max_cpus;
>>>
>>> @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState
>>> *machine)
>>>
>>>      create_gpio(vms, pic);
>>>
>>> +    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
>>> +        vms->acpi_dev = create_acpi_ged(vms, pic);
>>> +    }
>>> +
>>>      /* Create mmio transports, so the user can create virtio backends
>>>       * (which will be automatically plugged in to the transports). If
>>>       * no backend is created the transport will just sit harmlessly idle.
>>> @@ -1876,14 +1905,23 @@ static const CPUArchIdList
>>> *virt_possible_cpu_arch_ids(MachineState *ms)  static void
>> virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>>>                                   Error **errp)  {
>>> +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
>>> +    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev),
>> TYPE_NVDIMM);
>>> +    Error *local_err = NULL;
>>>
>>> -    /*
>>> -     * The device memory is not yet exposed to the Guest either through
>>> -     * DT or ACPI and hence both cold/hot plug of memory is explicitly
>>> -     * disabled for now.
>>> -     */
>>> -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
>>> -        error_setg(errp, "memory cold/hot plug is not yet supported");
>>> +    if (is_nvdimm) {
>>> +        error_setg(errp, "nvdimm is not yet supported");
>>> +        return;
>>> +    }
>>> +
>>> +    if (!vms->acpi_dev) {
>>> +        error_setg(errp, "memory hotplug is not enabled: missing acpi
>> device");
>>> +        return;
>>> +    }
>>> +
>>> +    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev,
>> &local_err);
>>> +    if (local_err) {
>>> +        error_propagate(errp, local_err);
>>>          return;
>>>      }
>>>
>>> @@ -1893,11 +1931,18 @@ static void
>>> virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
>> static void virt_memory_plug(HotplugHandler *hotplug_dev,
>>>                               DeviceState *dev, Error **errp)  {
>>> +    HotplugHandlerClass *hhc;
>>>      VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
>>>      Error *local_err = NULL;
>>>
>>>      pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
>>> +    if (local_err) {
>>> +        goto out;
>>> +    }
>>>
>>> +    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
>>> +    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
>>> +out:
>>>      error_propagate(errp, local_err);  }
>>>
>>> @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
>>>
>>>  static void virt_machine_4_1_options(MachineClass *mc)  {
>>> +    VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
>>> +
>>>      virt_machine_4_2_options(mc);
>>>      compat_props_add(mc->compat_props, hw_compat_4_1,
>>> hw_compat_4_1_len);
>>> +    vmc->no_ged = true;
>>>  }
>>>  DEFINE_VIRT_MACHINE(4, 1)
>>>
>>> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index
>>> a72094204e..577ee49b4b 100644
>>> --- a/include/hw/arm/virt.h
>>> +++ b/include/hw/arm/virt.h
>>> @@ -77,6 +77,8 @@ enum {
>>>      VIRT_GPIO,
>>>      VIRT_SECURE_UART,
>>>      VIRT_SECURE_MEM,
>>> +    VIRT_PCDIMM_ACPI,
>>> +    VIRT_ACPI_GED,
>>>      VIRT_LOWMEMMAP_LAST,
>>>  };
>>>
>>> @@ -106,6 +108,7 @@ typedef struct {
>>>      bool claim_edge_triggered_timers;
>>>      bool smbios_old_sys_ver;
>>>      bool no_highmem_ecam;
>>> +    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED device
>> */
>>>  } VirtMachineClass;
>>>
>>>  typedef struct {
>>> @@ -133,6 +136,7 @@ typedef struct {
>>>      uint32_t iommu_phandle;
>>>      int psci_conduit;
>>>      hwaddr highest_gpa;
>>> +    DeviceState *acpi_dev;
>>>  } VirtMachineState;
>>>
>>>  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM :
>>> VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h
>>> b/tests/bios-tables-test-allowed-diff.h
>>> index dfb8523c8b..7b4adbc822 100644
>>> --- a/tests/bios-tables-test-allowed-diff.h
>>> +++ b/tests/bios-tables-test-allowed-diff.h
>>> @@ -1 +1,2 @@
>>>  /* List of comma-separated changed AML files to ignore */
>>> +"tests/data/acpi/virt/DSDT",
>>>


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

* Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot
  2019-09-01 11:22     ` Auger Eric
@ 2019-09-02  9:34       ` Shameerali Kolothum Thodi
  0 siblings, 0 replies; 29+ messages in thread
From: Shameerali Kolothum Thodi @ 2019-09-02  9:34 UTC (permalink / raw)
  To: Auger Eric, qemu-devel, qemu-arm, imammedo
  Cc: peter.maydell, sameo, ard.biesheuvel, Linuxarm, shannon.zhaosl,
	sebastien.boeuf, xuwei (O),
	lersek

Hi Eric,

> -----Original Message-----
> From: Auger Eric [mailto:eric.auger@redhat.com]
> Sent: 01 September 2019 12:23
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>;
> qemu-devel@nongnu.org; qemu-arm@nongnu.org; imammedo@redhat.com
> Cc: peter.maydell@linaro.org; sameo@linux.intel.com;
> ard.biesheuvel@linaro.org; Linuxarm <linuxarm@huawei.com>; xuwei (O)
> <xuwei5@huawei.com>; shannon.zhaosl@gmail.com;
> sebastien.boeuf@intel.com; lersek@redhat.com
> Subject: Re: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device
> memory cold/hot plug with ACPI boot
> 
> Hi Shameer,
> On 9/1/19 1:18 PM, Auger Eric wrote:
> > Hi Shameer,
> >
> > On 8/13/19 11:05 PM, Shameer Kolothum wrote:
> >> This initializes the GED device with base memory and irq, configures
> >> ged memory hotplug event and builds the corresponding aml code. With
> >> this, both hot and cold plug of device memory is enabled now for
> >> Guest with ACPI boot.
> >>
> >> Memory cold plug support with Guest DT boot is not yet supported.
> >
> > I think you should comment about bios-tables-test-allowed-diff.h update.
> > Can't you update the table instead of ignoring the test?
> >
> > Thanks
> >
> > Eric
> >>
> >> Signed-off-by: Shameer Kolothum
> >> <shameerali.kolothum.thodi@huawei.com>
> >> ---
> >> v8 --> v9
> >>  -Changes related to GED being a TYPE_SYS_BUS_DEVICE now.
> >>  -Error propagation to _plug() handler.
> >>  -Removed R-by by Eric for now.
> >>
> >> v7 --> v8
> >>  -Changed no_acpi_dev to no_ged.
> >>  -Fixed 'dev' reference leak by object_new().
> >>  -Updated bios-tables-test-allowed-diff.h to avoid "make check"
> >>   failure.
> >>
> >> ---
> >>  hw/arm/Kconfig                        |  2 +
> >>  hw/arm/virt-acpi-build.c              | 16 +++++++
> >>  hw/arm/virt.c                         | 62
> ++++++++++++++++++++++++---
> >>  include/hw/arm/virt.h                 |  4 ++
> >>  tests/bios-tables-test-allowed-diff.h |  1 +
> >>  5 files changed, 78 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index
> >> 84961c17ab..ad7f7c089b 100644
> >> --- a/hw/arm/Kconfig
> >> +++ b/hw/arm/Kconfig
> >> @@ -22,6 +22,8 @@ config ARM_VIRT
> >>      select ACPI_PCI
> >>      select MEM_DEVICE
> >>      select DIMM
> >> +    select ACPI_MEMORY_HOTPLUG
> >> +    select ACPI_HW_REDUCED
> >>
> >>  config CHEETAH
> >>      bool
> >> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> >> index 0afb372769..63fa845076 100644
> >> --- a/hw/arm/virt-acpi-build.c
> >> +++ b/hw/arm/virt-acpi-build.c
> >> @@ -40,6 +40,8 @@
> >>  #include "hw/acpi/aml-build.h"
> >>  #include "hw/acpi/utils.h"
> >>  #include "hw/acpi/pci.h"
> >> +#include "hw/acpi/memory_hotplug.h"
> >> +#include "hw/acpi/generic_event_device.h"
> >>  #include "hw/pci/pcie_host.h"
> >>  #include "hw/pci/pci.h"
> >>  #include "hw/arm/virt.h"
> >> @@ -705,6 +707,7 @@ static void
> >>  build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState
> >> *vms)  {
> >>      Aml *scope, *dsdt;
> >> +    MachineState *ms = MACHINE(vms);
> >>      const MemMapEntry *memmap = vms->memmap;
> >>      const int *irqmap = vms->irqmap;
> >>
> >> @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> VirtMachineState *vms)
> >>                        vms->highmem, vms->highmem_ecam);
> >>      acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
> >>                         (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
> >> +    if (vms->acpi_dev) {
> >> +        build_ged_aml(scope, "\\_SB."GED_DEVICE,
> >> +                      HOTPLUG_HANDLER(vms->acpi_dev),
> >> +                      irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE,
> AML_SYSTEM_MEMORY,
> >> +                      memmap[VIRT_ACPI_GED].base);
> >> +    }
> >> +
> >> +    if (vms->acpi_dev && ms->ram_slots) {
> >> +        build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB",
> NULL,
> >> +                                 AML_SYSTEM_MEMORY,
> >> +
> memmap[VIRT_PCDIMM_ACPI].base);
> >> +    }
> >> +
> >>      acpi_dsdt_add_power_button(scope);
> >>
> >>      aml_append(dsdt, scope);
> >> diff --git a/hw/arm/virt.c b/hw/arm/virt.c index
> >> ef65e721d2..0949a227a9 100644
> >> --- a/hw/arm/virt.c
> >> +++ b/hw/arm/virt.c
> >> @@ -66,6 +66,7 @@
> >>  #include "target/arm/internals.h"
> >>  #include "hw/mem/pc-dimm.h"
> >>  #include "hw/mem/nvdimm.h"
> >> +#include "hw/acpi/generic_event_device.h"
> >>
> >>  #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \
> >>      static void virt_##major##_##minor##_class_init(ObjectClass *oc,
> >> \ @@ -136,6 +137,8 @@ static const MemMapEntry base_memmap[] = {
> >>      [VIRT_GPIO] =               { 0x09030000, 0x00001000 },
> >>      [VIRT_SECURE_UART] =        { 0x09040000, 0x00001000 },
> >>      [VIRT_SMMU] =               { 0x09050000, 0x00020000 },
> >> +    [VIRT_PCDIMM_ACPI] =        { 0x09070000,
> MEMORY_HOTPLUG_IO_LEN },
> >> +    [VIRT_ACPI_GED] =           { 0x09080000,
> ACPI_GED_EVT_SEL_LEN },
> >>      [VIRT_MMIO] =               { 0x0a000000, 0x00000200 },
> >>      /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that
> size */
> >>      [VIRT_PLATFORM_BUS] =       { 0x0c000000, 0x02000000 },
> >> @@ -171,6 +174,7 @@ static const int a15irqmap[] = {
> >>      [VIRT_PCIE] = 3, /* ... to 6 */
> >>      [VIRT_GPIO] = 7,
> >>      [VIRT_SECURE_UART] = 8,
> >> +    [VIRT_ACPI_GED] = 9,
> >>      [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
> >>      [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
> >>      [VIRT_SMMU] = 74,    /* ...to 74 + NUM_SMMU_IRQS - 1 */
> >> @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const
> VirtMachineState *vms)
> >>      }
> >>  }
> >>
> >> +static inline DeviceState *create_acpi_ged(VirtMachineState *vms,
> >> +qemu_irq *pic) {
> >> +    DeviceState *dev;
> >> +    int irq = vms->irqmap[VIRT_ACPI_GED];
> >> +    uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT;
> >> +
> >> +    dev = qdev_create(NULL, TYPE_ACPI_GED);
> >> +    qdev_prop_set_uint32(dev, "ged-event", event);
> >> +    object_property_add_child(qdev_get_machine(), "acpi-ged",
> >> +                              OBJECT(dev), NULL);
> Out of curiosity, what is the object_property_add_child() used for?

Right. That is an artifact from the previous versions where GED used to be
inherited from DEVICE type. IIUIC, the purpose was to link it explicitly with
machine object. Now that we are back to SYSBUS, I think we can get rid of it.

Thanks,
Shameer
 
> Thanks
> 
> Eric
> >> +    qdev_init_nofail(dev);
> >> +
> >> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
> vms->memmap[VIRT_ACPI_GED].base);
> >> +    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1,
> >> + vms->memmap[VIRT_PCDIMM_ACPI].base);
> >> +
> >> +    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]);
> >> +
> >> +    return dev;
> >> +}
> >> +
> >>  static void create_its(VirtMachineState *vms, DeviceState *gicdev)
> >> {
> >>      const char *itsclass = its_class_name(); @@ -1483,6 +1507,7 @@
> >> static void machvirt_init(MachineState *machine)
> >>      MemoryRegion *ram = g_new(MemoryRegion, 1);
> >>      bool firmware_loaded;
> >>      bool aarch64 = true;
> >> +    bool has_ged = !vmc->no_ged;
> >>      unsigned int smp_cpus = machine->smp.cpus;
> >>      unsigned int max_cpus = machine->smp.max_cpus;
> >>
> >> @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState
> >> *machine)
> >>
> >>      create_gpio(vms, pic);
> >>
> >> +    if (has_ged && aarch64 && firmware_loaded && acpi_enabled) {
> >> +        vms->acpi_dev = create_acpi_ged(vms, pic);
> >> +    }
> >> +
> >>      /* Create mmio transports, so the user can create virtio backends
> >>       * (which will be automatically plugged in to the transports). If
> >>       * no backend is created the transport will just sit harmlessly idle.
> >> @@ -1876,14 +1905,23 @@ static const CPUArchIdList
> >> *virt_possible_cpu_arch_ids(MachineState *ms)  static void
> virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> >>                                   Error **errp)  {
> >> +    VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> >> +    const bool is_nvdimm = object_dynamic_cast(OBJECT(dev),
> TYPE_NVDIMM);
> >> +    Error *local_err = NULL;
> >>
> >> -    /*
> >> -     * The device memory is not yet exposed to the Guest either through
> >> -     * DT or ACPI and hence both cold/hot plug of memory is explicitly
> >> -     * disabled for now.
> >> -     */
> >> -    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
> >> -        error_setg(errp, "memory cold/hot plug is not yet supported");
> >> +    if (is_nvdimm) {
> >> +        error_setg(errp, "nvdimm is not yet supported");
> >> +        return;
> >> +    }
> >> +
> >> +    if (!vms->acpi_dev) {
> >> +        error_setg(errp, "memory hotplug is not enabled: missing acpi
> device");
> >> +        return;
> >> +    }
> >> +
> >> +    hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev,
> &local_err);
> >> +    if (local_err) {
> >> +        error_propagate(errp, local_err);
> >>          return;
> >>      }
> >>
> >> @@ -1893,11 +1931,18 @@ static void
> >> virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev,
> static void virt_memory_plug(HotplugHandler *hotplug_dev,
> >>                               DeviceState *dev, Error **errp)  {
> >> +    HotplugHandlerClass *hhc;
> >>      VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
> >>      Error *local_err = NULL;
> >>
> >>      pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err);
> >> +    if (local_err) {
> >> +        goto out;
> >> +    }
> >>
> >> +    hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev);
> >> +    hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err);
> >> +out:
> >>      error_propagate(errp, local_err);  }
> >>
> >> @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2)
> >>
> >>  static void virt_machine_4_1_options(MachineClass *mc)  {
> >> +    VirtMachineClass *vmc =
> VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
> >> +
> >>      virt_machine_4_2_options(mc);
> >>      compat_props_add(mc->compat_props, hw_compat_4_1,
> >> hw_compat_4_1_len);
> >> +    vmc->no_ged = true;
> >>  }
> >>  DEFINE_VIRT_MACHINE(4, 1)
> >>
> >> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index
> >> a72094204e..577ee49b4b 100644
> >> --- a/include/hw/arm/virt.h
> >> +++ b/include/hw/arm/virt.h
> >> @@ -77,6 +77,8 @@ enum {
> >>      VIRT_GPIO,
> >>      VIRT_SECURE_UART,
> >>      VIRT_SECURE_MEM,
> >> +    VIRT_PCDIMM_ACPI,
> >> +    VIRT_ACPI_GED,
> >>      VIRT_LOWMEMMAP_LAST,
> >>  };
> >>
> >> @@ -106,6 +108,7 @@ typedef struct {
> >>      bool claim_edge_triggered_timers;
> >>      bool smbios_old_sys_ver;
> >>      bool no_highmem_ecam;
> >> +    bool no_ged;   /* Machines < 4.2 has no support for ACPI GED
> device */
> >>  } VirtMachineClass;
> >>
> >>  typedef struct {
> >> @@ -133,6 +136,7 @@ typedef struct {
> >>      uint32_t iommu_phandle;
> >>      int psci_conduit;
> >>      hwaddr highest_gpa;
> >> +    DeviceState *acpi_dev;
> >>  } VirtMachineState;
> >>
> >>  #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM :
> >> VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h
> >> b/tests/bios-tables-test-allowed-diff.h
> >> index dfb8523c8b..7b4adbc822 100644
> >> --- a/tests/bios-tables-test-allowed-diff.h
> >> +++ b/tests/bios-tables-test-allowed-diff.h
> >> @@ -1 +1,2 @@
> >>  /* List of comma-separated changed AML files to ignore */
> >> +"tests/data/acpi/virt/DSDT",
> >>
> >

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

end of thread, other threads:[~2019-09-02  9:35 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 21:05 [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable Shameer Kolothum
2019-08-15  8:42   ` Shameerali Kolothum Thodi
2019-08-29  8:45     ` Igor Mammedov
2019-08-29 11:04       ` Shameerali Kolothum Thodi
2019-08-29 12:38         ` Igor Mammedov
2019-08-29 13:45           ` Shameerali Kolothum Thodi
2019-09-01 11:17   ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support Shameer Kolothum
2019-09-01 11:17   ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot Shameer Kolothum
2019-09-01 11:18   ` Auger Eric
2019-09-01 11:22     ` Auger Eric
2019-09-02  9:34       ` Shameerali Kolothum Thodi
2019-09-02  9:21     ` Shameerali Kolothum Thodi
2019-09-02  9:32       ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO Shameer Kolothum
2019-09-02  7:37   ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event Shameer Kolothum
2019-09-02  7:37   ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation Shameer Kolothum
2019-09-01 11:20   ` Auger Eric
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 11/12] tests: add dummy ACPI tables for arm/virt board Shameer Kolothum
2019-08-13 21:05 ` [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt Shameer Kolothum
2019-08-14  6:46 ` [Qemu-devel] [PATCH-for-4.2 v9 00/12] ARM virt: ACPI memory hotplug support no-reply

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).