From nobody Tue Feb 10 11:32:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90873+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90873+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1656515102; cv=none; d=zohomail.com; s=zohoarc; b=LxLOow9XbVvC5UUdSUTdIcZvrLMbt6UwJd/70/1AOxWebBw5CqxDfN2Qg5feWSi9g7OH83QaRtAjSCt6gZ0wxLdD3tFxa4MDq0manWsw2XyWHRIasOesj0ZvVNhZCjuat8mxRCjfpNnDwwHCBxQYSlUNFNlcAWQy5V504VBjMM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656515102; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=czJ5UUf7q6wfndgPNHm+Mr1C0IhqmRLpREBsG37Cuj0=; b=DOaioQMtSCyJ9pzo/KZySbiWmMKp7l18DEYUNDCQzedbUq/Osg0Vw/XiMLZbzQQMW9Rz5gxgDwxAOJ+zQdoWZ+cMKGNhbpem/fk6EjwjxyxD95VAsQMLH4g5RPIUaU0L1ex7SUzmJJw79cWnizMHdIMNvszWhGYtEf7YFlK3vfk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90873+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1656515102967219.4212189744086; Wed, 29 Jun 2022 08:05:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id klWTYY1788612xSmMfewLcho; Wed, 29 Jun 2022 08:05:02 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.12575.1656515101897231123 for ; Wed, 29 Jun 2022 08:05:02 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BBE951764; Wed, 29 Jun 2022 08:05:01 -0700 (PDT) X-Received: from pierre123.arm.com (unknown [10.57.42.208]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 726FF3F792; Wed, 29 Jun 2022 08:04:59 -0700 (PDT) From: "PierreGondois" To: devel@edk2.groups.io Cc: Sami Mujawar , Leif Lindholm , Ard Biesheuvel , Rebecca Cran , Michael D Kinney , Liming Gao , Jiewen Yao , Jian J Wang Subject: [edk2-devel] [PATCH v3 20/21] SecurityPkg/RngDxe: Add Arm support of RngDxe Date: Wed, 29 Jun 2022 17:02:37 +0200 Message-Id: <20220629150241.2597898-29-Pierre.Gondois@arm.com> In-Reply-To: <20220629150241.2597898-1-Pierre.Gondois@arm.com> References: <20220629150241.2597898-1-Pierre.Gondois@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: I6qWgCu2NSvcvMEZqEdHDhePx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1656515102; bh=ia2bzYEb1sOw5+CMFNiw7MMR7SWl9835qM6yCuM2qu4=; h=Cc:Date:From:Reply-To:Subject:To; b=RqWD0kjtlbv74If0TTug1EV/jBOX8iklsA8IOG9BjyEyXg9WSLR7WNWOwEnfQnoiQ84 gc/RGwVecaiCGeh7i4iVzfUCqWrvW+dv9fS/oG9Z/R74vm+ZFZxhgzhiL1gJMmgnirSQ3 QOpSdjAzAU+Q1z10SDRc/t26IhfY1SAPYYw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1656515103622100013 Content-Type: text/plain; charset="utf-8" From: Pierre Gondois Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3D3668) Add RngDxe support for Arm. This implementation uses the TrngLib to support the RawAlgorithm and doens't support the RNDR instruction. Signed-off-by: Pierre Gondois --- SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c | 8 ++++++-- SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf | 9 ++++++--- SecurityPkg/SecurityPkg.dsc | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c b/Securit= yPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c index ffa32a29dc6a..4775252d30b6 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c @@ -22,6 +22,7 @@ =20 **/ =20 +#include #include #include #include @@ -55,8 +56,9 @@ RngInitAvailableAlgoArray ( UINT16 MajorRevision; UINT16 MinorRevision; =20 - // Check RngGetBytes() before advertising PcdCpuRngSupportedAlgorithm. - if (!EFI_ERROR (RngGetBytes (sizeof (Rand), (UINT8 *)&Rand))) { + #ifdef MDE_CPU_AARCH64 + // Check FEAT_RNG before advertising PcdCpuRngSupportedAlgorithm. + if (ArmHasRngExt ()) { CopyMem ( &mAvailableAlgoArray[mAvailableAlgoArrayCount], PcdGetPtr (PcdCpuRngSupportedAlgorithm), @@ -75,6 +77,8 @@ RngInitAvailableAlgoArray ( DEBUG_CODE_END (); } =20 + #endif + // Raw algorithm (Trng) if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) { CopyMem ( diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/Security= Pkg/RandomNumberGenerator/RngDxe/RngDxe.inf index d2d0ff9ebb98..599a3085102d 100644 --- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf +++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf @@ -27,7 +27,7 @@ [Defines] # # The following information is for reference only and not required by the = build tools. # -# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 +# VALID_ARCHITECTURES =3D IA32 X64 AARCH64 ARM # =20 [Sources.common] @@ -40,7 +40,7 @@ [Sources.IA32, Sources.X64] Rand/AesCore.c Rand/AesCore.h =20 -[Sources.AARCH64] +[Sources.AARCH64, Sources.ARM] ArmRngDxe.c ArmTrng.c =20 @@ -49,6 +49,9 @@ [Packages] MdePkg/MdePkg.dec SecurityPkg/SecurityPkg.dec =20 +[Packages.AARCH64, Packages.ARM] + ArmPkg/ArmPkg.dec + [LibraryClasses] UefiLib UefiBootServicesTableLib @@ -58,7 +61,7 @@ [LibraryClasses] TimerLib RngLib =20 -[LibraryClasses.AARCH64] +[LibraryClasses.AARCH64, LibraryClasses.ARM] TrngLib =20 [Guids] diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 490076542a33..882d639489ea 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -292,7 +292,7 @@ [Components.IA32, Components.X64, Components.ARM, Compo= nents.AARCH64] SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDef= aultKeysDxe.inf =20 -[Components.IA32, Components.X64, Components.AARCH64] +[Components.IA32, Components.X64, Components.AARCH64, Components.ARM] # # Random Number Generator # --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90873): https://edk2.groups.io/g/devel/message/90873 Mute This Topic: https://groups.io/mt/92066759/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-