From patchwork Wed Sep 4 08:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172899 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp955462ily; Wed, 4 Sep 2019 01:59:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuOCK8Iur+KF/iIodUPYf97LLjoAS4nQ8DTCl2WOrhUd0Ih5VOdD6ftRgeujh/HSk5MT1e X-Received: by 2002:a37:660e:: with SMTP id a14mr23829812qkc.481.1567587587260; Wed, 04 Sep 2019 01:59:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587587; cv=none; d=google.com; s=arc-20160816; b=MccgXvKtE47a5Jh4yEp+ON4JXWNePWyXSCFPkb0Uw7mUeYIJeLEwVssaqsNN2qB7Nq moB2etIbmDcITrQFAMRoS8aMZvcoZTDH9a7L7PMQRNRH8oQOSsBO6Wpe7T6t5upR/VMX THxOzbAcw2hntoyZOWu2cZhWlwwV5QRA6OOjKYQ8fcqxPO2zmrxa9U9iUZJp2/7m+B5F NaHiPDxN4hKfZwMD6EKOblgPu0kHrUVwdzIdFqSIjmRUioauRXTWHJb+gaztB3vMGJNf Zgff2YWWh+hD4bGcWDe4m7ntd6RTlp4Slf4nOFt9pAmK/CpgjtPlDvFhGDoU+qGNzqFW wbkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=rTWsOEXzZWRlyjwcN3WId8GrW9T2jjGI3jtrfw+Kh+Y=; b=wxKNMAOq8sXdrN6gnl50Oq6/BiXu3lXsqeRSliLTicQO8RilXe6f5Pcogdfrg8Ym6+ CtWW0mtWKl0RipjO+VrZXNtW+7tjn33DMTN0dmgfBTz5qO7jibRdCjbSHU5XFDi6luwy tT0DuwzpSl+oOjHncRbkpgC7bEb9838pnBu07pQbB+OnwejPgqB7VvcINOb+K1GNYpIR +s0M//C9kj/r/0aXCk1VIXrukIwdcly7nGxw742hgSjg1ngCqI/FEHvVhymq7tO4tah8 +8ivmutLR8JprxtMz6DMWwBK4bF1caLZchddlnO6cnL93Fv2XTXsBeyMmwCHyIMkjnaf ntVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i7si7007682qtj.197.2019.09.04.01.59.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 01:59:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R8j-0000Wc-T7 for patch@linaro.org; Wed, 04 Sep 2019 04:59:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38450) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R6q-000736-Az for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R6o-00077G-Am for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2258 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6j-00073Y-Dq; Wed, 04 Sep 2019 04:57:42 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id AF4CEAB72B497DE3D10E; Wed, 4 Sep 2019 16:57:38 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:29 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:19 +0100 Message-ID: <20190904085629.13872-2-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 01/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- v9 --> v10 - Fixed "make check" failure on x86_64. 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 | 33 ++++++++++++++------------------ hw/i386/acpi-build.c | 7 ++++++- hw/i386/pc.c | 3 +++ include/hw/acpi/memory_hotplug.h | 9 +++++++-- include/hw/i386/pc.h | 3 +++ 5 files changed, 33 insertions(+), 22 deletions(-) -- 2.17.1 Reviewed-by: Igor Mammedov diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 9483d66e86..9b0b150f4f 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -30,12 +30,7 @@ #define MEMORY_SLOT_PROXIMITY_METHOD "MPXM" #define MEMORY_SLOT_EJECT_METHOD "MEJ0" #define MEMORY_SLOT_NOTIFY_METHOD "MTFY" -#define MEMORY_SLOT_SCAN_METHOD "MSCN" #define MEMORY_HOTPLUG_DEVICE "MHPD" -#define MEMORY_HOTPLUG_IO_LEN 24 -#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" - -static uint16_t memhp_io_base; static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev) { @@ -210,7 +205,7 @@ static const MemoryRegionOps acpi_memory_hotplug_ops = { }; void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base) + MemHotplugState *state, hwaddr io_base) { MachineState *machine = MACHINE(qdev_get_machine()); @@ -219,12 +214,10 @@ void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, return; } - assert(!memhp_io_base); - memhp_io_base = io_base; state->devs = g_malloc0(sizeof(*state->devs) * state->dev_count); memory_region_init_io(&state->io, owner, &acpi_memory_hotplug_ops, state, "acpi-mem-hotplug", MEMORY_HOTPLUG_IO_LEN); - memory_region_add_subregion(as, memhp_io_base, &state->io); + memory_region_add_subregion(as, io_base, &state->io); } /** @@ -343,7 +336,8 @@ const VMStateDescription vmstate_memory_hotplug = { void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, const char *res_root, - const char *event_handler_method) + const char *event_handler_method, + AmlRegionSpace rs, hwaddr memhp_io_base) { int i; Aml *ifctx; @@ -352,10 +346,6 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, Aml *mem_ctrl_dev; char *mhp_res_path; - if (!memhp_io_base) { - return; - } - mhp_res_path = g_strdup_printf("%s." MEMORY_HOTPLUG_DEVICE, res_root); mem_ctrl_dev = aml_device("%s", mhp_res_path); { @@ -366,14 +356,19 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, aml_name_decl("_UID", aml_string("Memory hotplug resources"))); crs = aml_resource_template(); - aml_append(crs, - aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, - MEMORY_HOTPLUG_IO_LEN) - ); + if (rs == AML_SYSTEM_IO) { + aml_append(crs, + aml_io(AML_DECODE16, memhp_io_base, memhp_io_base, 0, + MEMORY_HOTPLUG_IO_LEN) + ); + } else { + aml_append(crs, aml_memory32_fixed(memhp_io_base, + MEMORY_HOTPLUG_IO_LEN, AML_READ_WRITE)); + } aml_append(mem_ctrl_dev, aml_name_decl("_CRS", crs)); aml_append(mem_ctrl_dev, aml_operation_region( - MEMORY_HOTPLUG_IO_REGION, AML_SYSTEM_IO, + MEMORY_HOTPLUG_IO_REGION, rs, aml_int(memhp_io_base), MEMORY_HOTPLUG_IO_LEN) ); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 034e413fd0..0d97cc701d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1873,7 +1873,12 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, build_cpus_aml(dsdt, machine, opts, pm->cpu_hp_io_base, "\\_SB.PCI0", "\\_GPE._E02"); } - build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", "\\_GPE._E03"); + + if (pcms->memhp_io_base && nr_mem) { + build_memory_hotplug_aml(dsdt, nr_mem, "\\_SB.PCI0", + "\\_GPE._E03", AML_SYSTEM_IO, + pcms->memhp_io_base); + } scope = aml_scope("_GPE"); { diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c14ed86439..b38cd07231 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1951,6 +1951,9 @@ void pc_memory_init(PCMachineState *pcms, /* Init default IOAPIC address space */ pcms->ioapic_as = &address_space_memory; + + /* Init ACPI memory hotplug IO base address */ + pcms->memhp_io_base = ACPI_MEMORY_HOTPLUG_BASE; } /* diff --git a/include/hw/acpi/memory_hotplug.h b/include/hw/acpi/memory_hotplug.h index 77c65765d6..dfe9cf3fde 100644 --- a/include/hw/acpi/memory_hotplug.h +++ b/include/hw/acpi/memory_hotplug.h @@ -5,6 +5,10 @@ #include "hw/acpi/acpi.h" #include "hw/acpi/aml-build.h" +#define MEMORY_SLOT_SCAN_METHOD "MSCN" +#define MEMORY_DEVICES_CONTAINER "\\_SB.MHPC" +#define MEMORY_HOTPLUG_IO_LEN 24 + /** * MemStatus: * @is_removing: the memory device in slot has been requested to be ejected. @@ -29,7 +33,7 @@ typedef struct MemHotplugState { } MemHotplugState; void acpi_memory_hotplug_init(MemoryRegion *as, Object *owner, - MemHotplugState *state, uint16_t io_base); + MemHotplugState *state, hwaddr io_base); void acpi_memory_plug_cb(HotplugHandler *hotplug_dev, MemHotplugState *mem_st, DeviceState *dev, Error **errp); @@ -48,5 +52,6 @@ void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list); void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, const char *res_root, - const char *event_handler_method); + const char *event_handler_method, + AmlRegionSpace rs, hwaddr memhp_io_base); #endif diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 19a837889d..ac09e42030 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -69,6 +69,9 @@ struct PCMachineState { /* Address space used by IOAPIC device. All IOAPIC interrupts * will be translated to MSI messages in the address space. */ AddressSpace *ioapic_as; + + /* ACPI Memory hotplug IO base address */ + hwaddr memhp_io_base; }; #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" From patchwork Wed Sep 4 08:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172902 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp959609ily; Wed, 4 Sep 2019 02:03:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFOHCQzV5emb1396+hL1hoD01e4k+wrT+zoG61UAn1m+WDV0vhIcapUsTvh/v1Jp7Xp/PE X-Received: by 2002:ac8:7246:: with SMTP id l6mr1238607qtp.359.1567587817780; Wed, 04 Sep 2019 02:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587817; cv=none; d=google.com; s=arc-20160816; b=hLmKJoOBP0IkJzdXsl64oob8uKKSht7d4fe0kXOnwO4BsfDufxgECH7irQUvfcJJ+2 ZaQntilWRbhgJV6o2L6UMvLeDiaG0c/DIs/P/QrR03Udir4CC7HhNMAnsWIg0YeD4KW9 cb7x+2XwQW87GaiVgZ2TlTpaM4bITaYUY31t2z33QcUnXDDlsOlEErekeK50OrRsLI7Z 0LC7rvxL7kicvUvHYS+Cvy2k4qbeAa4AHhuuQqYpF+8e02c5XBIflkWXL2HCG4IqL5PK yqss7EGjbPBibD7LtKE9dD7Tnx3uLgN2xHZ3Ujug+3fpH6V7TG9TabZg0WctuS+vGjVh l2WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=baRvW1oCGVZkVk4Dgfg2Qxz+MISC/NzNUi8xulrSLos=; b=P57bpofWy7cqBJ/A2s64hnJEMhEHBCGqARCJYCIA4Nd1xXej4hZAVPl8r5cs/r22vj bmGgFleNJ2VoaD6LzyLQjMxSWeBimcMWOOum1khaVkiecKIljEE2+QZApT3Yo0KRlp7k LZld54bkWwh6bD7lxbwvM7dlFBEQ36Qt7JtkXhIqDweYVlxrXFCDeHZOfZ+DZRfs8hDR q6oXmC8tG361gk58lCopD17/41BHO1GN4Oo96puTGpPrRrcpwn1WTzGv7UT5Dqp6l539 dVE4zbbQPOs50zDFdlrm9TH8UVxXzPXss5tOaH1gCdXy8ikorjsw88DeWiVl6vk9QrY8 RKkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z139si13659791qkb.58.2019.09.04.02.03.37 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:03:37 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54766 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RCS-0004No-UK for patch@linaro.org; Wed, 04 Sep 2019 05:03:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38474) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R6s-00075V-5X for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R6q-00078Y-Mx for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54312 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6n-000765-Pc; Wed, 04 Sep 2019 04:57:46 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C94F367E587719552E02; Wed, 4 Sep 2019 16:57:43 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:33 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:20 +0100 Message-ID: <20190904085629.13872-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 02/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 diff --git a/hw/acpi/memory_hotplug.c b/hw/acpi/memory_hotplug.c index 9b0b150f4f..8d2e82240f 100644 --- a/hw/acpi/memory_hotplug.c +++ b/hw/acpi/memory_hotplug.c @@ -712,10 +712,12 @@ void build_memory_hotplug_aml(Aml *table, uint32_t nr_mem, } aml_append(table, dev_container); - method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED); - aml_append(method, - aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); - aml_append(table, method); + if (event_handler_method) { + method = aml_method(event_handler_method, 0, AML_NOTSERIALIZED); + aml_append(method, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + aml_append(table, method); + } g_free(mhp_res_path); } From patchwork Wed Sep 4 08:56:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172898 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp955350ily; Wed, 4 Sep 2019 01:59:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwchJclBs4Gyo98R6bGiX1Ce0tsGFajjcRbAyLS2pHWCepcH4DGpE+lOUxDgf1xufgQ3hNC X-Received: by 2002:a37:b001:: with SMTP id z1mr37252006qke.383.1567587579020; Wed, 04 Sep 2019 01:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587579; cv=none; d=google.com; s=arc-20160816; b=Z2+fhYWbANghAdy2BTy/9+bmDsnKxwLbAls2Xsy0ogfSycqL018RTXDU0Yeau+4rrd tWC+h8CVZsUqpGVPvDpoKxX9eVOg5f9tPGj321v2GmuyK75FXtKbZNCh3/omVwZrFGe6 8t3DHhVyzhK0Orns0Q7pDK43VC9ayXOjdIHMPCMgdpgPCysABqZ6I8q43uxXmEbxCnQq ICuLz71EIrAHcKEIWVLmrY6Ku5inqS+vuGqcPXOIOysK5zvEfq+iZIiB1Xo4CvuP93Du IvHg+gEKhhl8eoF3gs+Qo9La7etnaeMbj7FKRCLsLG+1kRZyd2Yu07rT7j8ieiyATM9+ s0+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=E1M3PiFSpbV7E40FISJHMLR+DPF5zNr5VzosViUDjhA=; b=pZ6cg+PnkbJ7ELkFnqFGTr9HT04+icyWjUQa0M639RL9mxiCjyqDRxCWsW5hzbWwE8 QYeSn2auEE0LuqRKFlsMuGugY7DN3jNWVv8nmt9g/6z1t82t41qKXjizOEu0+QGF3Rjw 9pnNJLG5d+4Z3EFSozT31f0dhFMLQvcPo+XnwD7lAeq+tzGwLtm/kPO7S2Oa8yBXJ5k4 dQoAOxeFgsvYxDmHvIv49ylRYJ/y7cCaDYN/48fTcZvvFqPHFaUOwS2YfOmkyACxDEWt la+kJWXEfHL935rQpwmiJ0gJ0/o3MCFTw8fTDjAHd7hDX40P5RSVCpwOoNzNO+ED3R6w f+Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t126si14824321qke.168.2019.09.04.01.59.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 01:59:39 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R8b-0007iM-Rp for patch@linaro.org; Wed, 04 Sep 2019 04:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38513) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R6w-0007BU-Gl for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R6u-0007AE-36 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:54 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:54306 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6n-000760-JJ; Wed, 04 Sep 2019 04:57:46 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C06B0DBA399C5DB76083; Wed, 4 Sep 2019 16:57:43 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:36 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:21 +0100 Message-ID: <20190904085629.13872-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 03/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- v9 --> v10 -Added few required headers. -Added Eric's R-by 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 | 317 +++++++++++++++++++++++++ include/hw/acpi/generic_event_device.h | 100 ++++++++ 4 files changed, 422 insertions(+) create mode 100644 hw/acpi/generic_event_device.c create mode 100644 include/hw/acpi/generic_event_device.h -- 2.17.1 diff --git a/hw/acpi/Kconfig b/hw/acpi/Kconfig index 7c59cf900b..12e3f1e86e 100644 --- a/hw/acpi/Kconfig +++ b/hw/acpi/Kconfig @@ -31,3 +31,7 @@ config ACPI_VMGENID bool default y depends on PC + +config ACPI_HW_REDUCED + bool + depends on ACPI diff --git a/hw/acpi/Makefile.objs b/hw/acpi/Makefile.objs index 9bb2101e3b..655a9c1973 100644 --- a/hw/acpi/Makefile.objs +++ b/hw/acpi/Makefile.objs @@ -6,6 +6,7 @@ common-obj-$(CONFIG_ACPI_MEMORY_HOTPLUG) += memory_hotplug.o common-obj-$(CONFIG_ACPI_CPU_HOTPLUG) += cpu.o common-obj-$(CONFIG_ACPI_NVDIMM) += nvdimm.o common-obj-$(CONFIG_ACPI_VMGENID) += vmgenid.o +common-obj-$(CONFIG_ACPI_HW_REDUCED) += generic_event_device.o common-obj-$(call lnot,$(CONFIG_ACPI_X86)) += acpi-stub.o common-obj-y += acpi_interface.o diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c new file mode 100644 index 0000000000..f81d966058 --- /dev/null +++ b/hw/acpi/generic_event_device.c @@ -0,0 +1,317 @@ +/* + * + * 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/irq.h" +#include "hw/mem/pc-dimm.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "qemu/error-report.h" + +static const uint32_t ged_supported_events[] = { + ACPI_GED_MEM_HOTPLUG_EVT, +}; + +/* + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Platforms need to specify their own + * GED Event bitmap to describe what kind of events they want to support + * through GED. This routine uses a single interrupt for the GED device, + * relying on IO memory region to communicate the type of device + * affected by the interrupt. This way, we can support up to 32 events + * with a unique interrupt. + */ +void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base) +{ + AcpiGedState *s = ACPI_GED(hotplug_dev); + Aml *crs = aml_resource_template(); + Aml *evt, *field; + Aml *dev = aml_device("%s", name); + Aml *evt_sel = aml_local(0); + Aml *esel = aml_name(AML_GED_EVT_SEL); + + /* _CRS interrupt */ + aml_append(crs, aml_interrupt(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH, + AML_EXCLUSIVE, &ged_irq, 1)); + + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0013"))); + aml_append(dev, aml_name_decl("_UID", aml_string(GED_DEVICE))); + aml_append(dev, aml_name_decl("_CRS", crs)); + + /* Append IO region */ + aml_append(dev, aml_operation_region(AML_GED_EVT_REG, rs, + aml_int(ged_base + ACPI_GED_EVT_SEL_OFFSET), + ACPI_GED_EVT_SEL_LEN)); + field = aml_field(AML_GED_EVT_REG, AML_DWORD_ACC, AML_NOLOCK, + AML_WRITE_AS_ZEROS); + aml_append(field, aml_named_field(AML_GED_EVT_SEL, + ACPI_GED_EVT_SEL_LEN * BITS_PER_BYTE)); + aml_append(dev, field); + + /* + * For each GED event we: + * - Add a conditional block for each event, inside a loop. + * - Call a method for each supported GED event type. + * + * The resulting ASL code looks like: + * + * Local0 = ESEL + * If ((Local0 & One) == One) + * { + * MethodEvent0() + * } + * + * If ((Local0 & 0x2) == 0x2) + * { + * MethodEvent1() + * } + * ... + */ + evt = aml_method("_EVT", 1, AML_SERIALIZED); + { + Aml *if_ctx; + uint32_t i; + uint32_t ged_events = ctpop32(s->ged_event_bitmap); + + /* Local0 = ESEL */ + aml_append(evt, aml_store(esel, evt_sel)); + + for (i = 0; i < ARRAY_SIZE(ged_supported_events) && ged_events; i++) { + uint32_t event = s->ged_event_bitmap & ged_supported_events[i]; + + if (!event) { + continue; + } + + if_ctx = aml_if(aml_equal(aml_and(evt_sel, aml_int(event), NULL), + aml_int(event))); + switch (event) { + case ACPI_GED_MEM_HOTPLUG_EVT: + aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." + MEMORY_SLOT_SCAN_METHOD)); + break; + default: + /* + * Please make sure all the events in ged_supported_events[] + * are handled above. + */ + g_assert_not_reached(); + } + + aml_append(evt, if_ctx); + ged_events--; + } + + if (ged_events) { + error_report("Unsupported events specified"); + abort(); + } + } + + /* Append _EVT method */ + aml_append(dev, evt); + + aml_append(table, dev); +} + +/* Memory read by the GED _EVT AML dynamic method */ +static uint64_t ged_read(void *opaque, hwaddr addr, unsigned size) +{ + uint64_t val = 0; + GEDState *ged_st = opaque; + + switch (addr) { + case ACPI_GED_EVT_SEL_OFFSET: + /* Read the selector value and reset it */ + val = ged_st->sel; + ged_st->sel = 0; + break; + default: + break; + } + + return val; +} + +/* Nothing is expected to be written to the GED memory region */ +static void ged_write(void *opaque, hwaddr addr, uint64_t data, + unsigned int size) +{ +} + +static const MemoryRegionOps ged_ops = { + .read = ged_read, + .write = ged_write, + .endianness = DEVICE_LITTLE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, +}; + +static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + AcpiGedState *s = ACPI_GED(hotplug_dev); + + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + if (s->memhp_state.is_enabled) { + acpi_memory_plug_cb(hotplug_dev, &s->memhp_state, dev, errp); + } else { + error_setg(errp, + "memory hotplug is not enabled: %s.memory-hotplug-support " + "is not set", object_get_typename(OBJECT(s))); + } + } else { + error_setg(errp, "virt: device plug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); + } +} + +static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) +{ + AcpiGedState *s = ACPI_GED(adev); + GEDState *ged_st = &s->ged_state; + uint32_t sel; + + if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { + sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else { + /* Unknown event. Return without generating interrupt. */ + warn_report("GED: Unsupported event %d. No irq injected", ev); + return; + } + + /* + * Set the GED selector field to communicate the event type. + * This will be read by GED aml code to select the appropriate + * event method. + */ + ged_st->sel |= sel; + + /* Trigger the event by sending an interrupt to the guest. */ + qemu_irq_pulse(s->irq); +} + +static void acpi_ged_device_realize(DeviceState *dev, Error **errp) +{ + AcpiGedState *s = ACPI_GED(dev); + GEDState *ged_st = &s->ged_state; + + memory_region_init_io(&ged_st->io, OBJECT(dev), &ged_ops, ged_st, + TYPE_ACPI_GED, ACPI_GED_EVT_SEL_LEN); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &ged_st->io); + + sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); + + if (s->memhp_state.is_enabled) { + /* + * GED handles memory hotplug event and acpi-mem-hotplug + * memory region gets initialized here. Create an exclusive + * container for memory hotplug IO and expose it as GED sysbus + * MMIO so that boards can map it separately. + */ + memory_region_init(&s->container_memhp, OBJECT(dev), "container", + MEMORY_HOTPLUG_IO_LEN); + sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container_memhp); + acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev), + &s->memhp_state, 0); + } +} + +static Property acpi_ged_properties[] = { + DEFINE_PROP_BOOL("memory-hotplug-support", AcpiGedState, + memhp_state.is_enabled, true), + DEFINE_PROP_UINT32("ged-event", AcpiGedState, ged_event_bitmap, 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static bool vmstate_test_use_memhp(void *opaque) +{ + AcpiGedState *s = opaque; + return s->memhp_state.is_enabled; +} + +static const VMStateDescription vmstate_memhp_state = { + .name = "acpi-ged/memhp", + .version_id = 1, + .minimum_version_id = 1, + .needed = vmstate_test_use_memhp, + .fields = (VMStateField[]) { + VMSTATE_MEMORY_HOTPLUG(memhp_state, AcpiGedState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_ged_state = { + .name = "acpi-ged-state", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(sel, GEDState), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_acpi_ged = { + .name = "acpi-ged", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(ged_state, AcpiGedState, 1, vmstate_ged_state, GEDState), + VMSTATE_END_OF_LIST(), + }, + .subsections = (const VMStateDescription * []) { + &vmstate_memhp_state, + NULL + } +}; + +static void acpi_ged_class_init(ObjectClass *class, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(class); + HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(class); + AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_CLASS(class); + + dc->desc = "ACPI Generic Event Device"; + dc->props = acpi_ged_properties; + dc->realize = acpi_ged_device_realize; + dc->vmsd = &vmstate_acpi_ged; + + hc->plug = acpi_ged_device_plug_cb; + + adevc->send_event = acpi_ged_send_event; +} + +static const TypeInfo acpi_ged_info = { + .name = TYPE_ACPI_GED, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(AcpiGedState), + .class_init = acpi_ged_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { TYPE_ACPI_DEVICE_IF }, + { } + } +}; + +static void acpi_ged_register_types(void) +{ + type_register_static(&acpi_ged_info); +} + +type_init(acpi_ged_register_types) diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h new file mode 100644 index 0000000000..2049e8d873 --- /dev/null +++ b/include/hw/acpi/generic_event_device.h @@ -0,0 +1,100 @@ +/* + * + * Copyright (c) 2018 Intel Corporation + * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd + * Written by Samuel Ortiz, Shameer Kolothum + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2 or later, as published by the Free Software Foundation. + * + * The ACPI Generic Event Device (GED) is a hardware-reduced specific + * device[ACPI v6.1 Section 5.6.9] that handles all platform events, + * including the hotplug ones. Generic Event Device allows platforms + * to handle interrupts in ACPI ASL statements. It follows a very + * similar approach like the _EVT method from GPIO events. All + * interrupts are listed in _CRS and the handler is written in _EVT + * method. Here, we use a single interrupt for the GED device, relying + * on IO memory region to communicate the type of device affected by + * the interrupt. This way, we can support up to 32 events with a + * unique interrupt. + * + * Here is an example. + * + * Device (\_SB.GED) + * { + * Name (_HID, "ACPI0013") + * Name (_UID, Zero) + * Name (_CRS, ResourceTemplate () + * { + * Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, ) + * { + * 0x00000029, + * } + * }) + * OperationRegion (EREG, SystemMemory, 0x09080000, 0x04) + * Field (EREG, DWordAcc, NoLock, WriteAsZeros) + * { + * ESEL, 32 + * } + * + * Method (_EVT, 1, Serialized) // _EVT: Event + * { + * Local0 = ESEL // ESEL = IO memory region which specifies the + * // device type. + * If (((Local0 & One) == One)) + * { + * MethodEvent1() + * } + * If ((Local0 & 0x2) == 0x2) + * { + * MethodEvent2() + * } + * ... + * } + * } + * + */ + +#ifndef HW_ACPI_GED_H +#define HW_ACPI_GED_H + +#include "hw/sysbus.h" +#include "hw/acpi/memory_hotplug.h" + +#define TYPE_ACPI_GED "acpi-ged" +#define ACPI_GED(obj) \ + OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) + +#define ACPI_GED_EVT_SEL_OFFSET 0x0 +#define ACPI_GED_EVT_SEL_LEN 0x4 + +#define GED_DEVICE "GED" +#define AML_GED_EVT_REG "EREG" +#define AML_GED_EVT_SEL "ESEL" + +/* + * Platforms need to specify the GED event bitmap + * to describe what kind of events they want to support + * through GED. + */ +#define ACPI_GED_MEM_HOTPLUG_EVT 0x1 + +typedef struct GEDState { + MemoryRegion io; + uint32_t sel; +} GEDState; + +typedef struct AcpiGedState { + SysBusDevice parent_obj; + MemHotplugState memhp_state; + MemoryRegion container_memhp; + GEDState ged_state; + uint32_t ged_event_bitmap; + qemu_irq irq; +} AcpiGedState; + +void build_ged_aml(Aml *table, const char* name, HotplugHandler *hotplug_dev, + uint32_t ged_irq, AmlRegionSpace rs, hwaddr ged_base); + +#endif From patchwork Wed Sep 4 08:56:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172897 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp954714ily; Wed, 4 Sep 2019 01:58:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFLySehUyttkitUrfLTHCCzxnlgmkzSR5EYziLtGQm8AaXIVUvhcjYW9zljxwmWm5l3xjk X-Received: by 2002:ac8:6d21:: with SMTP id r1mr12849026qtu.256.1567587520397; Wed, 04 Sep 2019 01:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587520; cv=none; d=google.com; s=arc-20160816; b=gJY8ph1GfSeeNC/cQkaNLQPVQrs52aSJV7p9fYcan81a4GnE0oDxKYcxtXWgeRBsyf H6rj4nq2eQDkqFH4rwbu2OAC/p2mpPWdWClExLuvM9aEt7A/vug0OGGERspv7ecP9mV5 cc2IOdwpDQBbuOBxQ2m7V0oyIRILRlAg295Kvm/u5E9N2MVcayI8uk/97dTw2XWYEO1t mD40hjeFbLtwquU9AS9ghdRo18PGS8t1RY3/nRlEkL0UynxwL8YHNM2hdvogu6pywBzx jE3m4jibJxpLrtoopTDZ6vls10/JtclY/r3dVNdswV5/nI1cAut+4D5Z4ET79gtre50u rS0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=B+4wOK+d4YRZWNj7xcPZHXcBjqrPtbt/7Mm4Z7IFDxM=; b=WD8WH9MrfCC/3ejxepyQE9UzFoA1FCqsHMAugdQyqO8G7lKmWmHLYNlhSMIqdAgTwc 9VYCvs69nKovkVLqAgkpL3ID8D+dmy724m2ByPXAoL2aZkaVdwsI3rAk1brBXDw9p7dM CBcsxYuAWgEN0z3g11EvxtV5KipKNjeGsum3DUXTrmFmO8NduqP1v2KlOJiZXe8ct3ox 43dgLOTP7dgTt0C5/y7+pQB2c4VOg2Qvv4kxUpklP+aGBgUq1LsPSugTb3uH+UJegLaT 0LgnXDuTN8690daGT/HT4Ym55xk0zFnS8n024yLilQFe+gYR7tWx8Z7bDcbnLonk+hxV FwMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x18si7495052qtm.260.2019.09.04.01.58.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 01:58:40 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R7e-0007dP-TB for patch@linaro.org; Wed, 04 Sep 2019 04:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38526) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R6y-0007Dt-Az for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R6w-0007BX-TB for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:56 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2192 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6t-00078t-NQ; Wed, 04 Sep 2019 04:57:52 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id CEB90424BEB734B7E874; Wed, 4 Sep 2019 16:57:48 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:40 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:22 +0100 Message-ID: <20190904085629.13872-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 04/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 76a2a6bcbf..39d285ad3d 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -20,6 +20,8 @@ config ARM_VIRT select SMBIOS select VIRTIO_MMIO select ACPI_PCI + select MEM_DEVICE + select DIMM config CHEETAH bool diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0d1629ccb3..7c492c31a0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -68,6 +68,8 @@ #include "hw/arm/smmuv3.h" #include "hw/acpi/acpi.h" #include "target/arm/internals.h" +#include "hw/mem/pc-dimm.h" +#include "hw/mem/nvdimm.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -1875,6 +1877,42 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) return ms->possible_cpus; } +static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + + /* + * The device memory is not yet exposed to the Guest either through + * DT or ACPI and hence both cold/hot plug of memory is explicitly + * disabled for now. + */ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + error_setg(errp, "memory cold/hot plug is not yet supported"); + return; + } + + pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); +} + +static void virt_memory_plug(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + Error *local_err = NULL; + + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + + error_propagate(errp, local_err); +} + +static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_pre_plug(hotplug_dev, dev, errp); + } +} + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { @@ -1886,12 +1924,23 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, SYS_BUS_DEVICE(dev)); } } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + virt_memory_plug(hotplug_dev, dev, errp); + } +} + +static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) +{ + error_setg(errp, "device unplug request for unsupported device" + " type: %s", object_get_typename(OBJECT(dev))); } static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || + (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { return HOTPLUG_HANDLER(machine); } @@ -1955,7 +2004,9 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) mc->kvm_type = virt_kvm_type; assert(!mc->get_hotplug_handler); mc->get_hotplug_handler = virt_machine_get_hotplug_handler; + hc->pre_plug = virt_machine_device_pre_plug_cb; hc->plug = virt_machine_device_plug_cb; + hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; } From patchwork Wed Sep 4 08:56:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172903 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp962224ily; Wed, 4 Sep 2019 02:06:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwIw3TG+0Nwxx7oZD0LqJ/3TQKgCvPmInZVRXy/DzHiwbWqEnj30M1kcZSln6qqVNyxYG4 X-Received: by 2002:a50:884c:: with SMTP id c12mr28867300edc.134.1567587970180; Wed, 04 Sep 2019 02:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587970; cv=none; d=google.com; s=arc-20160816; b=D3OrpP0/GbsW1sKrfwW2FHBCrDIr94xqAmTx8JWBFGlq9GG1tOwYaZoXmfmsydhvha O7R2WVs4y4gxxH7ye7wysyumvXpathItNxyWw2IKvft4cnMzrjSUTcs2L6dVbWRQlojL XIBn+KAZmAN4vdAUqbLviwe0+pfw0HqJwaRGm/uWjUeXD69Idb4LTHDePtCboVRdgQdW 0g6SF2zYmxVUVU4GcZKZR94a5rQDBPfKy/xEK+60QLdE5Ajh45bLHfXzgIVu0waLeR7g dBLSsHEKQnxZHA9Gi6bv5ZPxjmzpDybB3wA6G8YuBiUZh29ByH6tN9wodfWe5yqYRSCl FalA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=mSwMi8wuOP5VPviK24ZFrSZhCKHXTkhiZRbtqwL0z8Q=; b=onQnW+xbAqvs/9XC80aYFzi4/SPh/2uWA7llUZD1c8BwNvvL4uxT1NUdn/dcuHl4Lz tgetShY2xZ91Pj5izFzoVc/Tv7A6+nVapQ1bpALt1QpodD5HCBtnWG8vorps/SrG3/CV DBaGUgoZiAhM5bi+5TFqPDGwNLyOFb81OXQHqvb6KS+niIG9iyi+Nsm8VzYNaQDmQPsO AfIBTxEdkX955EBqCCuxrw1kefX+hdmUvLgca3YA9tAe81JUuVk5fHcnIlYAflSCQnCk w62Wq+3wCsBPnert1jL1N086fMqWJ8H+xqotWv40D6CpFKo6NaCkdEhoxKwwHqO/IBv9 7+Gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l12si6789878eda.86.2019.09.04.02.06.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:06:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5REu-0006Ju-LW for patch@linaro.org; Wed, 04 Sep 2019 05:06:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38588) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R73-0007L1-Ig for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R71-0007E2-So for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:01 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2194 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6x-0007BE-Q2; Wed, 04 Sep 2019 04:57:56 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E9D03E1136C3BD20DFEA; Wed, 4 Sep 2019 16:57:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:43 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:23 +0100 Message-ID: <20190904085629.13872-6-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 05/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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. As DSDT table gets changed by this, update bios-tables-test-allowed-diff.h to avoid "make check" failure. Signed-off-by: Shameer Kolothum --- v9 --> v10 -updated commit log with bios-tables-test-allowed-diff.h info. -Removed object_property_add_child() from create_acpi_ged(). 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 | 60 +++++++++++++++++++++++---- include/hw/arm/virt.h | 4 ++ tests/bios-tables-test-allowed-diff.h | 1 + 5 files changed, 76 insertions(+), 7 deletions(-) -- 2.17.1 diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 39d285ad3d..c6e7782580 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -22,6 +22,8 @@ config ARM_VIRT select ACPI_PCI select MEM_DEVICE select DIMM + select ACPI_MEMORY_HOTPLUG + select ACPI_HW_REDUCED config CHEETAH bool diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a8b2d97fe9..5063f28812 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -39,6 +39,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" @@ -706,6 +708,7 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { Aml *scope, *dsdt; + MachineState *ms = MACHINE(vms); const MemMapEntry *memmap = vms->memmap; const int *irqmap = vms->irqmap; @@ -730,6 +733,19 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) vms->highmem, vms->highmem_ecam); acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); + if (vms->acpi_dev) { + build_ged_aml(scope, "\\_SB."GED_DEVICE, + HOTPLUG_HANDLER(vms->acpi_dev), + irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY, + memmap[VIRT_ACPI_GED].base); + } + + if (vms->acpi_dev && ms->ram_slots) { + build_memory_hotplug_aml(scope, ms->ram_slots, "\\_SB", NULL, + AML_SYSTEM_MEMORY, + memmap[VIRT_PCDIMM_ACPI].base); + } + acpi_dsdt_add_power_button(scope); aml_append(dsdt, scope); diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7c492c31a0..b99c12ad9c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -70,6 +70,7 @@ #include "target/arm/internals.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/acpi/generic_event_device.h" #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ @@ -140,6 +141,8 @@ static const MemMapEntry base_memmap[] = { [VIRT_GPIO] = { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, [VIRT_SMMU] = { 0x09050000, 0x00020000 }, + [VIRT_PCDIMM_ACPI] = { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, + [VIRT_ACPI_GED] = { 0x09080000, ACPI_GED_EVT_SEL_LEN }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, @@ -175,6 +178,7 @@ static const int a15irqmap[] = { [VIRT_PCIE] = 3, /* ... to 6 */ [VIRT_GPIO] = 7, [VIRT_SECURE_UART] = 8, + [VIRT_ACPI_GED] = 9, [VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] = 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -524,6 +528,24 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } +static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) +{ + DeviceState *dev; + int irq = vms->irqmap[VIRT_ACPI_GED]; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + + dev = qdev_create(NULL, TYPE_ACPI_GED); + qdev_prop_set_uint32(dev, "ged-event", event); + qdev_init_nofail(dev); + + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base); + + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, pic[irq]); + + return dev; +} + static void create_its(VirtMachineState *vms, DeviceState *gicdev) { const char *itsclass = its_class_name(); @@ -1487,6 +1509,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram = g_new(MemoryRegion, 1); bool firmware_loaded; bool aarch64 = true; + bool has_ged = !vmc->no_ged; unsigned int smp_cpus = machine->smp.cpus; unsigned int max_cpus = machine->smp.max_cpus; @@ -1701,6 +1724,10 @@ static void machvirt_init(MachineState *machine) create_gpio(vms, pic); + if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { + vms->acpi_dev = create_acpi_ged(vms, pic); + } + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle. @@ -1880,14 +1907,23 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); + const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); + Error *local_err = NULL; - /* - * The device memory is not yet exposed to the Guest either through - * DT or ACPI and hence both cold/hot plug of memory is explicitly - * disabled for now. - */ - if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - error_setg(errp, "memory cold/hot plug is not yet supported"); + if (is_nvdimm) { + error_setg(errp, "nvdimm is not yet supported"); + return; + } + + if (!vms->acpi_dev) { + error_setg(errp, "memory hotplug is not enabled: missing acpi device"); + return; + } + + hotplug_handler_pre_plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } @@ -1897,11 +1933,18 @@ static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, static void virt_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + HotplugHandlerClass *hhc; VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); Error *local_err = NULL; pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); + if (local_err) { + goto out; + } + hhc = HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); +out: error_propagate(errp, local_err); } @@ -2108,8 +2151,11 @@ DEFINE_VIRT_MACHINE_AS_LATEST(4, 2) static void virt_machine_4_1_options(MachineClass *mc) { + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); + virt_machine_4_2_options(mc); compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); + vmc->no_ged = true; } DEFINE_VIRT_MACHINE(4, 1) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index a72094204e..577ee49b4b 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,6 +77,8 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_PCDIMM_ACPI, + VIRT_ACPI_GED, VIRT_LOWMEMMAP_LAST, }; @@ -106,6 +108,7 @@ typedef struct { bool claim_edge_triggered_timers; bool smbios_old_sys_ver; bool no_highmem_ecam; + bool no_ged; /* Machines < 4.2 has no support for ACPI GED device */ } VirtMachineClass; typedef struct { @@ -133,6 +136,7 @@ typedef struct { uint32_t iommu_phandle; int psci_conduit; hwaddr highest_gpa; + DeviceState *acpi_dev; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h index dfb8523c8b..7b4adbc822 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1 +1,2 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/DSDT", From patchwork Wed Sep 4 08:56:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172900 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp958470ily; Wed, 4 Sep 2019 02:02:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6NUjd/8GI3QVfZ6dLSjIKQD8RV1bgHj/WgfnEMEiZGX/53W4qljNfP+auBW3iYr70Y6lf X-Received: by 2002:a37:642:: with SMTP id 63mr25184469qkg.29.1567587754741; Wed, 04 Sep 2019 02:02:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587754; cv=none; d=google.com; s=arc-20160816; b=LGplZ8eLDvuA7a5MaCMRpx2S3Ksw6jwpTdGImAM5hyKOjGQUHf60w1zIZfeY6u7g3N dVmPEwb8gw6oy7UCoDHDJw97u+ho8CPlVPCbdRU+1EvrlLzqU6yhHySeEv6l3DCdBec6 kEUngehA3XgD3qbgvaE8fvq80neA/ly0Rzm8cJk80JN87+YP0XAoJ8dNRtC5eL9VeO/A LTsYyaVGy71bLv61YofDis+lHy7c4bxxfJEt+tBlVdFXWVWId4YGRfVHcoQ2Xq7T30GG dv+Gf5Y4U9N1MpV4iaNaUef65dC8j8RoJeNAdz/fxNC2Ml69yycf3rZEQDLcLY0oX+Cb tKqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=Mso2iKF+ryqsxuXQ7jqBseMQg87RrAqeDDEM5MdTdPA=; b=EUlP5VPT/52II2a8QjodvbUAUeqJxR0eEYO547kmX4Mx8rvVyidaqn7Ipnoi9pNc8c C1zyUFoZVYdSXkNtyzRB3W0XJyf4SjrvZ6xkHLQMI45EY3hfSl7FW+tpFHNDquKEdqUU P+buTrkYJdaTFZ8aX/+Z+rvPoaJsitDjCVNahA+p3Yjs0L52Q1ssVeWGlIjyws4RAdY2 WiqZ80a/5sVw9lrfgwDK43j0lFIqC684sIsuwaCvmPMeZ0Zz2fFJQVXKc5fCK4UMuqBP sD2wqQw0B8lqLpP4S4vV2yPRjNbacYd3iApLBJaVO5aRfMGVrTnWzx1NQjAhvzkwll8I Faig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v26si214008qkj.271.2019.09.04.02.02.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:02:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RBR-00035H-DB for patch@linaro.org; Wed, 04 Sep 2019 05:02:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38567) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R72-0007Ij-14 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R70-0007DL-J8 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:57:59 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2193 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R6x-0007BB-Pt; Wed, 04 Sep 2019 04:57:56 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id E2FED7AAAF89D396940F; Wed, 4 Sep 2019 16:57:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:46 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:24 +0100 Message-ID: <20190904085629.13872-7-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 06/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Generate Memory Affinity Structures for PC-DIMM ranges. Also, Linux and Windows need ACPI SRAT table to make memory hotplug work properly, however currently QEMU doesn't create SRAT table if numa options aren't present on CLI. Hence add support(>=4.2) to create numa node automatically (auto_enable_numa_with_memhp) when QEMU is started with memory hotplug enabled but without '-numa' options on CLI. Signed-off-by: Shameer Kolothum 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(+) -- 2.17.1 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 5063f28812..a4872a0b00 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -519,6 +519,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) int i, srat_start; uint64_t mem_base; MachineClass *mc = MACHINE_GET_CLASS(vms); + MachineState *ms = MACHINE(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); srat_start = table_data->len; @@ -544,6 +545,14 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) } } + if (ms->device_memory) { + numamem = acpi_data_push(table_data, sizeof *numamem); + build_srat_memory(numamem, ms->device_memory->base, + memory_region_size(&ms->device_memory->mr), + nb_numa_nodes - 1, + MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); + } + build_header(linker, table_data, (void *)(table_data->data + srat_start), "SRAT", table_data->len - srat_start, 3, NULL, NULL); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 29bc2837ce..95accc28f1 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2053,6 +2053,7 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) hc->plug = virt_machine_device_plug_cb; hc->unplug_request = virt_machine_device_unplug_request_cb; mc->numa_mem_supported = true; + mc->auto_enable_numa_with_memhp = true; } static void virt_instance_init(Object *obj) @@ -2158,6 +2159,7 @@ static void virt_machine_4_1_options(MachineClass *mc) virt_machine_4_2_options(mc); compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len); vmc->no_ged = true; + mc->auto_enable_numa_with_memhp = false; } DEFINE_VIRT_MACHINE(4, 1) From patchwork Wed Sep 4 08:56:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172904 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp963745ily; Wed, 4 Sep 2019 02:07:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+KICsxM9H+yInC+92xcpWjGOZ0OYwVIeo2HvMsX6N/HSvHzYDjO5/beidQjRdGJgxTIb7 X-Received: by 2002:a17:906:4e8c:: with SMTP id v12mr13912893eju.96.1567588055196; Wed, 04 Sep 2019 02:07:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567588055; cv=none; d=google.com; s=arc-20160816; b=a0B1ReKYCP68XFgmsLq2FEhmz8/fwjlqT81zciWxFb1QSWOEFuUEY8s+UPesYCif4e CIDU7JliidbEK0iSeEss5Y3duqOIZQlR2YyNEd1KznQb97t6rWPVJEVPBOA1JWTBjOvR UXPcCNVSpHyGWd4qAfAR653ec64C9CgBzYJYLzT4Vd7G6cgK+zggkTH3QpCum/9sfKQK nI+r1+3BOFccnViaLsICvWvo5ar9/o9rdoLlKsYfDMmlPkXfa5spWWSy01GxguDkOyAv dMypqLoTtLKxj9zZNNHxoakJ/wnmWuMb+qV2ONsekVOGMHG/n0IEpLS58/JBME8/ezwZ 8dzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=d+Y28knmJAqtHdG2lLlZJCXNKp7pRY9ulmhT4Mwhfoc=; b=f8GyY9+htS1K2NPE5uP36qPqmJhBd4roLH4dnLQ4n2an5Xy/MV3Xfza+1ssjh1/cYd GF/ue3kE7LQAMR7T8bbJ8sxJSstYE8uMqLTUswfFpQ4ppeI27wJDGgOoUew8CbOqQ82D 7j5y5Kpulr3L/LpoQpjXeku7qBxjxa14Ur6fsW2mHNMs3XAY2/O/hQk3XBI3pPZ0iIjW 3Ydvr1lQtR/nmklJiMO4ksls3f+h3yR+UwHjmfnMY0SEc8G/FyoEQDmnPr1HLm5i360y 5gdBjK0YNbPstmgVBddEucyn7TEx6AELHk0sjpAvbLgol7ChTuwc2KoRq2MJlZf4aW5Z U5Mg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v39si474934edc.234.2019.09.04.02.07.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:07:35 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RGI-00083x-2V for patch@linaro.org; Wed, 04 Sep 2019 05:07:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R76-0007P7-Qp for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R75-0007FV-Ge for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:04 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2259 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R72-0007Dh-SF; Wed, 04 Sep 2019 04:58:01 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 00B234839B1CCFF82788; Wed, 4 Sep 2019 16:57:59 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:50 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:25 +0100 Message-ID: <20190904085629.13872-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 07/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 Reviewed-by: Igor Mammedov diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 95accc28f1..89ee37d7de 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -791,10 +791,6 @@ static void virt_powerdown_req(Notifier *n, void *opaque) qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); } -static Notifier virt_system_powerdown_notifier = { - .notify = virt_powerdown_req -}; - static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) { char *nodename; @@ -835,10 +831,6 @@ static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) KEY_POWER); qemu_fdt_setprop_cells(vms->fdt, "/gpio-keys/poweroff", "gpios", phandle, 3, 0); - - /* connect powerdown request */ - qemu_register_powerdown_notifier(&virt_system_powerdown_notifier); - g_free(nodename); } @@ -1730,6 +1722,10 @@ static void machvirt_init(MachineState *machine) vms->acpi_dev = create_acpi_ged(vms, pic); } + /* connect powerdown request */ + vms->powerdown_notifier.notify = virt_powerdown_req; + qemu_register_powerdown_notifier(&vms->powerdown_notifier); + /* Create mmio transports, so the user can create virtio backends * (which will be automatically plugged in to the transports). If * no backend is created the transport will just sit harmlessly idle. diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 577ee49b4b..0b41083e9d 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -137,6 +137,7 @@ typedef struct { int psci_conduit; hwaddr highest_gpa; DeviceState *acpi_dev; + Notifier powerdown_notifier; } VirtMachineState; #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM) From patchwork Wed Sep 4 08:56:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172901 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp958704ily; Wed, 4 Sep 2019 02:02:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWJX+u7NY/clINw1uEgFnd7EVo90h2Q+kssrKsDahlY6Q5FFcpXwkh0pcUi+M1nDMMbpel X-Received: by 2002:a05:6214:12f1:: with SMTP id w17mr10920950qvv.108.1567587766839; Wed, 04 Sep 2019 02:02:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587766; cv=none; d=google.com; s=arc-20160816; b=oo6FDK1sYLvFBDSGMmRvofTXoSvY0D56NQV46INgdLtmlUOVLnoseQJgj7j2yGULd7 N2EHv8uK6OJ7CNwY9akTagHPrk5jhhCKvkBGPcuN46lEGgxYnGVOzBiITny3b7EMDRc2 tzXngxshQy6GsI3gx1Y8a+lLG2X0OhvAgKBfu7NKGNC+Oq/HnuRCuyE/B1MSCgEGtLG9 M+9U6hBdvoMCPGmS68G1lUP/GUGX1FeMhgQF8+AGYM1doC0u3iJDaAzEUOusHD8xUQqp dOWXZF8DslbTfg+NKjlilSbbrWwcPdQjtdfN3VxezRoDiNuxq+6uKkEKcj42aVsvtiL4 p57g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=PM1/LUgcWXIf/SWOn6r2EggZ/2GWbVEYgiv/xNig5kY=; b=VVwIDVxTBeewqem2plZ7YeNNgohrQhKL9efQohlvXhkeLnU9iKNCkKjty1vPtA6Tis LpZ4K99WO6Ft/295pp7ERlYk6+hmnbAmz5xdg8PMjReF/7w0XSkM892fc4AU9dAbTW1S LXFEOetclbKMiF5NW5gQfov3Q/3mmc4v9bGGi3jhuRrG/XL1wNOwYlRlhOQAcFVD2Q7M 5DFBr6U/D9aulVjhmLBUQC6rAU8lNTcWOB0Uysj4JafWV5SIlPiQ19p6McV0L/PdaiV8 6IslMeZ/ZQuhs8xuqkG28ryccolj70gkbizY9vPdUanX4arwBQIm4lS7bnoLY5npjSRC hJaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u47si12954575qvg.37.2019.09.04.02.02.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:02:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RBd-0003JA-Ci for patch@linaro.org; Wed, 04 Sep 2019 05:02:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R7D-0007Xu-S3 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R7B-0007Hq-9w for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:11 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2260 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R78-0007Ft-00; Wed, 04 Sep 2019 04:58:06 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1588BE67DB0E507DBD76; Wed, 4 Sep 2019 16:58:04 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:53 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:26 +0100 Message-ID: <20190904085629.13872-9-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 08/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- v9 --> v10 -Eric's R-by 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(-) -- 2.17.1 Reviewed-by: Igor Mammedov diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index f81d966058..47e178c583 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -22,6 +22,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; /* @@ -104,6 +105,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); break; + case ACPI_GED_PWR_DOWN_EVT: + aml_append(if_ctx, + aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), + aml_int(0x80))); + break; default: /* * Please make sure all the events in ged_supported_events[] @@ -190,6 +196,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) if (ev & ACPI_MEMORY_HOTPLUG_STATUS) { sel = ACPI_GED_MEM_HOTPLUG_EVT; + } else if (ev & ACPI_POWER_DOWN_STATUS) { + sel = ACPI_GED_PWR_DOWN_EVT; } else { /* Unknown event. Return without generating interrupt. */ warn_report("GED: Unsupported event %d. No irq injected", ev); diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a4872a0b00..bbf7f6fafa 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -50,7 +50,6 @@ #include "migration/vmstate.h" #define ARM_SPI_BASE 32 -#define ACPI_POWER_BUTTON_DEVICE "PWRB" static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus) { @@ -740,13 +739,14 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) (irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS); acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE), vms->highmem, vms->highmem_ecam); - acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], - (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev), irqmap[VIRT_ACPI_GED] + ARM_SPI_BASE, AML_SYSTEM_MEMORY, memmap[VIRT_ACPI_GED].base); + } else { + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO], + (irqmap[VIRT_GPIO] + ARM_SPI_BASE)); } if (vms->acpi_dev && ms->ram_slots) { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 89ee37d7de..32208e1058 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -532,7 +532,7 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms, qemu_irq *pic) { DeviceState *dev; int irq = vms->irqmap[VIRT_ACPI_GED]; - uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT; + uint32_t event = ACPI_GED_MEM_HOTPLUG_EVT | ACPI_GED_PWR_DOWN_EVT; dev = qdev_create(NULL, TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); @@ -787,8 +787,14 @@ static void create_rtc(const VirtMachineState *vms, qemu_irq *pic) static DeviceState *gpio_key_dev; static void virt_powerdown_req(Notifier *n, void *opaque) { - /* use gpio Pin 3 for power button event */ - qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + VirtMachineState *s = container_of(n, VirtMachineState, powerdown_notifier); + + if (s->acpi_dev) { + acpi_send_event(s->acpi_dev, ACPI_POWER_DOWN_STATUS); + } else { + /* use gpio Pin 3 for power button event */ + qemu_set_irq(qdev_get_gpio_in(gpio_key_dev, 0), 1); + } } static void create_gpio(const VirtMachineState *vms, qemu_irq *pic) @@ -1716,10 +1722,10 @@ static void machvirt_init(MachineState *machine) create_pcie(vms, pic); - create_gpio(vms, pic); - if (has_ged && aarch64 && firmware_loaded && acpi_enabled) { vms->acpi_dev = create_acpi_ged(vms, pic); + } else { + create_gpio(vms, pic); } /* connect powerdown request */ diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h index 0ba90effd2..a2a12af9b9 100644 --- a/include/hw/acpi/acpi_dev_interface.h +++ b/include/hw/acpi/acpi_dev_interface.h @@ -13,6 +13,7 @@ typedef enum { ACPI_MEMORY_HOTPLUG_STATUS = 8, ACPI_NVDIMM_HOTPLUG_STATUS = 16, ACPI_VMGENID_CHANGE_STATUS = 32, + ACPI_POWER_DOWN_STATUS = 64, } AcpiEventStatusBits; #define TYPE_ACPI_DEVICE_IF "acpi-device-interface" diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index 2049e8d873..d157eac088 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -62,6 +62,8 @@ #include "hw/sysbus.h" #include "hw/acpi/memory_hotplug.h" +#define ACPI_POWER_BUTTON_DEVICE "PWRB" + #define TYPE_ACPI_GED "acpi-ged" #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) @@ -79,6 +81,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 typedef struct GEDState { MemoryRegion io; From patchwork Wed Sep 4 08:56:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172905 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp965365ily; Wed, 4 Sep 2019 02:09:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOFP/w8IhF0N6TmchA1jbdtPqfT7zDnmGMQyrqxPiO2IL0W3DwP+bn80MmscrdJDgV2MAR X-Received: by 2002:aed:3785:: with SMTP id j5mr37179101qtb.87.1567588155412; Wed, 04 Sep 2019 02:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567588155; cv=none; d=google.com; s=arc-20160816; b=B7NIWk+NLmmY5DHlSX3FOIULP6yNu87CZzN5of6hmgRoj10lpYIJCFRNmfVotl3L0r Lv9d8AocKn4hf5bh7hJe4QWb/8lRYneds0ZYVZupE0Hu/BIqzLJ+aJlx75xYy9EHKViA nwwEFFsVRizoIcTHuVCwG2aB5CaXKoc8tlQMKPj/gwss4OT/26UqBychRLfhpXIg05Z5 5F08AzOi2bm+I2O13At8UI0seAJTL6jBaJlEtrRT8w7pKL9sSj3bpyhTeVy9sdGYYP6M OiFFuKCvVFvddtz7c4LV3Y3ELuqLbpssVkrhdSs31OAKxZk257K2AhwdqAwB+8/oO3Qh rHIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=f8D/tQdT+Jv9daEw0/qh5r6hCDPHdJrh65qK9xGVIUo=; b=gPnBur3lehaCq7gWbYas9/x3qEtIH90S+bkcMANZ/v55O2toS923KJ+2Kd/JLV5u4Y 9UKnHgbWS5oZKEFLwpiyzMohRdZcHAsUi1z2DmWOKWF3N463luvK0FyslRedHArlnOjE amP1EuFJ7dV/4t5+Pkd4ma0+BZKDuusAzJiUuINlAU9lrsGZHBLYrNWJLI52NHzD/f71 nLS70DVCMLw4vf03Awsn3IOTk3qpDaLSUaYKnLUYhrChVBm93wyTGUpqgPQt69uHOmaa kL6q3PiKlk4K2Ct09Yk5q81L3nM29Q+tpUhJt8gNuxuIZK3lcnComGt1tixNGQhhYEg+ Gc8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l30si5796252qtn.360.2019.09.04.02.09.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54818 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RHu-0001Jk-R0 for patch@linaro.org; Wed, 04 Sep 2019 05:09:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R7C-0007WW-Ah for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R7B-0007Hc-28 for qemu-devel@nongnu.org; Wed, 04 Sep 2019 04:58:10 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2261 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R78-0007Fw-0n; Wed, 04 Sep 2019 04:58:06 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1D9BD3FCE8CBABA5053F; Wed, 4 Sep 2019 16:58:04 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:57:56 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:27 +0100 Message-ID: <20190904085629.13872-10-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 09/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 -- 2.17.1 diff --git a/docs/specs/acpi_hw_reduced_hotplug.txt b/docs/specs/acpi_hw_reduced_hotplug.txt new file mode 100644 index 0000000000..2d78c40d6a --- /dev/null +++ b/docs/specs/acpi_hw_reduced_hotplug.txt @@ -0,0 +1,60 @@ +QEMU<->ACPI BIOS Generic Event Device interface + +The ACPI Generic Event Device (GED) is a HW reduced platform +specific device introduced in ACPI v6.1 that handles all platform +events, including the hotplug ones. GED is modelled as a device +in the namespace with a _HID defined to be ACPI0013. This document +describes the interface between QEMU and the ACPI BIOS. + +GED allows HW reduced platforms to handle interrupts in ACPI ASL +statements. It follows a very similar approach like the _EVT method +from GPIO events. All interrupts are listed in _CRS and the handler +is written in _EVT method. However, Qemu implementation uses a single +interrupt for the GED device, relying on IO memory region to communicate +the type of device affected by the interrupt. This way, we can support +up to 32 events with a unique interrupt. + +Here is an example. + +Device (\_SB.GED) +{ + Name (_HID, "ACPI0013") + Name (_UID, Zero) + Name (_CRS, ResourceTemplate () + { + Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, ) + { + 0x00000029, + } + }) + OperationRegion (EREG, SystemMemory, 0x09080000, 0x04) + Field (EREG, DWordAcc, NoLock, WriteAsZeros) + { + ESEL, 32 + } + Method (_EVT, 1, Serialized) + { + Local0 = ESEL // ESEL = IO memory region which specifies the + // device type. + If (((Local0 & One) == One)) + { + MethodEvent1() + } + If ((Local0 & 0x2) == 0x2) + { + MethodEvent2() + } + ... + } +} + +GED IO interface (4 byte access): +read access: + [0x0-0x3] Event selector bit field(32 bit) set by Qemu. + bits: + 0: Memory hotplug event + 1: System power down event + 2-31: Reserved + +write_access: + Nothing is expected to be written into GED IO memory From patchwork Wed Sep 4 08:56:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 172906 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp968200ily; Wed, 4 Sep 2019 02:12:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5scSx4g1D2RCtBdVxxg+pjk4ItoqZ/RkzrbPB5YQC1R5oyDpeL6HhAxlcPnPGx/DUh2m7 X-Received: by 2002:a17:906:1385:: with SMTP id f5mr6963212ejc.145.1567588335852; Wed, 04 Sep 2019 02:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567588335; cv=none; d=google.com; s=arc-20160816; b=MtTP9Kx90HyORIPyYIziQvOjXDdj53VHaEoKw/DipfchGLfqGF5JGdTh7PLoJ+0ky8 YJuXZofMpt0DpFQSiXVr6HOn7GHkXr+4p/0iABG+E8zHh8mS90CJRKPdpZ7dZ/SRkPJ9 M0SC2/dbRJ8WLLywAezy5VYIzCMSj9AQPu/PGcmEC1oYS8u2G7hQKKbjL8J0H0pC5INs LGOeBE3bfJV6cejvzXyRVe1p/iMcXEfPEr8Ow20p1Usk2cCFgL3xeh4bfIxLP2d4hhRZ guqx5gCgGH9Fs1kE0ZUIUIY/wQtXfyne5cvYh4JMYT0PG3eMyBOaLbvx+UEfFwcabFkl zhjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:mime-version:references :in-reply-to:message-id:date:to:from; bh=uftxv5ZWfB4oXgjJMG+CxRkuwojbJUaZfZoxhvhXDsw=; b=KZvzE56hZxv4wwz1yDmKwDbcqhj6DAbXrzcNTyXr4jsTtJAQ3fV/Y6UDUaSDgMES33 QQ9G3+qcVIBfDkjSdipInEZPSEMo4/uz0YWZZKsxxxWalcYX8oc455wcx/kGjnnopXXZ RmSa89lSn0v64YY9cUM59/07DhPBzlFl2nDMR8qOKOS/UQcAAu8WFb58tkz+uDJtlw81 tUk7SKY+gD6CQLfbsM+eog+1HQg1+/sbCMJRunkNcdxmPvfPQUnbIc5WzDyATfAsx1Vp aB0ydGyeAt+tvkAoH8Qxi0v9ZHqbekTCvC/bXPubCGc3VsNwZwEFDPQGzXRYWZLfeTfI rjCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f9si2344019ejx.375.2019.09.04.02.12.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Sep 2019 02:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:54852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5RKo-0003zA-5t for patch@linaro.org; Wed, 04 Sep 2019 05:12:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38771) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5R9Q-0001pX-Iv for qemu-devel@nongnu.org; Wed, 04 Sep 2019 05:00:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5R9P-0008OR-Bb for qemu-devel@nongnu.org; Wed, 04 Sep 2019 05:00:28 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:35262 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i5R7I-0007KQ-Sb; Wed, 04 Sep 2019 05:00:17 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3C46460C48E5AA9265DA; Wed, 4 Sep 2019 16:58:14 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Sep 2019 16:58:03 +0800 From: Shameer Kolothum To: , , , Date: Wed, 4 Sep 2019 09:56:29 +0100 Message-ID: <20190904085629.13872-12-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> References: <20190904085629.13872-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] 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 v10 11/11] 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(+) -- 2.17.1 Reviewed-by: Igor Mammedov diff --git a/tests/bios-tables-test-allowed-diff.h b/tests/bios-tables-test-allowed-diff.h index 7b4adbc822..d181a4da4a 100644 --- a/tests/bios-tables-test-allowed-diff.h +++ b/tests/bios-tables-test-allowed-diff.h @@ -1,2 +1,3 @@ /* List of comma-separated changed AML files to ignore */ "tests/data/acpi/virt/DSDT", +"tests/data/acpi/virt/SRAT", diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index a356ac3489..1d6f330d53 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -871,6 +871,53 @@ static void test_acpi_piix4_tcg_dimm_pxm(void) test_acpi_tcg_dimm_pxm(MACHINE_PC); } +static void test_acpi_virt_tcg_memhp(void) +{ + test_data data = { + .machine = "virt", + .accel = "tcg", + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", + .ram_start = 0x40000000ULL, + .scan_len = 256ULL * 1024 * 1024, + }; + + data.variant = ".memhp"; + test_acpi_one(" -cpu cortex-a57" + " -m 256M,slots=3,maxmem=1G" + " -object memory-backend-ram,id=ram0,size=128M" + " -object memory-backend-ram,id=ram1,size=128M" + " -numa node,memdev=ram0 -numa node,memdev=ram1" + " -numa dist,src=0,dst=1,val=21", + &data); + + free_test_data(&data); + +} + +static void test_acpi_virt_tcg_numamem(void) +{ + test_data data = { + .machine = "virt", + .accel = "tcg", + .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd", + .uefi_fl2 = "pc-bios/edk2-arm-vars.fd", + .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2", + .ram_start = 0x40000000ULL, + .scan_len = 128ULL * 1024 * 1024, + }; + + data.variant = ".numamem"; + test_acpi_one(" -cpu cortex-a57" + " -object memory-backend-ram,id=ram0,size=128M" + " -numa node,memdev=ram0", + &data); + + free_test_data(&data); + +} + static void test_acpi_virt_tcg(void) { test_data data = { @@ -917,6 +964,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); } else if (strcmp(arch, "aarch64") == 0) { qtest_add_func("acpi/virt", test_acpi_virt_tcg); + qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem); + qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp); } ret = g_test_run(); boot_sector_cleanup(disk);