From patchwork Tue May 22 14:08:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 136553 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1683191lji; Tue, 22 May 2018 07:09:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqjnwa07tllVU/NfRpoZv1QI1fZ/awqnb91HyP8FJ6Dshy6VuggMsPlKk+HecCumKc8crfo X-Received: by 2002:a17:902:264:: with SMTP id 91-v6mr24740748plc.341.1526998158627; Tue, 22 May 2018 07:09:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526998158; cv=none; d=google.com; s=arc-20160816; b=yAF2cYwHwDg47be6SiQ3q9PR1VSZomxNd+FjF6qqLUt6gNyIfMGnN2LMxGKi7s+cFa rUzX40VJJjX8DJILqksUxt7fBct3u19AvImGl5JhbIJh/hTC2pRcpN/sKGe3RmpsXZdV EHDY5lTwZmAwI6LAITnxjlYrI4qawkEUp/5mUrgo55moCBCmrmWKaHmswrL9y7u3V+jD 7sYeNMJLG0V+29XPkUElq7EDnlg0TtcMcxhHUnT4fVLAtY5nFxPkKzcbOqEo0kRZpC2u hXhJnEwykblRTx5AYkiekj7Hghsm0zBd3bVnyEz+lgsn+SxMH9qoIh2K8DDanDGJ3bxE /rIQ== 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=QELOMD8TfreaLGHZaYVaA9bALPNNOvW2pLQ+CoFe/ZE=; b=ynM7Hxdcj5WlvKCnSPlSsiYx+U/qFjyQOewPVRIL6lGka9U+ZYpOmQnQREUe8kJESJ BPFGZEHF3dQyrgSRNnj5FPQ2g/NDgr3tPUN3gQhqY/LM3H+S+i8zf6+pc1a0pIJ6bBdn CBeysvZZLbSphfxVb3Pn9vaSFKVuLQhWWKFqcYHTeAXLac3oX5E/4U/zO/AYhegRUPys a5lSNGNB8dOhbtcwiLIkddTPxA893GwJRNB9Fb9Vi52yl3qdlvQ4R3swQyNmiEX9c+lC /Le7BNoGWNUI044ypWPOgpqaXcGu46iW5iVtlnSqG1ZXazqrdFUebR4xDmds4cWcv2L+ 9ZQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NXNfigyk; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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. [198.145.21.10]) by mx.google.com with ESMTPS id v5-v6si15585932pfe.63.2018.05.22.07.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:09:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NXNfigyk; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 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 0384E203BBBA8; Tue, 22 May 2018 07:09:13 -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:c0c::243; helo=mail-wr0-x243.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::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 B2870203BBB9D for ; Tue, 22 May 2018 07:09:11 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id 94-v6so20443425wrf.5 for ; Tue, 22 May 2018 07:09:11 -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=dJb7Uzr4P2g7MxLj0zkOrlo4J97LJz22TQl6IDozbG8=; b=NXNfigykrQClJ+euBUD4Myi97IaB8LfAFkwa9TqBolm3RaaWBi/9GYKEedufBL9gf9 hOPcERCEM3TCH8+d31fmiZET6hX/ALj7qF+IeePL3ey1X30KFNL/NQRELkKN0YHo6a/J 52V7baOmJ+aKhcWmR/UbZVZy/tt9/bVf6+nXQ= 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=dJb7Uzr4P2g7MxLj0zkOrlo4J97LJz22TQl6IDozbG8=; b=CR4wxfg+UMhp1K0MwCMgXkvBaSpbu5Xs6QX+ZS4cwhoczhvafPjJZEajdrbp0Rhcd6 dVfbhDgH2tEAYy5/+zXjILmtutvb7tLDCGnWeDSTM6w0fTv3ftowYbJdmERkfJBgn9HC 8K2MlX+0c26EAlSsufo8goAYxG7R2ixPGSs2R7QwDfJ/NuCq5enggFjtH+YtJUSS0U9V sLB0WY/mUi/2T/uyCIfhSlLZcmJqrFvqdJah6UpOGQYqrALrq12X/4QWjfoVxEbi7UAd 4xAK5ikZc0x9MHbWfi/e7JH0cTqr8TGGDCz62/rGckjNvzjsBjrtzQ5SuBLgXzMTMQeN UTrw== X-Gm-Message-State: ALKqPwcu8M5YhwIPhJBkJhp6dxh9CGDQ0U6FTo/H//+/mcF771XTYdGz dJRXftdzHRGfQ7pDxS8StDuWskiZfcg= X-Received: by 2002:adf:b852:: with SMTP id u18-v6mr1020633wrf.162.1526998149980; Tue, 22 May 2018 07:09:09 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:3995:5470:200:1aff:fe1b:b328]) by smtp.gmail.com with ESMTPSA id r6-v6sm17755545wrg.73.2018.05.22.07.09.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:09:09 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 22 May 2018 16:08:50 +0200 Message-Id: <20180522140850.30369-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180522140850.30369-1-ard.biesheuvel@linaro.org> References: <20180522140850.30369-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 6/6] MdeModulePkg/FirmwarePerformanceDataTableDxe: use EfiAllocatePeiAccessiblePages 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 EfiAllocatePeiAccessiblePages, 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 --- MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c | 50 ++++---------------- 1 file changed, 8 insertions(+), 42 deletions(-) -- 2.17.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c index e719e9e482cb..6663cbeac501 100644 --- a/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c +++ b/MdeModulePkg/Universal/Acpi/FirmwarePerformanceDataTableDxe/FirmwarePerformanceDxe.c @@ -179,46 +179,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 +247,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 *) EfiAllocatePeiAccessiblePages ( + 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 +331,10 @@ InstallFirmwarePerformanceDataTable ( // // Fail to allocate at specified address, continue to allocate at any address. // - mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) FpdtAllocateReservedMemoryBelow4G (BootPerformanceDataSize); + mAcpiBootPerformanceTable = (BOOT_PERFORMANCE_TABLE *) EfiAllocatePeiAccessiblePages ( + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (BootPerformanceDataSize) + ); } DEBUG ((DEBUG_INFO, "FPDT: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable)); if (mAcpiBootPerformanceTable == NULL) {