From patchwork Sat Aug 9 02:08:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 35176 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D0DCC2118A for ; Sat, 9 Aug 2014 02:09:28 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id 9sf19234408ykp.7 for ; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:reply-to:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=w0LGDonsCpJHS1KS4KB/RLjb8VR4Jd1N+x+Q1ZwekNU=; b=HiUabQ+IgvSIZXA4Bnt+dP6MIpZ5Pmcw+qLmZ9tJ8CaClLwkrc5GkREN4LVg/3rchQ QcsrYcScsIp7k3XxoFVuhN2Rl6MfGx09illYR4zCiLw2akV4Y5pJMz0djTxY9EGyBD0T n2TOoFl29bHliYY7B3EyVQkzhkCF+UMzIUd7EC+OM2nwHq3FzPwSkmyngc+Ea58aks4B kmSfgO8LoKcuq3i2WOd4PYsrQoRcPFf6Ejc2UqgAe5oiUHif/F5pHp7+mXySi0nedAoG oN6imZLiienwiUrGOiSGkWW6XVxsqg/bv8a8OmRTvttbYv1mRmxxfJpFStnlUNDEtWpt aMAw== X-Gm-Message-State: ALoCoQl2IN7V3Ur5NmIaXyT6yU/7M0mar9IlQa26lMXR17jGrLy696bYyKi4LEUNl8aRx30VPujM X-Received: by 10.236.18.135 with SMTP id l7mr6652264yhl.1.1407550168649; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.202 with SMTP id k68ls457218qge.48.gmail; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) X-Received: by 10.220.130.131 with SMTP id t3mr24870099vcs.30.1407550168559; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id j20si3475328ver.69.2014.08.08.19.09.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 08 Aug 2014 19:09:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so9358407vcb.29 for ; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) X-Received: by 10.220.81.194 with SMTP id y2mr24707345vck.29.1407550168456; Fri, 08 Aug 2014 19:09:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp169382vcb; Fri, 8 Aug 2014 19:09:28 -0700 (PDT) X-Received: by 10.43.136.134 with SMTP id ik6mr16464363icc.6.1407550167790; Fri, 08 Aug 2014 19:09:27 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id au4si6571017igc.59.2014.08.08.19.09.27 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 08 Aug 2014 19:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-4.v29.ch3.sourceforge.com) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XFw5s-000133-E4; Sat, 09 Aug 2014 02:09:16 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-4.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XFw5q-00012t-SM for edk2-devel@lists.sourceforge.net; Sat, 09 Aug 2014 02:09:14 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=lersek@redhat.com; helo=mx1.redhat.com; Received: from mx1.redhat.com ([209.132.183.28]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XFw5p-0006hH-CU for edk2-devel@lists.sourceforge.net; Sat, 09 Aug 2014 02:09:14 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s79296vv021242 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 8 Aug 2014 22:09:06 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s79291UF014215; Fri, 8 Aug 2014 22:09:05 -0400 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net, "Michael S. Tsirkin" Date: Sat, 9 Aug 2014 04:08:58 +0200 Message-Id: <1407550139-25313-4-git-send-email-lersek@redhat.com> In-Reply-To: <1407550139-25313-1-git-send-email-lersek@redhat.com> References: <1407550139-25313-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Spam-Score: -2.2 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XFw5p-0006hH-CU Subject: [edk2] [PATCH 3/4] OvmfPkg: AcpiPlatformDxe: remove current ACPI table loader X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In the next patch we rewrite the client code for QEMU's fw_cfg ACPI table loader interface. In order to avoid randomly intermixed hunks in that patch, first remove the old code cleanly. We remove the InstallQemuLinkedTables() function and empty the InstallAllQemuLinkedTables() function. We keep CheckRsdp(), and the way we call it ensures that - compilers won't complain about it being a unused static function, - InstallAllQemuLinkedTables() will return constant EFI_NOT_FOUND to AcpiPlatformEntryPoint(), causing the latter to proceed to OVMF's builtin tables. This way the history remains bisectable and the new client gets a clean start in the next patch. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h | 2 +- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 2 +- OvmfPkg/AcpiPlatformDxe/Qemu.c | 266 +-------------------------------- 3 files changed, 4 insertions(+), 266 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h index e757233..3837134 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.h @@ -64,7 +64,7 @@ InstallXenTables ( EFI_STATUS EFIAPI InstallAllQemuLinkedTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol + VOID ); #endif diff --git a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c index 11f0ca8..c254e14 100644 --- a/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +++ b/OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c @@ -257,7 +257,7 @@ AcpiPlatformEntryPoint ( if (XenDetected ()) { Status = InstallXenTables (AcpiTable); } else { - Status = InstallAllQemuLinkedTables (AcpiTable); + Status = InstallAllQemuLinkedTables (); } if (EFI_ERROR (Status)) { diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c index 70f3ff6..333766e 100644 --- a/OvmfPkg/AcpiPlatformDxe/Qemu.c +++ b/OvmfPkg/AcpiPlatformDxe/Qemu.c @@ -591,198 +591,6 @@ CheckRsdp ( return EFI_SUCCESS; } -// -// We'll be saving the keys of installed tables so that we can roll them back -// in case of failure. 128 tables should be enough for anyone (TM). -// -#define INSTALLED_TABLES_MAX 128 - -/** - Download one ACPI table data file from QEMU and interpret it. - - @param[in] FwCfgFile The NUL-terminated name of the fw_cfg file to - download and interpret. - - @param[in] AcpiProtocol The ACPI table protocol used to install tables. - - @param[in,out] InstalledKey On input, an array of INSTALLED_TABLES_MAX UINTN - elements, allocated by the caller. On output, - the function will have stored (appended) the - AcpiProtocol-internal keys of the ACPI tables - that the function has installed from the fw_cfg - file. The array reflects installed tables even - if the function returns with an error. - - @param[in,out] NumInstalled On input, the number of entries already used in - InstalledKey; it must be in [0, - INSTALLED_TABLES_MAX] inclusive. On output, the - parameter is updated to the new cumulative count - of the keys stored in InstalledKey; the value - reflects installed tables even if the function - returns with an error. - - @retval EFI_INVALID_PARAMETER NumInstalled is outside the allowed range on - input. - - @retval EFI_UNSUPPORTED Firmware configuration is unavailable. - - @retval EFI_NOT_FOUND The host doesn't export the requested fw_cfg - file. - - @retval EFI_OUT_OF_RESOURCES Memory allocation failed, or no more room in - InstalledKey. - - @retval EFI_PROTOCOL_ERROR Found truncated or invalid ACPI table header - in the fw_cfg contents. - - @return Status codes returned by - AcpiProtocol->InstallAcpiTable(). - -**/ - -STATIC -EFI_STATUS -InstallQemuLinkedTables ( - IN CONST CHAR8 *FwCfgFile, - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol, - IN OUT UINTN InstalledKey[INSTALLED_TABLES_MAX], - IN OUT INT32 *NumInstalled - ) -{ - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM TablesFile; - UINTN TablesFileSize; - UINT8 *Tables; - UINTN Processed; - - if (*NumInstalled < 0 || *NumInstalled > INSTALLED_TABLES_MAX) { - return EFI_INVALID_PARAMETER; - } - - Status = QemuFwCfgFindFile (FwCfgFile, &TablesFile, &TablesFileSize); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, "%a: \"%a\" unavailable: %r\n", __FUNCTION__, - FwCfgFile, Status)); - return Status; - } - - Tables = AllocatePool (TablesFileSize); - if (Tables == NULL) { - return EFI_OUT_OF_RESOURCES; - } - - QemuFwCfgSelectItem (TablesFile); - QemuFwCfgReadBytes (TablesFileSize, Tables); - - Processed = 0; - while (Processed < TablesFileSize) { - UINTN Remaining; - UINTN RsdpSize; - EFI_ACPI_DESCRIPTION_HEADER *Probe; - - Remaining = TablesFileSize - Processed; - - // - // See if we're looking at an RSD PTR structure. - // - RsdpSize = 0; - Status = CheckRsdp (Tables + Processed, Remaining, &RsdpSize); - if (Status == EFI_PROTOCOL_ERROR) { - // - // RSD PTR found but its size is inconsistent; abort processing. (Note - // that "RSD PTR found" excludes the NUL-padding case by definition.) - // - break; - } - if (!EFI_ERROR (Status)) { - // - // Consistent RSD PTR found, skip it. - // - DEBUG ((EFI_D_VERBOSE, "%a: \"%a\" offset 0x%016Lx: RSD PTR " - "Length=0x%08x\n", __FUNCTION__, FwCfgFile, (UINT64)Processed, - (UINT32)RsdpSize)); - Processed += RsdpSize; - continue; - } - ASSERT (Status == EFI_NOT_FOUND); - - // - // What we're looking at is not an RSD PTR structure; attempt to parse it - // as an ACPI table. - // - if (Remaining < sizeof *Probe) { - Status = EFI_PROTOCOL_ERROR; - break; - } - - Probe = (EFI_ACPI_DESCRIPTION_HEADER *) (Tables + Processed); - if (Remaining < Probe->Length || Probe->Length < sizeof *Probe) { - Status = EFI_PROTOCOL_ERROR; - break; - } - - DEBUG ((EFI_D_VERBOSE, "%a: \"%a\" offset 0x%016Lx:" - " Signature=\"%-4.4a\" Length=0x%08x\n", - __FUNCTION__, FwCfgFile, (UINT64) Processed, - (CONST CHAR8 *) &Probe->Signature, Probe->Length)); - - // - // skip automatically handled "root" tables: RSDT, XSDT - // - if (Probe->Signature != - EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE && - Probe->Signature != - EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { - if (*NumInstalled == INSTALLED_TABLES_MAX) { - DEBUG ((EFI_D_ERROR, "%a: can't install more than %d tables\n", - __FUNCTION__, INSTALLED_TABLES_MAX)); - Status = EFI_OUT_OF_RESOURCES; - break; - } - - Status = AcpiProtocol->InstallAcpiTable (AcpiProtocol, Probe, - Probe->Length, &InstalledKey[*NumInstalled]); - if (EFI_ERROR (Status)) { - DEBUG ((EFI_D_ERROR, - "%a: failed to install table \"%-4.4a\" at \"%a\" offset 0x%Lx: " - "%r\n", __FUNCTION__, (CONST CHAR8 *)&Probe->Signature, FwCfgFile, - (UINT64) Processed, Status)); - break; - } - - ++*NumInstalled; - } - - Processed += Probe->Length; - } - - // - // NUL-padding at the end is accepted - // - if (Status == EFI_PROTOCOL_ERROR) { - UINTN ErrorLocation; - - ErrorLocation = Processed; - while (Processed < TablesFileSize && Tables[Processed] == '\0') { - ++Processed; - } - if (Processed < TablesFileSize) { - DEBUG ((EFI_D_ERROR, "%a: truncated or invalid ACPI table header at " - "\"%a\" offset 0x%Lx\n", __FUNCTION__, FwCfgFile, - (UINT64)ErrorLocation)); - } - } - - if (Processed == TablesFileSize) { - Status = EFI_SUCCESS; - } else { - ASSERT (EFI_ERROR (Status)); - } - - FreePool (Tables); - return Status; -} - /** Download all ACPI table data files from QEMU and interpret them. @@ -806,78 +614,8 @@ InstallQemuLinkedTables ( EFI_STATUS EFIAPI InstallAllQemuLinkedTables ( - IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol + VOID ) { - UINTN *InstalledKey; - INT32 Installed; - EFI_STATUS Status; - FIRMWARE_CONFIG_ITEM LoaderItem; - UINTN LoaderSize; - UINT8 *Loader; - QEMU_LOADER_ENTRY *Entry, *End; - - InstalledKey = AllocatePool (INSTALLED_TABLES_MAX * sizeof *InstalledKey); - if (InstalledKey == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Installed = 0; - - Status = QemuFwCfgFindFile ("etc/table-loader", &LoaderItem, &LoaderSize); - if (EFI_ERROR (Status)) { - goto FreeInstalledKey; - } - if (LoaderSize % sizeof *Entry != 0) { - Status = EFI_PROTOCOL_ERROR; - goto FreeInstalledKey; - } - - Loader = AllocatePool (LoaderSize); - if (Loader == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto FreeInstalledKey; - } - - QemuFwCfgSelectItem (LoaderItem); - QemuFwCfgReadBytes (LoaderSize, Loader); - - Entry = (QEMU_LOADER_ENTRY *)Loader; - End = (QEMU_LOADER_ENTRY *)(Loader + LoaderSize); - while (Entry < End) { - if (Entry->Type == QemuLoaderCmdAllocate) { - QEMU_LOADER_ALLOCATE *Allocate; - - Allocate = &Entry->Command.Allocate; - if (Allocate->File[sizeof Allocate->File - 1] != '\0') { - Status = EFI_PROTOCOL_ERROR; - break; - } - - Status = InstallQemuLinkedTables ((CHAR8 *)Allocate->File, AcpiProtocol, - InstalledKey, &Installed); - if (EFI_ERROR (Status)) { - ASSERT (Status != EFI_INVALID_PARAMETER); - break; - } - } - ++Entry; - } - - FreePool (Loader); - - if (EFI_ERROR (Status)) { - // - // Roll back partial installation. - // - while (Installed > 0) { - --Installed; - AcpiProtocol->UninstallAcpiTable (AcpiProtocol, InstalledKey[Installed]); - } - } else { - DEBUG ((EFI_D_INFO, "%a: installed %d tables\n", __FUNCTION__, Installed)); - } - -FreeInstalledKey: - FreePool (InstalledKey); - return Status; + return CheckRsdp (NULL, 0, NULL); }