From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.1722.1573634208495748603 for ; Wed, 13 Nov 2019 00:36:48 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: jian.j.wang@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2019 00:36:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,299,1569308400"; d="scan'208";a="194600776" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga007.jf.intel.com with ESMTP; 13 Nov 2019 00:36:47 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 13 Nov 2019 00:36:45 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.63]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.149]) with mapi id 14.03.0439.000; Wed, 13 Nov 2019 16:36:44 +0800 From: "Wang, Jian J" To: Laszlo Ersek , "devel@edk2.groups.io" CC: "Kinney, Michael D" , "Gao, Liming" , Ard Biesheuvel , "Ni, Ray" Subject: Re: [PATCH v2] MdePkg: add null version of RngLib Thread-Topic: [PATCH v2] MdePkg: add null version of RngLib Thread-Index: AQHVmfwlfopmZwgNiE+yFMeEFxuExKeIxdqw Date: Wed, 13 Nov 2019 08:36:44 +0000 Message-ID: References: <20191113053529.7768-1-jian.j.wang@intel.com> <7468e8dc-8eb6-a433-903e-23a014d2dc36@redhat.com> In-Reply-To: <7468e8dc-8eb6-a433-903e-23a014d2dc36@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzFiOWZjYmEtMTYwMC00Y2ExLWExZmItYjI5MTBkOTk5NDg4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNFJkZDZEdW1yRVVVSjcraVlKYXZRSWQrdFRnVmR5dHN1Tzgwdmh5OTA4THFTK0lYN0FXVDNDVStjeW9jZ3NXRCJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: jian.j.wang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Laszlo, Thanks for the comments. I agree all of them. Since there's still EBC liste= d in SUPPORTED_ARCHITECTURES in dsc file, I don't see any reason not to add it. But likewise, I'll leave the final decision to package maintainers. Regards, Jian > -----Original Message----- > From: Laszlo Ersek > Sent: Wednesday, November 13, 2019 4:27 PM > To: Wang, Jian J ; devel@edk2.groups.io > Cc: Kinney, Michael D ; Gao, Liming > ; Ard Biesheuvel ; Ni, R= ay > > Subject: Re: [PATCH v2] MdePkg: add null version of RngLib >=20 > Hi Jian, >=20 > thanks for the update. Comments below: >=20 > On 11/13/19 06:35, Jian J Wang wrote: > >> v2: > >> - Change the name from RngLibNull to BaseRngLibNull according to Lasz= lo's > >> comments > >> - Move the module from SecurityPkg to MdePkg according to Laszlo's > comments > >> - Update commit message according to Laszlo and Ray's comments > > > > This is null version of RngLib which should be used with modules that > > inherit an (indirect) dependency on the RngLib class, but never actuall= y > > call RngLib APIs for consuming randomness. > > > > > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1871 > > Cc: Michael D Kinney > > Cc: Liming Gao > > Cc: Laszlo Ersek > > Cc: Ard Biesheuvel > > Cc: Ray Ni > > Signed-off-by: Jian J Wang > > --- > > .../Library/BaseRngLibNull/BaseRngLibNull.c | 95 +++++++++++++++++++ > > .../Library/BaseRngLibNull/BaseRngLibNull.inf | 31 ++++++ > > .../Library/BaseRngLibNull/BaseRngLibNull.uni | 14 +++ > > MdePkg/MdePkg.dsc | 1 + > > 4 files changed, 141 insertions(+) > > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > > create mode 100644 MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > > > > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > > new file mode 100644 > > index 0000000000..13677abc84 > > --- /dev/null > > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.c > > @@ -0,0 +1,95 @@ > > +/** @file > > + Null version of Random number generator services. > > + > > +Copyright (c) 2019, Intel Corporation. All rights reserved.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include >=20 > (1) I think we can drop BaseLib. >=20 > > +#include > > +#include > > + > > +/** > > + Generates a 16-bit random number. > > + > > + if Rand is NULL, then ASSERT(). > > + > > + @param[out] Rand Buffer pointer to store the 16-bit random value= . > > + > > + @retval TRUE Random number generated successfully. > > + @retval FALSE Failed to generate the random number. > > + > > +**/ > > +BOOLEAN > > +EFIAPI > > +GetRandomNumber16 ( > > + OUT UINT16 *Rand > > + ) > > +{ > > + ASSERT (FALSE); > > + return FALSE; > > +} > > + > > +/** > > + Generates a 32-bit random number. > > + > > + if Rand is NULL, then ASSERT(). > > + > > + @param[out] Rand Buffer pointer to store the 32-bit random value= . > > + > > + @retval TRUE Random number generated successfully. > > + @retval FALSE Failed to generate the random number. > > + > > +**/ > > +BOOLEAN > > +EFIAPI > > +GetRandomNumber32 ( > > + OUT UINT32 *Rand > > + ) > > +{ > > + ASSERT (FALSE); > > + return FALSE; > > +} > > + > > +/** > > + Generates a 64-bit random number. > > + > > + if Rand is NULL, then ASSERT(). > > + > > + @param[out] Rand Buffer pointer to store the 64-bit random value= . > > + > > + @retval TRUE Random number generated successfully. > > + @retval FALSE Failed to generate the random number. > > + > > +**/ > > +BOOLEAN > > +EFIAPI > > +GetRandomNumber64 ( > > + OUT UINT64 *Rand > > + ) > > +{ > > + ASSERT (FALSE); > > + return FALSE; > > +} > > + > > +/** > > + Generates a 128-bit random number. > > + > > + if Rand is NULL, then ASSERT(). > > + > > + @param[out] Rand Buffer pointer to store the 128-bit random valu= e. > > + > > + @retval TRUE Random number generated successfully. > > + @retval FALSE Failed to generate the random number. > > + > > +**/ > > +BOOLEAN > > +EFIAPI > > +GetRandomNumber128 ( > > + OUT UINT64 *Rand > > + ) > > +{ > > + ASSERT (FALSE); > > + return FALSE; > > +} > > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > > new file mode 100644 > > index 0000000000..f456df1dae > > --- /dev/null > > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf > > @@ -0,0 +1,31 @@ > > +## @file > > +# Null instance of RNG (Random Number Generator) Library. > > +# > > +# Copyright (c) 2019, Intel Corporation. All rights reserved.
> > +# > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +## > > + > > +[Defines] > > + INF_VERSION =3D 0x00010005 >=20 > (2) When adding a new library instance, I seem to remember that we > recommend referring to the latest published INF spec version (and using > a decimal version reference). That would be "1.29" at this point. >=20 > https://edk2-docs.gitbooks.io/edk-ii-inf-specification/content/#edk-ii-mo= dule- > information-inf-file-specification >=20 > I defer to the MdePkg maintainers on this, I just wanted to raise this. >=20 >=20 > > + BASE_NAME =3D BaseRngLibNull > > + MODULE_UNI_FILE =3D BaseRngLibNull.uni > > + FILE_GUID =3D CD8991F8-2061-4084-8C9E-9C6F352DC= 58D > > + MODULE_TYPE =3D BASE > > + VERSION_STRING =3D 1.0 > > + LIBRARY_CLASS =3D RngLib > > + > > +# > > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > > +# >=20 > (3) Again, just another idea that I'd like the MdePkg reviewers to > comment on: >=20 > I don't see why this library instance would not work with EBC. >=20 > However, I can also imagine we should not add EBC unless we at least > build-test the lib instance for EBC. >=20 > What is the general approach here? >=20 > (Note that I would never consider adding EBC in OvmfPkg or ArmVirtPkg > INF files, simply because I don't even know what EBC compilers exist. > But this is MdePkg, and a Null instance, so EBC *could* make sense.) >=20 >=20 > > + > > +[Sources] > > + BaseRngLibNull.c > > + > > +[Packages] > > + MdePkg/MdePkg.dec > > + > > +[LibraryClasses] > > + BaseLib >=20 > (4) Same as (1). >=20 > > + DebugLib > > diff --git a/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > > new file mode 100644 > > index 0000000000..f32be6a617 > > --- /dev/null > > +++ b/MdePkg/Library/BaseRngLibNull/BaseRngLibNull.uni > > @@ -0,0 +1,14 @@ > > +// /** @file > > +// Null Instance of RNG (Random Number Generator) Library. > > +// > > +// Copyright (c) 2019, Intel Corporation. All rights reserved.
> > +// > > +// SPDX-License-Identifier: BSD-2-Clause-Patent > > +// > > +// **/ > > + > > + > > +#string STR_MODULE_ABSTRACT #language en-US "Null Instance= of > RNG Library" > > + > > +#string STR_MODULE_DESCRIPTION #language en-US "This library > instance should be used with modules that inherit an (indirect) dependenc= y on > the RngLib class, but never actually call RngLib APIs for consuming rando= mness." > > + > > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc > > index c1278e7907..0aeafaaacc 100644 > > --- a/MdePkg/MdePkg.dsc > > +++ b/MdePkg/MdePkg.dsc > > @@ -61,6 +61,7 @@ > > > MdePkg/Library/BaseUefiDecompressLib/BaseUefiTianoCustomDecompressLib. > inf > > MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > > MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf > > + MdePkg/Library/BaseRngLibNull/BaseRngLibNull.inf >=20 > OK, so this actually seems to confirm my question (3). This hunk > modifies the [Components] section in the DSC file, and not the > - [Components.IA32, Components.X64], > - [Components.ARM, Components.AARCH64] > sections. >=20 > Furthermore, there is even a [Components.EBC] section in the DSC file. >=20 > So I think "EBC" is still considered a viable ARCH in MdePkg, and we're > actually enabling this lib instance for the EBC arch. Therefore, EBC > should be listed in VALID_ARCHITECTURES, in the INF File -- as long as > we care to add a VALID_ARCHITECTURES comment at all, that is. >=20 > If you agree to fix (1) through (4), you can immediately add: >=20 > Reviewed-by: Laszlo Ersek >=20 > Thanks! > Laszlo >=20 >=20 > > > > MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf > > MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf > >