From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by mx.groups.io with SMTP id smtpd.web12.25684.1644408806437960630 for ; Wed, 09 Feb 2022 04:13:27 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: linux.alibaba.com, ip: 115.124.30.131, mailfrom: huangming@linux.alibaba.com) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R251e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=huangming@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0V4.E1Wp_1644408800; Received: from 30.212.161.191(mailfrom:huangming@linux.alibaba.com fp:SMTPD_---0V4.E1Wp_1644408800) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Feb 2022 20:13:21 +0800 Message-ID: <0c06c7ef-ac1c-2227-852d-d2b1ccc6e7f1@linux.alibaba.com> Date: Wed, 9 Feb 2022 20:13:20 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH v1 1/1] StandaloneMmPkg: Fix HOB space and heap space conflicted issue 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 References: <20220208024319.32841-1-huangming@linux.alibaba.com> From: "Ming Huang" In-Reply-To: <20220208024319.32841-1-huangming@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 > --- > 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