From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.39781.1609114333032890501 for ; Sun, 27 Dec 2020 16:12:13 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=XJjHDOq6; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: jiewen.yao@intel.com) IronPort-SDR: HtSUxZE0L1eKky8vrvOQVzZEt2PoUChXFeGvtZ5OIN70xqBAWNd1fKnHhr0anTxxrWerSgbmFK ZFVm6+GWo4jA== X-IronPort-AV: E=McAfee;i="6000,8403,9847"; a="163391452" X-IronPort-AV: E=Sophos;i="5.78,453,1599548400"; d="scan'208";a="163391452" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2020 16:12:12 -0800 IronPort-SDR: 64/AnU8lxGT82tBN6ML4yOOH7uBtLp7OuBj3Rsaexbuf1f3bwOjLU0Ler0g4ghAM1iv3bGbPTu 2TYQlVXrIQJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,453,1599548400"; d="scan'208";a="375404004" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga008.jf.intel.com with ESMTP; 27 Dec 2020 16:12:12 -0800 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Dec 2020 16:12:12 -0800 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Sun, 27 Dec 2020 16:12:11 -0800 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Sun, 27 Dec 2020 16:12:11 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.107) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Sun, 27 Dec 2020 16:12:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrGCxU/nxcAvTciylpbxnMDzh0qNLBgIncJ8hNq7qQ7qVixZaAUiJFytLM9wqCdstvIaQ/LAq+0eZGZp22rPw5lpURG+S5E3UGdgh8De8Uedgoe4Fa2kbcSqIqYbqbExhg2wV+N6mDAT6lDWGHLmW3zJwLIF+ZBg7sb0/T1wZ/Ntcr7HFf6X3Lvq4IbuzuhSNMUjDj1xpLyiZO1YM0XGav4yXwIVUDsKy0QODBiwJ2msH4VhH8FyUkYTQw0JazyeiYSozdx6aIZ7FtUt7RsGz41NDqHMAQK4G6X11csGwNFCflrI3FgNHumDRhhmKLmbzdF/WadaJATQES8gliOGLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RjjO2dzxKapZwGKvk0Hp9kWFhzDFgcQjfC6/josDy+8=; b=ZPmP8NFCGFT366tYv6Om2MwHoqXfpJ+Wn4+b6lGx6Jvv/K/QFClRtKu0J4N0MvXHg1ITnXw9/hCMhtEsq1EXsqOfoeL3gXYEREqE/Lf/JdYN9vxm0nO5kqzhWYdQZiXB/4r1YFba8qhAZ68cRjnKgaeJ2xtuWb8pSMyn2HZujXDqo1MMAMF2gd0CS8ZXJFNC5Iz778o1wv6tGI1JP4RXbZvDMk7ih2/KNepiAEBDd1xxmSNd5JW9d7PTlWzwkHGKCiY6bV+2yLLSr2qH9eIMBc5Q/KY8B7OalLoeUBNJV2xc+3HXpUAO2kYzj9ux3uTf1SyOGp6Km/OcoMqos7rCQg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RjjO2dzxKapZwGKvk0Hp9kWFhzDFgcQjfC6/josDy+8=; b=XJjHDOq6A6+j9CqhafqOFVPs9o0HJF1+9jptrXd/HCukc5EsRijXcHfRQ8Tww8ESG9Ji2LMplGEv/Q+97NZ1f7jfYJ3KTYNhpJ4FeXVo5RZl1ZJBRDk8ozF0e0lv2CXokzXQq1tPaoEjmOzO9Mur9STwDfEE81CphZmoMsakzdI= Received: from CY4PR11MB1288.namprd11.prod.outlook.com (2603:10b6:903:23::8) by CY4PR11MB0054.namprd11.prod.outlook.com (2603:10b6:910:79::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3611.31; Mon, 28 Dec 2020 00:12:07 +0000 Received: from CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17]) by CY4PR11MB1288.namprd11.prod.outlook.com ([fe80::e058:fd5a:28d8:2b17%12]) with mapi id 15.20.3700.031; Mon, 28 Dec 2020 00:12:07 +0000 From: "Yao, Jiewen" To: Kun Qin , "devel@edk2.groups.io" CC: Ard Biesheuvel , Sami Mujawar , Supreeth Venkatesh Subject: Re: [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core Thread-Topic: [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core Thread-Index: AQHW1W6yJ+hOnkk8QkazJ5fQM0JfV6oLsQbA Date: Mon, 28 Dec 2020 00:12:06 +0000 Message-ID: References: <20201218185011.1366-1-kun.q@outlook.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: outlook.com; dkim=none (message not signed) header.d=none;outlook.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.37] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 978e04ea-2dc8-4f79-5795-08d8aac5365f x-ms-traffictypediagnostic: CY4PR11MB0054: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: KwpN990Ayi07r8HVhYe17NTom0GFticfjIr+afpT6M7LfXlmZHU3UsrPYyHlqV3eJYvmv+5ZzNZ+MRO9NabKSjSGqq1VSNgsrJnfikWXx+EGk4CKghxwwi0eEV0m2iQF5LZsmQohaqaVxB+QYdiAykV5KDEc0DHgQeD2I7tgEOxvEAVnB9K2PJWPoYgNOg46/ll4dG8MiHAUsYiIBzYxBpAHQhyA022z+h9EgldKGKSPiv5+SSfCaLzol8ZnWXt1WETm9NMm6nh3JPY6SRJpKQUpsRN1xcOsh4LnG47dkVsIXJ8oi8+W4wVmBchjSFwQvCfJob1LRoDijssjG0tAEA== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR11MB1288.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(39860400002)(346002)(376002)(136003)(366004)(396003)(66476007)(4326008)(66446008)(26005)(54906003)(110136005)(5660300002)(2906002)(83380400001)(64756008)(52536014)(76116006)(86362001)(66946007)(8676002)(6506007)(19627235002)(8936002)(9686003)(316002)(7696005)(53546011)(71200400001)(55016002)(66556008)(30864003)(33656002)(478600001)(186003)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?FkO9VyZ5BFkuNvT3bF2v858ZnkuIXR+L3R/FtVbOLmNi5nRZlQ0ppWZeVDZm?= =?us-ascii?Q?pJGhpe0WvTwANO8/5lgXbXOcivNQIuXgIm6oK8uVRfNzsuSRzYRTLo5XqGXG?= =?us-ascii?Q?Gvb3gKg87/2cIuzliGosY00i3ay6Oa7NXYbSl/L4xEjSZkfF0txO7P53EvMh?= =?us-ascii?Q?VXTtavp9MohNo33qbbyotizCfiofqHgiBRg25nkFjhxH+jEzLR1rhFge+nG9?= =?us-ascii?Q?Q/XvZPvyN+JgXQx8gnoBrnOS9tmTSmkMpIMBtBh276wwCk64le7EXOFoNfRb?= =?us-ascii?Q?cMLAZDMdUB3vn01mAqeQUln/T0YRf36ulogwYV4j6O/EcpVa1u/JfMlZPIoM?= =?us-ascii?Q?XdY/CWGJE1FgAHQ6rlQYcPCLM7zMr1qBcaj6M5PpFWrTgOmCT+39l2twqksE?= =?us-ascii?Q?wDxoIql6OMuJO3OYaO+o5x8moWxrVGNYWxHZeQUsih7KEjhC3Omst9EzUUGW?= =?us-ascii?Q?0Hl6kETrMcSTaGQP78+XEcSTXZ3871bryrh92PyAT1zfCT7pPfNmcZ4ol//I?= =?us-ascii?Q?1QmdPAimKRR4DWAJReAy0X0i3omhPKy+Izc2n/0P03wJ/oWpByEddhi7mqcT?= =?us-ascii?Q?QmDLyLP7rRX0mVLusROVA8XH6v7TJk/fAGbM3YsLukmV4t6U1jJajmHlPJEF?= =?us-ascii?Q?jzMoAtxI4ZfAq7yuBBmeqnw+cYpALzp8mUneC4XTbgI3vw1Psm1R//bT6lzw?= =?us-ascii?Q?2h1P6UcWL9UltWTN0SrTQA6mPkCpOEyqlY+1VusRAjNX9oZrJdXRx/dSXKLz?= =?us-ascii?Q?njb/jrl4ejFzAMjJpxTYB5SYCaDHx1MFa+Jm9AQEpn46kCSzMWcKkbByQhAA?= =?us-ascii?Q?H4v6YHsjmQRIFK/XLzdEg2pLBSg8vgDbFeFoPzhsM3++iysgEQySgtv3Q0AF?= =?us-ascii?Q?09d4GpkBYaVEe0Q5X/Z8qASK3P971wgvMeuWGFVj/FbXhzDsD7zdQ3c6ifJG?= =?us-ascii?Q?urJlN3UM5545KO/mmw4CNjQ3i9ofwvIzefw7LNxQ+rs=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR11MB1288.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 978e04ea-2dc8-4f79-5795-08d8aac5365f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Dec 2020 00:12:06.9312 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: SxIcQHGO9tJputlkk5nLo/LBHfqp8OXPtJGdk/V2tzUgAHHuK2QsaVkfAfKWFIi4ANZUcghwq6Vmyal/o3MOmg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR11MB0054 Return-Path: jiewen.yao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Can we merge the common part between X64 and AArch64 into one Common.c? > -----Original Message----- > From: Kun Qin > Sent: Saturday, December 19, 2020 2:50 AM > To: devel@edk2.groups.io > Cc: Ard Biesheuvel ; Sami Mujawar > ; Yao, Jiewen ; Supreeth > Venkatesh > Subject: [PATCH v1 02/15] StandaloneMmPkg: StandaloneMmCoreHobLib: > Extend support for x64 Mm Core >=20 > 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. >=20 > Cc: Ard Biesheuvel > Cc: Sami Mujawar > Cc: Jiewen Yao > Cc: Supreeth Venkatesh >=20 > Signed-off-by: Kun Qin > --- > StandaloneMmPkg/Library/StandaloneMmCoreHobLib/{ =3D> > AArch64}/StandaloneMmCoreHobLib.c | 6 +- > StandaloneMmPkg/Library/StandaloneMmCoreHobLib/{ =3D> > X64}/StandaloneMmCoreHobLib.c | 426 ++++++++++---------- >=20 > StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCore > HobLib.inf | 8 +- > 3 files changed, 215 insertions(+), 225 deletions(-) >=20 > 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 > #include > #include > +#include >=20 > #include >=20 > -// > -// Cache copy of HobList pointer. > -// > -VOID *gHobList =3D NULL; > - > /** > Returns the pointer to the HOB list. >=20 > 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 > #include > #include > +#include >=20 > #include >=20 > -// > -// Cache copy of HobList pointer. > -// > -VOID *gHobList =3D NULL; > - > /** > Returns the pointer to the HOB list. >=20 > @@ -203,48 +199,13 @@ GetBootModeHob ( > return HandOffHob->BootMode; > } >=20 > -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 =3D GetHobList (); > - > - HobLength =3D (UINT16)((HobLength + 0x7) & (~0x7)); > - > - FreeMemory =3D HandOffHob->EfiFreeMemoryTop - HandOffHob- > >EfiFreeMemoryBottom; > - > - if (FreeMemory < HobLength) { > - return NULL; > - } > - > - Hob =3D (VOID*) (UINTN) HandOffHob->EfiEndOfHobList; > - ((EFI_HOB_GENERIC_HEADER*) Hob)->HobType =3D HobType; > - ((EFI_HOB_GENERIC_HEADER*) Hob)->HobLength =3D HobLength; > - ((EFI_HOB_GENERIC_HEADER*) Hob)->Reserved =3D 0; > - > - HobEnd =3D (EFI_HOB_GENERIC_HEADER*) ((UINTN)Hob + HobLength); > - HandOffHob->EfiEndOfHobList =3D (EFI_PHYSICAL_ADDRESS) (UINTN) > HobEnd; > - > - HobEnd->HobType =3D EFI_HOB_TYPE_END_OF_HOB_LIST; > - HobEnd->HobLength =3D sizeof (EFI_HOB_GENERIC_HEADER); > - HobEnd->Reserved =3D 0; > - HobEnd++; > - HandOffHob->EfiFreeMemoryBottom =3D (EFI_PHYSICAL_ADDRESS) (UINTN) > HobEnd; > - > - return Hob; > -} > - > /** > Builds a HOB for a loaded PE32 module. >=20 > 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(). >=20 > @@ -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); > +} >=20 > - ASSERT (((MemoryAllocationModule & (EFI_PAGE_SIZE - 1)) =3D=3D 0) && > - ((ModuleLength & (EFI_PAGE_SIZE - 1)) =3D=3D 0)); > +/** > + Builds a HOB that describes a chunk of system memory with Owner GUID. >=20 > - Hob =3D 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= . >=20 > - CopyGuid (&(Hob->MemoryAllocationHeader.Name), > &gEfiHobMemoryAllocModuleGuid); > - Hob->MemoryAllocationHeader.MemoryBaseAddress =3D > MemoryAllocationModule; > - Hob->MemoryAllocationHeader.MemoryLength =3D ModuleLength; > - Hob->MemoryAllocationHeader.MemoryType =3D EfiBootServicesCode; > + If there is no additional space for HOB creation, then ASSERT(). >=20 > + @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 =3D EntryPoint; > + ASSERT (FALSE); > } >=20 > /** > Builds a HOB that describes a chunk of system memory. >=20 > 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(). >=20 > @param ResourceType The type of resource described by this HOB= . > @@ -305,31 +286,32 @@ BuildResourceDescriptorHob ( > IN UINT64 NumberOfBytes > ) > { > - EFI_HOB_RESOURCE_DESCRIPTOR *Hob; > - > - Hob =3D CreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof > (EFI_HOB_RESOURCE_DESCRIPTOR)); > - ASSERT (Hob !=3D NULL); > - > - Hob->ResourceType =3D ResourceType; > - Hob->ResourceAttribute =3D ResourceAttribute; > - Hob->PhysicalStart =3D PhysicalStart; > - Hob->ResourceLength =3D NumberOfBytes; > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > } >=20 > /** > - 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. >=20 > 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 >=3D (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. >=20 > @param Guid The GUID to tag the customized HOB. > @param DataLength The size of the data payload for the GUID HOB. >=20 > - @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. >=20 > **/ > 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 <=3D (0xffff - sizeof (EFI_HOB_GUID_TYPE))); > - > - Hob =3D CreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof > (EFI_HOB_GUID_TYPE) + DataLength)); > - CopyGuid (&Hob->Name, Guid); > - return Hob + 1; > + ASSERT (FALSE); > + return NULL; > } >=20 > - > /** > - 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. >=20 > - 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 addr= ess > 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 H= OB > 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 >=3D (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. >=20 > @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. >=20 > - @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. >=20 > **/ > VOID * > @@ -378,20 +361,22 @@ BuildGuidDataHob ( > IN UINTN DataLength > ) > { > - VOID *HobData; > - > - ASSERT (Data !=3D NULL || DataLength =3D=3D 0); > - > - HobData =3D BuildGuidHob (Guid, DataLength); > - > - return CopyMem (HobData, Data, DataLength); > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > + return NULL; > } >=20 > /** > Builds a Firmware Volume HOB. >=20 > 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(). >=20 > @param BaseAddress The base address of the Firmware Volume. > @param Length The size of the Firmware Volume in bytes. > @@ -404,24 +389,25 @@ BuildFvHob ( > IN UINT64 Length > ) > { > - EFI_HOB_FIRMWARE_VOLUME *Hob; > - > - Hob =3D CreateHob (EFI_HOB_TYPE_FV, sizeof > (EFI_HOB_FIRMWARE_VOLUME)); > - > - Hob->BaseAddress =3D BaseAddress; > - Hob->Length =3D Length; > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > } >=20 > - > /** > Builds a EFI_HOB_TYPE_FV2 HOB. >=20 > This function builds a EFI_HOB_TYPE_FV2 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(). >=20 > @param BaseAddress The base address of the Firmware Volume. > @param Length The size of the Firmware Volume in bytes. > - @param FvName The name of the Firmware Volume. > + @param FvName The name of the Firmware Volume. > @param FileName The name of the file. >=20 > **/ > @@ -434,21 +420,78 @@ BuildFv2Hob ( > IN CONST EFI_GUID *FileName > ) > { > - EFI_HOB_FIRMWARE_VOLUME2 *Hob; > + ASSERT (FALSE); > +} > + > +/** > + Builds a EFI_HOB_TYPE_FV3 HOB. > + > + This function builds a EFI_HOB_TYPE_FV3 HOB. > + It can only be invoked during PEI phase; > + for MM phase, it will ASSERT() since PEI HOB is read-only for MM phase= . >=20 > - Hob =3D CreateHob (EFI_HOB_TYPE_FV2, sizeof > (EFI_HOB_FIRMWARE_VOLUME2)); > + If there is no additional space for HOB creation, then ASSERT(). > + If the FvImage buffer is not at its required alignment, then ASSERT(). >=20 > - Hob->BaseAddress =3D BaseAddress; > - Hob->Length =3D Length; > - CopyGuid (&Hob->FvName, FvName); > - CopyGuid (&Hob->FileName, FileName); > + @param BaseAddress The base address of the Firmware Volume. > + @param Length The size of the Firmware Volume in bytes= . > + @param AuthenticationStatus The authentication status. > + @param ExtractedFv TRUE if the FV was extracted as a file w= ithin > + another firmware volume. FALSE otherwise= . > + @param FvName The name of the Firmware Volume. > + Valid only if IsExtractedFv is TRUE. > + @param FileName The name of the file. > + Valid only if IsExtractedFv is TRUE. > + > +**/ > +VOID > +EFIAPI > +BuildFv3Hob ( > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > + IN UINT64 Length, > + IN UINT32 AuthenticationStatus, > + IN BOOLEAN ExtractedFv, > + IN CONST EFI_GUID *FvName, OPTIONAL > + IN CONST EFI_GUID *FileName OPTIONAL > + ) > +{ > + ASSERT (FALSE); > } >=20 > +/** > + Builds a Capsule Volume HOB. > + > + This function builds a Capsule 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 the platform does not support Capsule Volume HOBs, then ASSERT(). > + If there is no additional space for HOB creation, then ASSERT(). > + > + @param BaseAddress The base address of the Capsule Volume. > + @param Length The size of the Capsule Volume in bytes. > + > +**/ > +VOID > +EFIAPI > +BuildCvHob ( > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > + IN UINT64 Length > + ) > +{ > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > +} >=20 > /** > Builds a HOB for the CPU. >=20 > This function builds a HOB for the CPU. > + 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(). >=20 > @param SizeOfMemorySpace The maximum physical memory > addressability of the processor. > @@ -462,122 +505,9 @@ BuildCpuHob ( > IN UINT8 SizeOfIoSpace > ) > { > - EFI_HOB_CPU *Hob; > - > - Hob =3D CreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU)); > - > - Hob->SizeOfMemorySpace =3D SizeOfMemorySpace; > - Hob->SizeOfIoSpace =3D SizeOfIoSpace; > - > // > - // Zero the reserved space to match HOB spec > + // PEI HOB is read only for MM phase > // > - ZeroMem (Hob->Reserved, sizeof (Hob->Reserved)); > -} > - > -/** > - Builds a HOB for the memory allocation. > - > - This function builds a HOB for the memory allocation. > - If there is no additional space for HOB creation, then ASSERT(). > - > - @param BaseAddress The 64 bit physical address of the memory. > - @param Length The length of the memory allocation in bytes. > - @param MemoryType Type of memory allocated by this HOB. > - > -**/ > -VOID > -EFIAPI > -BuildMemoryAllocationHob ( > - IN EFI_PHYSICAL_ADDRESS BaseAddress, > - IN UINT64 Length, > - IN EFI_MEMORY_TYPE MemoryType > - ) > -{ > - EFI_HOB_MEMORY_ALLOCATION *Hob; > - > - ASSERT (((BaseAddress & (EFI_PAGE_SIZE - 1)) =3D=3D 0) && > - ((Length & (EFI_PAGE_SIZE - 1)) =3D=3D 0)); > - > - Hob =3D CreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof > (EFI_HOB_MEMORY_ALLOCATION)); > - > - ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID)); > - Hob->AllocDescriptor.MemoryBaseAddress =3D BaseAddress; > - Hob->AllocDescriptor.MemoryLength =3D Length; > - Hob->AllocDescriptor.MemoryType =3D MemoryType; > - // > - // Zero the reserved space to match HOB spec > - // > - ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob- > >AllocDescriptor.Reserved)); > -} > - > -/** > - Builds a HOB that describes a chunk of system memory with Owner GUID. > - > - This function builds a HOB that describes a chunk of system memory. > - 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 > - ) > -{ > - ASSERT (FALSE); > -} > - > -/** > - Builds a Capsule Volume HOB. > - > - This function builds a Capsule Volume HOB. > - If the platform does not support Capsule Volume HOBs, then ASSERT(). > - If there is no additional space for HOB creation, then ASSERT(). > - > - @param BaseAddress The base address of the Capsule Volume. > - @param Length The size of the Capsule Volume in bytes. > - > -**/ > -VOID > -EFIAPI > -BuildCvHob ( > - IN EFI_PHYSICAL_ADDRESS BaseAddress, > - IN UINT64 Length > - ) > -{ > - ASSERT (FALSE); > -} > - > - > -/** > - Builds a HOB for the BSP store. > - > - This function builds a HOB for BSP store. > - If there is no additional space for HOB creation, then ASSERT(). > - > - @param BaseAddress The 64 bit physical address of the BSP. > - @param Length The length of the BSP store in bytes. > - @param MemoryType Type of memory allocated by this HOB. > - > -**/ > -VOID > -EFIAPI > -BuildBspStoreHob ( > - IN EFI_PHYSICAL_ADDRESS BaseAddress, > - IN UINT64 Length, > - IN EFI_MEMORY_TYPE MemoryType > - ) > -{ > ASSERT (FALSE); > } >=20 > @@ -585,6 +515,9 @@ BuildBspStoreHob ( > Builds a HOB for the Stack. >=20 > This function builds a HOB for the stack. > + 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(). >=20 > @param BaseAddress The 64 bit physical address of the Stack. > @@ -598,5 +531,64 @@ BuildStackHob ( > IN UINT64 Length > ) > { > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > +} > + > +/** > + Builds a HOB for the BSP store. > + > + This function builds a HOB for BSP store. > + 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 BaseAddress The 64 bit physical address of the BSP. > + @param Length The length of the BSP store in bytes. > + @param MemoryType Type of memory allocated by this HOB. > + > +**/ > +VOID > +EFIAPI > +BuildBspStoreHob ( > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > + IN UINT64 Length, > + IN EFI_MEMORY_TYPE MemoryType > + ) > +{ > + // > + // PEI HOB is read only for MM phase > + // > + ASSERT (FALSE); > +} > + > +/** > + Builds a HOB for the memory allocation. > + > + This function builds a HOB for the memory allocation. > + 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 BaseAddress The 64 bit physical address of the memory. > + @param Length The length of the memory allocation in bytes. > + @param MemoryType Type of memory allocated by this HOB. > + > +**/ > +VOID > +EFIAPI > +BuildMemoryAllocationHob ( > + IN EFI_PHYSICAL_ADDRESS BaseAddress, > + IN UINT64 Length, > + IN EFI_MEMORY_TYPE MemoryType > + ) > +{ > + // > + // PEI HOB is read only for MM phase > + // > ASSERT (FALSE); > } > diff --git > a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo > reHobLib.inf > b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmC > oreHobLib.inf > index 0046cd804def..e43a1e63bf14 100644 > --- > a/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmCo > reHobLib.inf > +++ > b/StandaloneMmPkg/Library/StandaloneMmCoreHobLib/StandaloneMmC > oreHobLib.inf > @@ -22,16 +22,18 @@ [Defines] > LIBRARY_CLASS =3D HobLib|MM_CORE_STANDALONE >=20 > # > -# VALID_ARCHITECTURES =3D AARCH64 > +# VALID_ARCHITECTURES =3D X64 AARCH64 > # > -[Sources.Common] > - StandaloneMmCoreHobLib.c > +[Sources.X64] > + X64/StandaloneMmCoreHobLib.c >=20 > [Sources.AARCH64] > + AArch64/StandaloneMmCoreHobLib.c > AArch64/StandaloneMmCoreHobLibInternal.c >=20 > [Packages] > MdePkg/MdePkg.dec > + StandaloneMmPkg/StandaloneMmPkg.dec >=20 >=20 > [LibraryClasses] > -- > 2.28.0.windows.1