mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-24 22:24:37 +02:00
MdePkg/BaseLib: AARCH64: Add ArmReadCntPctReg()
To enable AARCH64 native instruction support for Openssl, some interfaces must be implemented. OPENSSL_rdtsc() requests an access to a counter to get some non-trusted entropy. Add ArmReadCntPctReg() to read system count. A similar ArmReadCntPct() function is available in the ArmPkg, but the CryptoPkg where OPENSSL_rdtsc will reside cannot rely on the ArmPkg. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
This commit is contained in:
parent
71b9bda1ac
commit
a72d93e163
@ -7,6 +7,7 @@ Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
|||||||
Copyright (c) Microsoft Corporation.<BR>
|
Copyright (c) Microsoft Corporation.<BR>
|
||||||
Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
||||||
Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
||||||
|
Copyright (c) 2023 - 2024, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
@ -126,6 +127,20 @@ typedef struct {
|
|||||||
|
|
||||||
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reads the current value of CNTPCT_EL0 register.
|
||||||
|
|
||||||
|
Reads and returns the current value of CNTPCT_EL0.
|
||||||
|
This function is only available on AARCH64.
|
||||||
|
|
||||||
|
@return The current value of CNTPCT_EL0
|
||||||
|
**/
|
||||||
|
UINT64
|
||||||
|
EFIAPI
|
||||||
|
ArmReadCntPctReg (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
#endif // defined (MDE_CPU_AARCH64)
|
#endif // defined (MDE_CPU_AARCH64)
|
||||||
|
|
||||||
#if defined (MDE_CPU_RISCV64)
|
#if defined (MDE_CPU_RISCV64)
|
||||||
|
30
MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.S
Normal file
30
MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.S
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#------------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# ArmReadCntPctReg() for AArch64
|
||||||
|
#
|
||||||
|
# Copyright (c) 2023 - 2024, Arm Limited. All rights reserved.<BR>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.text
|
||||||
|
.p2align 2
|
||||||
|
GCC_ASM_EXPORT(ArmReadCntPctReg)
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# Reads the CNTPCT_EL0 Register.
|
||||||
|
#
|
||||||
|
# @return The contents of the CNTPCT_EL0 register.
|
||||||
|
#
|
||||||
|
#**/
|
||||||
|
#UINT64
|
||||||
|
#EFIAPI
|
||||||
|
#ArmReadCntPctReg (
|
||||||
|
# VOID
|
||||||
|
# );
|
||||||
|
#
|
||||||
|
ASM_PFX(ArmReadCntPctReg):
|
||||||
|
AARCH64_BTI(c)
|
||||||
|
mrs x0, cntpct_el0
|
||||||
|
ret
|
30
MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.asm
Normal file
30
MdePkg/Library/BaseLib/AArch64/ArmReadCntPctReg.asm
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
;------------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
; ArmReadCntPctReg() for AArch64
|
||||||
|
;
|
||||||
|
; Copyright (c) 2023 - 2024, Arm Limited. All rights reserved.<BR>
|
||||||
|
;
|
||||||
|
; SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
;
|
||||||
|
;------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EXPORT ArmReadCntPctReg
|
||||||
|
AREA BaseLib_LowLevel, CODE, READONLY
|
||||||
|
|
||||||
|
;/**
|
||||||
|
; Reads the CNTPCT_EL0 Register.
|
||||||
|
;
|
||||||
|
; @return The contents of the CNTPCT_EL0 register.
|
||||||
|
;
|
||||||
|
;**/
|
||||||
|
;UINT64
|
||||||
|
;EFIAPI
|
||||||
|
;ArmReadCntPctReg (
|
||||||
|
; VOID
|
||||||
|
; );
|
||||||
|
;
|
||||||
|
ArmReadCntPctReg
|
||||||
|
mrs x0, cntpct_el0
|
||||||
|
ret
|
||||||
|
|
||||||
|
END
|
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>
|
||||||
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||||
# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
|
# Portions copyright (c) 2011 - 2024, Arm Limited. All rights reserved.<BR>
|
||||||
# Copyright (c) 2020 - 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
# Copyright (c) 2020 - 2021, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
@ -378,6 +378,7 @@
|
|||||||
AArch64/SetJumpLongJump.S | GCC
|
AArch64/SetJumpLongJump.S | GCC
|
||||||
AArch64/CpuBreakpoint.S | GCC
|
AArch64/CpuBreakpoint.S | GCC
|
||||||
AArch64/SpeculationBarrier.S | GCC
|
AArch64/SpeculationBarrier.S | GCC
|
||||||
|
AArch64/ArmReadCntPctReg.S | GCC
|
||||||
|
|
||||||
AArch64/MemoryFence.asm | MSFT
|
AArch64/MemoryFence.asm | MSFT
|
||||||
AArch64/SwitchStack.asm | MSFT
|
AArch64/SwitchStack.asm | MSFT
|
||||||
@ -387,6 +388,7 @@
|
|||||||
AArch64/SetJumpLongJump.asm | MSFT
|
AArch64/SetJumpLongJump.asm | MSFT
|
||||||
AArch64/CpuBreakpoint.asm | MSFT
|
AArch64/CpuBreakpoint.asm | MSFT
|
||||||
AArch64/SpeculationBarrier.asm | MSFT
|
AArch64/SpeculationBarrier.asm | MSFT
|
||||||
|
AArch64/ArmReadCntPctReg.asm | MSFT
|
||||||
|
|
||||||
[Sources.RISCV64]
|
[Sources.RISCV64]
|
||||||
Math64.c
|
Math64.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user