From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web11.1567.1598466863690100233 for ; Wed, 26 Aug 2020 11:34:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=QplRnSw3; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: guo.dong@intel.com) IronPort-SDR: 1/iJD4uG5WEAxSOwMTub7Kd9XtNiDVqq7jjY0gzDQaZJiLyyK8HcOmdR0adZ4OMIwG2Feo9DQX +iYYZqOuepDw== X-IronPort-AV: E=McAfee;i="6000,8403,9725"; a="135913889" X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="135913889" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 11:34:15 -0700 IronPort-SDR: ersuwX9LpuKe46mM9Xa+wlgCNO2eFfUx665vHMR+9lFnTWsbROly9WN287Y+2Z9qvxSbA8xCtS w9xCI9lb15xQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,356,1592895600"; d="scan'208";a="474873789" Received: from orsmsx606-2.jf.intel.com (HELO ORSMSX606.amr.corp.intel.com) ([10.22.229.86]) by orsmga005.jf.intel.com with ESMTP; 26 Aug 2020 11:34:14 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Wed, 26 Aug 2020 11:34:14 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Wed, 26 Aug 2020 11:34:14 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.177) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Wed, 26 Aug 2020 11:34:13 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B+vWk6mhln43qRhI5JJ6e/hOau35CmftM8CmSUN1LJXiAF3SfnETApx7nj0aKxCAQOEV9saAlSZiRTQxFpZlmVI/RhHUEdGdOzZVqQGVDxwa4/pRpkQlpzzZdkEEK9wPvsDRI95IMMFRGgjktbEF40fGMPwr/8OmZZUqT3vFNxCNSTllohzPyV3qQ9FSaRhaQrqxh8IRXWJl7IHWKQMOJbJuXXMfwFzYVPI6xMwzb/s5Z5H/hIxuAfj4Qg3t0HolApkVp1Ct5rG+MMtsBlB99CPZWIhHeJ2yezrgcrckO9B7e9v97La8bCq9q4Up+AG0WyOPT4rbnmLloCDHgx0DKw== 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=gqannYGBzsyKNgeImOFmTtV24E4Bj2856whacDvnNj0=; b=SxT8rzYOIbVHfFpCQ54M+gRPMqZdR+3eVb/4PRLny84/DBCfzq2EnNgq+7Lqp7VczMnyCr16y8pkAwo117sFU5uibT8GKWLNYHD5ESjL6szPWbheqgR+znQBSnvK7WxcJQzzXf36iT28qO+pTtpc0rJTdw6rocdmlhgz6VYoDoLaaQEq0dIeknrf7iu8+vgAtRJ/Wfn1KmXfY4LXHFLYpttfPykD8+4OBAfhb2tl01M1y+RmqLLJ+urLiWgtKfisZ/jOOudyXgV3jZUhul7peVybSUsCtooC52NSy6FbZXDWFN1Hd5RC7D0venwca6r0GHLjv+fHRYG6FplOUlrNMg== 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=gqannYGBzsyKNgeImOFmTtV24E4Bj2856whacDvnNj0=; b=QplRnSw3YAzgM4yX0zWo/K54BBIpEI5Mp+WOHPNM84/H7s21BsSL9Vm/nbnvqjdz2RwlZ+qJh/D8cOBbgu8alHyDXQv6qSImqD6GLqqMizRXFi0jZndkP0jsZ/qjkuEPiHnroPrIsL/Z3rl8t/R50Z05jTCT1wLE3eSUHnYTlSw= Received: from BYAPR11MB3622.namprd11.prod.outlook.com (2603:10b6:a03:fe::30) by BYAPR11MB2840.namprd11.prod.outlook.com (2603:10b6:a02:c9::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3305.26; Wed, 26 Aug 2020 18:34:12 +0000 Received: from BYAPR11MB3622.namprd11.prod.outlook.com ([fe80::edcc:d9ab:61a6:bd13]) by BYAPR11MB3622.namprd11.prod.outlook.com ([fe80::edcc:d9ab:61a6:bd13%3]) with mapi id 15.20.3305.032; Wed, 26 Aug 2020 18:34:12 +0000 From: "Guo Dong" To: "Dong, Guo" , "leif@nuviainc.com" , "ard.biesheuvel@arm.com" , "Ma, Maurice" CC: "devel@edk2.groups.io" Subject: Re: [edk2-devel] [PATCH] [EmbeddedPkg]:Update PrePiLib to return DxeCoreEntrypoint Thread-Topic: [edk2-devel] [PATCH] [EmbeddedPkg]:Update PrePiLib to return DxeCoreEntrypoint Thread-Index: AQHWaF7rN7EdYDVXGUSKORIkVanuuKlK3crg Date: Wed, 26 Aug 2020 18:34:11 +0000 Message-ID: References: <16274A04AA5F3FDA.22185@groups.io> In-Reply-To: <16274A04AA5F3FDA.22185@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [68.2.51.172] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7f621c86-ca39-40a2-02df-08d849eea0e0 x-ms-traffictypediagnostic: BYAPR11MB2840: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Oy9Tcm98edRczSZGGDd6iMawIuss6a+dG0Xch0amyonOaXHhZKrDceUa6KIqV22o45zAoRv/uPDC1yYwqsUypRLImslUKYn6mG4H51bdpJRXAceXVTU818mlPOfN9CwgYTkpZBUKOuRNFE+HenE9T6JrBtCDwRswb6WhSrzpTNaycD1yoTNoQwCgHzOiygX4nlRallhycfT6wzcq2Nz7qtQOJ/GFVwG8vrFsMdTVyBXOU0eIONnfyznS3hqhbzJgxEWI1O0UnM0QpWfXaoklQd0KxiVl3snJ66KbADFQwLO1Ehw/KsakQCxok4yvxq2B9wqBMB5Rn86vzH105Kd3w+h0v90j3nHr+bqyUGK2osm8UdRTtWv+TQlm13QPUfM7No4D45saotfmPjUEbCFMxg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3622.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(366004)(396003)(346002)(376002)(39860400002)(136003)(86362001)(6506007)(53546011)(76116006)(4326008)(66946007)(316002)(66446008)(66556008)(7696005)(64756008)(66476007)(8676002)(26005)(8936002)(110136005)(186003)(9686003)(55016002)(15650500001)(2906002)(478600001)(966005)(33656002)(6636002)(83380400001)(71200400001)(52536014)(5660300002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: 3UoAa+TsMcL9ROZ+piMlHyAkEVhyWqfIH9kdrror35LD8QUh+hWcXZj36+PwwzCb23MM5Fg11zFZeKcTJzhmbm9bPNmYOhgaX1FKTzIeHzKZ1Q9a2hAzkT9/tyLPOZyxuGhxuySPxR5QwgbZnKy8f30XIAMMMqIDPQjrpWLqC3hKm05U8C7/Iqnuly6L7wAH1L+oYm4/gn7/Z8+aUW8MbtU6WjNMhDhugWfrKsag+mTtQrcoA36CQslPN6SOcLxUnx3ELlnILR4APQJ3zSo7dByxI+gTKSo9jrd1Nz/7BtJIExO4ajWZ+9huuuGUbMZaax5c+tQu6bAvDV6SD3nTCaN4sQ5H1Na4jYYuHfkz58V+vNg0GnhbaTSAa8w4+n1UvfJMpkYN7Enp1Dlb6NOQKv1HPPlKBnJPDeO3C/RmJLwbuB00VYJFcnXl/BJJezJpylV3H71KX0I5n9LRckC0KlIkcPTDuj+3Xse6QEuFQLG4IMlLZUEHM77zgKxv51iMqqym5lY8yayQii7VtIq2xeRuMLLX02+cL0AecD8Ppg7PS8OWJs8xbEehTKc8EmsVwzLAJ4gqVLRw2ZWaZj4/nuAOSHeDaleeqv3AAF+PEhrVVgsmWPCw6X+hFYPv6La6iLS4/lM5lTX2zIzuB0zYpg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3622.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f621c86-ca39-40a2-02df-08d849eea0e0 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2020 18:34:12.1325 (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: WqIBhEwy+4BrDwwxMjGaB0Zpny2dYXe3ed0rUQ+6/d3bKMBhs3DFRxVYhdKY3zPxpw0QQII2WUSmsRxQmdVSJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2840 Return-Path: guo.dong@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Leif and Biesheuvel, Could you help review this patch? Thanks, Guo > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Guo Dong > Sent: Saturday, August 1, 2020 4:53 PM > To: devel@edk2.groups.io > Cc: leif@nuviainc.com; ard.biesheuvel@arm.com > Subject: [edk2-devel] [PATCH] [EmbeddedPkg]:Update PrePiLib to return > DxeCoreEntrypoint >=20 > Added LoadDxeCore() API to return DxeCore entry point after loading DxeC= ore > from FV, and del LoadDxeCoreFromFfsFile() as it is replaced by LoadDxeCo= re(). > Update LoadDxeCoreFromFv() to use LoadDxeCore() to reduce code, and its > behavior is same. > Updated FfsProcessSection() to support both IA32 and X64 build. > With this patch, PrePiLib could be used by UefiPayloadPkg to load DxeCor= e > and get its entry point. >=20 > Signed-off-by: Guo Dong > --- > EmbeddedPkg/Include/Library/PrePiLib.h | 17 ++++++++++++++--- > EmbeddedPkg/Library/PrePiLib/FwVol.c | 2 +- > EmbeddedPkg/Library/PrePiLib/PrePiLib.c | 95 > +++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- > ----------------------- > 3 files changed, 68 insertions(+), 46 deletions(-) >=20 > diff --git a/EmbeddedPkg/Include/Library/PrePiLib.h > b/EmbeddedPkg/Include/Library/PrePiLib.h > index 54f8e1e582..269907108e 100644 > --- a/EmbeddedPkg/Include/Library/PrePiLib.h > +++ b/EmbeddedPkg/Include/Library/PrePiLib.h > @@ -735,11 +735,22 @@ LoadPeCoffImage ( > OUT EFI_PHYSICAL_ADDRESS *EntryPoint > ); >=20 > + > +/** > + Load DXE core from FV and return DXE core entrypoint. > + > + @param[in] FvInstance The FV instance to search DXE core. Wi= ll search > all the FVs if it is NULL. > + @param[out] EntryPoint DXE core entrypoint. > + > + @return EFI_SUCCESS The DxeCore is loaded successfully. > + @return Others Failed to load the DxeCore. > + > +**/ > EFI_STATUS > EFIAPI > -LoadDxeCoreFromFfsFile ( > - IN EFI_PEI_FILE_HANDLE FileHandle, > - IN UINTN StackSize > +LoadDxeCore ( > + IN UINTN *FvInstance, OPTIONAL > + OUT EFI_PHYSICAL_ADDRESS *EntryPoint > ); >=20 > EFI_STATUS > diff --git a/EmbeddedPkg/Library/PrePiLib/FwVol.c > b/EmbeddedPkg/Library/PrePiLib/FwVol.c > index 881506eddd..46ea5f733f 100644 > --- a/EmbeddedPkg/Library/PrePiLib/FwVol.c > +++ b/EmbeddedPkg/Library/PrePiLib/FwVol.c > @@ -298,7 +298,7 @@ FfsProcessSection ( > UINT16 SectionAttribute; > UINT32 AuthenticationStatus; > CHAR8 *CompressedData; > - UINTN CompressedDataLength; > + UINT32 CompressedDataLength; >=20 >=20 > *OutputBuffer =3D NULL; > diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c > b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c > index afbe146632..c18b30e22e 100644 > --- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.c > +++ b/EmbeddedPkg/Library/PrePiLib/PrePiLib.c > @@ -119,30 +119,52 @@ VOID > IN VOID *HobStart > ); >=20 > +/** > + Load DXE core from FV and return DXE core entrypoint. > + > + @param[in] FvInstance The FV instance to search DXE core. Wi= ll search > all the FVs if it is NULL. > + @param[out] EntryPoint DXE core entrypoint. > + > + @return EFI_SUCCESS The DxeCore is loaded successfully. > + @return Others Failed to load the DxeCore. > + > +**/ > EFI_STATUS > EFIAPI > -LoadDxeCoreFromFfsFile ( > - IN EFI_PEI_FILE_HANDLE FileHandle, > - IN UINTN StackSize > +LoadDxeCore ( > + IN UINTN *FvInstance, OPTIONAL > + OUT EFI_PHYSICAL_ADDRESS *EntryPoint > ) > { > EFI_STATUS Status; > + EFI_PEI_FV_HANDLE VolumeHandle; > + EFI_PEI_FILE_HANDLE FileHandle; > VOID *PeCoffImage; > EFI_PHYSICAL_ADDRESS ImageAddress; > UINT64 ImageSize; > - EFI_PHYSICAL_ADDRESS EntryPoint; > - VOID *BaseOfStack; > - VOID *TopOfStack; > - VOID *Hob; > EFI_FV_FILE_INFO FvFileInfo; >=20 > + FileHandle =3D NULL; > + if (FvInstance !=3D NULL) { > + // > + // Caller passed in a specific FV to try, so only try that one > + // > + Status =3D FfsFindNextVolume (*FvInstance, &VolumeHandle); > + if (!EFI_ERROR (Status)) { > + Status =3D FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandl= e, > &FileHandle); > + } > + } else { > + Status =3D FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, > &VolumeHandle, &FileHandle); > + DEBUG ((EFI_D_ERROR, "FfsAnyFvFindFirstFile Status =3D %r\n", Statu= s)); > + } > + > Status =3D FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffI= mage); > if (EFI_ERROR (Status)) { > return Status; > } >=20 >=20 > - Status =3D LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, > &EntryPoint); > + Status =3D LoadPeCoffImage (PeCoffImage, &ImageAddress, &ImageSize, > EntryPoint); > // For NT32 Debug Status =3D SecWinNtPeiLoadFile (PeCoffImage, > &ImageAddress, &ImageSize, &EntryPoint); > ASSERT_EFI_ERROR (Status); >=20 > @@ -152,13 +174,33 @@ LoadDxeCoreFromFfsFile ( > Status =3D FfsGetFileInfo (FileHandle, &FvFileInfo); > ASSERT_EFI_ERROR (Status); >=20 > - BuildModuleHob (&FvFileInfo.FileName, > (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) > ImageSize) * EFI_PAGE_SIZE, EntryPoint); > + BuildModuleHob (&FvFileInfo.FileName, > (EFI_PHYSICAL_ADDRESS)(UINTN)ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) > ImageSize) * EFI_PAGE_SIZE, *EntryPoint); >=20 > - DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p > EntryPoint=3D0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID > *)(UINTN)EntryPoint)); > + DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Loading DxeCore at 0x%10p > EntryPoint=3D0x%10p\n", (VOID *)(UINTN)ImageAddress, (VOID > *)(UINTN)*EntryPoint)); > + > + return EFI_SUCCESS; > +} > + > + > +EFI_STATUS > +EFIAPI > +LoadDxeCoreFromFv ( > + IN UINTN *FvInstance, OPTIONAL > + IN UINTN StackSize > + ) > +{ > + EFI_STATUS Status; > + EFI_PHYSICAL_ADDRESS EntryPoint; > + VOID *BaseOfStack; > + VOID *TopOfStack; > + VOID *Hob; > + > + Status =3D LoadDxeCore (FvInstance, &EntryPoint); > + ASSERT_EFI_ERROR (Status); >=20 > Hob =3D GetHobList (); > if (StackSize =3D=3D 0) { > - // User the current stack > + // Use the current stack >=20 > ((DXE_CORE_ENTRY_POINT)(UINTN)EntryPoint) (Hob); > } else { > @@ -199,37 +241,6 @@ LoadDxeCoreFromFfsFile ( >=20 >=20 >=20 > -EFI_STATUS > -EFIAPI > -LoadDxeCoreFromFv ( > - IN UINTN *FvInstance, OPTIONAL > - IN UINTN StackSize > - ) > -{ > - EFI_STATUS Status; > - EFI_PEI_FV_HANDLE VolumeHandle; > - EFI_PEI_FILE_HANDLE FileHandle =3D NULL; > - > - if (FvInstance !=3D NULL) { > - // > - // Caller passed in a specific FV to try, so only try that one > - // > - Status =3D FfsFindNextVolume (*FvInstance, &VolumeHandle); > - if (!EFI_ERROR (Status)) { > - Status =3D FfsFindNextFile (EFI_FV_FILETYPE_DXE_CORE, VolumeHandl= e, > &FileHandle); > - } > - } else { > - Status =3D FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_DXE_CORE, > &VolumeHandle, &FileHandle); > - } > - > - if (!EFI_ERROR (Status)) { > - return LoadDxeCoreFromFfsFile (FileHandle, StackSize); > - } > - > - return Status; > -} > - > - > EFI_STATUS > EFIAPI > DecompressFirstFv ( > -- > 2.16.2.windows.1 >=20 >=20 >=20