From: Dawn <shedvll@yahoo.com>
To: devel@edk2.groups.io, jiewen.yao@intel.com, "Yao,
Jiewen" <jiewen.yao@intel.com>, Kun Qin <kun.q@outlook.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Subject: Re: [edk2-devel] [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core
Date: Wed, 24 Mar 2021 20:33:30 +0000 (UTC) [thread overview]
Message-ID: <1027562214.3043619.1616618010539@mail.yahoo.com> (raw)
In-Reply-To: <CY4PR11MB1288F5E6BFD56F4A00CA33EA8CD90@CY4PR11MB1288.namprd11.prod.outlook.com>
[-- Attachment #1: Type: text/plain, Size: 13293 bytes --]
Importing spamReporting Tracking successful
On Fri, Mar 12, 2021 at 4:46 AM, Yao, Jiewen<jiewen.yao@intel.com> wrote: Can we merge the common part between X64 and AArch64 into one Common.c?
> -----Original Message-----
> From: Kun Qin <kun.q@outlook.com>
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Sami Mujawar
> <sami.mujawar@arm.com>; Yao, Jiewen <jiewen.yao@intel.com>; Supreeth
> Venkatesh <supreeth.venkatesh@arm.com>
> Subject: [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib:
> Extend support for x64 Mm Core
>
> This change adds support of x64 version of StandaloneMmCoreHobLib. It
> brings in global variable "gHobList" through StandaloneMmCoreEntryPoint
> and imports implementation from DxeCoreHobLib.inf to support x64 Mm
> Core.
>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Sami Mujawar <sami.mujawar@arm.com>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
>
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/{ =>
> AArch64}/StandaloneMmCoreHobLib.c | 6 +-
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/{ =>
> X64}/StandaloneMmCoreHobLib.c | 426 ++++++++++----------
>
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCore
> HobLib.inf | 8 +-
> 3 files changed, 215 insertions(+), 225 deletions(-)
>
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo
> reHobLib.c
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/Standal
> oneMmCoreHobLib.c
> similarity index 96%
> copy from
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCore
> HobLib.c
> copy to
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/Standalon
> eMmCoreHobLib.c
> index e3d4743b63f2..006bff816e39 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo
> reHobLib.c
> +++
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/AArch64/Standal
> oneMmCoreHobLib.c
> @@ -13,14 +13,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/HobLib.h>
> #include <Library/DebugLib.h>
> #include <Library/BaseMemoryLib.h>
> +#include <Library/StandaloneMmCoreEntryPoint.h>
>
> #include <Guid/MemoryAllocationHob.h>
>
> -//
> -// Cache copy of HobList pointer.
> -//
> -VOID *gHobList = NULL;
> -
> /**
> Returns the pointer to the HOB list.
>
> diff --git
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo
> reHobLib.c
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/X64/Standalone
> MmCoreHobLib.c
> similarity index 70%
> rename from
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCore
> HobLib.c
> rename to
> StandaloneMmPkg/Library/StandaloneMmCoreHobLib/X64/StandaloneM
> mCoreHobLib.c
> index e3d4743b63f2..69b20bf07a21 100644
> ---
> a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo
> reHobLib.c
> +++
> b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/X64/Standalone
> MmCoreHobLib.c
> @@ -13,14 +13,10 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> #include <Library/HobLib.h>
> #include <Library/DebugLib.h>
> #include <Library/BaseMemoryLib.h>
> +#include <Library/StandaloneMmCoreEntryPoint.h>
>
> #include <Guid/MemoryAllocationHob.h>
>
> -//
> -// Cache copy of HobList pointer.
> -//
> -VOID *gHobList = NULL;
> -
> /**
> Returns the pointer to the HOB list.
>
> @@ -203,48 +199,13 @@ GetBootModeHob (
> return HandOffHob->BootMode;
> }
>
> -VOID *
> -CreateHob (
> - IN UINT16 HobType,
> - IN UINT16 HobLength
> - )
> -{
> - EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
> - EFI_HOB_GENERIC_HEADER *HobEnd;
> - EFI_PHYSICAL_ADDRESS FreeMemory;
> - VOID *Hob;
> -
> - HandOffHob = GetHobList ();
> -
> - HobLength = (UINT16)((HobLength + 0x7) & (~0x7));
> -
> - FreeMemory = HandOffHob->EfiFreeMemoryTop - HandOffHob-
> >EfiFreeMemoryBottom;
> -
> - if (FreeMemory < HobLength) {
> - return NULL;
> - }
> -
> - Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
> - ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType = HobType;
> - ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength = HobLength;
> - ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved = 0;
> -
> - HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength);
> - HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN)
> HobEnd;
> -
> - HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
> - HobEnd->HobLength = sizeof (EFI_HOB_GENERIC_HEADER);
> - HobEnd->Reserved = 0;
> - HobEnd++;
> - HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN)
> HobEnd;
> -
> - return Hob;
> -}
> -
> /**
> Builds a HOB for a loaded PE32 module.
>
> This function builds a HOB for a loaded PE32 module.
> + It can only be invoked during PEI phase;
> + for MM phase, it will ASSERT() because PEI HOB is read-only for MM
> phase.
> +
> If ModuleName is NULL, then ASSERT().
> If there is no additional space for HOB creation, then ASSERT().
>
> @@ -263,31 +224,51 @@ BuildModuleHob (
> IN EFI_PHYSICAL_ADDRESS EntryPoint
> )
> {
> - EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
> + //
> + // PEI HOB is read only for MM phase
> + //
> + ASSERT (FALSE);
> +}
>
> - ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) == 0) &&
> - ((ModuleLength & (EFI_PAGE_SIZE - 1)) == 0));
> +/**
> + Builds a HOB that describes a chunk of system memory with Owner GUID.
>
> - Hob = CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof
> (EFI_HOB_MEMORY_ALLOCATION_MODULE));
> + This function builds a HOB that describes a chunk of system memory.
> + It can only be invoked during PEI phase;
> + for MM phase, it will ASSERT() since PEI HOB is read-only for MM phase.
>
> - CopyGuid (&(Hob->MemoryAllocationHeader.Name),
> &gEfiHobMemoryAllocModuleGuid);
> - Hob->MemoryAllocationHeader.MemoryBaseAddress =
> MemoryAllocationModule;
> - Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;
> - Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;
> + If there is no additional space for HOB creation, then ASSERT().
>
> + @param ResourceType The type of resource described by this HOB.
> + @param ResourceAttribute The resource attributes of the memory
> described by this HOB.
> + @param PhysicalStart The 64 bit physical address of memory
> described by this HOB.
> + @param NumberOfBytes The length of the memory described by this
> HOB in bytes.
> + @param OwnerGUID GUID for the owner of this resource.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildResourceDescriptorWithOwnerHob (
> + IN EFI_RESOURCE_TYPE ResourceType,
> + IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
> + IN EFI_PHYSICAL_ADDRESS PhysicalStart,
> + IN UINT64 NumberOfBytes,
> + IN EFI_GUID *OwnerGUID
> + )
> +{
> //
> - // Zero the reserved space to match HOB spec
> + // PEI HOB is read only for MM phase
> //
> - ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob-
> >MemoryAllocationHeader.Reserved));
> -
> - CopyGuid (&Hob->ModuleName, ModuleName);
> - Hob->EntryPoint = EntryPoint;
> + ASSERT (FALSE);
> }
>
> /**
> Builds a HOB that describes a chunk of system memory.
>
> This function builds a HOB that describes a chunk of system memory.
> + It can only be invoked during PEI phase;
> + for MM phase, it will ASSERT() because PEI HOB is read-only for MM
> phase.
> +
> If there is no additional space for HOB creation, then ASSERT().
>
> @param ResourceType The type of resource described by this HOB.
> @@ -305,31 +286,32 @@ BuildResourceDescriptorHob (
> IN UINT64 NumberOfBytes
> )
> {
> - EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
> -
> - Hob = CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof
> (EFI_HOB_RESOURCE_DESCRIPTOR));
> - ASSERT (Hob != NULL);
> -
> - Hob->ResourceType = ResourceType;
> - Hob->ResourceAttribute = ResourceAttribute;
> - Hob->PhysicalStart = PhysicalStart;
> - Hob->ResourceLength = NumberOfBytes;
> + //
> + // PEI HOB is read only for MM phase
> + //
> + ASSERT (FALSE);
> }
>
> /**
> - Builds a GUID HOB with a certain data length.
> + Builds a customized HOB tagged with a GUID for identification and
> returns
> + the start address of GUID HOB data.
>
> This function builds a customized HOB tagged with a GUID for
> identification
> and returns the start address of GUID HOB data so that caller can fill the
> customized data.
> The HOB Header and Name field is already stripped.
> + It can only be invoked during PEI phase.
> + For MM phase, it will ASSERT() because PEI HOB is read-only for MM
> phase.
> +
> If Guid is NULL, then ASSERT().
> If there is no additional space for HOB creation, then ASSERT().
> - If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is
> 0xFFF8.
>
> @param Guid The GUID to tag the customized HOB.
> @param DataLength The size of the data payload for the GUID HOB.
>
> - @return The start address of GUID HOB data.
> + @retval NULL The GUID HOB could not be allocated.
> + @retval others The start address of GUID HOB data.
>
> **/
> VOID *
> @@ -339,35 +321,36 @@ BuildGuidHob (
> IN UINTN DataLength
> )
> {
> - EFI_HOB_GUID_TYPE *Hob;
> -
> //
> - // Make sure that data length is not too long.
> + // PEI HOB is read only for MM phase
> //
> - ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
> -
> - Hob = CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof
> (EFI_HOB_GUID_TYPE) + DataLength));
> - CopyGuid (&Hob->Name, Guid);
> - return Hob + 1;
> + ASSERT (FALSE);
> + return NULL;
> }
>
> -
> /**
> - Copies a data buffer to a newly-built HOB.
> + Builds a customized HOB tagged with a GUID for identification, copies the
> input data to the HOB
> + data field, and returns the start address of the GUID HOB data.
>
> - This function builds a customized HOB tagged with a GUID for
> identification,
> - copies the input data to the HOB data field and returns the start address
> of the GUID HOB data.
> + This function builds a customized HOB tagged with a GUID for
> identification and copies the input
> + data to the HOB data field and returns the start address of the GUID HOB
> data. It can only be
> + invoked during PEI phase; for MM phase, it will ASSERT() because PEI
> HOB is read-only for MM phase.
> The HOB Header and Name field is already stripped.
> + It can only be invoked during PEI phase.
> + For MM phase, it will ASSERT() because PEI HOB is read-only for MM
> phase.
> +
> If Guid is NULL, then ASSERT().
> If Data is NULL and DataLength > 0, then ASSERT().
> If there is no additional space for HOB creation, then ASSERT().
> - If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> + If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> + HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is
> 0xFFF8.
>
> @param Guid The GUID to tag the customized HOB.
> @param Data The data to be copied into the data field of the GUID
> HOB.
> @param DataLength The size of the data payload for the GUID HOB.
>
> - @return The start address of GUID HOB data.
> + @retval NULL The GUID HOB could not be allocated.
> + @retval others The start address of GUID HOB data.
>
> **/
> VOID *
> @@ -378,20 +361,22 @@ BuildGuidDataHob (
> IN UINTN DataLength
> )
> {
> - VOID *HobData;
> -
> - ASSERT (Data != NULL || DataLength == 0);
> -
> - HobData = BuildGuidHob (Guid, DataLength);
> -
> - return CopyMem (HobData, Data, DataLength);
> + //
> + // PEI HOB is read only for MM phase
> + //
> + ASSERT (FALSE);
> + return NULL;
> }
>
> /**
> Builds a Firmware Volume HOB.
>
> This function builds a Firmware Volume HOB.
> + It can only be invoked during PEI phase;
> + for MM phase, it will ASSERT() because PEI HOB is read-only for MM
> phase.
> +
> If there is no additional space for HOB creation, then ASSERT().
> + If the FvImage buffer is not at its required alignment, then ASSERT()
[-- Attachment #2: Type: text/html, Size: 26508 bytes --]
next prev parent reply other threads:[~2021-03-24 20:33 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201218185011.1366-1-kun.q@outlook.com>
2020-12-18 18:49 ` [PATCH v1 01/15] StandaloneMmPkg: StandaloneMmCoreEntryPoint: Extends support for X64 Kun Qin
2020-12-28 0:11 ` [edk2-devel] " Yao, Jiewen
2020-12-18 18:49 ` [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core Kun Qin
2020-12-28 0:12 ` Yao, Jiewen
2021-03-24 20:33 ` Dawn [this message]
2020-12-18 18:49 ` [PATCH v1 03/15] StandaloneMmPkg: StandaloneMmCoreMemoryAllocationLib: Fix compiler warning Kun Qin
2020-12-28 0:14 ` Yao, Jiewen
2020-12-28 4:07 ` Kun Qin
2020-12-18 18:50 ` [PATCH v1 04/15] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Kun Qin
2020-12-28 0:18 ` Yao, Jiewen
2020-12-28 4:15 ` Kun Qin
2020-12-28 6:24 ` Yao, Jiewen
2020-12-28 6:36 ` Kun Qin
2020-12-28 6:37 ` [edk2-devel] " Yao, Jiewen
2020-12-18 18:50 ` [PATCH v1 05/15] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Kun Qin
2020-12-22 8:35 ` [edk2-devel] " Wu, Hao A
2020-12-18 18:50 ` [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Kun Qin
2020-12-22 8:35 ` [edk2-devel] " Wu, Hao A
2020-12-22 19:15 ` Kun Qin
2020-12-23 6:09 ` Wu, Hao A
2020-12-24 1:53 ` 回复: " gaoliming
2020-12-24 9:11 ` Kun Qin
2020-12-29 1:23 ` 回复: " gaoliming
2020-12-29 1:31 ` Kun Qin
2020-12-18 18:50 ` [PATCH v1 07/15] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Kun Qin
2020-12-22 8:36 ` Wu, Hao A
2020-12-22 20:06 ` [edk2-devel] " Kun Qin
2020-12-18 18:50 ` [PATCH v1 08/15] MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router Kun Qin
2020-12-22 8:42 ` Wu, Hao A
2020-12-18 18:50 ` [PATCH v1 09/15] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Kun Qin
2021-01-04 18:32 ` [edk2-devel] " Kun Qin
2021-01-05 13:25 ` 回复: " gaoliming
2020-12-18 18:50 ` [PATCH v1 10/15] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Kun Qin
2021-01-04 18:30 ` [edk2-devel] " Kun Qin
2020-12-18 18:50 ` [PATCH v1 11/15] SecurityPkg: Tcg2PhysicalPresenceLib: Introduce StandaloneMm instance Kun Qin
2020-12-28 0:08 ` Yao, Jiewen
2020-12-18 18:50 ` [PATCH v1 12/15] SecurityPkg: Tcg2PpVendorLibNull: Added support for MM_STANDALONE type Kun Qin
2020-12-28 0:08 ` Yao, Jiewen
2020-12-18 18:50 ` [PATCH v1 13/15] SecurityPkg: Tpm2DeviceLibDTpm: Introduce StandaloneMm instance Kun Qin
2020-12-28 0:08 ` Yao, Jiewen
2020-12-18 18:50 ` [PATCH v1 14/15] UefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm Kun Qin
2021-01-04 18:31 ` [edk2-devel] " Kun Qin
2020-12-18 18:50 ` [PATCH v1 15/15] UefiCpuPkg: SmmCpuExceptionHandlerLib: Added StandaloneMm module support Kun Qin
2021-01-04 18:30 ` [edk2-devel] " Kun Qin
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=1027562214.3043619.1616618010539@mail.yahoo.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