* [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code
@ 2020-05-02 13:53 Gaurav Jain
2020-05-04 18:06 ` [edk2-devel] " edhaya.chandran
0 siblings, 1 reply; 2+ messages in thread
From: Gaurav Jain @ 2020-05-02 13:53 UTC (permalink / raw)
To: devel
Cc: Eric Jin, Supreeth Venkatesh, Prasanth Pulla,
Samer El-Haj-Mahmoud, G Edhaya Chandran, Ard Biesheuvel,
Pankaj Bansal, Gaurav Jain
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-devel] [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code
2020-05-02 13:53 [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code Gaurav Jain
@ 2020-05-04 18:06 ` edhaya.chandran
0 siblings, 0 replies; 2+ messages in thread
From: edhaya.chandran @ 2020-05-04 18:06 UTC (permalink / raw)
To: Gaurav Jain, devel
[-- Attachment #1: Type: text/plain, Size: 58 bytes --]
Reviewed-by: G Edhaya Chandran <edhaya.chandran@arm.com>
[-- Attachment #2: Type: text/html, Size: 406 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-04 18:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-02 13:53 [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code Gaurav Jain
2020-05-04 18:06 ` [edk2-devel] " edhaya.chandran
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox