From patchwork Mon May 28 14:40:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137086 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2909111lji; Mon, 28 May 2018 07:40:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL8hipV54bV/u76xAiHtp+MiV62bzQGeuvPuPdSWJsfwmbk26IvajuxPGin4KLGw0ocn+T0 X-Received: by 2002:a63:778b:: with SMTP id s133-v6mr4752317pgc.400.1527518450446; Mon, 28 May 2018 07:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527518450; cv=none; d=google.com; s=arc-20160816; b=QANb1k9yJjizXQ4PcfPTuZNBldgaEM8iA6MxHodZVp8gFGZz9Atuhm7yDV5CBysuC5 rpNZXszpmHIARq3trAIeBzaw1VdoCYE0RqQiqydFxp1zh4yWIhM0wjCod+r7wv4zLAqB WfG8nUsVCkEkvxmgT0EvUVjgrcdhQPZ3H6Pcp4kvAAFi9CTaZadRJThCfUEG7+5TFCbe BkhOUuxoXffSnCA653HHSTpU1MSBps4ySzCFDsIzM0mgSrrWPjhkq1mVO8sDAV6qO+EG rKGWWj+sNtc6WQL/cSSbXrtP5/wn9kbATYnDDaIFjnc1KbY/uofCx+gaqc8cqdSIzCDL CU2g== 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=7nFY9gnPiY8Cm4X7Vd7J6YlrSN439IjFRzxhz1Iimco=; b=fximQB4Q6wTVR4Jg6738Tmvd1ShdDxvJNtIWcoo8Np+wltBpVPdlZEeD3/s0LXHPkA Dv19VrwqOaU1N6e7oIA05peVyHqIjenl0StJAl8iHyXMk0SInp9yqdOyRa/VE5f+d+4D drNRfnpp48OIR8HXJsaCpt2gAsI9IGJ1t2s46MQLgLQTL8o3xEQx7NNE1vILRCqf4Wsx 6LJtGQ18JHuGe8SqQbVZrbBkW2FKA2JpE9dJow1cX0mhy0NtsZxu7NwOm+9f1o+yBKpX OCoSh4cxuaml3ByJA0GUicKTTKp6rEZwRd0hQ82cSxM+XFx3eWzBwhJCKPjempCKEE2f uVbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=UWNNWgtq; 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 x14-v6si29529501pfn.41.2018.05.28.07.40.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:50 -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=UWNNWgtq; 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 EB26820348603; Mon, 28 May 2018 07:40:41 -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 C285020977877 for ; Mon, 28 May 2018 07:40:38 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id f8-v6so32749703wmc.4 for ; Mon, 28 May 2018 07:40:38 -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=2mfqJqNMucuBxDg42ENRB7P/wgjoANgMFzPCFg5NVWA=; b=UWNNWgtqHDt7SC7mjPnlsiVlbPw3qXBtCxG3eGcUncwjZUloUpK/J2JLMbcI4ba7FU oKwrBUCKwNhtU0H4hauSmB6P20vfa+z/BPlh5tOsIoArmSD79eMKRHbadbhMkBNDoQfe FxxltARrK3xjxb87dvUtumwHRhAsDLoQv53Jk= 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=2mfqJqNMucuBxDg42ENRB7P/wgjoANgMFzPCFg5NVWA=; b=oqPcLZzhtcecwBtG5drzU166hcsT45tycLWz2GaMtvIqGgc2FVFRPBAsW/11c6LeMc 9tIaLMF/a+49Qelt4IH3Rz/IrL3cV+o95eYjQZenDcfqTc+P3GZCldaJTFOIz4PlV5y4 w7hs9k+Wn9lfDTTRKbjldIKA1Dt7z6l/rOSXIQzDyiC7E3BHT5ye5s01DH4JWKJnvJn5 w2TEyZhQlX0VCAMSo48G35FNa4dxxWvhG/3DKET/Roqo0InVWuz3T5Eg5gCU54ZvEAeN 1FqYfrY57XLIHSLWhfZwPrbxv19i88cAZH3wM2UVXDaYB4zwSjCDBd67t/ZTBTPWjM06 reXQ== X-Gm-Message-State: ALKqPwez8Q5npDYWPU1tT7SevpkJ8CDQVYTZ0InL8zv0Jkp0pZAzwxvq doCJtaaERn4ZpRoAIk1achdUVCNmzfw= X-Received: by 2002:a1c:e906:: with SMTP id q6-v6mr8708808wmc.23.1527518437126; Mon, 28 May 2018 07:40:37 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id y18-v6sm4177938wrl.53.2018.05.28.07.40.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:36 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 28 May 2018 16:40:24 +0200 Message-Id: <20180528144024.10809-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528144024.10809-1-ard.biesheuvel@linaro.org> References: <20180528144024.10809-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v3 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: Ard Biesheuvel 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 Reviewed-by: Laszlo Ersek --- 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: Star Zeng Signed-off-by: Ard Biesheuvel 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