From patchwork Sun Sep 21 15:46:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 37665 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6560420063 for ; Sun, 21 Sep 2014 15:47:32 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id y10sf877799wgg.6 for ; Sun, 21 Sep 2014 08:47:31 -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=NvGUBbJVZVYW61Jxr2z+/i4Ly/qb/tsKr0MjmM/E1Os=; b=WgNAIaziX45oZxvNZ0y58W3FVsV13XqbKknUJLNvmpDTXkvXb0btGMVvk75oWeIqTj 3uD+eFWgsJEvwIKXNLxc5dza+zeZuQ0z1ev4/5Ov3ik+iABrhzAOrzyBVycELuFEA7XJ 4u2mih6LYQcWdDvYfOsM61audrFaLVRkdZMD3+FWFqG1kPaF8r87IzbQUtcjt4BSb883 GDrj/YH2Lr/fSLnXUsMM00lZPONQwU0BE47kmyKZUMp3eItEx+coBNbDOgeo1av9mumK OaS2RHjxioJQjsO7LdmFi92CspWQNkuN/GK+8MlxqfLIvePKSPc5tpIMHHdj61OgWX2k grHg== X-Gm-Message-State: ALoCoQlDenwrSU2usI9LNV6kTCRpD1fzE75yuRXdv+lj2EvShZ1RitSh7n54Q1scnsJE+7+P1uvT X-Received: by 10.112.64.35 with SMTP id l3mr343551lbs.12.1411314451629; Sun, 21 Sep 2014 08:47:31 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls355192lae.37.gmail; Sun, 21 Sep 2014 08:47:31 -0700 (PDT) X-Received: by 10.152.87.170 with SMTP id az10mr20173852lab.20.1411314450613; Sun, 21 Sep 2014 08:47:30 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176]) by mx.google.com with ESMTPS id ee12si11110890lbd.126.2014.09.21.08.47.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Sep 2014 08:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id w7so634830lbi.21 for ; Sun, 21 Sep 2014 08:47:30 -0700 (PDT) X-Received: by 10.152.5.168 with SMTP id t8mr19661652lat.67.1411314450515; Sun, 21 Sep 2014 08:47:30 -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.112.130.169 with SMTP id of9csp122851lbb; Sun, 21 Sep 2014 08:47:29 -0700 (PDT) X-Received: by 10.50.115.73 with SMTP id jm9mr9045167igb.3.1411314449104; Sun, 21 Sep 2014 08:47:29 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id ip4si7048895icc.11.2014.09.21.08.47.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 21 Sep 2014 08:47:29 -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-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XVjM5-00083k-J9; Sun, 21 Sep 2014 15:47:17 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XVjM3-00083Y-Lp for edk2-devel@lists.sourceforge.net; Sun, 21 Sep 2014 15:47:15 +0000 Received-SPF: pass (sog-mx-2.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-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XVjM2-0007xp-9j for edk2-devel@lists.sourceforge.net; Sun, 21 Sep 2014 15:47:15 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8LFl7Pi009913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 21 Sep 2014 11:47:08 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8LFkwAM029046; Sun, 21 Sep 2014 11:47:06 -0400 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net, jordan.l.justen@intel.com Date: Sun, 21 Sep 2014 17:46:52 +0200 Message-Id: <1411314413-9723-4-git-send-email-lersek@redhat.com> In-Reply-To: <1411314413-9723-1-git-send-email-lersek@redhat.com> References: <1411314413-9723-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Spam-Score: -2.3 (--) 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.8 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XVjM2-0007xp-9j Subject: [edk2] [PATCH v3 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.217.176 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 also remove CheckRsdp(). 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/Qemu.c | 338 +---------------------------------------- 1 file changed, 1 insertion(+), 337 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/Qemu.c b/OvmfPkg/AcpiPlatformDxe/Qemu.c index 70f3ff6..ef2ba11 100644 --- a/OvmfPkg/AcpiPlatformDxe/Qemu.c +++ b/OvmfPkg/AcpiPlatformDxe/Qemu.c @@ -518,272 +518,6 @@ QemuInstallAcpiTable ( /** - Check if an array of bytes starts with an RSD PTR structure. - - Checksum is ignored. - - @param[in] Buffer The array to check. - - @param[in] Size Number of bytes in Buffer. - - @param[out] RsdpSize If the function returns EFI_SUCCESS, this parameter - contains the size of the detected RSD PTR structure. - - @retval EFI_SUCCESS RSD PTR structure detected at the beginning of - Buffer, and its advertised size does not exceed - Size. - - @retval EFI_PROTOCOL_ERROR RSD PTR structure detected at the beginning of - Buffer, but it has inconsistent size. - - @retval EFI_NOT_FOUND RSD PTR structure not found. - -**/ - -STATIC -EFI_STATUS -CheckRsdp ( - IN CONST VOID *Buffer, - IN UINTN Size, - OUT UINTN *RsdpSize - ) -{ - CONST UINT64 *Signature; - CONST EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp1; - CONST EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp2; - - if (Size < sizeof *Signature) { - return EFI_NOT_FOUND; - } - Signature = Buffer; - - if (*Signature != EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) { - return EFI_NOT_FOUND; - } - - // - // Signature found -- from this point on we can only report - // EFI_PROTOCOL_ERROR or EFI_SUCCESS. - // - if (Size < sizeof *Rsdp1) { - return EFI_PROTOCOL_ERROR; - } - Rsdp1 = Buffer; - - if (Rsdp1->Reserved == 0) { - // - // ACPI 1.0 doesn't include the Length field - // - *RsdpSize = sizeof *Rsdp1; - return EFI_SUCCESS; - } - - if (Size < sizeof *Rsdp2) { - return EFI_PROTOCOL_ERROR; - } - Rsdp2 = Buffer; - - if (Size < Rsdp2->Length || Rsdp2->Length < sizeof *Rsdp2) { - return EFI_PROTOCOL_ERROR; - } - - *RsdpSize = Rsdp2->Length; - 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. @param[in] AcpiProtocol The ACPI table protocol used to install tables. @@ -809,75 +543,5 @@ InstallAllQemuLinkedTables ( IN EFI_ACPI_TABLE_PROTOCOL *AcpiProtocol ) { - 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 EFI_NOT_FOUND; }