public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Oliver Smith-Denny" <osde@linux.microsoft.com>
To: devel@edk2.groups.io, nhi@os.amperecomputing.com,
	Ard Biesheuvel <ardb@kernel.org>
Cc: huangming@linux.alibaba.com, Sami Mujawar <sami.mujawar@arm.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Jiewen Yao <jiewen.yao@intel.com>,
	Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
	ming.huang-@outlook.com
Subject: Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
Date: Fri, 1 Sep 2023 13:43:21 -0700	[thread overview]
Message-ID: <ab896d2b-a9f4-44c2-9d51-c400163e274c@linux.microsoft.com> (raw)
In-Reply-To: <d864e17a-524f-66e7-5f5c-3e5f1c2f6c79@amperemail.onmicrosoft.com>

On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote:
> 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@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@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?
> 

If I am understanding this correctly, this is only an issue when
HOBs are created in StMM, i.e. not from HOBs that are passed in. Is this
correct?

If so, is HOB creation in StMM and supported use case? The only instance
a quick search turns up is the ARM StMM Core entry, where some
information from TF-A is converted to HOB format. Do we have any other
use cases (and curious more on this use case). My thought process would
be that StMM would not create any HOBs. Depending on FW configuration,
it may receive HOBs from PEI.

In PEI/DXE to StMM communication, we should be using the
MM_Communicate interface.

But in StMM to StMM communication, I would expect we would go through
interfaces like protocols, PCDs, or UEFI variables. Any reason for HOBs
that I'm not thinking of? I'm wondering if the answer here is to
address what seemingly is one (or a very small set) of use cases and
remove the HOB creation code in StMM altogether.

Thanks,
Oliver


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108232): https://edk2.groups.io/g/devel/message/108232
Mute This Topic: https://groups.io/mt/89020085/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-09-01 20:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-09 12:25 [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
2022-02-09 12:25 ` [PATCH v1 1/2] StandaloneMmPkg/Hob: Assert or return NULL for create hob failed Ming Huang
2022-02-09 12:25 ` [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue Ming Huang
2022-05-03  9:10   ` Ard Biesheuvel
2022-05-12 10:09     ` [edk2-devel] " Ming Huang
2023-08-16  8:55       ` Nhi Pham via groups.io
2023-08-30 13:10         ` Ard Biesheuvel
2023-08-31  8:20           ` Nhi Pham via groups.io
2023-09-01 20:43             ` Oliver Smith-Denny [this message]
2023-09-05  2:20               ` Nhi Pham via groups.io
2023-09-05 21:29                 ` Oliver Smith-Denny
2023-09-06  6:33                   ` Ni, Ray
2023-09-06  6:56                     ` Ard Biesheuvel
2023-09-06  7:55                     ` Nhi Pham via groups.io
2023-09-06  8:50                       ` Ard Biesheuvel
2023-09-06 16:22                         ` Oliver Smith-Denny
2023-09-07 15:38                           ` Nhi Pham via groups.io
2023-11-30 13:59                             ` Nhi Pham via groups.io
2023-12-01  5:29                               ` Ni, Ray
2023-09-06  7:35                   ` Nhi Pham via groups.io
     [not found]       ` <177BD141FD103BE4.8497@groups.io>
2023-08-29  2:48         ` Nhi Pham via groups.io
2022-03-30  9:35 ` [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang

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=ab896d2b-a9f4-44c2-9d51-c400163e274c@linux.microsoft.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