From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5AF11202E60ED for ; Wed, 25 Oct 2017 07:08:17 -0700 (PDT) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP; 25 Oct 2017 07:12:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,431,1503385200"; d="scan'208";a="327563656" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 25 Oct 2017 07:12:01 -0700 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Oct 2017 07:12:01 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Oct 2017 07:12:01 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Wed, 25 Oct 2017 22:11:59 +0800 From: "Ni, Ruiyu" To: "Dong, Eric" , "edk2-devel@lists.01.org" CC: Laszlo Ersek Thread-Topic: [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in PEI. Thread-Index: AQHTTWcWKN+sCyMNYE6t28AtU/aJG6L0m0qQ Date: Wed, 25 Oct 2017 14:11:55 +0000 Deferred-Delivery: Wed, 25 Oct 2017 14:11:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BAA5F87@SHSMSX104.ccr.corp.intel.com> References: <1508918319-10232-1-git-send-email-eric.dong@intel.com> In-Reply-To: <1508918319-10232-1-git-send-email-eric.dong@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2ExMTk0ZWItNmQ2OC00ZDNlLWFkYTYtZWQwNjJmMjY4ZjM4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX1BVQkxJQyJ9XX1dfSwiU3ViamVjdExhYmVscyI6W10sIlRNQ1ZlcnNpb24iOiIxNy4yLjUuMTgiLCJUcnVzdGVkTGFiZWxIYXNoIjoiQWY2aFM5dWZPdEFtTHZjXC9wc0hLaGRzSUdQSWg1Q2ZxbllESVZVbFJyekJqOVpEOXU3WWl4eWFhcnhkOGpxalcifQ== x-ctpclassification: CTP_PUBLIC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in PEI. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Oct 2017 14:08:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni -----Original Message----- From: Dong, Eric=20 Sent: Wednesday, October 25, 2017 3:59 PM To: edk2-devel@lists.01.org Cc: Ni, Ruiyu ; Laszlo Ersek Subject: [Patch] UefiCpuPkg/CpuFeatures: Export HOB if CPU initialized in P= EI. In current implementation, CPU initialized can be done in PEI or DXE phase.= PEI uses CpuFeaturesPie and Dxe uses CpuFeaturesDxe. If CPU initialized in PEI phase, CpuFeaturesDxe driver will not be used. Th= is driver will install gEdkiiCpuFeaturesInitDoneGuid protocol after it init= ializes the CPU. Some drivers depend on this protocol to dispatch themselves. If CpuFeatures= Dxe not been used, these drivers will not be dispatched. This patch fix the above issue. If Cpu initialized in PEI phase, it also re= port a guid HOB for CpuFeaturesDxe. CpuFeaturesDxe will check this HOB first. If it found this HOB, it just ins= tall gEdkiiCpuFeaturesInitDoneGuid protocol, else it will also do the CPU i= nitialization. Cc: Ruiyu Ni Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Eric Dong --- UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c | 19 +++++++++++++++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf | 1 + UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c | 6 ++++++ UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf | 1 + 4 files changed, 27 insertions(+) diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesDxe.c index b0b186d..6c0ae9d 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include #include @@ -101,6 +102,24 @@ CpuFeaturesDxeInitialize ( ) { VOID *Registration; + EFI_STATUS Status; + EFI_HANDLE Handle; + + if (GetFirstGuidHob (&gEdkiiCpuFeaturesInitDoneGuid) !=3D NULL) { + // + // Try to find HOB first. This HOB exist means CPU features have=20 + // been initialized by CpuFeaturesPei driver, just install gEdkiiCpuFe= aturesInitDoneGuid. + // + Handle =3D NULL; + Status =3D gBS->InstallProtocolInterface ( + &Handle, + &gEdkiiCpuFeaturesInitDoneGuid, + EFI_NATIVE_INTERFACE, + NULL + ); + ASSERT_EFI_ERROR (Status); + return EFI_SUCCESS; + } =20 if (PcdGetBool (PcdCpuFeaturesInitAfterSmmRelocation)) { // diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesDxe.inf index 175e8a9..b1733be 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesDxe.inf @@ -33,6 +33,7 @@ UefiDriverEntryPoint UefiBootServicesTableLib RegisterCpuFeaturesLib + HobLib =20 [Sources] CpuFeaturesDxe.c diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c b/UefiCpuPkg/CpuFeatur= es/CpuFeaturesPei.c index b052d55..72ee19b 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 #include =20 @@ -70,6 +71,11 @@ CpuFeaturesPeimInitialize ( Status =3D PeiServicesInstallPpi(&mPeiCpuFeaturesInitDonePpiDesc); ASSERT_EFI_ERROR (Status); =20 + // + // Build HOB to let CpuFeatureDxe driver skip the initialization process= . + // + BuildGuidHob (&gEdkiiCpuFeaturesInitDoneGuid, 0); + return EFI_SUCCESS; } =20 diff --git a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf b/UefiCpuPkg/CpuFeat= ures/CpuFeaturesPei.inf index dd4b388..e617c5b 100644 --- a/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf +++ b/UefiCpuPkg/CpuFeatures/CpuFeaturesPei.inf @@ -32,6 +32,7 @@ PeimEntryPoint PeiServicesLib RegisterCpuFeaturesLib + HobLib =20 [Sources] CpuFeaturesPei.c -- 2.7.0.windows.1