From patchwork Mon May 28 14:40:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 137085 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2909022lji; Mon, 28 May 2018 07:40:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoVvlXmiGOuiXVhP5ybrf4a9mHBT6Zuy2oUNdGIDRyzr+T3AI4AoQDaMJ9u6OpPghGzlpPU X-Received: by 2002:a17:902:7686:: with SMTP id m6-v6mr14009541pll.340.1527518445101; Mon, 28 May 2018 07:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527518445; cv=none; d=google.com; s=arc-20160816; b=is30NVY/W4FYP0L+2w5x6b/+ff11LrNsOPNpATDCAPFs9OuB+7ED2f7z6Q6yydiHur JM4b/RKFZust1MJv0aBkQa6hzVikVdLiZND18vYrKgQWQwo/aULq2V5+AYQuOJNy0Naf jCH+8OW1mFRyRXv079cYw0dqNbDXu/o20Y8VhQwkPiq9Voy2s4vHZ3KpCQO6npzGSgeA IROZ/IE7kYjAoFpz30ZuQENaAu+NHimmp0Fo7ruRR0z4znSfrMWR7M4YvT7jH8v7iJD9 Inim0Rnc94GxVPlC0QFQLbmc2N01533h6v3wJYbBIJTu0r2wWieGxkebjAHz7V3BS1/4 fcJg== 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=FZw/QAR9EyKwKsv691Caa/oM9dCTw4XYDXwAxE9Nytg=; b=SxMc41MThh1WJYAHKSeGYu3rFpyU8wqPjA8sXg1h5NyNMAPlFhQpWtBm9bhjlKCb8y 8LWO8TULWdkMF+RlkL2DsRd/oM2BiqdJa41xiMRjjKTWlBfKO0saDZMJNgTNNqB4UkMe Gkpl5AQrWe9DBGJoikbr1wNFm/Ak0xbydM4ShBkjIVeUxl1h4AgEgOPvC++3D3OpQP0/ cE9vkW+aS4LmhZjnC1NbT+3eMkTKzVGkEWKpvQstH3U6Rt8mcpVAwpjvsRsXfHXFJIq8 0+mRrUbxw6YuYtCQA9jx6db1nn1fWtvAKNpO/RAJKUMR5EMneFt8w1sMyTRVUCd5xyNi gRVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Up/RJK47; 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 b2-v6si24373588pgc.569.2018.05.28.07.40.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:45 -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=Up/RJK47; 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 A83E020971743; Mon, 28 May 2018 07:40:38 -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 730592007E7EA for ; Mon, 28 May 2018 07:40:37 -0700 (PDT) Received: by mail-wm0-x243.google.com with SMTP id f6-v6so32744573wmc.4 for ; Mon, 28 May 2018 07:40:37 -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=/JEKeo7S/737rZrZeZuXQkl9OAczJ86VGCjE1eeWUIA=; b=Up/RJK47oDFE/H6Qqai9BP4SuOp/6kurwIAnZDXVyApboCmn5MgHcXvTulqf/8p+Rh D2u5/QjWUVsYIcasVn9Lqfn0gF8pSfNgNwRUmKdZl14eSJDtjdBL/LWEJKWnV3PBGWAn ryUrzOioIL2NPUD5o0w6cyJt1fDiZzrIJapOM= 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=/JEKeo7S/737rZrZeZuXQkl9OAczJ86VGCjE1eeWUIA=; b=SXYcvtPunWGVau4xrBBWwol/C92m6a9S0D2GnKcV6y2NwSZROBaow4tspCt7vj2dor UOE+h2Ws1ueGrGXwE29lKuj0hpkUcSG57C2X7W7JCgK1cNEyA39IUevtioIKpMkIjeYV ldWtaVgoU4Zt7RXRhU1jLHWIxmM11rujQFK3ed6MJ3dRj0BA6Biv8PcTezVGFkXQjBm2 qUfGgrGRNR9IiOMqmISVHy2WeNugHOw2XO3a6VQUT9Oc1X5a/gG4g5IB/5FW/uWBphpC ucPoade8JSZe/9MlqtYK3KV0+qtJNeYlWZaOjHVHJL1YwCrTQfzHpYQizpK8wpGNUOX8 bv9g== X-Gm-Message-State: ALKqPwfwBTxhVuQZZHtoVkoE1j0Etooz/BDll9r7NP5K0oi9ElaYssux LRm2JhTMfJeYLFe9Nea+qAANhVCYlnE= X-Received: by 2002:a1c:9c2:: with SMTP id 185-v6mr9033332wmj.53.1527518435737; Mon, 28 May 2018 07:40:35 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 May 2018 07:40:35 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Mon, 28 May 2018 16:40:23 +0200 Message-Id: <20180528144024.10809-5-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 4/5] MdeModulePkg/DxeCorePerformanceLib: 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/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 48 +++----------------- 1 file changed, 7 insertions(+), 41 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/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 71d624fc9ce9..68b29ac5a9e2 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -165,46 +165,6 @@ IsKnownID ( } } -/** - 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; -} - /** Allocate buffer for Boot Performance table. @@ -348,7 +308,13 @@ AllocateBootPerformanceTable ( // // 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) + ); + if (mAcpiBootPerformanceTable != NULL) { + ZeroMem (mAcpiBootPerformanceTable, BootPerformanceDataSize); + } } DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));