From patchwork Tue May 22 14:08:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 136552 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1683122lji; Tue, 22 May 2018 07:09:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpwlm8YFX+P7uRSkWp+kQPGoYLTZn3YBmZISEETVJ8K6TumyIDiM+qzNxcErQyDofO2mlT2 X-Received: by 2002:a17:902:6181:: with SMTP id u1-v6mr24521007plj.272.1526998155255; Tue, 22 May 2018 07:09:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526998155; cv=none; d=google.com; s=arc-20160816; b=Qc1V6HVWi9pKdLn+y7OqhBmvy/rQtUgg6Lryo9W+mt5zy7J8RvGOAvDUA6q9uvat3e ICajqsEhnEWVwwzG9Fqp7zXpJ107yIF6HdDwhvZ1092GN0M7219MgvzGu34pFKYHEDMs fvmB0/FxSmOGd4DyTBxYPPrvS10kb3qLrurAmLVyFM7R/7/xo9+t2Eon9sNPVuUu4COj H4DRbJtYKdeNzdv5OdxmswdgC7IFuTiGufMrWq46AJ2kUlC6IMWuj7HyJA5DoX3QFyPr zTryOVuiDJ1h+dowq5/LkuBAXEP6J98QqhhAeaiWEwiCVcGZprl0zDZlxmEnu9qMS9QT RrFw== 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=7PrGUR/Q8Mpjn5BI+HzTvRc/0EGleJp3RHsHwG/lSB0=; b=c2QfFTn94FQ/C5xDeN75QVE/NZSiKtkg5TFwnMpdIdO+QsNpd6chqkal+dykiMMjpF gxLQWSIFekjd9cyu/t5/xjy0ZgqHIhDiKdrIQHkvQOZX6Ad7ez4oQcbiJenf/SrjV98d 342n9H7JYhLWpmGWrt3oEdCicf9Gup9Mp8qZCNFFT4BWaDROWwcGHZxdVYJI86pnoYaQ O72ruHraxU3huVtlmsboZe095Jfv/o6+GiHoSGpzDbu4Pjhr3v4SniKxDZRKTEYSjZPk I1QUsV4rw2KI82ZKLpGSSQZp52Cw+O+pp2TJMsktzCIaURjh3m+cnYY23IL9xtr9eFij dGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=A7JxjQFs; 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 t24-v6si16291357pfj.231.2018.05.22.07.09.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:09:15 -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=A7JxjQFs; 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 CBE35203BBB81; Tue, 22 May 2018 07:09:10 -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 310C1203BA517 for ; Tue, 22 May 2018 07:09:09 -0700 (PDT) Received: by mail-wr0-x243.google.com with SMTP id i12-v6so7289949wrc.4 for ; Tue, 22 May 2018 07:09:09 -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=qTkV/oPWWertT8HQ/H30NgTe8FFSj3CzCejtUi6pTds=; b=A7JxjQFszCvmLGll3UHVW+RU5LJx9zHfOXjD8hfNV91ysQffQyp+mfOTSS4wvjh1mn 2NOSWpjOnDXSst4dVU6Be7kQqQWX8phrbrzB0JMGVDroqDyWUHL/uhtY4S2rFnFeixsV xom0WNAALTZ2YvCdUACExPWDGYa5nmIyaYfag= 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=qTkV/oPWWertT8HQ/H30NgTe8FFSj3CzCejtUi6pTds=; b=cb+tCZXK+0Gp6/ntmor++pGCa4Dn8rNG/wemoHraPaHRKt7WSw8W1Jzthm6HvEg8HT kDjGQvq1YrX1fauQjVATzsfNR6Hawo9TZYWBoXYHq03UJhcarW9HvQCVsLyjqCysDClQ rGGCjkxcteETCoCoeNlKvYydIFeO3+ky+NJ4s/Z0g7tk9RRIEVsHky4CfSuMkAVQuPqs MGh7RQ4lIQpD6FTOeK3K8vs91uaMrI2Qfdbng3gYgF3gnoTRehykoodJ0eqD6J8Yyjto Yi1UE8GzZGpOOxo1XiQ18Y4geyBILhIEDfKMCZD4yZvjmxRvTOZz9iwccbbTtV7/9uS2 QtVg== X-Gm-Message-State: ALKqPwdiUwbniNC3HJp84HpOHd0c1I7+XJqw7U3QrOsX1MRwQ66S5tyn x5peUIZKW+9bIPFtV03nZqDMn0hFrgw= X-Received: by 2002:adf:9301:: with SMTP id 1-v6mr5015571wro.175.1526998147587; Tue, 22 May 2018 07:09:07 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 07:09:07 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 22 May 2018 16:08:49 +0200 Message-Id: <20180522140850.30369-6-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 5/6] MdeModulePkg/DxeCorePerformanceLib: 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/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 diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index 71d624fc9ce9..301ea4c32a78 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 *) EfiAllocatePeiAccessiblePages ( + EfiReservedMemoryType, + EFI_SIZE_TO_PAGES (BootPerformanceDataSize) + ); } DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: ACPI Boot Performance Table address = 0x%x\n", mAcpiBootPerformanceTable));