From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AB8JxZpZ9xHdJLJpnAiXIcENgqW4W5CKv0dWyZI6Zv8zfD8WOv8PMxmGq/Ynfgsmf1s+qsTUc5o2eA== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Michael D Kinney , Liming Gao , Star Zeng , Eric Dong , Dandan Bi 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: [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: , X-List-Received-Date: Thu, 24 May 2018 09:09:59 -0000 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(-) 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)); -- 2.17.0