From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730580; cv=none; d=zoho.com; s=zohoarc; b=i9aQRnuggHzIikdv2jGq6qD4S46rXznx2mM+j24myBGd5jXlROKU/H2WPl15Nl1p4dQ68BjaCKCKCuJkYoBDvsdJLDI+I8cgxaNXNxlo2I+VAouBvUldBQd3/xz13RTm2EIRfcJtgfcoqCV/rrowp3ezvjriIiqvRRrDCR3A/Ok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730580; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KOaBbheiXegr9n05bHIw34hEbIwBv9xvZKRMYUeQ0UA=; b=dtjk2A7A7RSQsrrwaWh+VnO88sS1YPP3PYHl2tcwFAssRlCsBi0VmuoHHlfIA0L7sDAFT5usQl2BRTT5CPEVZVFspL0q95tNPYBA+WC2LeDL5k9sGAklA7hW0+eXcP08+1VXEzUkXZmGhuwgVHlM/ccXur96Db6kiZUHo9JlURQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730580704101.33923211922308; Tue, 13 Aug 2019 14:09:40 -0700 (PDT) Received: from localhost ([::1]:55476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe2v-0006UR-Vc for importer@patchew.org; Tue, 13 Aug 2019 17:09:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41623) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0q-0004c5-Op for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0p-00012c-F6 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:24 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2251 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0l-0000tW-Mh; Tue, 13 Aug 2019 17:07:20 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CFB2BDBBB1A785A531F5; Wed, 14 Aug 2019 05:07:16 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:06 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:28 +0100 Message-ID: <20190813210539.31164-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 01/12] hw/acpi: Make ACPI IO address space configurable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Auger --- 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; =20 static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -209,7 +204,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = =3D { }; =20 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base) + MemHotplugState *state, hwaddr io_base) { MachineState *machine =3D MACHINE(qdev_get_machine()); =20 @@ -218,12 +213,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Objec= t *owner, return; } =20 - assert(!memhp_io_base); - memhp_io_base =3D io_base; state->devs =3D g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, sta= te, "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); } =20 /** @@ -342,7 +335,8 @@ const VMStateDescription vmstate_memory_hotplug =3D { =20 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"))); =20 crs =3D aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, - MEMORY_HOTPLUG_IO_LEN) - ); + if (rs =3D=3D 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)); =20 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) ); =20 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); =20 scope =3D 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, =20 /* Init default IOAPIC address space */ pcms->ioapic_as =3D &address_space_memory; + + /* Init ACPI memory hotplug IO base address */ + pcms->memhp_io_base =3D ACPI_MEMORY_HOTPLUG_BASE; } =20 /* diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotp= lug.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" =20 +#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 ejecte= d. @@ -29,7 +33,7 @@ typedef struct MemHotplugState { } MemHotplugState; =20 void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base); + MemHotplugState *state, hwaddr io_base); =20 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, ACP= IOSTInfoList ***list); =20 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; }; =20 #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730605; cv=none; d=zoho.com; s=zohoarc; b=eMDHYvz71MV8g6Eec151OYkvFIR1hh3dfX7ySQri2bT7CYrI4UZAExeJJwecx6S6BOWUs9pRyZeUNVFDy1aOc9Ih8mvTFZ8GoKlyjLLELl9NoQHDCS+xJYsKC3iTz4axa9KD52HUztIqSFRADfa0gKIBeRH69BiQvbdV0aaQoeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730605; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Mr1ezuKYoxi9xD3uOq/jX8oVxNnNpcd1PW9SAOmoapY=; b=K6/DrP1u6Or6nAlvHsn5PlpqdV6EAamaxpDxs/QE9KxzWYo3JW9AHZ9XckEN2xsiBteLwHADUrf9DDxsPpYyLQwz4RHcibHjXKxFHX8TyOt6QHYoIUNoU+EF/i/H3WKtiRm5nZWdTi+WbpGZ80D2kGg59wuu6iVjG5gHMgZ2wjQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730605637949.826485926664; Tue, 13 Aug 2019 14:10:05 -0700 (PDT) Received: from localhost ([::1]:55480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe3Q-0006zr-2Y for importer@patchew.org; Tue, 13 Aug 2019 17:10:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41602) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0o-0004Zd-P8 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0n-00010e-TY for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2252 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0l-0000tZ-Fm; Tue, 13 Aug 2019 17:07:19 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D986516219B64C76B000; Wed, 14 Aug 2019 05:07:16 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:10 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:29 +0100 Message-ID: <20190813210539.31164-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 02/12] hw/acpi: Do not create memory hotplug method when handler is not defined X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Samuel Ortiz 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 Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger Reviewed-by: Igor Mammedov --- 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); =20 - method =3D 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 =3D aml_method(event_handler_method, 0, AML_NOTSERIALIZED); + aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + aml_append(table, method); + } =20 g_free(mhp_res_path); } --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730719; cv=none; d=zoho.com; s=zohoarc; b=Uo9rTjhXdE3K5lWS9pAeKkjGmE/P0UxUKB8aOMd38CWHZhyWPuxSIifc9ddq+e7TKzX30tJZF1MS/7dUkcYSSycEaY3iRW6ot+InUZQgd9bkn6UDGt0FBxK/2J9oePurCU229p3DSKznQDnw6Ve5dYxhUtwHKgqVqFI7lcqYvE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730719; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=OMZxs+LbxpFFds/GUwN2lu/gGYfT8nBRCsDJhMLjD/E=; b=Yb4c/xJcPGikSvpPt5LN7/bQFBfEjmAGop2WaUSAqvrgA2eNn8xirajqiU+bkEWtxhI3VSyTBnM4PQZMFNHyhQQIvr5Fn75FQmBKoSOfMa4SaJUSmfwctOIhIH3MQkhwDrOfewHUmtHA/+cCKDFXMUN9YkugfNObAXIfhMyjQ94= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730719988542.492947484144; Tue, 13 Aug 2019 14:11:59 -0700 (PDT) Received: from localhost ([::1]:55506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe5H-0001lw-0S for importer@patchew.org; Tue, 13 Aug 2019 17:11:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41671) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0x-0004s4-PZ for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0v-0001A6-KV for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:31 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33344 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0q-00010y-O9; Tue, 13 Aug 2019 17:07:25 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8E539D6B25135C5F72ED; Wed, 14 Aug 2019 05:07:21 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:13 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:30 +0100 Message-ID: <20190813210539.31164-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 03/12] hw/acpi: Add ACPI Generic Event Device Support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Samuel Ortiz 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 Signed-off-by: Sebastien Boeuf Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger --- 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) +=3D memory_hotplu= g.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) +=3D cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) +=3D nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) +=3D vmgenid.o +common-obj-$(CONFIG_ACPI_HW_REDUCED) +=3D generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) +=3D acpi-stub.o =20 common-obj-y +=3D 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[] =3D { + 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_d= ev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) +{ + AcpiGedState *s =3D ACPI_GED(hotplug_dev); + Aml *crs =3D aml_resource_template(); + Aml *evt, *field; + Aml *dev =3D aml_device("%s", name); + Aml *evt_sel =3D aml_local(0); + Aml *esel =3D 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 =3D 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 =3D ESEL + * If ((Local0 & One) =3D=3D One) + * { + * MethodEvent0() + * } + * + * If ((Local0 & 0x2) =3D=3D 0x2) + * { + * MethodEvent1() + * } + * ... + */ + evt =3D aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *if_ctx; + uint32_t i; + uint32_t ged_events =3D ctpop32(s->ged_event_bitmap); + + /* Local0 =3D ESEL */ + aml_append(evt, aml_store(esel, evt_sel)); + + for (i =3D 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; = i++) { + uint32_t event =3D s->ged_event_bitmap & ged_supported_events[= i]; + + if (!event) { + continue; + } + + if_ctx =3D aml_if(aml_equal(aml_and(evt_sel, aml_int(event), N= ULL), + 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 =3D 0; + GEDState *ged_st =3D opaque; + + switch (addr) { + case ACPI_GED_EVT_SEL_OFFSET: + /* Read the selector value and reset it */ + val =3D ged_st->sel; + ged_st->sel =3D 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 =3D { + .read =3D ged_read, + .write =3D ged_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + AcpiGedState *s =3D 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 =3D ACPI_GED(adev); + GEDState *ged_st =3D &s->ged_state; + uint32_t sel; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel =3D 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 |=3D 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 =3D ACPI_GED(dev); + GEDState *ged_st =3D &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[] =3D { + 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 =3D opaque; + return s->memhp_state.is_enabled; +} + +static const VMStateDescription vmstate_memhp_state =3D { + .name =3D "acpi-ged/memhp", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_test_use_memhp, + .fields =3D (VMStateField[]) { + VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ged_state =3D { + .name =3D "acpi-ged-state", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32(sel, GEDState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_acpi_ged =3D { + .name =3D "acpi-ged", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDS= tate), + VMSTATE_END_OF_LIST(), + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_memhp_state, + NULL + } +}; + +static void acpi_ged_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(class); + HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(class); + AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_CLASS(class); + + dc->desc =3D "ACPI Generic Event Device"; + dc->props =3D acpi_ged_properties; + dc->realize =3D acpi_ged_device_realize; + dc->vmsd =3D &vmstate_acpi_ged; + + hc->plug =3D acpi_ged_device_plug_cb; + + adevc->send_event =3D acpi_ged_send_event; +} + +static const TypeInfo acpi_ged_info =3D { + .name =3D TYPE_ACPI_GED, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(AcpiGedState), + .class_init =3D acpi_ged_class_init, + .interfaces =3D (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/gener= ic_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 =3D ESEL // ESEL =3D IO memory region which specifies the + * // device type. + * If (((Local0 & One) =3D=3D One)) + * { + * MethodEvent1() + * } + * If ((Local0 & 0x2) =3D=3D 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_d= ev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base); + +#endif --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730607; cv=none; d=zoho.com; s=zohoarc; b=gm9akZ9Rr/96wWXmAzNcNebB86w8lDOoPA6otubq98CdaIufHECCtsaDNmkJVwy4AfPZlUApjzDapSR2DWQMAJ7mWEp7ItHRZ/qjpJXpZjJAmcooHxa/NKO0RMbP2fSvLNmZQYJzVw3XzJJ2kqogyh4kMNdnYHckRBz1K471G34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730607; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=X2YPILbyafHd6ejeqAe7nqDLxe78CklcYHCBmUkx44o=; b=DBzmZ+aBA/IreGExLIvCkuoOFkaiFNzhs39W87u2WA3OmQv+u17B/D/OR75qTzd3hwVkKA6vlRkivuAPY496ra2vMQyC3NLoZkPFzefr2HeTuM2mKN/ZPxdfge7X3+o09TOCGaW0cvVo2N0Uqe6A0gBDOsot1jQ1x4qnJfgSW+4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730607810816.219015730059; Tue, 13 Aug 2019 14:10:07 -0700 (PDT) Received: from localhost ([::1]:55478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe3N-0006nA-GT for importer@patchew.org; Tue, 13 Aug 2019 17:10:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41678) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe0z-0004t4-63 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe0x-0001Bn-On for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:32 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2186 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0u-00016N-Nf; Tue, 13 Aug 2019 17:07:29 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D6296777F7D2255294D1; Wed, 14 Aug 2019 05:07:26 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:17 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:31 +0100 Message-ID: <20190813210539.31164-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH-for-4.2 v9 04/12] hw/arm/virt: Add memory hotplug framework X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Auger 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 Signed-off-by: Kwangwoo Lee Signed-off-by: Shameer Kolothum Reviewed-by: Peter Maydell Reviewed-by: Igor Mammedov --- 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 =20 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" =20 #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_i= ds(MachineState *ms) return ms->possible_cpus; } =20 +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 =3D VIRT_MACHINE(hotplug_dev); + Error *local_err =3D 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(HotplugHand= ler *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))); } =20 static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *mach= ine, 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); } =20 @@ -1951,7 +2000,9 @@ static void virt_machine_class_init(ObjectClass *oc, = void *data) mc->kvm_type =3D virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; + hc->pre_plug =3D virt_machine_device_pre_plug_cb; hc->plug =3D virt_machine_device_plug_cb; + hc->unplug_request =3D virt_machine_device_unplug_request_cb; mc->numa_mem_supported =3D true; } =20 --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730797; cv=none; d=zoho.com; s=zohoarc; b=mpeo28acMGSnSZoka1hWuCHAIEMWrQ7s/gBRBmIYAZ+5GIoTYPONhpgvADI97PWoP5AoWFHpVLRO7IAQhX2FsKkkB2FML/JZUGT77rPaQWRqDQmTIpNiXng/TuiZw5JuCEcUdhjkArOEmfaE7Gzi57u23N30Odut21XrNqiPeJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730797; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=902FfrCE18fMMDnbH1AbjewyJewJhlr780PGsmnk3K4=; b=Yo+Gmn0YyW2xqYdqWZiOdEgCjVrNArNACwqOll4gXXcYQ2/2zbPYSZ9xv0ZxdVU/NUnn+8pt2jkzahUvrAM5GS1F/VwikLbIylRN2VD7IWXxDjytGcka0oB6+bKCVVIkUXlHZ4XQScZ1JDgBIXLtVwyYkwR50H3Iorq7Vd9Rldk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730797320513.9878475619745; Tue, 13 Aug 2019 14:13:17 -0700 (PDT) Received: from localhost ([::1]:55544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe6W-0005cS-DY for importer@patchew.org; Tue, 13 Aug 2019 17:13:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41726) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe19-0004vQ-W3 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe17-0001Kr-Vs for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:43 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33576 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0z-0001CJ-Lm; Tue, 13 Aug 2019 17:07:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B3D2A16FBA25251D182D; Wed, 14 Aug 2019 05:07:31 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:21 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:32 +0100 Message-ID: <20190813210539.31164-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 05/12] hw/arm/virt: Add 4.2 machine type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Igor Mammedov --- 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); =20 +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) =20 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" =20 +GlobalProperty hw_compat_4_1[] =3D {}; +const size_t hw_compat_4_1_len =3D G_N_ELEMENTS(hw_compat_4_1); + GlobalProperty hw_compat_4_0[] =3D { { "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) =20 +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; =20 --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730626; cv=none; d=zoho.com; s=zohoarc; b=blqoQruh+J6D5/sA9i9LLQ5phe9c9WmstIt/r5iw0xOPm/LSq4FY1G0HR3wiwJC10oI4sz196m45zZ5tT6MU3lahyzaFbI5rNanZ/Vkyc6KEgHdWWJCuHqqTOx9HFb6qfNkWOdCv5peZjMr92/+4gJqGDRG0QPNH3PD7DRNdZeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730626; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=lDC5wxKEnbG+QmevK2jhJk5KcxHOOiburnLjAoG0e4s=; b=ITLVu8qSRCOf6hhrWGP0fLV6i5axKu04yq40PW4JooPGsYdC1AonReXIDif4mINx8LWET20pRs+hCZbYam3fWMF51YEQyfyTOokLAcSmo6ZGKhOS488mpTUjJAoB7Yo8Ex/aRh6XaOtQ2ia+beDs29eXhkxTnGTz50Apo3i8tPo= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730626235532.8790461504342; Tue, 13 Aug 2019 14:10:26 -0700 (PDT) Received: from localhost ([::1]:55482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe3l-0007bn-A0 for importer@patchew.org; Tue, 13 Aug 2019 17:10:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41780) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1C-0004xe-0a for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1A-0001ND-Bm for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:45 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33570 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe0z-0001CL-PG; Tue, 13 Aug 2019 17:07:34 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id ABD28ED78EFA60630CCB; Wed, 14 Aug 2019 05:07:31 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:25 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:33 +0100 Message-ID: <20190813210539.31164-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 06/12] hw/arm/virt: Enable device memory cold/hot plug with ACPI boot X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 =20 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 =3D MACHINE(vms); const MemMapEntry *memmap =3D vms->memmap; const int *irqmap =3D vms->irqmap; =20 @@ -729,6 +732,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *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_MEM= ORY, + 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); =20 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" =20 #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[] =3D { [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] =3D { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, + [VIRT_ACPI_GED] =3D { 0x09080000, ACPI_GED_EVT_SEL_LEN }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -171,6 +174,7 @@ static const int a15irqmap[] =3D { [VIRT_PCIE] =3D 3, /* ... to 6 */ [VIRT_GPIO] =3D 7, [VIRT_SECURE_UART] =3D 8, + [VIRT_ACPI_GED] =3D 9, [VIRT_MMIO] =3D 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] =3D 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] =3D 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -520,6 +524,26 @@ static void fdt_add_pmu_nodes(const VirtMachineState *= vms) } } =20 +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq= *pic) +{ + DeviceState *dev; + int irq =3D vms->irqmap[VIRT_ACPI_GED]; + uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT; + + dev =3D 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].bas= e); + 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 =3D its_class_name(); @@ -1483,6 +1507,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 =3D true; + bool has_ged =3D !vmc->no_ged; unsigned int smp_cpus =3D machine->smp.cpus; unsigned int max_cpus =3D machine->smp.max_cpus; =20 @@ -1697,6 +1722,10 @@ static void machvirt_init(MachineState *machine) =20 create_gpio(vms, pic); =20 + if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { + vms->acpi_dev =3D 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 =3D VIRT_MACHINE(hotplug_dev); + const bool is_nvdimm =3D object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + Error *local_err =3D NULL; =20 - /* - * 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 devi= ce"); + return; + } + + hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_e= rr); + if (local_err) { + error_propagate(errp, local_err); return; } =20 @@ -1893,11 +1931,18 @@ static void virt_memory_pre_plug(HotplugHandler *ho= tplug_dev, DeviceState *dev, static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + HotplugHandlerClass *hhc; VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); Error *local_err =3D NULL; =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + if (local_err) { + goto out; + } =20 + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); +out: error_propagate(errp, local_err); } =20 @@ -2104,8 +2149,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) =20 static void virt_machine_4_1_options(MachineClass *mc) { + VirtMachineClass *vmc =3D 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 =3D true; } DEFINE_VIRT_MACHINE(4, 1) =20 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, }; =20 @@ -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; =20 typedef struct { @@ -133,6 +136,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi_dev; } VirtMachineState; =20 #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", --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730868; cv=none; d=zoho.com; s=zohoarc; b=BkckHXILCIMMD8L+CYH4/y/4EB7BXlDBxXvUTli0vviCUOYZCoc6CoXSXns5dt7t39rLXjNxlsS+y2eNX6jO3XAwxnIH9TIWMTLxEHB4MKdBw3haV1JsSxzyReMS81jYwhBx/NqenDVLqX+9535lnCnCEMvOcIPdxQ1Obvl8di0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730868; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=4AA/f4hAnUvuMcxTGXjpVMnrEDmO5xa+XaS0cP7GV3g=; b=Pj1s/YuWvTT+yFJ9/FaFCNdE+rhCoCradPQtjXMIyi8Njfi1pwqh/6+DGeHQKWYkKl5gWkzghhqYtX+6iJ+Rl0g1ZGBIxwNAgnMQPk2x4guBVNwNF3JMUjo9Fa0/CGkw2LoA70lHdWxIKwG9/00nkZ081WuVjgEfWx3MO45y94A= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730868902368.05740552519944; Tue, 13 Aug 2019 14:14:28 -0700 (PDT) Received: from localhost ([::1]:55578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe7f-0008O4-VF for importer@patchew.org; Tue, 13 Aug 2019 17:14:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053B-Ix for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YA-FX for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60828 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1A-0001H0-K9; Tue, 13 Aug 2019 17:07:45 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BEB44CF41561ABA8969A; Wed, 14 Aug 2019 05:07:36 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:28 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:34 +0100 Message-ID: <20190813210539.31164-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH-for-4.2 v9 07/12] hw/arm/virt-acpi-build: Add PC-DIMM in SRAT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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(>=3D4.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 Signed-off-by: Eric Auger Reviewed-by: Igor Mammedov --- 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, Virt= MachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc =3D MACHINE_GET_CLASS(vms); + MachineState *ms =3D MACHINE(vms); const CPUArchIdList *cpu_list =3D mc->possible_cpu_arch_ids(MACHINE(vm= s)); =20 srat_start =3D table_data->len; @@ -543,6 +544,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) } } =20 + if (ms->device_memory) { + numamem =3D 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_star= t), "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 =3D virt_machine_device_plug_cb; hc->unplug_request =3D virt_machine_device_unplug_request_cb; mc->numa_mem_supported =3D true; + mc->auto_enable_numa_with_memhp =3D true; } =20 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 =3D true; + mc->auto_enable_numa_with_memhp =3D false; } DEFINE_VIRT_MACHINE(4, 1) =20 --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730732; cv=none; d=zoho.com; s=zohoarc; b=mQ7vjvWhY6DqtofTSTB/Fx/yRApJrMPPtrSAf8eJnecGny41MKFlEWmctrbcvZjhuSfh77+Ef46YTJz0zeT+wzUS7m1nEkD8NJgov/rck5zG1EubtZPTotJ8lR23I4o3CScY5dAAvaINDf0KIvEWgfghtGU0iCrrchZYnV8C3fc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730732; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=FsLpo8JpdiLXdKuXzSpP/A/dAc8J0CbYIS3Cl6WOb28=; b=W5xZEJg419S1q4e3Y8PIoQiROfOLi9/giKhsXxVOHi6HiY7r6SYYtuwOXkXSOpwALmAA4l+C34Jp7fdlH8kUs2NLg+n1g9MhOP6HDbJjXZGLeVDaMnpXnhFnBenTPTOZ9gANZWxADIL7xVNWNZ9iNJ8G7p5iPFv9G/kK3XVm83g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730732914357.84096500315684; Tue, 13 Aug 2019 14:12:12 -0700 (PDT) Received: from localhost ([::1]:55510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe5U-0002Iy-1Y for importer@patchew.org; Tue, 13 Aug 2019 17:12:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41899) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053C-JA for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YF-Fh for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33788 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1A-0001LH-Kq; Tue, 13 Aug 2019 17:07:44 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CF7AED25FCFDA0750D96; Wed, 14 Aug 2019 05:07:41 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:32 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:35 +0100 Message-ID: <20190813210539.31164-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 08/12] hw/arm: Factor out powerdown notifier from GPIO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Auger --- 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 *opaq= ue) qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); } =20 -static Notifier virt_system_powerdown_notifier =3D { - .notify =3D 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, q= emu_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); } =20 @@ -1726,6 +1718,10 @@ static void machvirt_init(MachineState *machine) vms->acpi_dev =3D create_acpi_ged(vms, pic); } =20 + /* connect powerdown request */ + vms->powerdown_notifier.notify =3D 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; =20 #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730808; cv=none; d=zoho.com; s=zohoarc; b=Ctbt3EdwlAEJ3kxUbOzZ7XjPye27Z56/FXzxtl2zbBwVnsm+4i1oBoyU4tVvso4p9LGoRArcXgrZY/TLmq19hf8bx5GDvolNlWYGvM/uGXGs3xNQZuJIG8gWjsUQTe4Iie/UmrIs3d7Pk/1eXSl12DJU11ViwEXYL1M42oP2kEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730808; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=hKHHY1cJw7n5+GwvXCIspcDe8BTV9o7Z2jROMlC41XQ=; b=JyfB/WX9lwM/9EBOp4v4DQuUAIjG82TcisNy3Hi1Mu7FhT2cIN3s8xypwuEeUQBEDsk6QHCEyRwT6nbjahdB3CB3AWFWO1yzv088gGc908V85vmeowQxoEP5/d28WXBBoqp0I21Ja/GVJev3zh6pUSyifFSIZqUZ0rhoRQeobO4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730808551921.4702000588608; Tue, 13 Aug 2019 14:13:28 -0700 (PDT) Received: from localhost ([::1]:55548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe6h-00067B-Ll for importer@patchew.org; Tue, 13 Aug 2019 17:13:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41905) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053u-Tg for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001YX-HF for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33914 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1F-0001RE-0b; Tue, 13 Aug 2019 17:07:49 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E8FD7FB4E9428B21955B; Wed, 14 Aug 2019 05:07:46 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:36 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:36 +0100 Message-ID: <20190813210539.31164-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 09/12] hw/arm: Use GED for system_powerdown event X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Eric Auger --- 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 @@ =20 static const uint32_t ged_supported_events[] =3D { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; =20 /* @@ -103,6 +104,11 @@ void build_ged_aml(Aml *table, const char *name, Hotpl= ugHandler *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, Acp= iEventStatusBits ev) =20 if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { sel =3D ACPI_GED_MEM_HOTPLUG_EVT; + } else if (ev & ACPI_POWER_DOWN_STATUS) { + sel =3D 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" =20 #define ARM_SPI_BASE 32 -#define ACPI_POWER_BUTTON_DEVICE "PWRB" =20 static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { @@ -739,13 +738,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPO= RTS); 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_MEM= ORY, memmap[VIRT_ACPI_GED].base); + } else { + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); } =20 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(VirtMachineS= tate *vms, qemu_irq *pic) { DeviceState *dev; int irq =3D vms->irqmap[VIRT_ACPI_GED]; - uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT; + uint32_t event =3D ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; =20 dev =3D 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, qe= mu_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 =3D container_of(n, VirtMachineState, powerdown_no= tifier); + + 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); + } } =20 static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) @@ -1712,10 +1718,10 @@ static void machvirt_init(MachineState *machine) =20 create_pcie(vms, pic); =20 - create_gpio(vms, pic); - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev =3D create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } =20 /* connect powerdown request */ diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_de= v_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 =3D 8, ACPI_NVDIMM_HOTPLUG_STATUS =3D 16, ACPI_VMGENID_CHANGE_STATUS =3D 32, + ACPI_POWER_DOWN_STATUS =3D 64, } AcpiEventStatusBits; =20 #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/gener= ic_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" =20 +#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 =20 typedef struct GEDState { MemoryRegion io; --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730747; cv=none; d=zoho.com; s=zohoarc; b=ooPNBj6pKooQ6raYonBxpHeRS0gU5ivXiYxdT+FwNj+1QEkePeQHyh3GNdlWiBKveJiEnnIaC7sv7A/DWnMWkk4N9kOuRCZedxitbWIxa0sQoDvrtP45iOmE2/RbN6bPOAU8mPvZBuitF8wAaAA7/1ARBmySBqaU5B7N1kTicNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730747; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2A77xDkBGjIvIFXCxAe1nFVvDQrOJVTqECfZ2tujOXE=; b=Gtq38NFSTGX3x+4Pfr0s8iZ1pYktjJ25uCIDt+IlugSzaZkRs35WNefo84LMUUV36BmaL+M6UkT9dk3qnYjHJ9CFS0YKlJ+yFPcMY/JjVhLTW7ooEjPfL1EJBQReL9rsJPi/5LE7yo7hNccEveZ9U6Zfr6VvufhX0s0xj936X/k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730747256277.50207284223563; Tue, 13 Aug 2019 14:12:27 -0700 (PDT) Received: from localhost ([::1]:55512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe5i-00031Q-Co for importer@patchew.org; Tue, 13 Aug 2019 17:12:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41903) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1J-00053t-Rq for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1I-0001Yc-Ht for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:07:53 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33900 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1E-0001RA-Tp; Tue, 13 Aug 2019 17:07:49 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E23D4E12C927C458684F; Wed, 14 Aug 2019 05:07:46 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:40 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:37 +0100 Message-ID: <20190813210539.31164-11-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.32 Subject: [Qemu-devel] [PATCH-for-4.2 v9 10/12] docs/specs: Add ACPI GED documentation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Documents basic concepts of ACPI Generic Event device(GED) and interface between QEMU and the ACPI BIOS. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger --- 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_re= duced_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 =3D ESEL // ESEL =3D IO memory region which specifies the + // device type. + If (((Local0 & One) =3D=3D One)) + { + MethodEvent1() + } + If ((Local0 & 0x2) =3D=3D 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 --=20 2.17.1 From nobody Thu Apr 25 08:28:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1565730874; cv=none; d=zoho.com; s=zohoarc; b=faifSAmzd+quH8wo26GL3yXmWyI1jdwdUK0W0Sqw6WKCHGLT4ewsqbeIV/MPBs0HSXCHJe16y7tJvodtSQrWpDfiWPj/t/WL0m+9B8zgY4s8nFOqIX7R4p6xoLqPUn97Pq4rXmm+xNMV/5p5vYKTF9VY2QWPaNdurZIULdnJvMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565730874; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gzZP6fj4OMJOhAgrqkQc84hO7+jjCQFROQ+6U8qxrhA=; b=hnICshC6tO7oWEwcrgtGYilBwQE0+gXhuhBPqdPx9qKq7OPbYgHFGJHhos4HEgwZZx5CyycmpfEJ12AqXsmvsqp0UcMJDHvio3S0idQloiI2d/7RQtWAdV/uuxMKURT+vuSEZFhicGSehcjsEpt4suK+pTHdMQmY0pUhi/tjhuM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730874140159.77245404843472; Tue, 13 Aug 2019 14:14:34 -0700 (PDT) Received: from localhost ([::1]:55580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe7l-0000CD-94 for importer@patchew.org; Tue, 13 Aug 2019 17:14:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42002) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1R-0005GZ-Gq for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1P-0001fF-2W for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:00 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:32894 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1J-0001Y5-Uw; Tue, 13 Aug 2019 17:07:54 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id F15B9C2BA4CDCEF09560; Wed, 14 Aug 2019 05:07:51 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:43 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:38 +0100 Message-ID: <20190813210539.31164-12-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.35 Subject: [Qemu-devel] [PATCH-for-4.2 v9 11/12] tests: add dummy ACPI tables for arm/virt board X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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: (ex= p_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..74ec3b4b461ffecca36d8537975= c202a5f011185 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..119922f4973f621602047d1dc16= 0519f810922a3 GIT binary patch literal 224 zcmWFzatwLEz`(%x)yd!4BUr&HBEUHqD8>jB1F=3DCg2*ZH@DxXmUMHZ-x3$7Gd2B8jU X02q8=3Dhbcr=3D2NT6lGiu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565730799696967.7729354346792; Tue, 13 Aug 2019 14:13:19 -0700 (PDT) Received: from localhost ([::1]:55546 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe6Y-0005h4-Q9 for importer@patchew.org; Tue, 13 Aug 2019 17:13:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42107) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxe1X-0005Ia-Dc for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxe1V-0001oO-Db for qemu-devel@nongnu.org; Tue, 13 Aug 2019 17:08:06 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2253 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hxe1P-0001dE-37; Tue, 13 Aug 2019 17:08:00 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 0E3FEE996CB23ADEC89A; Wed, 14 Aug 2019 05:07:57 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.47.94.0) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Wed, 14 Aug 2019 05:07:47 +0800 From: Shameer Kolothum To: , , , Date: Tue, 13 Aug 2019 22:05:39 +0100 Message-ID: <20190813210539.31164-13-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> References: <20190813210539.31164-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.94.0] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH-for-4.2 v9 12/12] tests: Add bios tests to arm/virt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This adds numamem and memhp tests for arm/virt platform Signed-off-by: Shameer Kolothum --- 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); } =20 +static void test_acpi_virt_tcg_memhp(void) +{ + test_data data =3D { + .machine =3D "virt", + .accel =3D "tcg", + .uefi_fl1 =3D "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 =3D "pc-bios/edk2-arm-vars.fd", + .cd =3D "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.= qcow2", + .ram_start =3D 0x40000000ULL, + .scan_len =3D 256ULL * 1024 * 1024, + }; + + data.variant =3D ".memhp"; + test_acpi_one(" -cpu cortex-a57" + " -m 256M,slots=3D3,maxmem=3D1G" + " -object memory-backend-ram,id=3Dram0,size=3D128M" + " -object memory-backend-ram,id=3Dram1,size=3D128M" + " -numa node,memdev=3Dram0 -numa node,memdev=3Dram1" + " -numa dist,src=3D0,dst=3D1,val=3D21", + &data); + + free_test_data(&data); + +} + +static void test_acpi_virt_tcg_numamem(void) +{ + test_data data =3D { + .machine =3D "virt", + .accel =3D "tcg", + .uefi_fl1 =3D "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 =3D "pc-bios/edk2-arm-vars.fd", + .cd =3D "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.= qcow2", + .ram_start =3D 0x40000000ULL, + .scan_len =3D 128ULL * 1024 * 1024, + }; + + data.variant =3D ".numamem"; + test_acpi_one(" -cpu cortex-a57" + " -object memory-backend-ram,id=3Dram0,size=3D128M" + " -numa node,memdev=3Dram0", + &data); + + free_test_data(&data); + +} + static void test_acpi_virt_tcg(void) { test_data data =3D { @@ -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") =3D=3D 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 =3D g_test_run(); boot_sector_cleanup(disk); --=20 2.17.1