On 1/22/2024 11:52 AM, Rebecca Cran wrote:
I've been working on updating the T32 script EfiLoadDxe.cmm in EmbeddedPkg/Scripts/LauterbachT32 and one of the issues I've run into is that the EFI_SYSTEM_TABLE - pointed to by `gST` and `gDxeCoreST` - isn't aligned to 4KB like the script expects.

Instead, I'm seeing AllocateRuntimeCopyPool return 0xFB7D0018 in MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c:

//
// Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
//
gDxeCoreST = AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
ASSERT (gDxeCoreST != NULL);

I'm wondering which is wrong: should AllocateRuntimeCopyPool be returning a 4KB-aligned pointer, or is the script's assumption wrong?



Allocating pool memory will never be 4KB aligned because of the
POOL_HEAD. See: https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Mem/Pool.c#L463-L537.

The allocated page is 4KB aligned, of course, but we store the POOL_HEAD
at the beginning of that page and return Head->Data to the caller.

In addition, this is only in the case where you allocate a new page for
the pool. In the case where the pool has the pages it needs, you don't
have any alignment guarantee, I believe, it is just offset further
into one of the already allocated pages.

Oliver


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#114147): https://edk2.groups.io/g/devel/message/114147
Mute This Topic: https://groups.io/mt/103894456/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to