From patchwork Thu May 24 09:09:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 136725 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1938490lji; Thu, 24 May 2018 02:10:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpiWA0CpnBvNfAIEF0QnEW3iIfaPoCRWf96zFoEPYG4h2QYkx95rwYgrFHqVtI9KXKr4kQS X-Received: by 2002:a17:902:a711:: with SMTP id w17-v6mr6533952plq.292.1527153008888; Thu, 24 May 2018 02:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527153008; cv=none; d=google.com; s=arc-20160816; b=ICxfml4RZtsBnrnLFof72D8v0c0Gc0oLgtgoz7wHC5Sl1eQMNbs5nbRYEoqi4jz0oo 5VHo/zBJLHrF8U2/z7LOG3oKCYNBCU2DRMJiUdB0X6bYEDFzoKwxK+AtF1DWbcvLQHPW 3v7DG6wWUQb1ClJFItKPRLJnBKIKU0PDE1g0GuqoabK4UQKAUYL80e356lx0P4QSGYZW OHHG7YvrWbbue+EAkJA0mZ3QZjQElljlNzOG9P51qKLEuubArcdvrGtLG3u4V1XVnZqV jVubDd76B4cLqd+Vrf57u2wJKRyOl9s+2h0mmGjMtdPIT8LmILAp3TfK038LV9PlTWdM l2Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=vBWc7SBD2gPmfJviP/FrkC3p3lIamOmkJszznQtfvRQ=; b=TKumzgocEWirdlVdOwbzal/jBqrlOFyNPgJLMLYX7pco1mNDAsA/aNwQgLa/A/ivuu QHSb1v8tfkcupoETamgfYYXWMsLtdSDrQhh3X10xjoT7TWgDKBF5GuDHKt26az/8nDio J16S1EAYsEsIxlukjS6vXV/OSpypQFePt3JXEZSkFCJNkXT1JLn4t2oy4LqLSFxkYO/h WL8jqAWuGsygwIr0G7ma/12EVSLNOfqYzTbc8fQcHkAiWA5iBa+kKRDPm/HqJJ0CquIJ yKgz4JzQJJHGsBUljE9Q1WnqERy9AculcYagh7taAeZlrCLXiUA89oPZUYjxxaoHgC0m oL8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PTH5IMa2; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id b66-v6si722282pgc.319.2018.05.24.02.10.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:10:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=PTH5IMa2; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4A8B620886FC6; Thu, 24 May 2018 02:10:02 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E81C6207E6376 for ; Thu, 24 May 2018 02:10:00 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id f8-v6so3054054wmc.4 for ; Thu, 24 May 2018 02:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5eF0ccwnc7SXGizXrhT5cyihgK0mFeyVuLwuitooXY0=; b=PTH5IMa2aSGgHBwD+sjV1t5Nvn8EIycUBwP8c50En3g33GiyNj3XJRlTIP6o2Pkhfq dewJXQtgnFcPW5NIegaj6bCXXWX7EzyW2anM3QLeuTM8A6kEqR4ngD31aeulaLnVIlEr AG7bH3ueWWsQ/xnEsaTtbfyEnUIEnppM7IqQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5eF0ccwnc7SXGizXrhT5cyihgK0mFeyVuLwuitooXY0=; b=kMivz+NfNOaV3QBDi7FUykqKbPzOCIEzqh7Cl8OJiTnnGE5SBMLjjpn89bVzoKe+bA 3EZ2XSJjFVAkgWgFvQuBCe6KBHSLCsWXMBQuYWLxIA3xK0RYnXxkU4GbScYrvQpkU0mM DZfdJQBSlO9IKDCn80eqCt4AMW9LSlv+T3gtwfrIt9r6c0GoED0OMflRyuA2s9MjFje5 VApA+oCsozWgMh30N/9Uz8Ro+YQBXAKxGXjkvvzRjYaEfqTNIHTCWYT+qOckqYZF7mvb /29539ySGuxyA99Ok6+3NzVLINO9vOwkjdwAz44jD860dnf/4vWNKUqayGwzVZCN8XH9 1yxA== X-Gm-Message-State: ALKqPwemxrP0fS8GcmI2qNnZRcYQQPhcOQQifhEtRZ2dsXijf1mP08oH aFPwlFHuCPRjgC74ASblkArT/kxK5x0= X-Received: by 2002:a1c:b9d0:: with SMTP id j199-v6mr7137684wmf.131.1527152999123; Thu, 24 May 2018 02:09:59 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id x16-v6sm8505467wmc.2.2018.05.24.02.09.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:09:58 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 24 May 2018 11:09:45 +0200 Message-Id: <20180524090945.10289-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524090945.10289-1-ard.biesheuvel@linaro.org> References: <20180524090945.10289-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 5/5] MdeModulePkg/FirmwarePerformanceDataTableDxe: use AllocatePeiAccessiblePages X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Dong , Ard Biesheuvel , Liming Gao , Dandan Bi , Leif Lindholm , Michael D Kinney , Laszlo Ersek , Star Zeng MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" Replace the call to and implementation of the function FpdtAllocateReservedMemoryBelow4G() with a call to AllocatePeiAccessiblePages, which boils down to the same on X64, but does not crash non-X64 systems that lack memory below 4 GB. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Note that the ZeroMem() call is dropped, but it is redundant anyway, given that in both cases, the subsequent CopyMem() call supersedes it immediately. MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c | 51 ++++---------------- MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf | 1 + 2 files changed, 10 insertions(+), 42 deletions(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index e719e9e482cb..ded817f37301 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -179,46 +180,6 @@ FpdtAcpiTableChecksum ( Buffer[ChecksumOffset] = CalculateCheckSum8 (Buffer, Size); } -/** - Allocate EfiReservedMemoryType below 4G memory address. - - This function allocates EfiReservedMemoryType below 4G memory address. - - @param[in] Size Size of memory to allocate. - - @return Allocated address for output. - -**/ -VOID * -FpdtAllocateReservedMemoryBelow4G ( - IN UINTN Size - ) -{ - UINTN Pages; - EFI_PHYSICAL_ADDRESS Address; - EFI_STATUS Status; - VOID *Buffer; - - Buffer = NULL; - Pages = EFI_SIZE_TO_PAGES (Size); - Address = 0xffffffff; - - Status = gBS->AllocatePages ( - AllocateMaxAddress, - EfiReservedMemoryType, - Pages, - &Address - ); - ASSERT_EFI_ERROR (Status); - - if (!EFI_ERROR (Status)) { - Buffer = (VOID *) (UINTN) Address; - ZeroMem (Buffer, Size); - } - - return Buffer; -} - /** Callback function upon VariableArchProtocol and LockBoxProtocol to allocate S3 performance table memory and save the pointer to LockBox. @@ -287,7 +248,10 @@ FpdtAllocateS3PerformanceTableMemory ( // // Fail to allocate at specified address, continue to allocate at any address. // - mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (sizeof (S3_PERFORMANCE_TABLE)); + mAcpiS3PerformanceTable = (S3_PERFORMANCE_TABLE *) AllocatePeiAccessiblePages ( + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (sizeof (S3_PERFORMANCE_TABLE)) + ); } DEBUG ((EFI_D_INFO, "FPDT: ACPI S3 Performance Table address = 0x%x\n", mAcpiS3PerformanceTable)); if (mAcpiS3PerformanceTable != NULL) { @@ -368,7 +332,10 @@ InstallFirmwarePerformanceDataTable ( // // Fail to allocate at specified address, continue to allocate at any address. // - mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize); + mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) AllocatePeiAccessiblePages ( + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (BootPerformanceDataSize) + ); } DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable)); if (mAcpiBootPerformanceTable == NULL) { diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf index 8757bbd0aaa9..3d2dd6eb732f 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.inf @@ -44,6 +44,7 @@ [LibraryClasses] UefiRuntimeServicesTableLib BaseLib DebugLib + DxeServicesLib TimerLib BaseMemoryLib MemoryAllocationLib