public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Jiewen Yao <jiewen.yao@intel.com>, Yi Li <yi1.li@intel.com>,
	Xiaoyu Lu <xiaoyu1.lu@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [edk2-devel] [PATCH v1 3/7] MdePkg/BaseRngLib: Prefer ArmReadIdAA64Isar0Reg() over ArmReadIdIsar0()
Date: Thu,  2 Nov 2023 14:54:13 +0100	[thread overview]
Message-ID: <20231102135417.336334-4-pierre.gondois@arm.com> (raw)
In-Reply-To: <20231102135417.336334-1-pierre.gondois@arm.com>

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 <pierre.gondois@arm.com>
---
 .../BaseRngLib/AArch64/ArmReadIdIsar0.S       | 30 -------------------
 .../BaseRngLib/AArch64/ArmReadIdIsar0.asm     | 30 -------------------
 MdePkg/Library/BaseRngLib/AArch64/ArmRng.h    | 12 --------
 MdePkg/Library/BaseRngLib/AArch64/Rndr.c      | 14 ++-------
 MdePkg/Library/BaseRngLib/BaseRngLib.inf      |  2 --
 5 files changed, 3 insertions(+), 85 deletions(-)
 delete mode 100644 MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S
 delete mode 100644 MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm

diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S b/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S
deleted file mode 100644
index d30b63fe5c68..000000000000
--- a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.S
+++ /dev/null
@@ -1,30 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# ArmReadIdIsar0() for AArch64
-#
-# Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#------------------------------------------------------------------------------
-
-.text
-.p2align 2
-GCC_ASM_EXPORT(ArmReadIdIsar0)
-
-#/**
-#  Reads the ID_AA64ISAR0 Register.
-#
-#  @return The contents of the ID_AA64ISAR0 register.
-#
-#**/
-#UINT64
-#EFIAPI
-#ArmReadIdIsar0 (
-#  VOID
-#  );
-#
-ASM_PFX(ArmReadIdIsar0):
-  AARCH64_BTI(c)
-  mrs  x0, id_aa64isar0_el1 // Read ID_AA64ISAR0 Register
-  ret
diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm b/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm
deleted file mode 100644
index 1d9f9a808c0c..000000000000
--- a/MdePkg/Library/BaseRngLib/AArch64/ArmReadIdIsar0.asm
+++ /dev/null
@@ -1,30 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; ArmReadIdIsar0() for AArch64
-;
-; Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
-;
-; SPDX-License-Identifier: BSD-2-Clause-Patent
-;
-;------------------------------------------------------------------------------
-
-  EXPORT ArmReadIdIsar0
-  AREA BaseLib_LowLevel, CODE, READONLY
-
-;/**
-;  Reads the ID_AA64ISAR0 Register.
-;
-; @return The contents of the ID_AA64ISAR0 register.
-;
-;**/
-;UINT64
-;EFIAPI
-;ArmReadIdIsar0 (
-;  VOID
-;  );
-;
-ArmReadIdIsar0
-  mrs  x0, id_aa64isar0_el1 // Read ID_AA64ISAR0 Register
-  ret
-
-  END
diff --git a/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h b/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h
index 2d6ef48ab941..b4b3c97071bb 100644
--- a/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h
+++ b/MdePkg/Library/BaseRngLib/AArch64/ArmRng.h
@@ -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_ */
diff --git a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
index d39db62153ee..684b02f018b6 100644
--- a/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
+++ b/MdePkg/Library/BaseRngLib/AArch64/Rndr.c
@@ -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.
@@ -43,16 +38,13 @@ BaseRngLibConstructor (
   VOID
   )
 {
-  UINT64  Isar0;
-
   //
   // 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 ();
-  ASSERT ((Isar0 & RNDR_MASK) != 0);
-
-  mRndrSupported = ((Isar0 & RNDR_MASK) != 0);
+  mRndrSupported = !((ArmReadIdAA64Isar0Reg () >> ARM_ID_AA64ISAR0_EL1_AES_SHIFT) &
+                     ARM_ID_AA64ISAR0_EL1_AES_MASK);
+  ASSERT (mRndrSupported);
 
   return EFI_SUCCESS;
 }
diff --git a/MdePkg/Library/BaseRngLib/BaseRngLib.inf b/MdePkg/Library/BaseRngLib/BaseRngLib.inf
index 49503b139be9..bd89cf3a1927 100644
--- a/MdePkg/Library/BaseRngLib/BaseRngLib.inf
+++ b/MdePkg/Library/BaseRngLib/BaseRngLib.inf
@@ -38,10 +38,8 @@ [Sources.AARCH64]
   AArch64/Rndr.c
   AArch64/ArmRng.h
 
-  AArch64/ArmReadIdIsar0.S   | GCC
   AArch64/ArmRng.S           | GCC
 
-  AArch64/ArmReadIdIsar0.asm | MSFT
   AArch64/ArmRng.asm         | MSFT
 
 [Guids.AARCH64]
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#110550): https://edk2.groups.io/g/devel/message/110550
Mute This Topic: https://groups.io/mt/102342397/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  parent reply	other threads:[~2023-11-02 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02 13:54 [edk2-devel] [PATCH v1 0/7] CryptoPkg: Enable Openssl native instruction support for AARCH64 PierreGondois
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 1/7] MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg() PierreGondois
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 2/7] MdePkg/BaseLib: AARCH64: Add ArmReadIdAA64Isar0Reg() PierreGondois
2023-11-02 13:54 ` PierreGondois [this message]
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 4/7] CryptoPkg/OpensslLib: Add native instruction support for AARCH64 PierreGondois
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 5/7] CryptoPkg/OpensslLib: Generate files for AARCH64 native support PierreGondois
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 6/7] CryptoPkg/OpensslLib: Add AArch64Cap for arch specific hooks PierreGondois
2023-11-07  9:21   ` Gerd Hoffmann
2023-11-08 14:40     ` PierreGondois
2023-11-02 13:54 ` [edk2-devel] [PATCH v1 7/7] CryptoPkg: Enable Openssl Accel builds for AARCH64 PierreGondois
2023-11-07  2:38 ` [edk2-devel] [PATCH v1 0/7] CryptoPkg: Enable Openssl native instruction support " Li, Yi
2023-11-07  2:57   ` Yao, Jiewen
2023-11-08 14:39   ` PierreGondois
2023-11-08 15:03     ` Ard Biesheuvel
2023-11-08 16:19       ` PierreGondois

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231102135417.336334-4-pierre.gondois@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox