From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [edk2-devel] [PATCH v3 0/4] ArmPkg/SecurityPkg: Fixes for ArmTrngLib/RngDxe To: Ard Biesheuvel ,devel@edk2.groups.io From: "Sami Mujawar" X-Originating-Location: Cambridge, England, GB (217.140.106.53) X-Originating-Platform: Windows Firefox 107 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Wed, 07 Dec 2022 00:53:18 -0800 References: In-Reply-To: Message-ID: <10752.1670403198331721857@groups.io> Content-Type: multipart/alternative; boundary="Y2VWPywo4Ny0hts8MQXf" --Y2VWPywo4Ny0hts8MQXf Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Ard, On Sat, Nov 26, 2022 at 06:34 AM, Ard Biesheuvel wrote: >=20 > The remaining code still looks a bit clunky to me. Can't we just > return an error from the library constructor of the library cannot > initialize due to a missing prerequisite? The problem with returning an error code from a library constructor is that= it generates an ASSERT for debug builds. The reason is that the generated = code in AutoGen.c looks as shown below: VOID EFIAPI ProcessLibraryConstructorList ( IN EFI_HANDLE=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ImageHandle, IN EFI_SYSTEM_TABLE=C2=A0 *SystemTable ) { EFI_STATUS=C2=A0 Status; Status =3D HobLibConstructor (ImageHandle, SystemTable); ASSERT_EFI_ERROR (Status); ... Status =3D ArmTrngLibConstructor (); ASSERT_RETURN_ERROR (Status); } --Y2VWPywo4Ny0hts8MQXf Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Ard,
On Sat, Nov 26, 2022 at 06:34 AM, Ard Biesheuvel wrote:
The remaining code still looks a bit clunky to me. Can't we jus= t
return an error from the library constructor of the library cannotinitialize due to a missing prerequisite?
The problem with returning an error code from a library constructor is that= it generates an ASSERT for debug builds. The reason is that the generated = code in AutoGen.c looks as shown below:

VOID
EFIAPI
Pr= ocessLibraryConstructorList (
  IN EFI_HANDLE   &n= bsp;    ImageHandle,
  IN EFI_SYSTEM_TABLE  *= SystemTable
  )
{
  EFI_STATUS  Status;
=
  Status =3D HobLibConstructor (ImageHandle, SystemTable);
=   ASSERT_EFI_ERROR (Status);
...
  Status =3D ArmTrngLi= bConstructor ();
  ASSERT_RETURN_ERROR (Status);

}

--Y2VWPywo4Ny0hts8MQXf--