From nobody Tue Feb 10 11:32:44 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+90876+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+90876+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1656515111; cv=none; d=zohomail.com; s=zohoarc; b=jD+4zpZqy94MOw1h5NMECtMKM3vxa/ltOqgtqIuWpfnTd0ctKsjIwofynNQl/4y3NRXWNctpxODGDVa3kHuBYYb4X6oyJ5YuJUx3k+zwqL+GqMBnONfdfMSNpEEPzj0wwc+mNYemFgP6zppnvYbX82dCA6pvk7MVsRTs92Xfpzo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656515111; 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=JsiJMh4N5KDQwp8JA/hMLEvCai2Zu4bPUm1lW0qnvdM=; b=CYMW8odIc/7kdvgIZIjs0BP33yJCfnwBX7cgFooyF9Ink4BZ9XYwbYeYMru2trOhMjEB+KzOSLqo6If+qE0XYYySe9q0CHivK/3nk7EUGBzuOGVi5AQm3XoMc7y2S+MlX0/u5/HaCTFwhr4I4H3f4tcl+RF0nJwCL9ChkYtpQxs= 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+90876+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 1656515111027962.7250224165839; Wed, 29 Jun 2022 08:05:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ep9GYY1788612xWcriF8xLcP; Wed, 29 Jun 2022 08:05:10 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.12729.1656515109879590768 for ; Wed, 29 Jun 2022 08:05:10 -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 B9DDA19F0; Wed, 29 Jun 2022 08:05:09 -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 2ACA73F792; Wed, 29 Jun 2022 08:05:06 -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 21/22] SecurityPkg/RngDxe: Add Arm support of RngDxe Date: Wed, 29 Jun 2022 17:02:40 +0200 Message-Id: <20220629150241.2597898-32-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: lmwlvcKLoqrCkv0RJvBzTXQNx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1656515110; bh=vP+fHRDEiO8LIT2HSj/RuNzCMpK9fi4QSsdg1KFsLm0=; h=Cc:Date:From:Reply-To:Subject:To; b=GQSk6WTVWe8W7Cdi6j0YdgccDOLANWY8cGuIlLu7DQJWqOUQ9RAwmo1LPeDDP17nRmu Hag+6Z7C45WN2V4Rg+uGeJdzrNg7hzPIIbI20PIcY3feyJRsdNpddJ34z/DBTi/nu7aVF Tl70bwJsWGjWvzFkAAkNDPFR3RgsirDfCck= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1656515111666100025 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 | 10 +++++++--- SecurityPkg/SecurityPkg.dsc | 5 ++++- 3 files changed, 17 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..20752e71ac4e 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,8 @@ [LibraryClasses] TimerLib RngLib =20 -[LibraryClasses.AARCH64] +[LibraryClasses.AARCH64, LibraryClasses.ARM] + ArmLib TrngLib =20 [Guids] diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc index 490076542a33..779aa2a061a0 100644 --- a/SecurityPkg/SecurityPkg.dsc +++ b/SecurityPkg/SecurityPkg.dsc @@ -94,6 +94,9 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64] ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf =20 + # RngDxe dependencies + ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf + [LibraryClasses.ARM] RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf =20 @@ -292,7 +295,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 (#90876): https://edk2.groups.io/g/devel/message/90876 Mute This Topic: https://groups.io/mt/92066763/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-