From nobody Thu Nov 6 12:11:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540831448149107.46370348161565; Mon, 29 Oct 2018 09:44:08 -0700 (PDT) Received: from localhost ([::1]:46836 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAe6-0002Wa-FT for importer@patchew.org; Mon, 29 Oct 2018 12:44:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHAMP-0000DF-04 for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:25:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHAMK-0007yE-Lp for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:25:48 -0400 Received: from mga06.intel.com ([134.134.136.31]:12963) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gHAMK-0007uW-BM for qemu-devel@nongnu.org; Mon, 29 Oct 2018 12:25:44 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2018 09:25:37 -0700 Received: from mjadwisz-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.7.64]) by fmsmga001.fm.intel.com with ESMTP; 29 Oct 2018 09:25:36 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,440,1534834800"; d="scan'208";a="103491994" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 29 Oct 2018 17:24:26 +0100 Message-Id: <20181029162441.31631-5-sameo@linux.intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181029162441.31631-1-sameo@linux.intel.com> References: <20181029162441.31631-1-sameo@linux.intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 Subject: [Qemu-devel] [PATCH v2 04/19] hw: acpi: Implement XSDT support for RSDP 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" XSDT is the 64-bit version of the legacy ACPI RSDT (Root System Description Table). RSDT only allow for 32-bit addressses and have thus been deprecated. Since ACPI version 2.0, RSDPs should point at XSDTs and no longer RSDTs, although RSDTs are still supported for backward compatibility. Since version 2.0, RSDPs should add an extended checksum, a complete table length and a version field to the table. Here we provide a legacy API (RSDP points at RSDTs) for backward compatibility purpose and a default, XSDT pointing API. Signed-off-by: Samuel Ortiz --- hw/acpi/aml-build.c | 41 ++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 5 ++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 2d6f538f9d..77eb17b113 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1651,8 +1651,10 @@ build_xsdt(GArray *table_data, BIOSLinker *linker, G= Array *table_offsets, (void *)xsdt, "XSDT", xsdt_len, 1, oem_id, oem_table_id); } =20 +/* Legacy RSDP pointing at an RSDT. This is deprecated */ void -build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offse= t) +build_rsdp_rsdt(GArray *rsdp_table, + BIOSLinker *linker, unsigned rsdt_tbl_offset) { AcpiRsdpDescriptor *rsdp =3D acpi_data_push(rsdp_table, sizeof *rsdp); unsigned rsdt_pa_size =3D sizeof(rsdp->rsdt_physical_address); @@ -1675,6 +1677,43 @@ build_rsdp(GArray *rsdp_table, BIOSLinker *linker, u= nsigned rsdt_tbl_offset) (char *)&rsdp->checksum - rsdp_table->data); } =20 +/* RSDP pointing at an XSDT */ +void +build_rsdp(GArray *rsdp_table, + BIOSLinker *linker, unsigned xsdt_tbl_offset) +{ + AcpiRsdpDescriptor *rsdp =3D acpi_data_push(rsdp_table, sizeof *rsdp); + unsigned xsdt_pa_size =3D sizeof(rsdp->xsdt_physical_address); + unsigned xsdt_pa_offset =3D + (char *)&rsdp->xsdt_physical_address - rsdp_table->data; + unsigned xsdt_offset =3D + (char *)&rsdp->length - rsdp_table->data; + + bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16, + true /* fseg memory */); + + memcpy(&rsdp->signature, "RSD PTR ", 8); + memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, 6); + rsdp->length =3D cpu_to_le32(sizeof(*rsdp)); + /* version 2, we will use the XSDT pointer */ + rsdp->revision =3D 0x02; + + /* Address to be filled by Guest linker */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_RSDP_FILE, xsdt_pa_offset, xsdt_pa_size, + ACPI_BUILD_TABLE_FILE, xsdt_tbl_offset); + + /* Legacy checksum to be filled by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, + (char *)rsdp - rsdp_table->data, xsdt_offset, + (char *)&rsdp->checksum - rsdp_table->data); + + /* Extended checksum to be filled by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, + (char *)rsdp - rsdp_table->data, sizeof *rsdp, + (char *)&rsdp->extended_checksum - rsdp_table->data); +} + void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags) { diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 9f1c9f4cf5..eee2eb3ed2 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -2656,7 +2656,7 @@ void acpi_build(AcpiBuildTables *tables, slic_oem.id, slic_oem.table_id); =20 /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp(tables->rsdp, tables->linker, rsdt); + build_rsdp_rsdt(tables->rsdp, tables->linker, rsdt); =20 /* We'll expose it all to Guest so we want to reduce * chance of size changes. diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 865f5d23f5..8d1063a40b 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -390,8 +390,11 @@ void acpi_add_table(GArray *table_offsets, GArray *tab= le_data); void acpi_build_tables_init(AcpiBuildTables *tables); void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre); void +build_rsdp_rsdt(GArray *table_data, + BIOSLinker *linker, unsigned rsdt_tbl_offset); +void build_rsdp(GArray *table_data, - BIOSLinker *linker, unsigned rsdt_tbl_offset); + BIOSLinker *linker, unsigned xsdt_tbl_offset); void build_rsdt(GArray *table_data, BIOSLinker *linker, GArray *table_offsets, const char *oem_id, const char *oem_table_id); --=20 2.17.2