[edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue

Nhi Pham via groups.io nhi=os.amperecomputing.com at groups.io
Thu Aug 31 08:20:25 UTC 2023


Hi Ard,

Thanks for your response on this patch. Please see my reply inline...

On 8/30/2023 8:10 PM, Ard Biesheuvel wrote:
> [EXTERNAL EMAIL NOTICE: This email originated from an external sender. Please be mindful of safe email handling and proprietary information protection practices.]
>
>
> On Wed, 16 Aug 2023 at 10:56, Nhi Pham <nhi at amperemail.onmicrosoft.com> wrote:
>> Hi Ard and Ming,
>>
>> I have been seeing an issue with StandaloneMM HobLib that can be fixed
>> by this patch as well.
>>
>> The function CreateHob() in the HobLib instance
>> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCoreHobLib.inf
>> does not work at all. The HobList is early created by the
>> StandaloneMmCoreEntryPoint then it is relocated on the heap memory by
>> StandaloneMmCore. But the FreeMemoryTop and FreeMemoryBottom are not
>> updated accordingly and the HOB free memory top is overlapped with the
>> heap space. This causes the CreateHob() function to not work as
>> expected. Introducing the PcdMemoryHobSize is reasonable to fix this issue.
>>
>> I tested this patch in my end.
>>
>> Tested-by: Nhi Pham <nhi at os.amperecomputing.com>
>>
> Thanks for reminding me.
>
> So if the HOB creation is completely broken, are we sure this is the
> correct fix? Wouldn't it be better to update FreeMemoryTop and
> FreeMemoryBottom to the correct values?

Per your question, I had a deep dive into the HOB today. I think I need 
to clarify further the issue to make sure that we are on the same page.

1. When the base of the HOB list (HobStart) is reallocated in the MM 
heap memory, the Hob->EfiEndOfHobList must be adjusted accordingly 
compared to the new HOB base. Currently, we are missing that. That 
causes the CreateHob() function does not work. The GetNextHob() function 
always look up the old HOB list instead of the new HOB list.

2. The Memory Allocation StandaloneMmPkg/Core/Page.c does not update the 
Hob->EfiFreeMemoryTop, this may cause the MM heap space and HOB space to 
be overlapped at some points.

It sounds like the issue on the memory allocation in StandaloneMM. For 
#1, I think we should write a new patch for it. For #2, could you advise?

Thanks,

-Nhi



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108185): https://edk2.groups.io/g/devel/message/108185
Mute This Topic: https://groups.io/mt/89020085/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list