From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.72.49; helo=eur03-ve1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-oln040092072049.outbound.protection.outlook.com [40.92.72.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5A18F207E540E for ; Fri, 25 May 2018 05:08:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U0mP7vg1HIkVpD5it3/UZdAoKnrnv4g3+AXB4CultP8=; b=JvVIUs6OhNfov+WBRu63qYBBtLG2L5bHGilkUMvXeDHpqao+9YAJ8fJfX3drarc2wxdwPAPrSj3P8rmHhY6r5SxkAQ3eaqIMJ2AELufMCRwF0HL0tAxIePXlLlitu0JZX9CYdyGqi6R5glEIznzfn+4LnvNbzobxyMFmIQoZriXu5TyVYolQ8DHbT3xzzaxiYyp5zM9hurJLP/XycO5OsepmECxiqSCx7eCzwOtHzkzegnPBpGa0NFeVoruknmXLcjDM6wHDoAd6+J+HLVMFo7dgIEICZAtMHwXOnOYZUhE2OnJZIbo7kz+3+Oiuxp6S45GVuOaUX7VItYlbJcaQgg== Received: from VE1EUR03FT032.eop-EUR03.prod.protection.outlook.com (10.152.18.59) by VE1EUR03HT200.eop-EUR03.prod.protection.outlook.com (10.152.18.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.797.11; Fri, 25 May 2018 12:08:04 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.18.59) by VE1EUR03FT032.mail.protection.outlook.com (10.152.18.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.797.11 via Frontend Transport; Fri, 25 May 2018 12:08:04 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7010:5d5e:8dcf:d92e]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7010:5d5e:8dcf:d92e%17]) with mapi id 15.20.0797.011; Fri, 25 May 2018 12:08:04 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" , Laszlo Ersek CC: "eric.dong@intel.com" Thread-Topic: CpuS3DataDxe / DxeRegisterCpuFeaturesLib dependency. Thread-Index: AdP0FKyKttYo63uiQsS46d6wcJBt3AACINsAAABdjiA= Date: Fri, 25 May 2018 12:08:04 +0000 Message-ID: References: <2ef9271f-1bca-1d02-1ac8-fa845ff30ef7@redhat.com> In-Reply-To: <2ef9271f-1bca-1d02-1ac8-fa845ff30ef7@redhat.com> Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:CED6F3BD3C8EA41E5130FC9FE5723C8DEC73DB3ED51E52EAA69BE0E9C5CBFE3A; UpperCasedChecksum:4245523C482479654190D1EFDAEBE7B1D301C5422C492E99F4B43B4C5EF9E236; SizeAsReceived:7235; Count:46 x-tmn: [F7nGhkWrLywS4C5hpY2y/uILbWX2A/U7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR03HT200; 7:a37RluyqVEFy1R5uSoUxtU9+qTGKzKM9vzgDnVeqhl6y/mqOtbASCC6qPDOcnsb/99UO/NsIJOj61+E16184Xi5wyAw+u2oZXS8hgp5jAFiQBDkf/v1JglrOFKn66QkAa/pabBVc0QKbx7M4/mBlvez0exsQbBi0Z8dawKV60EiyMpNgHdKe1x9UDsNAfnFusiy9LJjggydidzIvMUPsZGd01bjAfLFrFnxQS8twiEP9+a+jD/rK8F/S4Dg20San x-incomingheadercount: 46 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125466)(1701031045); SRVR:VE1EUR03HT200; x-ms-traffictypediagnostic: VE1EUR03HT200: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:VE1EUR03HT200; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR03HT200; x-forefront-prvs: 06833C6A67 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(13464003)(189003)(199004)(377424004)(51444003)(53546011)(8676002)(55016002)(4326008)(6246003)(59450400001)(74316002)(76176011)(3280700002)(3660700001)(6306002)(5250100002)(8936002)(86362001)(4001150100001)(575784001)(6346003)(26005)(426003)(11346002)(25786009)(72206003)(14454004)(104016004)(102836004)(966005)(97736004)(446003)(81156014)(114624004)(2501003)(82202002)(486006)(6436002)(2900100001)(68736007)(99286004)(33656002)(229853002)(476003)(105586002)(106356001)(7696005)(305945005)(20460500001)(5660300001)(110136005)(87572001)(32563001)(213903007)(19627235001); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR03HT200; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Marvin.Haeuser@outlook.com; x-microsoft-antispam-message-info: LO0UFCN700TzmFjtLaKEe6DpEIqTISxBhNllvOSbvG0hrfq2R8KucsOGJlX+j4jtqryLdLfsY6EHAxLSUluWBjGQK4FhrJwWtzBOEVg2U5N4cY68Nl6YAKs6xR+Au/PzM5mn+h6TJGwxCmpf2ilwQb/PcIHY4pJ9TrL5IF4xS7bmp0Ae0gPttXOwoZ6zyot4 MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 563aab12-a79f-49e0-2fd8-08d5c2382b88 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: 563aab12-a79f-49e0-2fd8-08d5c2382b88 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2018 12:08:04.6002 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT200 Subject: Re: CpuS3DataDxe / DxeRegisterCpuFeaturesLib dependency. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2018 12:08:10 -0000 Content-Language: de-DE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey Laszlo and thanks once again for your detailed response. Comments are inline. Regards, Marvin. > -----Original Message----- > From: Laszlo Ersek > Sent: Friday, May 25, 2018 1:41 PM > To: Marvin H=E4user > Cc: edk2-devel@lists.01.org; eric.dong@intel.com > Subject: Re: CpuS3DataDxe / DxeRegisterCpuFeaturesLib dependency. >=20 > On 05/25/18 12:54, Marvin H?user wrote: > > Good day, > > > > While I was inspecting CpuS3DataDxe and the modules depending on its > > PCD PcdCpuS3DataAddress, >=20 > (Side remark: see e.g. the commit message on 92b87f1c8c0b, "OvmfPkg: > build CpuS3DataDxe for -D SMM_REQUIRE", 2015-11-30.) >=20 > > I noticed that DxeRegisterCpuFeaturesLib seemingly has an asserted > > dependency on the PCD being ready when it its executed. I did neither > > see a Depex entry, nor an event callback ensuring CpuS3DataDxe has > > been loaded, neither exposed by CpuS3DataDxe, nor consumed by this > > library. > > > https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/Regis > > terCpuFeaturesLib/DxeRegisterCpuFeaturesLib.c#L211 >=20 > "DxeRegisterCpuFeaturesLib.inf" has a depex on > "gEdkiiCpuFeaturesSetDoneGuid". >=20 > No module in the open source edk2 tree produces this protocol GUID, thus = I > think this library instance is unusable without other, out-of-tree, modul= es. I > assume that one of those modules satisfies the dependency somehow. > While this of course can be used to control the dependency flow, this GUID = is documented as follows: "CPU Features Set Done PPI/Protocol should be installed after CPU features = configuration are set." If it is really supposed to ensure the ACPI CPU Data PCD availability too, = I think it should be documented. However I do not think that would be a great idea in the first place becaus= e other modules might depend on it as well. I get your point is just that an out-of-tree module is needed, however if i= t exists and whatever it does, I don't think it should rely on this GUID fo= r this purpose. > Note that CpuS3DataDxe is a platform driver [1]; it is possible that the > platform that includes DxeRegisterCpuFeaturesLib in a driver *also* inclu= des > such a CpuS3DataDxe variant that populates the PCD and then installs > gEdkiiCpuFeaturesSetDoneGuid. That was one of the reasons I asked whether a dedicated signal protocol dum= my would be a good idea. I don't think it is likely that this is the case, but it is not impossible = and would need to be discussed internally, if it is the case, I guess. >=20 > [1] I suggest reviewing the message of commit bfec5efa56ca > ("UefiCpuPkg/CpuS3DataDxe: Add module to initialize ACPI_CPU_DATA for > S3", 2015-11-25). >=20 > In fact, the series that added "DxeRegisterCpuFeaturesLib.inf" (with the > depex mentioned above) *also* modified CpuS3DataDxe: see [2] and [3]. >=20 > [2] 8b371e93f206 ("UefiCpuPkg/CpuS3DataDxe: Consume the existing > PcdCpuS3DataAddress", 2017-03-22) This commit indicates to me that there is no proper dependency resolve, to = be honest. If the "main" PCD exposer has code to handle already present data, it means= that every consumer not executing dependent code very late, as you have shown PiSmmCpuDxeSmm does, has to have an allocation routine or= some kind of implicit dependency. >=20 > [3] "[edk2] [PATCH 00/11] Add CPU features driver" > https://bugzilla.tianocore.org/show_bug.cgi?id=3D421 > http://mid.mail-archive.com/20170309083553.6016-1-jeff.fan@intel.com >=20 > This suggests that there is an out-of-tree module that populates > PcdCpuS3DataAddress before *both* CpuS3DataDxe and > DxeRegisterCpuFeaturesLib access the PCD. For achieving this kind of > ordering, it would be enough for a driver to first populate the PCD, and = then > install "gEfiMpServiceProtocolGuid", as both > "DxeRegisterCpuFeaturesLib.inf" and "CpuS3DataDxe.inf" depend on that. gEfiMpServiceProtocolGuid is populated by CpuDxe, so I hope this is not act= ually the case. And yet again it would be only a dangerous implicit dependency. >=20 > > Is there anything I'm missing that ensures the execution of > > CpuS3DataDxe prior to executing the dependent code? If not, should > > there be a dummy protocol exposed? PiSmmCpuDxeSmm also retrieves > this > > PCD, however safely quits when it has not been set. However, this > > could cause unexpected behavior when the PCD is set after this code > > has been executed. I did not notice any dependency satisfaction > > actions here either. >=20 > The ordering between CpuS3DataDxe and PiSmmCpuDxeSmm is safe; it's > orchestrated by Platform BDS. See commit 92b87f1c8c0b above. I only noticed PiSmmCpuDxeSmm while grep'ing for the PCD name and didn't ch= eck it in detail, sorry for the trouble. >=20 > > Furthermore, not directly related to this dependency issue, the DXE > > code obviously does not implement AllocateAcpiCpuData() entirely. >=20 > More precisely, the DXE code expects AllocateAcpiCpuData() never to be > called; i.e., when the common "RegisterCpuFeaturesLib.c" source file is > executed in DXE, the expectation is that it never reaches the call to > AllocateAcpiCpuData(). >=20 > > Hence, the if-branch following its call, will either add another layer > > of firing ASSERTs, or it will plainly do nothing. Maybe it could be > > moved into the current AllocateAcpiCpuData() function and it be > > renamed accordingly? > > > https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/Library/Regis > > terCpuFeaturesLib/RegisterCpuFeaturesLib.c#L526 >=20 > Sorry, I don't understand your point -- CpuRegisterTableWriteWorker() is > used in both PEI and DXE, and it's implemented for the general case. > When it runs in DXE, the expectation is apparently that > AllocateAcpiCpuData() will never be needed / reached, hence the > ASSERT(FALSE) stub implementation for the latter, in > "DxeRegisterCpuFeaturesLib.c". >=20 > Oh wait, I think you mistyped your point. The "if" that you refer to does= not > *follow* the call to AllocateAcpiCpuData(). It *precedes* > (guards) it. What the "if" follows is the PcdGet64() call, for > PcdCpuS3DataAddress. In DXE, that PcdGet64() is expected to return a > nonzero value, hence AllocateAcpiCpuData() is never called, and the > assertions about the return value of AllocateAcpiCpuData() are irrelevant > (unreached). Sorry, this is true. It would just be a very small optimization. All in all, if there is an implicit dependency expected, I think that is ba= d design because one might attempt to use the modules as-is. The best option I see would be to introduce an explicit dependency, the mid= dle way documenting the expected, or at least a safe, implicit dependency route, or at worst either removing CpuS3DataDxe from th= e tree or explicitly marking it as "sample code". >=20 > Thanks > Laszlo