Skip to content

Commit

Permalink
MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() over ArmReadIdIsar0()
Browse files Browse the repository at this point in the history
A ArmReadIdAA64Isar0Reg() function was recently added
to BaseLib. Use it instead of its ArmReadIdIsar0() equivalent,
which was private to the BaseRngLib library.

This also allows to avoid the confusion between the following
registers:
- ID_ISAR0_EL1: allows to probe for Divide instructions, Debug
  instructions, ...
- ID_AA64ISAR0_EL1: AARCH64 specific register allowing to probe
  for AESE, RNDR, ... instructions

Signed-off-by: Pierre Gondois <[email protected]>
  • Loading branch information
pierregondois authored and Javagedes committed Oct 2, 2024
1 parent 93481df commit dba9c25
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 82 deletions.
30 changes: 0 additions & 30 deletions MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S

This file was deleted.

30 changes: 0 additions & 30 deletions MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm

This file was deleted.

12 changes: 0 additions & 12 deletions MdePkg/Library/BaseRngLib/AArch64/ArmRng.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,4 @@ ArmRndr (
OUT UINT64 *Rand
);

/**
Reads the ID_AA64ISAR0 Register.
@return The contents of the ID_AA64ISAR0 register.
**/
UINT64
EFIAPI
ArmReadIdIsar0 (
VOID
);

#endif /* ARM_RNG_H_ */
10 changes: 2 additions & 8 deletions MdePkg/Library/BaseRngLib/AArch64/Rndr.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

STATIC BOOLEAN mRndrSupported;

//
// Bit mask used to determine if RNDR instruction is supported.
//
#define RNDR_MASK ((UINT64)MAX_UINT16 << 60U)

/**
The constructor function checks whether or not RNDR instruction is supported
by the host hardware.
Expand All @@ -49,9 +44,8 @@ BaseRngLibConstructor (
// Determine RNDR support by examining bits 63:60 of the ISAR0 register returned by
// MSR. A non-zero value indicates that the processor supports the RNDR instruction.
//
Isar0 = ArmReadIdIsar0 ();

mRndrSupported = ((Isar0 & RNDR_MASK) != 0);
Isar0 = ArmReadIdAA64Isar0Reg ();
mRndrSupported = !!((Isar0 >> ARM_ID_AA64ISAR0_EL1_RNDR_SHIFT) & ARM_ID_AA64ISAR0_EL1_RNDR_MASK);

return EFI_SUCCESS;
}
Expand Down
2 changes: 0 additions & 2 deletions MdePkg/Library/BaseRngLib/BaseRngLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
AArch64/Rndr.c
AArch64/ArmRng.h

AArch64/ArmReadIdIsar0.S | GCC
AArch64/ArmRng.S | GCC

AArch64/ArmReadIdIsar0.asm | MSFT
AArch64/ArmRng.asm | MSFT

[Guids.AARCH64]
Expand Down

0 comments on commit dba9c25

Please sign in to comment.