From patchwork Thu May 24 09:09:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 136724 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1938414lji; Thu, 24 May 2018 02:10:05 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqReNUWjcIbr4QrBVI0pnkKh2j+GmPj7BcB+UwfJdn1HyIgqI3F41rwotHU1Hf0Iew9VedK X-Received: by 2002:a65:510c:: with SMTP id f12-v6mr5057816pgq.385.1527153004858; Thu, 24 May 2018 02:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527153004; cv=none; d=google.com; s=arc-20160816; b=mQUbihnuwpJlOAUznxbhnIjt7P9SVWkdfy2xiVEuVjFCNCr2/w5HNUd4KvRzIv5OFJ WM+fg9MGnWHzmpxWcFg1k+HCm196dtSxHjDr4vd8+M/ZL9NfGekcLgsHoD13Y7NqWtjH tZpfXhLXPQWbMvfpbBa6yo7LfqGERT51FB43x2K3A7PDL6oixKTuBJJXECX2yBPmyQOQ e24WiexrEFPxMsErUb5ymAJpW9CaaC+OFe7kSU9TI3xuIl/ayplRjZqSmwORg3Ei3oF7 P5vkpNtP4lVd1jqkEwWt+aF3xel9WLZGVwI6CrqmGi6/9KpLNn53YYpX3nSBrHHFsW65 t6bQ== 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=ZCy1DnyedmdGeiHV2EKLk7ZCmQVbWY4w4BlkD9TVQVY=; b=TxzCh6t0iYdxJEtz0DXGx3fsZjC6nuhOvYc+Gf5WiYgfWGt9TCRYIrq2v6oUp00huU ODvqL0eCTIsGpxnPf7DP6vx1jdbb/D/maUvI8NyE9WaiGl4GzudMjbTcwkt1cIHvzOfV xiCi7l0RJi0y2FnYQJYQJb3s0rS8wz3Nb/x/8V1AUNe75xrV7DqPQ7rzMS9OGhsoDBRw XW9DWWXHw+Bu5ldiEOakYsezPZp79vpkLoMylJ2bn5dGHoZXE/sDcrKxPNU87TKbXinz wVxJ2Abjxed/cvbqbtY2vv3Con3ygmGzemwc5QKCNiNNbf38zx3rfNZNlYhqbzh0ikvE moSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=McaetZ7b; 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 l187-v6si16181208pgl.485.2018.05.24.02.10.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:10:04 -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=McaetZ7b; 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 1EB4E20837994; Thu, 24 May 2018 02:10:00 -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::244; helo=mail-wm0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) (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 27B7C207E6376 for ; Thu, 24 May 2018 02:09:59 -0700 (PDT) Received: by mail-wm0-x244.google.com with SMTP id q4-v6so6983818wmq.1 for ; Thu, 24 May 2018 02:09:59 -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=rPtjPPs2OePpENhEcYxjOGfJODA/j7FNSfkyH+YwQWM=; b=McaetZ7bWeccHcj3stZ8Ushaxsr4mfXqfolUZIDAuhSZ69VKfp25CzrKH+rX9LQQei NsEV8WByDIDpELwULmAAnB9H+EgAaJp2rIoXGOv3p3CeTy/c67tvYfdDanEpzQHKdLuN 4/VnpPVl0Rq4y2eX7TRiH6eo81zRs2qQVlnY0= 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=rPtjPPs2OePpENhEcYxjOGfJODA/j7FNSfkyH+YwQWM=; b=KDnAYUzjMjdeTY8NRzcg53tI9BT/nM/isvXg2bPeSkyETx5US4JQYE8+F2iFo9PngG 8fjyXcJiLIE/FWIrFYDdP6mTeouinW0GS4/Slqtt6A5bmsFntawSsmdwCdWbKYJj/uMs uKM431iUGgZa78wypjYzhkEgyNYsvvQlRdOukN+Hb1AJcCCNwOSFjJXwmyYnuU0BYsu3 2SfEOEz9r029vp6a4jXF/BFmCz7PyLaSYLJOEoJtygdN0do9oqXjVsOYWjSuS3p22gNp GzRJOD/J+ocWBsOoPAkakGd8F00sibcqXpO7vxsGo9bAtf/OerasVdlbrVGDz81qjJk/ a+TQ== X-Gm-Message-State: ALKqPweJVMUeZEW8g1pkvadA0ZfUYmqUWOFpBuALJptmt6VEurwYyoiZ xY5rc9nREWo0ZzEQSBIW3U+cPwEf1yw= X-Received: by 2002:a1c:d809:: with SMTP id p9-v6mr7249555wmg.6.1527152997297; Thu, 24 May 2018 02:09:57 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 02:09:56 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Thu, 24 May 2018 11:09:44 +0200 Message-Id: <20180524090945.10289-5-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 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: 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 the subsequent CopyMem() call supersedes it immediately. MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c | 45 ++------------------ 1 file changed, 4 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: Laszlo Ersek diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 71d624fc9ce9..b1f09710b65c 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,10 @@ 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) + ); } DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));