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: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-Google-Smtp-Source: AB8JxZoiwg5U4Y90KH1r9FFtwNc31JIIkEim5g4wuOe6Fa1lcwxI0rbKf/l9iGsGnXVb+9f14JJ7ZA== 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 Cc: Ard Biesheuvel , Laszlo Ersek , Leif Lindholm , Michael D Kinney , Liming Gao , Star Zeng , Eric Dong , Dandan Bi 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: [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: , X-List-Received-Date: Tue, 22 May 2018 14:09:09 -0000 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(-) 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)); -- 2.17.0