* [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue
@ 2022-02-09 12:25 Ming Huang
2022-02-09 12:25 ` [PATCH v1 1/2] StandaloneMmPkg/Hob: Assert or return NULL for create hob failed Ming Huang
` (2 more replies)
0 siblings, 3 replies; 22+ messages in thread
From: Ming Huang @ 2022-02-09 12:25 UTC (permalink / raw)
To: devel, sami.mujawar, ardb+tianocore, jiewen.yao,
supreeth.venkatesh
Cc: ming.huang-, Ming Huang
Fix two issues in StandaloneMmPkg HOB.
Ming Huang (2):
StandaloneMmPkg/Hob: Assert or return NULL for create hob failed
StandaloneMmPkg: Fix HOB space and heap space conflicted issue
StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
.../Arm/StandaloneMmCoreHobLib.c | 6 ++++++
.../StandaloneMmHobLib/StandaloneMmHobLib.c | 3 +++
StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
5 files changed, 30 insertions(+), 1 deletion(-)
--
2.17.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v1 1/2] StandaloneMmPkg/Hob: Assert or return NULL for create hob failed
2022-02-09 12:25 [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
@ 2022-02-09 12:25 ` Ming Huang
2022-02-09 12:25 ` [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue Ming Huang
2022-03-30 9:35 ` [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
2 siblings, 0 replies; 22+ messages in thread
From: Ming Huang @ 2022-02-09 12:25 UTC (permalink / raw)
To: devel, sami.mujawar, ardb+tianocore, jiewen.yao,
supreeth.venkatesh
Cc: ming.huang-, Ming Huang
The rare case (create hob failed) should be considered. Assert for
StandaloneMmCoreHobLib and return NULL for StandaloneMmobLib.
Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
---
StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c | 6 ++++++
StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c | 3 +++
2 files changed, 9 insertions(+)
diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
index 1550e1babc..d27e5ceaa4 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/Arm/StandaloneMmCoreHobLib.c
@@ -89,6 +89,7 @@ BuildModuleHob (
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
+ ASSERT (Hob != NULL);
CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
@@ -167,6 +168,7 @@ BuildGuidHob (
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ ASSERT (Hob != NULL);
CopyGuid (&Hob->Name, Guid);
return Hob + 1;
}
@@ -226,6 +228,7 @@ BuildFvHob (
EFI_HOB_FIRMWARE_VOLUME *Hob;
Hob = CreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
+ ASSERT (Hob != NULL);
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -255,6 +258,7 @@ BuildFv2Hob (
EFI_HOB_FIRMWARE_VOLUME2 *Hob;
Hob = CreateHob (EFI_HOB_TYPE_FV2, sizeof (EFI_HOB_FIRMWARE_VOLUME2));
+ ASSERT (Hob != NULL);
Hob->BaseAddress = BaseAddress;
Hob->Length = Length;
@@ -282,6 +286,7 @@ BuildCpuHob (
EFI_HOB_CPU *Hob;
Hob = CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
+ ASSERT (Hob != NULL);
Hob->SizeOfMemorySpace = SizeOfMemorySpace;
Hob->SizeOfIoSpace = SizeOfIoSpace;
@@ -319,6 +324,7 @@ BuildMemoryAllocationHob (
);
Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
+ ASSERT (Hob != NULL);
ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
diff --git a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
index ee61bdd227..4acd44ceb3 100644
--- a/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
+++ b/StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.c
@@ -396,6 +396,9 @@ BuildGuidHob (
ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16)(sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ if (Hob == NULL) {
+ return NULL;
+ }
CopyGuid (&Hob->Name, Guid);
return Hob + 1;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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 ` Ming Huang
2022-05-03 9:10 ` Ard Biesheuvel
2022-03-30 9:35 ` [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue Ming Huang
2 siblings, 1 reply; 22+ messages in thread
From: Ming Huang @ 2022-02-09 12:25 UTC (permalink / raw)
To: devel, sami.mujawar, ardb+tianocore, jiewen.yao,
supreeth.venkatesh
Cc: ming.huang-, Ming Huang
The heap space will be rewrote if a StandloneMmPkg module create HOB
by BuildGuidHob() interface and write data to HOB space.
Add a PCD PcdMemoryHobSize for pre-allocation a space to create HOB to
fix this issue.
Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
---
StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
index d221f1d111..1cf259d946 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.c
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
@@ -512,6 +512,9 @@ StandaloneMmMain (
EFI_MMRAM_DESCRIPTOR *MmramRanges;
UINTN MmramRangeCount;
EFI_HOB_FIRMWARE_VOLUME *BfvHob;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobNew;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobOrg;
+ UINT64 MaxHobSize = PcdGet64 (PcdMemoryHobSize);
ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
@@ -619,10 +622,22 @@ StandaloneMmMain (
//
HobSize = GetHobListSize (HobStart);
DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
- MmHobStart = AllocatePool (HobSize);
+ ASSERT (HobSize <= MaxHobSize);
+ MmHobStart = AllocatePool (MaxHobSize);
DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
ASSERT (MmHobStart != NULL);
CopyMem (MmHobStart, HobStart, HobSize);
+ //
+ // Initlialize the new HOB table
+ //
+ HandOffHobOrg = (EFI_HOB_HANDOFF_INFO_TABLE *)HobStart;
+ HandOffHobNew = (EFI_HOB_HANDOFF_INFO_TABLE *)MmHobStart;
+ HandOffHobNew->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)MmHobStart +
+ (HandOffHobOrg->EfiEndOfHobList - (EFI_PHYSICAL_ADDRESS)HobStart);
+ HandOffHobNew->EfiFreeMemoryBottom = HandOffHobNew->EfiEndOfHobList +
+ sizeof (EFI_HOB_GENERIC_HEADER);
+ HandOffHobNew->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS)MmHobStart + MaxHobSize;
+
Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
ASSERT_EFI_ERROR (Status);
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
index c44b9ff333..37e6135d73 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
@@ -76,6 +76,9 @@
gEfiEventExitBootServicesGuid
gEfiEventReadyToBootGuid
+[FixedPcd]
+ gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize
+
#
# This configuration fails for CLANGPDB, which does not support PIE in the GCC
# sense. Such however is required for ARM family StandaloneMmCore
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/StandaloneMmPkg.dec
index 46784d94e4..cf554676e2 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dec
+++ b/StandaloneMmPkg/StandaloneMmPkg.dec
@@ -48,3 +48,5 @@
gEfiStandaloneMmNonSecureBufferGuid = { 0xf00497e3, 0xbfa2, 0x41a1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
gEfiArmTfCpuDriverEpDescriptorGuid = { 0x6ecbd5a1, 0xc0f8, 0x4702, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
+[PcdsFixedAtBuild]
+ gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize|0x00000000|UINT64|0x00000004
--
2.17.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v1 0/2] Fix StandaloneMmPkg HOB issue
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-03-30 9:35 ` Ming Huang
2 siblings, 0 replies; 22+ messages in thread
From: Ming Huang @ 2022-03-30 9:35 UTC (permalink / raw)
To: devel, sami.mujawar, ardb+tianocore, jiewen.yao,
supreeth.venkatesh
Cc: ming.huang-
Hi,
Any comment about this series?
在 2/9/22 8:25 PM, Ming Huang 写道:
> Fix two issues in StandaloneMmPkg HOB.
>
> Ming Huang (2):
> StandaloneMmPkg/Hob: Assert or return NULL for create hob failed
> StandaloneMmPkg: Fix HOB space and heap space conflicted issue
>
> StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
> StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
> .../Arm/StandaloneMmCoreHobLib.c | 6 ++++++
> .../StandaloneMmHobLib/StandaloneMmHobLib.c | 3 +++
> StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
> 5 files changed, 30 insertions(+), 1 deletion(-)
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Ard Biesheuvel @ 2022-05-03 9:10 UTC (permalink / raw)
To: Ming Huang
Cc: edk2-devel-groups-io, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
On Wed, 9 Feb 2022 at 13:26, Ming Huang <huangming@linux.alibaba.com> wrote:
>
> The heap space will be rewrote if a StandloneMmPkg module create HOB
> by BuildGuidHob() interface and write data to HOB space.
Can you elaborate? What is supposed to happen and why, and what is
happening instead?
> Add a PCD PcdMemoryHobSize for pre-allocation a space to create HOB to
> fix this issue.
>
> Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
> ---
> StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
> StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
> StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
> 3 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
> index d221f1d111..1cf259d946 100644
> --- a/StandaloneMmPkg/Core/StandaloneMmCore.c
> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
> @@ -512,6 +512,9 @@ StandaloneMmMain (
> EFI_MMRAM_DESCRIPTOR *MmramRanges;
> UINTN MmramRangeCount;
> EFI_HOB_FIRMWARE_VOLUME *BfvHob;
> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobNew;
> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobOrg;
> + UINT64 MaxHobSize = PcdGet64 (PcdMemoryHobSize);
>
> ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
>
> @@ -619,10 +622,22 @@ StandaloneMmMain (
> //
> HobSize = GetHobListSize (HobStart);
> DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
> - MmHobStart = AllocatePool (HobSize);
> + ASSERT (HobSize <= MaxHobSize);
> + MmHobStart = AllocatePool (MaxHobSize);
> DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
> ASSERT (MmHobStart != NULL);
> CopyMem (MmHobStart, HobStart, HobSize);
> + //
> + // Initlialize the new HOB table
> + //
> + HandOffHobOrg = (EFI_HOB_HANDOFF_INFO_TABLE *)HobStart;
> + HandOffHobNew = (EFI_HOB_HANDOFF_INFO_TABLE *)MmHobStart;
> + HandOffHobNew->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)MmHobStart +
> + (HandOffHobOrg->EfiEndOfHobList - (EFI_PHYSICAL_ADDRESS)HobStart);
> + HandOffHobNew->EfiFreeMemoryBottom = HandOffHobNew->EfiEndOfHobList +
> + sizeof (EFI_HOB_GENERIC_HEADER);
> + HandOffHobNew->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS)MmHobStart + MaxHobSize;
> +
> Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
> ASSERT_EFI_ERROR (Status);
>
> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
> index c44b9ff333..37e6135d73 100644
> --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
> @@ -76,6 +76,9 @@
> gEfiEventExitBootServicesGuid
> gEfiEventReadyToBootGuid
>
> +[FixedPcd]
> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize
> +
> #
> # This configuration fails for CLANGPDB, which does not support PIE in the GCC
> # sense. Such however is required for ARM family StandaloneMmCore
> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/StandaloneMmPkg.dec
> index 46784d94e4..cf554676e2 100644
> --- a/StandaloneMmPkg/StandaloneMmPkg.dec
> +++ b/StandaloneMmPkg/StandaloneMmPkg.dec
> @@ -48,3 +48,5 @@
> gEfiStandaloneMmNonSecureBufferGuid = { 0xf00497e3, 0xbfa2, 0x41a1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
> gEfiArmTfCpuDriverEpDescriptorGuid = { 0x6ecbd5a1, 0xc0f8, 0x4702, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
>
> +[PcdsFixedAtBuild]
> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize|0x00000000|UINT64|0x00000004
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2022-05-03 9:10 ` Ard Biesheuvel
@ 2022-05-12 10:09 ` Ming Huang
2023-08-16 8:55 ` Nhi Pham via groups.io
[not found] ` <177BD141FD103BE4.8497@groups.io>
0 siblings, 2 replies; 22+ messages in thread
From: Ming Huang @ 2022-05-12 10:09 UTC (permalink / raw)
To: devel, ardb
Cc: Sami Mujawar, Ard Biesheuvel, Jiewen Yao, Supreeth Venkatesh,
ming.huang-
在 5/3/22 5:10 PM, Ard Biesheuvel 写道:
> On Wed, 9 Feb 2022 at 13:26, Ming Huang <huangming@linux.alibaba.com> wrote:
>>
>> The heap space will be rewrote if a StandloneMmPkg module create HOB
>> by BuildGuidHob() interface and write data to HOB space.
>
> Can you elaborate? What is supposed to happen and why, and what is
> happening instead?
I tried my best to explain the issue:
-----------------------------<--HandOffHob->EfiFreeMemoryTop
| |
| |
| |
| |
| |
| |
| mMmMemoryMap |
|---------------------------|<--HandOffHob->EfiFreeMemoryBottom
| HobEnd |
|---------------------------|<--HandOffHob->EfiEndOfHobList
| |
| Hob #1 |
-----------------------------<--MmHobStart
1 The mMmMemoryMap which use for free page is on above the HobEnd.
2 Create a hob by BuildGuidHob(), the HobEnd will move up and cover
the structure or list using by free page.
After this patch, there is a pre-allocation space for creating hob.
-----------------------------<--HandOffHob->EfiFreeMemoryTop
| |
| |
| |
| |
| mMmMemoryMap |
|---------------------------|<--HandOffHob->EfiFreeMemoryBottom
| Hob free space | by PcdMemoryHobSize
|---------------------------|
| HobEnd |
|---------------------------|<--HandOffHob->EfiEndOfHobList
| |
| Hob #1 |
-----------------------------<--MmHobStart
>
>> Add a PCD PcdMemoryHobSize for pre-allocation a space to create HOB to
>> fix this issue.
>>
>> Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
>> ---
>> StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
>> StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
>> StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
>> 3 files changed, 21 insertions(+), 1 deletion(-)
>>
>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
>> index d221f1d111..1cf259d946 100644
>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.c
>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
>> @@ -512,6 +512,9 @@ StandaloneMmMain (
>> EFI_MMRAM_DESCRIPTOR *MmramRanges;
>> UINTN MmramRangeCount;
>> EFI_HOB_FIRMWARE_VOLUME *BfvHob;
>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobNew;
>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobOrg;
>> + UINT64 MaxHobSize = PcdGet64 (PcdMemoryHobSize);
>>
>> ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
>>
>> @@ -619,10 +622,22 @@ StandaloneMmMain (
>> //
>> HobSize = GetHobListSize (HobStart);
>> DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
>> - MmHobStart = AllocatePool (HobSize);
>> + ASSERT (HobSize <= MaxHobSize);
>> + MmHobStart = AllocatePool (MaxHobSize);
>> DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
>> ASSERT (MmHobStart != NULL);
>> CopyMem (MmHobStart, HobStart, HobSize);
>> + //
>> + // Initlialize the new HOB table
>> + //
>> + HandOffHobOrg = (EFI_HOB_HANDOFF_INFO_TABLE *)HobStart;
>> + HandOffHobNew = (EFI_HOB_HANDOFF_INFO_TABLE *)MmHobStart;
>> + HandOffHobNew->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)MmHobStart +
>> + (HandOffHobOrg->EfiEndOfHobList - (EFI_PHYSICAL_ADDRESS)HobStart);
>> + HandOffHobNew->EfiFreeMemoryBottom = HandOffHobNew->EfiEndOfHobList +
>> + sizeof (EFI_HOB_GENERIC_HEADER);
>> + HandOffHobNew->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS)MmHobStart + MaxHobSize;
>> +
>> Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
>> ASSERT_EFI_ERROR (Status);
>>
>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>> index c44b9ff333..37e6135d73 100644
>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>> @@ -76,6 +76,9 @@
>> gEfiEventExitBootServicesGuid
>> gEfiEventReadyToBootGuid
>>
>> +[FixedPcd]
>> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize
>> +
>> #
>> # This configuration fails for CLANGPDB, which does not support PIE in the GCC
>> # sense. Such however is required for ARM family StandaloneMmCore
>> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/StandaloneMmPkg.dec
>> index 46784d94e4..cf554676e2 100644
>> --- a/StandaloneMmPkg/StandaloneMmPkg.dec
>> +++ b/StandaloneMmPkg/StandaloneMmPkg.dec
>> @@ -48,3 +48,5 @@
>> gEfiStandaloneMmNonSecureBufferGuid = { 0xf00497e3, 0xbfa2, 0x41a1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
>> gEfiArmTfCpuDriverEpDescriptorGuid = { 0x6ecbd5a1, 0xc0f8, 0x4702, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
>>
>> +[PcdsFixedAtBuild]
>> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize|0x00000000|UINT64|0x00000004
>> --
>> 2.17.1
>>
>
>
>
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
[not found] ` <177BD141FD103BE4.8497@groups.io>
1 sibling, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-08-16 8:55 UTC (permalink / raw)
To: devel, huangming, ardb
Cc: Sami Mujawar, Ard Biesheuvel, Jiewen Yao, Supreeth Venkatesh,
ming.huang-
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,
-Nhi
On 5/12/2022 5:09 PM, Ming Huang via groups.io wrote:
>
> 在 5/3/22 5:10 PM, Ard Biesheuvel 写道:
>> On Wed, 9 Feb 2022 at 13:26, Ming Huang <huangming@linux.alibaba.com> wrote:
>>> The heap space will be rewrote if a StandloneMmPkg module create HOB
>>> by BuildGuidHob() interface and write data to HOB space.
>> Can you elaborate? What is supposed to happen and why, and what is
>> happening instead?
> I tried my best to explain the issue:
>
> -----------------------------<--HandOffHob->EfiFreeMemoryTop
> | |
> | |
> | |
> | |
> | |
> | |
> | mMmMemoryMap |
> |---------------------------|<--HandOffHob->EfiFreeMemoryBottom
> | HobEnd |
> |---------------------------|<--HandOffHob->EfiEndOfHobList
> | |
> | Hob #1 |
> -----------------------------<--MmHobStart
> 1 The mMmMemoryMap which use for free page is on above the HobEnd.
> 2 Create a hob by BuildGuidHob(), the HobEnd will move up and cover
> the structure or list using by free page.
>
> After this patch, there is a pre-allocation space for creating hob.
>
> -----------------------------<--HandOffHob->EfiFreeMemoryTop
> | |
> | |
> | |
> | |
> | mMmMemoryMap |
> |---------------------------|<--HandOffHob->EfiFreeMemoryBottom
> | Hob free space | by PcdMemoryHobSize
> |---------------------------|
> | HobEnd |
> |---------------------------|<--HandOffHob->EfiEndOfHobList
> | |
> | Hob #1 |
> -----------------------------<--MmHobStart
>
>>> Add a PCD PcdMemoryHobSize for pre-allocation a space to create HOB to
>>> fix this issue.
>>>
>>> Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
>>> ---
>>> StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
>>> StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
>>> StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
>>> 3 files changed, 21 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
>>> index d221f1d111..1cf259d946 100644
>>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.c
>>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
>>> @@ -512,6 +512,9 @@ StandaloneMmMain (
>>> EFI_MMRAM_DESCRIPTOR *MmramRanges;
>>> UINTN MmramRangeCount;
>>> EFI_HOB_FIRMWARE_VOLUME *BfvHob;
>>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobNew;
>>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobOrg;
>>> + UINT64 MaxHobSize = PcdGet64 (PcdMemoryHobSize);
>>>
>>> ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
>>>
>>> @@ -619,10 +622,22 @@ StandaloneMmMain (
>>> //
>>> HobSize = GetHobListSize (HobStart);
>>> DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
>>> - MmHobStart = AllocatePool (HobSize);
>>> + ASSERT (HobSize <= MaxHobSize);
>>> + MmHobStart = AllocatePool (MaxHobSize);
>>> DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
>>> ASSERT (MmHobStart != NULL);
>>> CopyMem (MmHobStart, HobStart, HobSize);
>>> + //
>>> + // Initlialize the new HOB table
>>> + //
>>> + HandOffHobOrg = (EFI_HOB_HANDOFF_INFO_TABLE *)HobStart;
>>> + HandOffHobNew = (EFI_HOB_HANDOFF_INFO_TABLE *)MmHobStart;
>>> + HandOffHobNew->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)MmHobStart +
>>> + (HandOffHobOrg->EfiEndOfHobList - (EFI_PHYSICAL_ADDRESS)HobStart);
>>> + HandOffHobNew->EfiFreeMemoryBottom = HandOffHobNew->EfiEndOfHobList +
>>> + sizeof (EFI_HOB_GENERIC_HEADER);
>>> + HandOffHobNew->EfiFreeMemoryTop = (EFI_PHYSICAL_ADDRESS)MmHobStart + MaxHobSize;
>>> +
>>> Status = MmInstallConfigurationTable (&gMmCoreMmst, &gEfiHobListGuid, MmHobStart, HobSize);
>>> ASSERT_EFI_ERROR (Status);
>>>
>>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>> index c44b9ff333..37e6135d73 100644
>>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>> @@ -76,6 +76,9 @@
>>> gEfiEventExitBootServicesGuid
>>> gEfiEventReadyToBootGuid
>>>
>>> +[FixedPcd]
>>> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize
>>> +
>>> #
>>> # This configuration fails for CLANGPDB, which does not support PIE in the GCC
>>> # sense. Such however is required for ARM family StandaloneMmCore
>>> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec b/StandaloneMmPkg/StandaloneMmPkg.dec
>>> index 46784d94e4..cf554676e2 100644
>>> --- a/StandaloneMmPkg/StandaloneMmPkg.dec
>>> +++ b/StandaloneMmPkg/StandaloneMmPkg.dec
>>> @@ -48,3 +48,5 @@
>>> gEfiStandaloneMmNonSecureBufferGuid = { 0xf00497e3, 0xbfa2, 0x41a1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
>>> gEfiArmTfCpuDriverEpDescriptorGuid = { 0x6ecbd5a1, 0xc0f8, 0x4702, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
>>>
>>> +[PcdsFixedAtBuild]
>>> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize|0x00000000|UINT64|0x00000004
>>> --
>>> 2.17.1
>>>
>>
>>
>>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107793): https://edk2.groups.io/g/devel/message/107793
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
[not found] ` <177BD141FD103BE4.8497@groups.io>
@ 2023-08-29 2:48 ` Nhi Pham via groups.io
0 siblings, 0 replies; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-08-29 2:48 UTC (permalink / raw)
To: devel, nhi, huangming, ming.huang-, ardb, Ard Biesheuvel,
Sami Mujawar
Cc: Jiewen Yao, Supreeth Venkatesh
Just a gentle ping!
Hi Ard, can you provide your feedback on this patch?
Thanks,
-Nhi
On 8/16/2023 3:55 PM, Nhi Pham via groups.io 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,
>
> -Nhi
>
> On 5/12/2022 5:09 PM, Ming Huang via groups.io wrote:
>>
>> 在 5/3/22 5:10 PM, Ard Biesheuvel 写道:
>>> On Wed, 9 Feb 2022 at 13:26, Ming Huang
>>> <huangming@linux.alibaba.com> wrote:
>>>> The heap space will be rewrote if a StandloneMmPkg module create HOB
>>>> by BuildGuidHob() interface and write data to HOB space.
>>> Can you elaborate? What is supposed to happen and why, and what is
>>> happening instead?
>> I tried my best to explain the issue:
>>
>> -----------------------------<--HandOffHob->EfiFreeMemoryTop
>> | |
>> | |
>> | |
>> | |
>> | |
>> | |
>> | mMmMemoryMap |
>> |---------------------------|<--HandOffHob->EfiFreeMemoryBottom
>> | HobEnd |
>> |---------------------------|<--HandOffHob->EfiEndOfHobList
>> | |
>> | Hob #1 |
>> -----------------------------<--MmHobStart
>> 1 The mMmMemoryMap which use for free page is on above the HobEnd.
>> 2 Create a hob by BuildGuidHob(), the HobEnd will move up and cover
>> the structure or list using by free page.
>>
>> After this patch, there is a pre-allocation space for creating hob.
>>
>> -----------------------------<--HandOffHob->EfiFreeMemoryTop
>> | |
>> | |
>> | |
>> | |
>> | mMmMemoryMap |
>> |---------------------------|<--HandOffHob->EfiFreeMemoryBottom
>> | Hob free space | by PcdMemoryHobSize
>> |---------------------------|
>> | HobEnd |
>> |---------------------------|<--HandOffHob->EfiEndOfHobList
>> | |
>> | Hob #1 |
>> -----------------------------<--MmHobStart
>>
>>>> Add a PCD PcdMemoryHobSize for pre-allocation a space to create HOB to
>>>> fix this issue.
>>>>
>>>> Signed-off-by: Ming Huang <huangming@linux.alibaba.com>
>>>> ---
>>>> StandaloneMmPkg/Core/StandaloneMmCore.c | 17 ++++++++++++++++-
>>>> StandaloneMmPkg/Core/StandaloneMmCore.inf | 3 +++
>>>> StandaloneMmPkg/StandaloneMmPkg.dec | 2 ++
>>>> 3 files changed, 21 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c
>>>> b/StandaloneMmPkg/Core/StandaloneMmCore.c
>>>> index d221f1d111..1cf259d946 100644
>>>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.c
>>>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
>>>> @@ -512,6 +512,9 @@ StandaloneMmMain (
>>>> EFI_MMRAM_DESCRIPTOR *MmramRanges;
>>>> UINTN MmramRangeCount;
>>>> EFI_HOB_FIRMWARE_VOLUME *BfvHob;
>>>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobNew;
>>>> + EFI_HOB_HANDOFF_INFO_TABLE *HandOffHobOrg;
>>>> + UINT64 MaxHobSize = PcdGet64
>>>> (PcdMemoryHobSize);
>>>>
>>>> ProcessLibraryConstructorList (HobStart, &gMmCoreMmst);
>>>>
>>>> @@ -619,10 +622,22 @@ StandaloneMmMain (
>>>> //
>>>> HobSize = GetHobListSize (HobStart);
>>>> DEBUG ((DEBUG_INFO, "HobSize - 0x%x\n", HobSize));
>>>> - MmHobStart = AllocatePool (HobSize);
>>>> + ASSERT (HobSize <= MaxHobSize);
>>>> + MmHobStart = AllocatePool (MaxHobSize);
>>>> DEBUG ((DEBUG_INFO, "MmHobStart - 0x%x\n", MmHobStart));
>>>> ASSERT (MmHobStart != NULL);
>>>> CopyMem (MmHobStart, HobStart, HobSize);
>>>> + //
>>>> + // Initlialize the new HOB table
>>>> + //
>>>> + HandOffHobOrg = (EFI_HOB_HANDOFF_INFO_TABLE *)HobStart;
>>>> + HandOffHobNew = (EFI_HOB_HANDOFF_INFO_TABLE *)MmHobStart;
>>>> + HandOffHobNew->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)MmHobStart +
>>>> + (HandOffHobOrg->EfiEndOfHobList -
>>>> (EFI_PHYSICAL_ADDRESS)HobStart);
>>>> + HandOffHobNew->EfiFreeMemoryBottom =
>>>> HandOffHobNew->EfiEndOfHobList +
>>>> + sizeof
>>>> (EFI_HOB_GENERIC_HEADER);
>>>> + HandOffHobNew->EfiFreeMemoryTop =
>>>> (EFI_PHYSICAL_ADDRESS)MmHobStart + MaxHobSize;
>>>> +
>>>> Status = MmInstallConfigurationTable (&gMmCoreMmst,
>>>> &gEfiHobListGuid, MmHobStart, HobSize);
>>>> ASSERT_EFI_ERROR (Status);
>>>>
>>>> diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>>> b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>>> index c44b9ff333..37e6135d73 100644
>>>> --- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>>> +++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
>>>> @@ -76,6 +76,9 @@
>>>> gEfiEventExitBootServicesGuid
>>>> gEfiEventReadyToBootGuid
>>>>
>>>> +[FixedPcd]
>>>> + gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize
>>>> +
>>>> #
>>>> # This configuration fails for CLANGPDB, which does not support
>>>> PIE in the GCC
>>>> # sense. Such however is required for ARM family StandaloneMmCore
>>>> diff --git a/StandaloneMmPkg/StandaloneMmPkg.dec
>>>> b/StandaloneMmPkg/StandaloneMmPkg.dec
>>>> index 46784d94e4..cf554676e2 100644
>>>> --- a/StandaloneMmPkg/StandaloneMmPkg.dec
>>>> +++ b/StandaloneMmPkg/StandaloneMmPkg.dec
>>>> @@ -48,3 +48,5 @@
>>>> gEfiStandaloneMmNonSecureBufferGuid = { 0xf00497e3,
>>>> 0xbfa2, 0x41a1, { 0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 }}
>>>> gEfiArmTfCpuDriverEpDescriptorGuid = { 0x6ecbd5a1,
>>>> 0xc0f8, 0x4702, { 0x83, 0x01, 0x4f, 0xc2, 0xc5, 0x47, 0x0a, 0x51 }}
>>>>
>>>> +[PcdsFixedAtBuild]
>>>> +
>>>> gStandaloneMmPkgTokenSpaceGuid.PcdMemoryHobSize|0x00000000|UINT64|0x00000004
>>>> --
>>>> 2.17.1
>>>>
>>>
>>>
>>>
>>
>>
>>
>>
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108075): https://edk2.groups.io/g/devel/message/108075
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Ard Biesheuvel @ 2023-08-30 13:10 UTC (permalink / raw)
To: Nhi Pham
Cc: devel, huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
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?
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108145): https://edk2.groups.io/g/devel/message/108145
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-08-31 8:20 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: devel, huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
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?
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/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2023-08-31 8:20 ` Nhi Pham via groups.io
@ 2023-09-01 20:43 ` Oliver Smith-Denny
2023-09-05 2:20 ` Nhi Pham via groups.io
0 siblings, 1 reply; 22+ messages in thread
From: Oliver Smith-Denny @ 2023-09-01 20:43 UTC (permalink / raw)
To: devel, nhi, Ard Biesheuvel
Cc: huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2023-09-01 20:43 ` Oliver Smith-Denny
@ 2023-09-05 2:20 ` Nhi Pham via groups.io
2023-09-05 21:29 ` Oliver Smith-Denny
0 siblings, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-09-05 2:20 UTC (permalink / raw)
To: Oliver Smith-Denny, devel, nhi, Ard Biesheuvel
Cc: huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
Hi Oliver, thank you for taking a look at this patch.
On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote:
> 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?
Yes, the issue only occurs when HOB are created in StandaloneMM by the
HOB library instance
StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>
> If so, is HOB creation in StMM and supported use case? The only instance
I think it is intended to work as the CreateHob() function is implemented.
> 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.
I have a use case when enabling the UEFI Variable driver running in
StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region is
allocated **dynamically** at boot time in the StMM secure memory. Then,
they will be passed into the gVariableFlashInfoHobGuid for being
consumed by other variable MM drivers.
>
> 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 (#108269): https://edk2.groups.io/g/devel/message/108269
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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 7:35 ` Nhi Pham via groups.io
0 siblings, 2 replies; 22+ messages in thread
From: Oliver Smith-Denny @ 2023-09-05 21:29 UTC (permalink / raw)
To: Nhi Pham, devel, nhi, Ard Biesheuvel
Cc: huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
On 9/4/2023 7:20 PM, Nhi Pham wrote:
> On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote:
>> On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote:
>>
>> 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?
> Yes, the issue only occurs when HOB are created in StandaloneMM by the
> HOB library instance
> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>>
>> If so, is HOB creation in StMM and supported use case? The only instance
> I think it is intended to work as the CreateHob() function is implemented.
Well, that may just be a copy/paste sort of thing :).
>> 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.
>
> I have a use case when enabling the UEFI Variable driver running in
> StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region is
> allocated **dynamically** at boot time in the StMM secure memory. Then,
> they will be passed into the gVariableFlashInfoHobGuid for being
> consumed by other variable MM drivers.
>
I do believe that per the PI spec, we should have HOB producer and HOB
consumer phases, where in this case PEI (if it was the launching entity
for StMM) is the HOB producer and StMM is the HOB producer. This is the
same pattern the PI spec details for PEI and DXE, where DXE is not
intended to create new HOBs, but just to consume information from the
previous phase.
As I mentioned, there are other interfaces for passing information
within a phase, such as protocols, dynamic PCDs, variables, etc. that
are built for this application. I think it is useful to adhere to the
model for HOBs (which are hand off blocks, one phase handing information
to another phase) and that we will create more issues if we rely on
HOB consumer phases producing HOBs.
My proposal would be to remove the HOB creation code from StMM
completely. I believe in your use case that you are describing a dynamic
PCD or a protocol could work to pass the information.
If we are saying that prior to your patch that HOB creation in StMM was
completely broken, anyway, it seems that folks were not relying on this
code?
Thanks,
Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108293): https://edk2.groups.io/g/devel/message/108293
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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 7:35 ` Nhi Pham via groups.io
1 sibling, 2 replies; 22+ messages in thread
From: Ni, Ray @ 2023-09-06 6:33 UTC (permalink / raw)
To: Nhi Pham, devel@edk2.groups.io, nhi@os.amperecomputing.com,
Ard Biesheuvel, osde@linux.microsoft.com
Cc: huangming@linux.alibaba.com, Sami Mujawar, Ard Biesheuvel,
Yao, Jiewen, Supreeth Venkatesh, ming.huang-@outlook.com
[-- Attachment #1: Type: text/plain, Size: 3990 bytes --]
I am a bit confused.
The HOB list in standalone MM is read-only. Why could any module call BuildGuidHob() to modify the HOB.
I saw Oliver mentioned something about StMM. I don't know what that is. But it seems that's ARM specific. Then, I don't think it's proper to modify code here for a specific arch ARM.
Thanks,
Ray
________________________________
From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Oliver Smith-Denny <osde@linux.microsoft.com>
Sent: Wednesday, September 6, 2023 5:29 AM
To: Nhi Pham <nhi@amperemail.onmicrosoft.com>; devel@edk2.groups.io <devel@edk2.groups.io>; nhi@os.amperecomputing.com <nhi@os.amperecomputing.com>; Ard Biesheuvel <ardb@kernel.org>
Cc: huangming@linux.alibaba.com <huangming@linux.alibaba.com>; Sami Mujawar <sami.mujawar@arm.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>; Yao, Jiewen <jiewen.yao@intel.com>; Supreeth Venkatesh <supreeth.venkatesh@arm.com>; ming.huang-@outlook.com <ming.huang-@outlook.com>
Subject: Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
On 9/4/2023 7:20 PM, Nhi Pham wrote:
> On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote:
>> On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote:
>>
>> 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?
> Yes, the issue only occurs when HOB are created in StandaloneMM by the
> HOB library instance
> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>>
>> If so, is HOB creation in StMM and supported use case? The only instance
> I think it is intended to work as the CreateHob() function is implemented.
Well, that may just be a copy/paste sort of thing :).
>> 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.
>
> I have a use case when enabling the UEFI Variable driver running in
> StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region is
> allocated **dynamically** at boot time in the StMM secure memory. Then,
> they will be passed into the gVariableFlashInfoHobGuid for being
> consumed by other variable MM drivers.
>
I do believe that per the PI spec, we should have HOB producer and HOB
consumer phases, where in this case PEI (if it was the launching entity
for StMM) is the HOB producer and StMM is the HOB producer. This is the
same pattern the PI spec details for PEI and DXE, where DXE is not
intended to create new HOBs, but just to consume information from the
previous phase.
As I mentioned, there are other interfaces for passing information
within a phase, such as protocols, dynamic PCDs, variables, etc. that
are built for this application. I think it is useful to adhere to the
model for HOBs (which are hand off blocks, one phase handing information
to another phase) and that we will create more issues if we rely on
HOB consumer phases producing HOBs.
My proposal would be to remove the HOB creation code from StMM
completely. I believe in your use case that you are describing a dynamic
PCD or a protocol could work to pass the information.
If we are saying that prior to your patch that HOB creation in StMM was
completely broken, anyway, it seems that folks were not relying on this
code?
Thanks,
Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108306): https://edk2.groups.io/g/devel/message/108306
Mute This Topic: https://groups.io/mt/89020085/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
[-- Attachment #2: Type: text/html, Size: 6855 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2023-09-06 6:33 ` Ni, Ray
@ 2023-09-06 6:56 ` Ard Biesheuvel
2023-09-06 7:55 ` Nhi Pham via groups.io
1 sibling, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2023-09-06 6:56 UTC (permalink / raw)
To: Ni, Ray
Cc: Nhi Pham, devel@edk2.groups.io, nhi@os.amperecomputing.com,
osde@linux.microsoft.com, huangming@linux.alibaba.com,
Sami Mujawar, Ard Biesheuvel, Yao, Jiewen, Supreeth Venkatesh,
ming.huang-@outlook.com
On Wed, 6 Sept 2023 at 08:33, Ni, Ray <ray.ni@intel.com> wrote:
>
> I am a bit confused.
>
> The HOB list in standalone MM is read-only. Why could any module call BuildGuidHob() to modify the HOB.
>
> I saw Oliver mentioned something about StMM. I don't know what that is. But it seems that's ARM specific. Then, I don't think it's proper to modify code here for a specific arch ARM.
>
Hello Ray,
StMM == Standalone MM
Does the PI spec document that the standalone MM hob list is
read-only? If so, the HOB build routines shouldn't be exposed (and/or
ASSERT in DEBUG builds). If not, they should work.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108308): https://edk2.groups.io/g/devel/message/108308
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2023-09-05 21:29 ` Oliver Smith-Denny
2023-09-06 6:33 ` Ni, Ray
@ 2023-09-06 7:35 ` Nhi Pham via groups.io
1 sibling, 0 replies; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-09-06 7:35 UTC (permalink / raw)
To: Oliver Smith-Denny, devel, nhi, Ard Biesheuvel, michael.kubacki
Cc: huangming, Sami Mujawar, Ard Biesheuvel, Jiewen Yao,
Supreeth Venkatesh, ming.huang-
On 9/6/2023 4:29 AM, Oliver Smith-Denny wrote:
> On 9/4/2023 7:20 PM, Nhi Pham wrote:
>> On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote:
>>> On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote:
>>>
>>> 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?
>> Yes, the issue only occurs when HOB are created in StandaloneMM by
>> the HOB library instance
>> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>>>
>>> If so, is HOB creation in StMM and supported use case? The only
>>> instance
>> I think it is intended to work as the CreateHob() function is
>> implemented.
>
> Well, that may just be a copy/paste sort of thing :).
>
>>> 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.
>>
>> I have a use case when enabling the UEFI Variable driver running in
>> StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region
>> is allocated **dynamically** at boot time in the StMM secure memory.
>> Then, they will be passed into the gVariableFlashInfoHobGuid for
>> being consumed by other variable MM drivers.
>>
>
> I do believe that per the PI spec, we should have HOB producer and HOB
> consumer phases, where in this case PEI (if it was the launching entity
> for StMM) is the HOB producer and StMM is the HOB producer. This is the
> same pattern the PI spec details for PEI and DXE, where DXE is not
> intended to create new HOBs, but just to consume information from the
> previous phase.
>
> As I mentioned, there are other interfaces for passing information
> within a phase, such as protocols, dynamic PCDs, variables, etc. that
> are built for this application. I think it is useful to adhere to the
> model for HOBs (which are hand off blocks, one phase handing information
> to another phase) and that we will create more issues if we rely on
> HOB consumer phases producing HOBs.
Thanks Oliver for the explanation. That makes sense to me.
>
> My proposal would be to remove the HOB creation code from StMM
> completely. I believe in your use case that you are describing a dynamic
> PCD or a protocol could work to pass the information.
I think the dynamic PCD is supposed to not being supported in
StandaloneMM and protocol does not fit because the Variable Flash Info
is created in PEI for UEFI variable non-MM flow and in StMM for UEFI
variable MM flow.
>
> If we are saying that prior to your patch that HOB creation in StMM was
> completely broken, anyway, it seems that folks were not relying on this
> code?
Right, it is just my curiosity that I don't see any showcase for
Variable MM + Variable Flash Info HOB in StandaloneMM.
Adding Michael Kubacki as the owner of the Variable Flash Info HOB for
getting further input.
>
> Thanks,
> Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108310): https://edk2.groups.io/g/devel/message/108310
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
1 sibling, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-09-06 7:55 UTC (permalink / raw)
To: Ni, Ray, devel@edk2.groups.io, nhi@os.amperecomputing.com,
Ard Biesheuvel, osde@linux.microsoft.com
Cc: huangming@linux.alibaba.com, Sami Mujawar, Ard Biesheuvel,
Yao, Jiewen, Supreeth Venkatesh, ming.huang-@outlook.com
On 9/6/2023 1:33 PM, Ni, Ray wrote:
> [EXTERNAL EMAIL NOTICE: This email originated from an external sender.
> Please be mindful of safe email handling and proprietary information
> protection practices.]
>
> I am a bit confused.
>
> The HOB list in standalone MM is read-only. Why could any module call
> BuildGuidHob() to modify the HOB.
>
> I saw Oliver mentioned something about StMM. I don't know what that is.
> But it seems that's ARM specific. Then, I don't think it's proper to
> modify code here for a specific arch ARM.
The HOB creation is available in the
StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf. If
other architectures also use that instance, I think the issue is not
specific to ARM.
Regards,
-Nhi
>
> Thanks,
> Ray
> ------------------------------------------------------------------------
> *From:* devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Oliver
> Smith-Denny <osde@linux.microsoft.com>
> *Sent:* Wednesday, September 6, 2023 5:29 AM
> *To:* Nhi Pham <nhi@amperemail.onmicrosoft.com>; devel@edk2.groups.io
> <devel@edk2.groups.io>; nhi@os.amperecomputing.com
> <nhi@os.amperecomputing.com>; Ard Biesheuvel <ardb@kernel.org>
> *Cc:* huangming@linux.alibaba.com <huangming@linux.alibaba.com>; Sami
> Mujawar <sami.mujawar@arm.com>; Ard Biesheuvel
> <ardb+tianocore@kernel.org>; Yao, Jiewen <jiewen.yao@intel.com>;
> Supreeth Venkatesh <supreeth.venkatesh@arm.com>; ming.huang-@outlook.com
> <ming.huang-@outlook.com>
> *Subject:* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB
> space and heap space conflicted issue
> On 9/4/2023 7:20 PM, Nhi Pham wrote:
>> On 9/2/2023 3:43 AM, Oliver Smith-Denny wrote:
>>> On 8/31/2023 1:20 AM, Nhi Pham via groups.io wrote:
>>>
>>> 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?
>> Yes, the issue only occurs when HOB are created in StandaloneMM by the
>> HOB library instance
>> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
>>>
>>> If so, is HOB creation in StMM and supported use case? The only instance
>> I think it is intended to work as the CreateHob() function is implemented.
>
> Well, that may just be a copy/paste sort of thing :).
>
>>> 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.
>>
>> I have a use case when enabling the UEFI Variable driver running in
>> StandaloneMM. Instead of using the PCDs, the in-memory NVRAM region is
>> allocated **dynamically** at boot time in the StMM secure memory. Then,
>> they will be passed into the gVariableFlashInfoHobGuid for being
>> consumed by other variable MM drivers.
>>
>
> I do believe that per the PI spec, we should have HOB producer and HOB
> consumer phases, where in this case PEI (if it was the launching entity
> for StMM) is the HOB producer and StMM is the HOB producer. This is the
> same pattern the PI spec details for PEI and DXE, where DXE is not
> intended to create new HOBs, but just to consume information from the
> previous phase.
>
> As I mentioned, there are other interfaces for passing information
> within a phase, such as protocols, dynamic PCDs, variables, etc. that
> are built for this application. I think it is useful to adhere to the
> model for HOBs (which are hand off blocks, one phase handing information
> to another phase) and that we will create more issues if we rely on
> HOB consumer phases producing HOBs.
>
> My proposal would be to remove the HOB creation code from StMM
> completely. I believe in your use case that you are describing a dynamic
> PCD or a protocol could work to pass the information.
>
> If we are saying that prior to your patch that HOB creation in StMM was
> completely broken, anyway, it seems that folks were not relying on this
> code?
>
> Thanks,
> Oliver
>
>
>
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108311): https://edk2.groups.io/g/devel/message/108311
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Ard Biesheuvel @ 2023-09-06 8:50 UTC (permalink / raw)
To: Nhi Pham
Cc: Ni, Ray, devel@edk2.groups.io, nhi@os.amperecomputing.com,
osde@linux.microsoft.com, huangming@linux.alibaba.com,
Sami Mujawar, Ard Biesheuvel, Yao, Jiewen, Supreeth Venkatesh,
ming.huang-@outlook.com
On Wed, 6 Sept 2023 at 09:56, Nhi Pham <nhi@amperemail.onmicrosoft.com> wrote:
>
> On 9/6/2023 1:33 PM, Ni, Ray wrote:
> > [EXTERNAL EMAIL NOTICE: This email originated from an external sender.
> > Please be mindful of safe email handling and proprietary information
> > protection practices.]
> >
> > I am a bit confused.
> >
> > The HOB list in standalone MM is read-only. Why could any module call
> > BuildGuidHob() to modify the HOB.
> >
> > I saw Oliver mentioned something about StMM. I don't know what that is.
> > But it seems that's ARM specific. Then, I don't think it's proper to
> > modify code here for a specific arch ARM.
>
> The HOB creation is available in the
> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf. If
> other architectures also use that instance, I think the issue is not
> specific to ARM.
>
The question here is whether the implementation follows the PI spec,
and whether HOB creation should be supported to begin with.
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108315): https://edk2.groups.io/g/devel/message/108315
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Oliver Smith-Denny @ 2023-09-06 16:22 UTC (permalink / raw)
To: devel, ardb, Nhi Pham
Cc: Ni, Ray, nhi@os.amperecomputing.com, huangming@linux.alibaba.com,
Sami Mujawar, Ard Biesheuvel, Yao, Jiewen, Supreeth Venkatesh,
ming.huang-@outlook.com
On 9/6/2023 1:50 AM, Ard Biesheuvel wrote:
> On Wed, 6 Sept 2023 at 09:56, Nhi Pham <nhi@amperemail.onmicrosoft.com> wrote:
>>
>> On 9/6/2023 1:33 PM, Ni, Ray wrote:
>>> [EXTERNAL EMAIL NOTICE: This email originated from an external sender.
>>> Please be mindful of safe email handling and proprietary information
>>> protection practices.]
>>>
>>> I am a bit confused.
>>>
>>> The HOB list in standalone MM is read-only. Why could any module call
>>> BuildGuidHob() to modify the HOB.
>>>
>>> I saw Oliver mentioned something about StMM. I don't know what that is.
>>> But it seems that's ARM specific. Then, I don't think it's proper to
>>> modify code here for a specific arch ARM.
>>
>> The HOB creation is available in the
>> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf. If
>> other architectures also use that instance, I think the issue is not
>> specific to ARM.
>>
>
> The question here is whether the implementation follows the PI spec,
> and whether HOB creation should be supported to begin with.
>
My reading of the PI spec is that this implementation does not follow
it. However, the PI spec is not very explicit about Standalone MM in
general, but particularly in relation to HOBs.
However, in the generic HOB section of PI spec v1.7, Vol. 3, section 4
(entitled HOB Design Discussion) it explicitly lays out that there are
HOB producer phases and HOB consumer phases. It uses PEI as a HOB
producer phase and DXE as a HOB consumer phase and explicitly says
that the HOB consumer phase must treat HOBs as read-only memory, per
Ray's comment.
In vol. 4, section 2.2, in discussing the Standalone MM entry point,
the document talks about the HOB list being passed to Standalone MM
to consume, which per the reading of the above section would classify
Standalone MM as a HOB consumer phase, where HOBs should then be
read-only.
So, I believe that we should not support HOB creation in Standalone MM
and instead rely on other mechanisms to pass information within the
phase. Per Nhi's other email in this thread, we should have the
discussion on how to solve that specific problem and that may well
lead to a discussion on whether HOBs are in fact the right mechanism
here, but I tend to lean towards leaving something as architectural as
HOBs to what the PI spec defines and using different mechanisms to
accomplish in-phase communication.
Does this reading of the spec align with others' expectations? As I
mentioned to Ray in another thread, Standalone MM feels like it could
have extra clarification in a few areas in the PI spec.
Thanks,
Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108333): https://edk2.groups.io/g/devel/message/108333
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-09-07 15:38 UTC (permalink / raw)
To: Oliver Smith-Denny, devel, ardb
Cc: Ni, Ray, nhi@os.amperecomputing.com, huangming@linux.alibaba.com,
Sami Mujawar, Ard Biesheuvel, Yao, Jiewen, Supreeth Venkatesh,
ming.huang-@outlook.com
On 9/6/2023 11:22 PM, Oliver Smith-Denny wrote:
> On 9/6/2023 1:50 AM, Ard Biesheuvel wrote:
>> On Wed, 6 Sept 2023 at 09:56, Nhi Pham
>> <nhi@amperemail.onmicrosoft.com> wrote:
>>>
>>> On 9/6/2023 1:33 PM, Ni, Ray wrote:
>>>> [EXTERNAL EMAIL NOTICE: This email originated from an external sender.
>>>> Please be mindful of safe email handling and proprietary information
>>>> protection practices.]
>>>>
>>>> I am a bit confused.
>>>>
>>>> The HOB list in standalone MM is read-only. Why could any module call
>>>> BuildGuidHob() to modify the HOB.
>>>>
>>>> I saw Oliver mentioned something about StMM. I don't know what that
>>>> is.
>>>> But it seems that's ARM specific. Then, I don't think it's proper to
>>>> modify code here for a specific arch ARM.
>>>
>>> The HOB creation is available in the
>>> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf. If
>>> other architectures also use that instance, I think the issue is not
>>> specific to ARM.
>>>
>>
>> The question here is whether the implementation follows the PI spec,
>> and whether HOB creation should be supported to begin with.
>>
>
> My reading of the PI spec is that this implementation does not follow
> it. However, the PI spec is not very explicit about Standalone MM in
> general, but particularly in relation to HOBs.
>
> However, in the generic HOB section of PI spec v1.7, Vol. 3, section 4
> (entitled HOB Design Discussion) it explicitly lays out that there are
> HOB producer phases and HOB consumer phases. It uses PEI as a HOB
> producer phase and DXE as a HOB consumer phase and explicitly says
> that the HOB consumer phase must treat HOBs as read-only memory, per
> Ray's comment.
>
> In vol. 4, section 2.2, in discussing the Standalone MM entry point,
> the document talks about the HOB list being passed to Standalone MM
> to consume, which per the reading of the above section would classify
> Standalone MM as a HOB consumer phase, where HOBs should then be
> read-only.
>
> So, I believe that we should not support HOB creation in Standalone MM
> and instead rely on other mechanisms to pass information within the
> phase. Per Nhi's other email in this thread, we should have the
> discussion on how to solve that specific problem and that may well
> lead to a discussion on whether HOBs are in fact the right mechanism
> here, but I tend to lean towards leaving something as architectural as
> HOBs to what the PI spec defines and using different mechanisms to
> accomplish in-phase communication.
Thanks Oliver so much for that. I agree. We should focus on my specific
problem with UEFI Variable Flash Info in StandaloneMM in another thread.
>
> Does this reading of the spec align with others' expectations? As I
> mentioned to Ray in another thread, Standalone MM feels like it could
> have extra clarification in a few areas in the PI spec.
Thanks again. The HOB library should be updated to remove the HOB
creation once we have the clarification.
Regards,
Nhi
>
> Thanks,
> Oliver
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#108403): https://edk2.groups.io/g/devel/message/108403
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
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
0 siblings, 1 reply; 22+ messages in thread
From: Nhi Pham via groups.io @ 2023-11-30 13:59 UTC (permalink / raw)
To: Oliver Smith-Denny, devel, ardb
Cc: Ni, Ray, huangming@linux.alibaba.com, Sami Mujawar,
Ard Biesheuvel, Yao, Jiewen, Supreeth Venkatesh,
ming.huang-@outlook.com
On 9/7/2023 10:38 PM, Nhi Pham wrote:
> On 9/6/2023 11:22 PM, Oliver Smith-Denny wrote:
>> On 9/6/2023 1:50 AM, Ard Biesheuvel wrote:
>>> On Wed, 6 Sept 2023 at 09:56, Nhi Pham
>>> <nhi@amperemail.onmicrosoft.com> wrote:
>>>>
>>>> On 9/6/2023 1:33 PM, Ni, Ray wrote:
>>>>> [EXTERNAL EMAIL NOTICE: This email originated from an external sender.
>>>>> Please be mindful of safe email handling and proprietary information
>>>>> protection practices.]
>>>>>
>>>>> I am a bit confused.
>>>>>
>>>>> The HOB list in standalone MM is read-only. Why could any module call
>>>>> BuildGuidHob() to modify the HOB.
>>>>>
>>>>> I saw Oliver mentioned something about StMM. I don't know what that
>>>>> is.
>>>>> But it seems that's ARM specific. Then, I don't think it's proper to
>>>>> modify code here for a specific arch ARM.
>>>>
>>>> The HOB creation is available in the
>>>> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf. If
>>>> other architectures also use that instance, I think the issue is not
>>>> specific to ARM.
>>>>
>>>
>>> The question here is whether the implementation follows the PI spec,
>>> and whether HOB creation should be supported to begin with.
>>>
>>
>> My reading of the PI spec is that this implementation does not follow
>> it. However, the PI spec is not very explicit about Standalone MM in
>> general, but particularly in relation to HOBs.
>>
>> However, in the generic HOB section of PI spec v1.7, Vol. 3, section 4
>> (entitled HOB Design Discussion) it explicitly lays out that there are
>> HOB producer phases and HOB consumer phases. It uses PEI as a HOB
>> producer phase and DXE as a HOB consumer phase and explicitly says
>> that the HOB consumer phase must treat HOBs as read-only memory, per
>> Ray's comment.
>>
>> In vol. 4, section 2.2, in discussing the Standalone MM entry point,
>> the document talks about the HOB list being passed to Standalone MM
>> to consume, which per the reading of the above section would classify
>> Standalone MM as a HOB consumer phase, where HOBs should then be
>> read-only.
>>
>> So, I believe that we should not support HOB creation in Standalone MM
>> and instead rely on other mechanisms to pass information within the
>> phase. Per Nhi's other email in this thread, we should have the
>> discussion on how to solve that specific problem and that may well
>> lead to a discussion on whether HOBs are in fact the right mechanism
>> here, but I tend to lean towards leaving something as architectural as
>> HOBs to what the PI spec defines and using different mechanisms to
>> accomplish in-phase communication.
> Thanks Oliver so much for that. I agree. We should focus on my specific
> problem with UEFI Variable Flash Info in StandaloneMM in another thread.
>>
>> Does this reading of the spec align with others' expectations? As I
>> mentioned to Ray in another thread, Standalone MM feels like it could
>> have extra clarification in a few areas in the PI spec.
>
> Thanks again. The HOB library should be updated to remove the HOB
> creation once we have the clarification.
I found that we can hook a platform NULL library class to the
StandaloneMmCore to create UEFI Variable Flash Info HOB. This way is
compliant to the spec as the HOB is created in MM_CORE_STANDALONE phase.
Should I write a patch to remove the HOB creation in StandaloneMmHobLib?
Regards,
Nhi
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111903): https://edk2.groups.io/g/devel/message/111903
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]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [edk2-devel] [PATCH v1 2/2] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
2023-11-30 13:59 ` Nhi Pham via groups.io
@ 2023-12-01 5:29 ` Ni, Ray
0 siblings, 0 replies; 22+ messages in thread
From: Ni, Ray @ 2023-12-01 5:29 UTC (permalink / raw)
To: Nhi Pham, Oliver Smith-Denny, devel@edk2.groups.io,
ardb@kernel.org
Cc: huangming@linux.alibaba.com, Sami Mujawar, Ard Biesheuvel,
Yao, Jiewen, Supreeth Venkatesh, ming.huang-@outlook.com
Yes please!
Thanks,
Ray
> -----Original Message-----
> From: Nhi Pham <nhi@os.amperecomputing.com>
> Sent: Thursday, November 30, 2023 9:59 PM
> To: Oliver Smith-Denny <osde@linux.microsoft.com>; devel@edk2.groups.io;
> ardb@kernel.org
> Cc: Ni, Ray <ray.ni@intel.com>; huangming@linux.alibaba.com; Sami Mujawar
> <sami.mujawar@arm.com>; Ard Biesheuvel <ardb+tianocore@kernel.org>;
> Yao, Jiewen <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
>
> On 9/7/2023 10:38 PM, Nhi Pham wrote:
> > On 9/6/2023 11:22 PM, Oliver Smith-Denny wrote:
> >> On 9/6/2023 1:50 AM, Ard Biesheuvel wrote:
> >>> On Wed, 6 Sept 2023 at 09:56, Nhi Pham
> >>> <nhi@amperemail.onmicrosoft.com> wrote:
> >>>>
> >>>> On 9/6/2023 1:33 PM, Ni, Ray wrote:
> >>>>> [EXTERNAL EMAIL NOTICE: This email originated from an external
> sender.
> >>>>> Please be mindful of safe email handling and proprietary information
> >>>>> protection practices.]
> >>>>>
> >>>>> I am a bit confused.
> >>>>>
> >>>>> The HOB list in standalone MM is read-only. Why could any module call
> >>>>> BuildGuidHob() to modify the HOB.
> >>>>>
> >>>>> I saw Oliver mentioned something about StMM. I don't know what that
> >>>>> is.
> >>>>> But it seems that's ARM specific. Then, I don't think it's proper to
> >>>>> modify code here for a specific arch ARM.
> >>>>
> >>>> The HOB creation is available in the
> >>>>
> StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf.
> If
> >>>> other architectures also use that instance, I think the issue is not
> >>>> specific to ARM.
> >>>>
> >>>
> >>> The question here is whether the implementation follows the PI spec,
> >>> and whether HOB creation should be supported to begin with.
> >>>
> >>
> >> My reading of the PI spec is that this implementation does not follow
> >> it. However, the PI spec is not very explicit about Standalone MM in
> >> general, but particularly in relation to HOBs.
> >>
> >> However, in the generic HOB section of PI spec v1.7, Vol. 3, section 4
> >> (entitled HOB Design Discussion) it explicitly lays out that there are
> >> HOB producer phases and HOB consumer phases. It uses PEI as a HOB
> >> producer phase and DXE as a HOB consumer phase and explicitly says
> >> that the HOB consumer phase must treat HOBs as read-only memory, per
> >> Ray's comment.
> >>
> >> In vol. 4, section 2.2, in discussing the Standalone MM entry point,
> >> the document talks about the HOB list being passed to Standalone MM
> >> to consume, which per the reading of the above section would classify
> >> Standalone MM as a HOB consumer phase, where HOBs should then be
> >> read-only.
> >>
> >> So, I believe that we should not support HOB creation in Standalone MM
> >> and instead rely on other mechanisms to pass information within the
> >> phase. Per Nhi's other email in this thread, we should have the
> >> discussion on how to solve that specific problem and that may well
> >> lead to a discussion on whether HOBs are in fact the right mechanism
> >> here, but I tend to lean towards leaving something as architectural as
> >> HOBs to what the PI spec defines and using different mechanisms to
> >> accomplish in-phase communication.
> > Thanks Oliver so much for that. I agree. We should focus on my specific
> > problem with UEFI Variable Flash Info in StandaloneMM in another thread.
> >>
> >> Does this reading of the spec align with others' expectations? As I
> >> mentioned to Ray in another thread, Standalone MM feels like it could
> >> have extra clarification in a few areas in the PI spec.
> >
> > Thanks again. The HOB library should be updated to remove the HOB
> > creation once we have the clarification.
>
> I found that we can hook a platform NULL library class to the
> StandaloneMmCore to create UEFI Variable Flash Info HOB. This way is
> compliant to the spec as the HOB is created in MM_CORE_STANDALONE
> phase.
>
> Should I write a patch to remove the HOB creation in StandaloneMmHobLib?
>
> Regards,
> Nhi
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111969): https://edk2.groups.io/g/devel/message/111969
Mute This Topic: https://groups.io/mt/89020085/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2023-12-01 5:29 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox