.../BlackBoxTest/MemoryAllocationServicesBBTestFunction.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2671
AllocatePages Functionality test.
Existing Code Increase Start address by 64k,
even if Start is already aligned to 64k.
Suggested Change will not modify Start,
if Start is already aligned to 64k
For Eg.
Available Memory(Start is aligned to 64k):
Start End PageNum(Free Pages)
80000000 EBD6EFFF 6BD6F(Number of Free pages are not 64k Aligned)
edk2-test code:
Start is increased & aligned by 64k(Equal to 16 pages of size 4k each).
Request for Pagenum is minus by 16 Pages.
Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000
Start = (0x80000000 + 0x10000) & 0xFFFFFFFFFFFF0000 = 0x80010000
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000) = 0x6BD6F - 0x10 = 0x6BD5F
edk2 memory allocation code to Align the requested pages to 64k boundary:
------------------------------------------------------------------------
NumberOfPages += EFI_SIZE_TO_PAGES(Alignment) - 1 = 0x6BD5F + 0xF = 0x6BD6E
NumberOfPages &= ~(EFI_SIZE_TO_PAGES(Alignment) - 1) = 0x6BD6E & 0xFFFFFFF0
= 0x6BD60
We can observe that requested pages is incraesed by 1 page,
which results in below error.
ConvertPages: range 80010000 - EBD6FFFF covers multiple entries.
Signed-off-by: Gaurav Jain <gaurav.jain@nxp.com>
---
Notes:
v2
Updated Commit Message with an Example
.../BlackBoxTest/MemoryAllocationServicesBBTestFunction.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c
index d18fe1f..a42cd9a 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MemoryAllocationServices/BlackBoxTest/MemoryAllocationServicesBBTestFunction.c
@@ -706,7 +706,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start;
@@ -836,7 +836,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start;
@@ -959,7 +959,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start + (SctLShiftU64 (PageNum/3, EFI_PAGE_SHIFT) & 0xFFFFFFFFFFFF0000);
@@ -1082,7 +1082,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start + (SctLShiftU64 (PageNum * 2 / 3, EFI_PAGE_SHIFT) & 0xFFFFFFFFFFFF0000);
@@ -1212,7 +1212,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start;
@@ -1335,7 +1335,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start;
@@ -1474,7 +1474,7 @@ BBTestAllocatePagesInterfaceTest (
if (PageNum <= 0x10) {
break;
}
- Start = (Start + 0x10000) & 0xFFFFFFFFFFFF0000;
+ Start = (Start + 0xFFFF) & 0xFFFFFFFFFFFF0000;
PageNum = PageNum - EFI_SIZE_TO_PAGES(0x10000);
Memory = Start;
--
2.7.4
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#58531): https://edk2.groups.io/g/devel/message/58531
Mute This Topic: https://groups.io/mt/73935158/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#58565): https://edk2.groups.io/g/devel/message/58565 Mute This Topic: https://groups.io/mt/73935158/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.