From: Pierre Gondois <pierre.gondois@arm.com>
Bugzilla: 3668 (https://bugzilla.tianocore.org/show_bug.cgi?id=3668)
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 <Pierre.Gondois@arm.com>
---
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/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
index ffa32a29dc6a..4775252d30b6 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
@@ -22,6 +22,7 @@
**/
+#include <Library/ArmLib.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
@@ -55,8 +56,9 @@ RngInitAvailableAlgoArray (
UINT16 MajorRevision;
UINT16 MinorRevision;
- // 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 ();
}
+ #endif
+
// Raw algorithm (Trng)
if (!EFI_ERROR (GetTrngVersion (&MajorRevision, &MinorRevision))) {
CopyMem (
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf b/SecurityPkg/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 = IA32 X64 AARCH64
+# VALID_ARCHITECTURES = IA32 X64 AARCH64 ARM
#
[Sources.common]
@@ -40,7 +40,7 @@ [Sources.IA32, Sources.X64]
Rand/AesCore.c
Rand/AesCore.h
-[Sources.AARCH64]
+[Sources.AARCH64, Sources.ARM]
ArmRngDxe.c
ArmTrng.c
@@ -49,6 +49,9 @@ [Packages]
MdePkg/MdePkg.dec
SecurityPkg/SecurityPkg.dec
+[Packages.AARCH64, Packages.ARM]
+ ArmPkg/ArmPkg.dec
+
[LibraryClasses]
UefiLib
UefiBootServicesTableLib
@@ -58,7 +61,8 @@ [LibraryClasses]
TimerLib
RngLib
-[LibraryClasses.AARCH64]
+[LibraryClasses.AARCH64, LibraryClasses.ARM]
+ ArmLib
TrngLib
[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
+ # RngDxe dependencies
+ ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
+
[LibraryClasses.ARM]
RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
@@ -292,7 +295,7 @@ [Components.IA32, Components.X64, Components.ARM, Components.AARCH64]
SecurityPkg/EnrollFromDefaultKeysApp/EnrollFromDefaultKeysApp.inf
SecurityPkg/VariableAuthenticated/SecureBootDefaultKeysDxe/SecureBootDefaultKeysDxe.inf
-[Components.IA32, Components.X64, Components.AARCH64]
+[Components.IA32, Components.X64, Components.AARCH64, Components.ARM]
#
# Random Number Generator
#
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
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]
-=-=-=-=-=-=-=-=-=-=-=-