public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ming Huang" <huangming@linux.alibaba.com>
To: devel@edk2.groups.io, sami.mujawar@arm.com,
	ardb+tianocore@kernel.org, jiewen.yao@intel.com,
	supreeth.venkatesh@arm.com
Cc: ming.huang-@outlook.com
Subject: Re: [PATCH v1 1/1] StandaloneMmPkg: Fix HOB space and heap space conflicted issue
Date: Wed, 9 Feb 2022 20:13:20 +0800	[thread overview]
Message-ID: <0c06c7ef-ac1c-2227-852d-d2b1ccc6e7f1@linux.alibaba.com> (raw)
In-Reply-To: <20220208024319.32841-1-huangming@linux.alibaba.com>

Abandon this patch, send a new one for fixing this issue.

在 2/8/22 10:43 AM, 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/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c            | 11 ++++++-----
>  StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf |  4 ++++
>  StandaloneMmPkg/StandaloneMmPkg.dec                                               |  2 ++
>  3 files changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> index eb0c1f82db..c9fb46c532 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c
> @@ -68,13 +68,14 @@ CreateHobListFromBootInfo (
>    EFI_PROCESSOR_INFORMATION        *ProcInfoBuffer;
>    EFI_SECURE_PARTITION_CPU_INFO    *CpuInfo;
>    ARM_TF_CPU_DRIVER_EP_DESCRIPTOR  *CpuDriverEntryPointDesc;
> +  UINT64                           MaxHobSize = PcdGet64 (PcdMemoryHobSize);
>  
>    // Create a hoblist with a PHIT and EOH
>    HobStart = HobConstructor (
>                 (VOID *)(UINTN)PayloadBootInfo->SpMemBase,
>                 (UINTN)PayloadBootInfo->SpMemLimit - PayloadBootInfo->SpMemBase,
>                 (VOID *)(UINTN)PayloadBootInfo->SpHeapBase,
> -               (VOID *)(UINTN)(PayloadBootInfo->SpHeapBase + PayloadBootInfo->SpHeapSize)
> +               (VOID *)(UINTN)(PayloadBootInfo->SpHeapBase +MaxHobSize)
>                 );
>  
>    // Check that the Hoblist starts at the bottom of the Heap
> @@ -192,13 +193,13 @@ CreateHobListFromBootInfo (
>    // Base and size of heap memory shared by all cpus
>    MmramRanges[4].PhysicalStart = (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
>    MmramRanges[4].CpuStart      = (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
> -  MmramRanges[4].PhysicalSize  = HobStart->EfiFreeMemoryBottom - (EFI_PHYSICAL_ADDRESS)(UINTN)HobStart;
> +  MmramRanges[4].PhysicalSize  = MaxHobSize;
>    MmramRanges[4].RegionState   = EFI_CACHEABLE | EFI_ALLOCATED;
>  
>    // Base and size of heap memory shared by all cpus
> -  MmramRanges[5].PhysicalStart = HobStart->EfiFreeMemoryBottom;
> -  MmramRanges[5].CpuStart      = HobStart->EfiFreeMemoryBottom;
> -  MmramRanges[5].PhysicalSize  = HobStart->EfiFreeMemoryTop - HobStart->EfiFreeMemoryBottom;
> +  MmramRanges[5].PhysicalStart = HobStart->EfiFreeMemoryTop;
> +  MmramRanges[5].CpuStart      = HobStart->EfiFreeMemoryTop;
> +  MmramRanges[5].PhysicalSize  = PayloadBootInfo->SpHeapSize - MaxHobSize;
>    MmramRanges[5].RegionState   = EFI_CACHEABLE;
>  
>    return HobStart;
> diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> index 75cfb98c0e..c469ac2cca 100644
> --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf
> @@ -40,6 +40,7 @@
>  [LibraryClasses]
>    BaseLib
>    DebugLib
> +  PcdLib
>  
>  [LibraryClasses.ARM, LibraryClasses.AARCH64]
>    StandaloneMmMmuLib
> @@ -54,6 +55,9 @@
>  [FeaturePcd.ARM, FeaturePcd.AARCH64]
>    gArmTokenSpaceGuid.PcdFfaEnable
>  
> +[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

      reply	other threads:[~2022-02-09 12:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-08  2:43 [PATCH v1 1/1] StandaloneMmPkg: Fix HOB space and heap space conflicted issue Ming Huang
2022-02-09 12:13 ` Ming Huang [this message]

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=0c06c7ef-ac1c-2227-852d-d2b1ccc6e7f1@linux.alibaba.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