From: "Gaurav Jain" <gaurav.jain@nxp.com>
To: devel@edk2.groups.io
Cc: Eric Jin <eric.jin@intel.com>,
Supreeth Venkatesh <Supreeth.Venkatesh@arm.com>,
Prasanth Pulla <Prasanth.Pulla@arm.com>,
Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@arm.com>,
G Edhaya Chandran <Edhaya.Chandran@arm.com>,
Ard Biesheuvel <ard.biesheuvel@arm.com>,
Pankaj Bansal <pankaj.bansal@nxp.com>,
Gaurav Jain <gaurav.jain@nxp.com>
Subject: [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code
Date: Sat, 2 May 2020 19:23:04 +0530 [thread overview]
Message-ID: <1588427584-31684-1-git-send-email-gaurav.jain@nxp.com> (raw)
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
next reply other threads:[~2020-05-02 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-02 13:53 Gaurav Jain [this message]
2020-05-04 18:06 ` [edk2-devel] [edk2-test PATCH v2] SctPkg: Updated Start Address Alignment code edhaya.chandran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1588427584-31684-1-git-send-email-gaurav.jain@nxp.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox