From nobody Sun Apr 28 21:58:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1501062193558677.8377487535317; Wed, 26 Jul 2017 02:43:13 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1daIoI-0003JI-Ey; Wed, 26 Jul 2017 11:40:54 +0200 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1daIo6-0003HO-7h for seabios@seabios.org; Wed, 26 Jul 2017 11:40:50 +0200 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4530A13A43; Wed, 26 Jul 2017 09:42:45 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCF09612B7; Wed, 26 Jul 2017 09:42:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4530A13A43 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com From: Paolo Bonzini To: seabios@seabios.org Date: Wed, 26 Jul 2017 11:42:34 +0200 Message-Id: <20170726094235.14267-2-pbonzini@redhat.com> In-Reply-To: <20170726094235.14267-1-pbonzini@redhat.com> References: <20170726094235.14267-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 26 Jul 2017 09:42:45 +0000 (UTC) X-Spam-Score: -8.0 (--------) Subject: [SeaBIOS] [seabios PATCH 1/2] seabios: build RSDT from XSDT X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: phil@philjordan.eu, mst@redhat.com, qemu-devel@nongnu.org, programmingkidx@gmail.com, kraxel@redhat.com, lists@philjordan.eu, lersek@redhat.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Old operating systems would like to have a rev1 (ACPI 1.0) FADT, but new operating systems would like to have rev3 (ACPI 2.0). Since old operating systems do not know about XSDTs, the solution is to point the RSDT to a rev1 FADT and the XSDT to a rev3 FADT. But, edk2 is not able to handle QEMU providing two FADTs and barfs when it sees the second; edk2 subscribes to the view that the platform code (meaning not only OVMF, but transitively QEMU's ACPI table builder) should not handle such hacks; it's common edk2 code that should handle FADT rev1 vs. rev3 and RSDT vs. XSDT. These patches make SeaBIOS follow the same model as edk2, the only difference being how the two identify ACPI tables from the BIOS linker/loader script. For SeaBIOS, this task is actually much simpler since it can just look into the RSDP: if QEMU only provides an XSDT, SeaBIOS takes care of building the RSDT and rev1 FADT to satisfy ACPI 1.0-compliant operating systems. This part makes SeaBIOS build an RSDT out of an existing XSDT, patching the RSDP to point to the RSDT. Reviewed-by: Phil Dennis-Jordan Signed-off-by: Paolo Bonzini --- src/fw/paravirt.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- src/std/acpi.h | 11 +++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 5b23d78..927fd75 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -25,6 +25,7 @@ #include "x86.h" // cpuid #include "xen.h" // xen_biostable_setup #include "stacks.h" // yield +#include "std/acpi.h" =20 // Amount of continuous ram under 4Gig u32 RamSize; @@ -147,6 +148,50 @@ static void msr_feature_control_setup(void) wrmsr_smp(MSR_IA32_FEATURE_CONTROL, feature_control_bits); } =20 +static void +build_compatibility_rsdt(void) +{ + if (RsdpAddr->rsdt_physical_address) + return; + + u64 xsdt_addr =3D RsdpAddr->xsdt_physical_address; + if (xsdt_addr & ~0xffffffffULL) + return; + + struct xsdt_descriptor_rev1 *xsdt =3D (void*)(u32)xsdt_addr; + void *end =3D (void*)xsdt + xsdt->length; + struct rsdt_descriptor_rev1 *rsdt; + int rsdt_size =3D offsetof(struct rsdt_descriptor_rev1, table_offset_e= ntry[0]); + int i; + for (i=3D0; (void*)&xsdt->table_offset_entry[i] < end; i++) { + u64 tbl_addr =3D xsdt->table_offset_entry[i]; + if (!tbl_addr || (tbl_addr & ~0xffffffffULL)) + continue; + rsdt_size +=3D 4; + } + + rsdt =3D malloc_high(rsdt_size); + RsdpAddr->rsdt_physical_address =3D (u32)rsdt; + RsdpAddr->checksum -=3D checksum(RsdpAddr, + offsetof(struct rsdp_descriptor, length)); + RsdpAddr->extended_checksum -=3D checksum(RsdpAddr, + sizeof(struct rsdp_descriptor)); + + memcpy(rsdt, xsdt, sizeof(struct acpi_table_header)); + rsdt->signature =3D RSDT_SIGNATURE; + rsdt->length =3D rsdt_size; + rsdt->revision =3D 1; + int j; + for (i=3Dj=3D0; (void*)&xsdt->table_offset_entry[i] < end; i++) { + u64 tbl_addr =3D xsdt->table_offset_entry[i]; + if (!tbl_addr || (tbl_addr & ~0xffffffffULL)) + continue; + rsdt->table_offset_entry[j++] =3D (u32)tbl_addr; + } + + rsdt->checksum -=3D checksum(rsdt, rsdt_size); +} + void qemu_platform_setup(void) { @@ -186,8 +231,10 @@ qemu_platform_setup(void) =20 RsdpAddr =3D find_acpi_rsdp(); =20 - if (RsdpAddr) + if (RsdpAddr) { + build_compatibility_rsdt(); return; + } =20 /* If present, loader should have installed an RSDP. * Not installed? We might still be able to continue diff --git a/src/std/acpi.h b/src/std/acpi.h index c2ea707..a77b53c 100644 --- a/src/std/acpi.h +++ b/src/std/acpi.h @@ -133,6 +133,17 @@ struct rsdt_descriptor_rev1 } PACKED; =20 /* + * ACPI 2.0 Extended System Description Table (XSDT) + */ +#define XSDT_SIGNATURE 0x54445358 // XSDT +struct xsdt_descriptor_rev1 +{ + ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + u64 table_offset_entry[0]; /* Array of pointers to other */ + /* ACPI tables */ +} PACKED; + +/* * ACPI 1.0 Firmware ACPI Control Structure (FACS) */ #define FACS_SIGNATURE 0x53434146 // FACS --=20 2.13.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios From nobody Sun Apr 28 21:58:06 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) client-ip=80.81.252.135; envelope-from=seabios-bounces@seabios.org; helo=mail.coreboot.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 80.81.252.135 is neither permitted nor denied by domain of seabios.org) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from mail.coreboot.org (mail.coreboot.org [80.81.252.135]) by mx.zohomail.com with SMTPS id 1501062204858576.490437727461; Wed, 26 Jul 2017 02:43:24 -0700 (PDT) Received: from [127.0.0.1] (helo=ra.coresystems.de) by mail.coreboot.org with esmtp (Exim 4.86_2) (envelope-from ) id 1daIoP-0003Kx-5x; Wed, 26 Jul 2017 11:41:01 +0200 Received: from mx1.redhat.com ([209.132.183.28]) by mail.coreboot.org with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1daIo8-0003Hh-Sz for seabios@seabios.org; Wed, 26 Jul 2017 11:41:00 +0200 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D360915561; Wed, 26 Jul 2017 09:42:47 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-117-59.ams2.redhat.com [10.36.117.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95ACB5D978; Wed, 26 Jul 2017 09:42:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D360915561 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com From: Paolo Bonzini To: seabios@seabios.org Date: Wed, 26 Jul 2017 11:42:35 +0200 Message-Id: <20170726094235.14267-3-pbonzini@redhat.com> In-Reply-To: <20170726094235.14267-1-pbonzini@redhat.com> References: <20170726094235.14267-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 26 Jul 2017 09:42:48 +0000 (UTC) X-Spam-Score: -7.5 (-------) Subject: [SeaBIOS] [seabios PATCH 2/2] seabios: create rev1 FADT in compatibility RSDT X-BeenThere: seabios@seabios.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SeaBIOS mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: phil@philjordan.eu, mst@redhat.com, qemu-devel@nongnu.org, programmingkidx@gmail.com, kraxel@redhat.com, lists@philjordan.eu, lersek@redhat.com MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: seabios-bounces@seabios.org Sender: "SeaBIOS" X-Duff: Orig. Duff, Duff Lite, Duff Dry, Duff Dark, Raspberry Duff, Lady Duff, Red Duff, Tartar Control Duff X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch completes the job, presenting a rev1 FADT inside the compatibility RSDT, so that ACPI 1.0 operating systems such as Windows 2000 are not broken. Signed-off-by: Paolo Bonzini --- src/fw/paravirt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/fw/paravirt.c b/src/fw/paravirt.c index 927fd75..97e2fe3 100644 --- a/src/fw/paravirt.c +++ b/src/fw/paravirt.c @@ -148,6 +148,20 @@ static void msr_feature_control_setup(void) wrmsr_smp(MSR_IA32_FEATURE_CONTROL, feature_control_bits); } =20 +static void* +build_rev1_fadt(struct fadt_descriptor_rev1 *fadt_v3) +{ + struct fadt_descriptor_rev1 *fadt_v1 =3D malloc_high(sizeof *fadt_v1); + + memcpy(fadt_v1, fadt_v3, sizeof *fadt_v1); + fadt_v1->length =3D sizeof *fadt_v1; + fadt_v1->revision =3D 1; + // the upper 23 bits are reserved in the rev1 FADT + fadt_v1->flags &=3D 0x1ff; + fadt_v1->checksum -=3D checksum(fadt_v1, fadt_v1->length); + return fadt_v1; +} + static void build_compatibility_rsdt(void) { @@ -186,6 +200,11 @@ build_compatibility_rsdt(void) u64 tbl_addr =3D xsdt->table_offset_entry[i]; if (!tbl_addr || (tbl_addr & ~0xffffffffULL)) continue; + struct acpi_table_header *tbl =3D (void*)(u32)tbl_addr; + // for compatibility with Windows 2000, the RSDT should contain + // an ACPI 1.0 FADT (table revision 1) + if (tbl->signature =3D=3D FACP_SIGNATURE && tbl->revision > 1) + tbl_addr =3D (u32)build_rev1_fadt((void *)tbl); rsdt->table_offset_entry[j++] =3D (u32)tbl_addr; } =20 --=20 2.13.3 _______________________________________________ SeaBIOS mailing list SeaBIOS@seabios.org https://mail.coreboot.org/mailman/listinfo/seabios