From patchwork Fri Sep 5 21:15:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 36896 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 174FE206A0 for ; Fri, 5 Sep 2014 21:16:11 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf41871863yha.3 for ; Fri, 05 Sep 2014 14:16:10 -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=nKq2czCWgU/P4aH+Ye70XZyKHoNq+fjs363eux1S+Zk=; b=bXmFWtDoMzVp7Plc++rn1Xvd9F2UUrXVvWg/RqBFruiTGQ8BsXuX8Jecw3wW+ec3Xk HUxbTylR13yRu0CId+XWvoX3dRK1i4NIHE0IR8z/9z/XmfCGliVhahYy+XE3e9EFo9YB JyqRM5Qfr8/WjmQ2C5yDNg9VEoIOWSv37vYk95maAppHDPY7tHicxjoq3nRn7/kYCDxo 1nAetnhsm11MqcTSntd4u8f9mFNiOLIrOETsVpeimWZlOoD9VWipTNOKiOnTLH9MIT9q YQ5c2mYJ3Tj8IxEPjuW218B5NoG1Q/+wFS+h4YX1RYwgC6R8V3kaQwa1FhMWe4Zi55q1 0YTw== X-Gm-Message-State: ALoCoQmjPa+h64XFWW+uWORwWVQ9QT0ruZgEm0DLeK47zLD6eqgQOvZbNAZGr24Yl3+e8OoCsbTe X-Received: by 10.224.124.195 with SMTP id v3mr8458684qar.4.1409951770869; Fri, 05 Sep 2014 14:16:10 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.92.102 with SMTP id a93ls902848qge.15.gmail; Fri, 05 Sep 2014 14:16:10 -0700 (PDT) X-Received: by 10.52.245.101 with SMTP id xn5mr10547282vdc.32.1409951770803; Fri, 05 Sep 2014 14:16:10 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id h9si1465412vcr.11.2014.09.05.14.16.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 14:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id im17so12853617vcb.41 for ; Fri, 05 Sep 2014 14:16:10 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr12673576vcn.16.1409951770719; Fri, 05 Sep 2014 14:16:10 -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.45.67 with SMTP id uj3csp139386vcb; Fri, 5 Sep 2014 14:16:10 -0700 (PDT) X-Received: by 10.140.38.73 with SMTP id s67mr21906777qgs.4.1409951769854; Fri, 05 Sep 2014 14:16:09 -0700 (PDT) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id g9si3099694qay.58.2014.09.05.14.16.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 05 Sep 2014 14:16:09 -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 1XQ0rQ-0002r3-Kj; Fri, 05 Sep 2014 21:16:00 +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 1XQ0rN-0002qt-R5 for edk2-devel@lists.sourceforge.net; Fri, 05 Sep 2014 21:15:57 +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 1XQ0rM-0001sE-Gd for edk2-devel@lists.sourceforge.net; Fri, 05 Sep 2014 21:15:57 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s85LFopX025949 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 5 Sep 2014 17:15:50 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s85LFic0015119 for ; Fri, 5 Sep 2014 17:15:49 -0400 From: Laszlo Ersek To: edk2-devel@lists.sourceforge.net Date: Fri, 5 Sep 2014 23:15:41 +0200 Message-Id: <1409951742-27218-4-git-send-email-lersek@redhat.com> In-Reply-To: <1409951742-27218-1-git-send-email-lersek@redhat.com> References: <1409951742-27218-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -3.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 -1.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XQ0rM-0001sE-Gd Subject: [edk2] [PATCH v2 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.182 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 --- Notes: v2: - CheckRsdp() is removed too, v2 of the next patch doesn't need it - the prototype of InstallAllQemuLinkedTables() is not changed; v2 of the next patch needs access to EFI_ACPI_TABLE_PROTOCOL 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; }