From patchwork Mon Apr 10 15:03:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 97169 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1402905qgd; Mon, 10 Apr 2017 08:08:25 -0700 (PDT) X-Received: by 10.31.204.1 with SMTP id c1mr12236696vkg.100.1491836905710; Mon, 10 Apr 2017 08:08:25 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t28si6971202uae.33.2017.04.10.08.08.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Apr 2017 08:08:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34863 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxavX-0004jV-98 for patch@linaro.org; Mon, 10 Apr 2017 11:08:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxarP-0001sF-6u for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxarL-000122-6S for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:07 -0400 Received: from mail-wr0-x22b.google.com ([2a00:1450:400c:c0c::22b]:33455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxarK-000117-W9 for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:03 -0400 Received: by mail-wr0-x22b.google.com with SMTP id l28so21460180wre.0 for ; Mon, 10 Apr 2017 08:04:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=pefO3EYIwfk25upQ1adnkS6Kg7iROQGGnwXmB7S5Z/I=; b=jFLlQ/OGiqNJqWnnAi22P1RBE8z9ILI/IAki6e5Ah1aESYvFMh/f4V0YZ/O/wwdAYw YkiZ5oFeqYmJBh9Enhm6Rot2LflyPaHHboUdMOTL0XhEK5sqra/28DjcWvPIrh4Fjrcg GT9V6x3j/+IbFa8XPWXedi6PGhbvC2ho6+2YY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=pefO3EYIwfk25upQ1adnkS6Kg7iROQGGnwXmB7S5Z/I=; b=Qsp56PpmUHCZ6G+AE+ASPZ1nDSc3EfB2Ad3xZqOfOtj7F8LbMqJQZ8JqRoTBgYOLUa FP2NdVAOM7gUFOzpuwt3PuSZBuKoPYjCwFd+P4IPVpqAAcFVdUvALmX+85qmAPdFE+Df cMV8A2v6wkxmTZiveL+FfE5suIsT9f7G21kk07FUpZD5PkftU8Lyuwqffh8d8qTaYrNv tXl1mPFVWbsvQQ3zCUTcje07jo7y+d6sdWk48eWv3+xBK+si47QZ7ZWAchj3SoGIKsge +3+RcNat8gX+QQLurj2OxC+dz92MRJzk1OYLkZG+kWwFtdP3zts952LKrLTc2C5dywY0 qGbg== X-Gm-Message-State: AN3rC/4rMwoicKtiMdyRlU/nJSOgdRSMHiDSdt/Gp9ZkvfKgYfbrrDzeD0YXUv4e+IoNjIqU X-Received: by 10.223.171.8 with SMTP id q8mr6722844wrc.115.1491836640360; Mon, 10 Apr 2017 08:04:00 -0700 (PDT) Received: from localhost.localdomain ([196.85.182.219]) by smtp.gmail.com with ESMTPSA id c202sm6047611wmd.32.2017.04.10.08.03.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Apr 2017 08:03:59 -0700 (PDT) From: Ard Biesheuvel To: qemu-devel@nongnu.org, peter.maydell@linaro.org, lersek@redhat.com Date: Mon, 10 Apr 2017 16:03:49 +0100 Message-Id: <20170410150350.3267-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22b Subject: [Qemu-devel] [PATCH v3 1/2] hw/acpi-defs: replace leading X with x_ in FADT field names X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: phil@philjordan.eu, Ard Biesheuvel , mst@redhat.com, drjones@redhat.com, zhaoshenglong@huawei.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" At the request of Michael, replace the leading capital X in the FADT field name Xfacs and Xdsdt with lower case x + underscore. Cc: Michael S. Tsirkin Signed-off-by: Ard Biesheuvel --- include/hw/acpi/acpi-defs.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.9.3 Reviewed-by: Laszlo Ersek diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index 4cc3630e613e..db48807056b3 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -165,8 +165,8 @@ struct AcpiFadtDescriptorRev5_1 { /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ uint16_t arm_boot_flags; uint8_t minor_revision; /* FADT Minor Revision (ACPI 5.1) */ - uint64_t Xfacs; /* 64-bit physical address of FACS */ - uint64_t Xdsdt; /* 64-bit physical address of DSDT */ + uint64_t x_facs; /* 64-bit physical address of FACS */ + uint64_t x_dsdt; /* 64-bit physical address of DSDT */ /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ struct AcpiGenericAddress xpm1a_event_block; /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ From patchwork Mon Apr 10 15:03:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 97168 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1401350qgd; Mon, 10 Apr 2017 08:05:20 -0700 (PDT) X-Received: by 10.176.85.221 with SMTP id w29mr2602950uaa.41.1491836720022; Mon, 10 Apr 2017 08:05:20 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b5si2928203uab.225.2017.04.10.08.05.19 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Apr 2017 08:05:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxasX-0002RU-Kd for patch@linaro.org; Mon, 10 Apr 2017 11:05:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33196) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxarP-0001sG-7D for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxarM-00012q-LZ for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:07 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:37893) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cxarM-00012D-D9 for qemu-devel@nongnu.org; Mon, 10 Apr 2017 11:04:04 -0400 Received: by mail-wm0-x234.google.com with SMTP id t189so39951559wmt.1 for ; Mon, 10 Apr 2017 08:04:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j6JQCQDTELYOlrxFZcNR6KBHSH1upnbmrSOjDMDBUVA=; b=aLKWqrT401Z8+z9IJCCu4U/0n8/bTF522WMCOGSG7pZzIPNRAgtb5ttBCfV6Vj/z6A RTCZXQnzLocY49COcQkOZhjogS0AOO+48vHXcTVga69Ustm+Auh/LeP0ZoUPp6tDtont g6oUGUnSQBsqSId20o6c73kIm0gTLT3aakHSU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j6JQCQDTELYOlrxFZcNR6KBHSH1upnbmrSOjDMDBUVA=; b=tD2aoOJnzC+ykbI1qMZYt3F6qlZJstXuB0X8fJwXeI20FZtNxg7BlA8IPQAdRK0LtR 3PhqhzIPSWa0+dfuK08emUwr628aEVdTDoFF3id/B+COsneA6sMIJDws/L2PzJyMqYtA rjBnQmBN5wjIKgeT6BqVUVLKZ9tgv2CJAHx1behWBYobsGqQD+DVvsg67zF/w/1blDmn 2uhpHu0ldhGH6ky8EyHoa22szJNyTx5on+J+b/lqXsGipnEPY+ZLf4rnmMHRE18K0szx KTm8u6ldAc4Rsv1uwagcflCorOLjWYnHXDsv5TxxWmTokcP3jAYhptsoL5YXiCJsn18T mkmA== X-Gm-Message-State: AN3rC/4nnd4bcNSbBhJvHPlyr5FbLytyycmCIADrvb3hOjpsCbhGR51z DYA/DKhnDW4yEXin X-Received: by 10.28.133.139 with SMTP id h133mr11062278wmd.87.1491836643141; Mon, 10 Apr 2017 08:04:03 -0700 (PDT) Received: from localhost.localdomain ([196.85.182.219]) by smtp.gmail.com with ESMTPSA id c202sm6047611wmd.32.2017.04.10.08.04.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Apr 2017 08:04:02 -0700 (PDT) From: Ard Biesheuvel To: qemu-devel@nongnu.org, peter.maydell@linaro.org, lersek@redhat.com Date: Mon, 10 Apr 2017 16:03:50 +0100 Message-Id: <20170410150350.3267-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170410150350.3267-1-ard.biesheuvel@linaro.org> References: <20170410150350.3267-1-ard.biesheuvel@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PATCH v3 2/2] hw/arm/virt: generate 64-bit addressable ACPI objects X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: phil@philjordan.eu, Ard Biesheuvel , mst@redhat.com, drjones@redhat.com, zhaoshenglong@huawei.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Our current ACPI table generation code limits the placement of ACPI tables to 32-bit addressable memory, in order to be able to emit the root pointer (RSDP) and root table (RSDT) using table types from the ACPI 1.0 days. Since ARM was not supported by ACPI before version 5.0, it makes sense to lift this restriction. This is not crucial for mach-virt, which is guaranteed to have some memory available below the 4 GB mark, but it is a nice to have for QEMU machines that do not have any 32-bit addressable memory, which is not uncommon for real world 64-bit ARM systems. Since we already emit a version of the RSDP root pointer that has a secondary 64-bit wide address field for the 64-bit root table (XSDT), all we need to do is replace the RSDT generation with the generation of an XSDT table, and use a different slot in the FADT table to refer to the DSDT. Signed-off-by: Ard Biesheuvel Reviewed-by: Andrew Jones Acked-by: Laszlo Ersek --- hw/acpi/aml-build.c | 27 ++++++++++++++++++++ hw/arm/virt-acpi-build.c | 26 +++++++++---------- include/hw/acpi/acpi-defs.h | 11 ++++++++ include/hw/acpi/aml-build.h | 3 +++ 4 files changed, 54 insertions(+), 13 deletions(-) -- 2.9.3 Acked-by: Peter Maydell diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index c6f2032decb1..4ddfb68b247f 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1599,6 +1599,33 @@ build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, (void *)rsdt, "RSDT", rsdt_len, 1, oem_id, oem_table_id); } +/* Build xsdt table */ +void +build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, + const char *oem_id, const char *oem_table_id) +{ + int i; + unsigned xsdt_entries_offset; + AcpiXsdtDescriptorRev2 *xsdt; + const unsigned table_data_len = (sizeof(uint64_t) * table_offsets->len); + const unsigned xsdt_entry_size = sizeof(xsdt->table_offset_entry[0]); + const size_t xsdt_len = sizeof(*xsdt) + table_data_len; + + xsdt = acpi_data_push(table_data, xsdt_len); + xsdt_entries_offset = (char *)xsdt->table_offset_entry - table_data->data; + for (i = 0; i < table_offsets->len; ++i) { + uint64_t ref_tbl_offset = g_array_index(table_offsets, uint32_t, i); + uint64_t xsdt_entry_offset = xsdt_entries_offset + xsdt_entry_size * i; + + /* xsdt->table_offset_entry to be filled by Guest linker */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, xsdt_entry_offset, xsdt_entry_size, + ACPI_BUILD_TABLE_FILE, ref_tbl_offset); + } + build_header(linker, table_data, + (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id); +} + void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags) { diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index b173bd109b91..711f18399d8f 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -391,12 +391,12 @@ static void acpi_dsdt_add_power_button(Aml *scope) /* RSDP */ static GArray * -build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset) +build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned xsdt_tbl_offset) { AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); - unsigned rsdt_pa_size = sizeof(rsdp->rsdt_physical_address); - unsigned rsdt_pa_offset = - (char *)&rsdp->rsdt_physical_address - rsdp_table->data; + unsigned xsdt_pa_size = sizeof(rsdp->xsdt_physical_address); + unsigned xsdt_pa_offset = + (char *)&rsdp->xsdt_physical_address - rsdp_table->data; bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16, true /* fseg memory */); @@ -408,8 +408,8 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset) /* Address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_RSDP_FILE, rsdt_pa_offset, rsdt_pa_size, - ACPI_BUILD_TABLE_FILE, rsdt_tbl_offset); + ACPI_BUILD_RSDP_FILE, xsdt_pa_offset, xsdt_pa_size, + ACPI_BUILD_TABLE_FILE, xsdt_tbl_offset); /* Checksum to be filled by Guest linker */ bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, @@ -686,7 +686,7 @@ static void build_fadt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms, unsigned dsdt_tbl_offset) { AcpiFadtDescriptorRev5_1 *fadt = acpi_data_push(table_data, sizeof(*fadt)); - unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data; + unsigned xdsdt_entry_offset = (char *)&fadt->x_dsdt - table_data->data; uint16_t bootflags; switch (vms->psci_conduit) { @@ -712,7 +712,7 @@ static void build_fadt(GArray *table_data, BIOSLinker *linker, /* DSDT address to be filled by Guest linker */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt), + ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->x_dsdt), ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset); build_header(linker, table_data, @@ -777,7 +777,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) { VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); GArray *table_offsets; - unsigned dsdt, rsdt; + unsigned dsdt, xsdt; GArray *tables_blob = tables->table_data; table_offsets = g_array_new(false, true /* clear */, @@ -817,12 +817,12 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) build_iort(tables_blob, tables->linker); } - /* RSDT is pointed to by RSDP */ - rsdt = tables_blob->len; - build_rsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); + /* XSDT is pointed to by RSDP */ + xsdt = tables_blob->len; + build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL); /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp(tables->rsdp, tables->linker, rsdt); + build_rsdp(tables->rsdp, tables->linker, xsdt); /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index db48807056b3..dff6d4fec8fc 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -238,6 +238,17 @@ struct AcpiRsdtDescriptorRev1 typedef struct AcpiRsdtDescriptorRev1 AcpiRsdtDescriptorRev1; /* + * ACPI 2.0 eXtended System Description Table (XSDT) + */ +struct AcpiXsdtDescriptorRev2 +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint64_t table_offset_entry[0]; /* Array of pointers to other */ + /* ACPI tables */ +} QEMU_PACKED; +typedef struct AcpiXsdtDescriptorRev2 AcpiXsdtDescriptorRev2; + +/* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ struct AcpiFacsDescriptorRev1 diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 00c21f160c19..eb07c2d43c99 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -381,6 +381,9 @@ void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre); void build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id); +void +build_xsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, + const char *oem_id, const char *oem_table_id); int build_append_named_dword(GArray *array, const char *name_format, ...)