diff --git a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S new file mode 100644 index 0000000000..500bdadca5 --- /dev/null +++ b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S @@ -0,0 +1,39 @@ +##------------------------------------------------------------------------------ +# +# SpeculationBarrier() for AArch64 +# +# Copyright (c) 2019, Linaro Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +##------------------------------------------------------------------------------ + +.text +.p2align 2 + +GCC_ASM_EXPORT(SpeculationBarrier) + + +#/** +# Uses as a barrier to stop speculative execution. +# +# Ensures that no later instruction will execute speculatively, until all prior +# instructions have completed. +# +#**/ +#VOID +#EFIAPI +#SpeculationBarrier ( +# VOID +# ); +# +ASM_PFX(SpeculationBarrier): + dsb sy + isb + ret diff --git a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.asm b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.asm new file mode 100644 index 0000000000..0c4b915b77 --- /dev/null +++ b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.asm @@ -0,0 +1,38 @@ +;------------------------------------------------------------------------------ +; +; SpeculationBarrier() for AArch64 +; +; Copyright (c) 2019, Linaro Ltd. All rights reserved. +; +; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + + EXPORT SpeculationBarrier + AREA BaseLib_LowLevel, CODE, READONLY + +;/** +; Uses as a barrier to stop speculative execution. +; +; Ensures that no later instruction will execute speculatively, until all prior +; instructions have completed. +; +;**/ +;VOID +;EFIAPI +;SpeculationBarrier ( +; VOID +; ); +; +SpeculationBarrier + dsb sy + isb + ret + + END diff --git a/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.S b/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.S new file mode 100644 index 0000000000..7857558aba --- /dev/null +++ b/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.S @@ -0,0 +1,39 @@ +##------------------------------------------------------------------------------ +# +# SpeculationBarrier() for AArch64 +# +# Copyright (c) 2019, Linaro Ltd. All rights reserved. +# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the BSD License +# which accompanies this distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php. +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +##------------------------------------------------------------------------------ + +.text +.p2align 2 + +GCC_ASM_EXPORT(SpeculationBarrier) + + +#/** +# Uses as a barrier to stop speculative execution. +# +# Ensures that no later instruction will execute speculatively, until all prior +# instructions have completed. +# +#**/ +#VOID +#EFIAPI +#SpeculationBarrier ( +# VOID +# ); +# +ASM_PFX(SpeculationBarrier): + dsb + isb + bx lr diff --git a/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.asm b/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.asm new file mode 100644 index 0000000000..425cd3de9e --- /dev/null +++ b/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.asm @@ -0,0 +1,39 @@ +;------------------------------------------------------------------------------ +; +; SpeculationBarrier() for AArch64 +; +; Copyright (c) 2019, Linaro Ltd. All rights reserved. +; +; This program and the accompanying materials +; are licensed and made available under the terms and conditions of the BSD License +; which accompanies this distribution. The full text of the license may be found at +; http://opensource.org/licenses/bsd-license.php. +; +; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +; +;------------------------------------------------------------------------------ + + EXPORT SpeculationBarrier + + AREA MemoryBarriers, CODE, READONLY + +;/** +; Uses as a barrier to stop speculative execution. +; +; Ensures that no later instruction will execute speculatively, until all prior +; instructions have completed. +; +;**/ +;VOID +;EFIAPI +;SpeculationBarrier ( +; VOID +; ); +; +SpeculationBarrier + dsb + isb + bx lr + + END diff --git a/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.c b/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.c deleted file mode 100644 index 8a6165a102..0000000000 --- a/MdePkg/Library/BaseLib/Arm/SpeculationBarrier.c +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - SpeculationBarrier() function for ARM. - - Copyright (C) 2018, Intel Corporation. All rights reserved.
- - This program and the accompanying materials are licensed and made available - under the terms and conditions of the BSD License which accompanies this - distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php. - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT - WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - - -/** - Uses as a barrier to stop speculative execution. - - Ensures that no later instruction will execute speculatively, until all prior - instructions have completed. - -**/ -VOID -EFIAPI -SpeculationBarrier ( - VOID - ) -{ -} diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf index d195c5417b..f25a067a23 100644 --- a/MdePkg/Library/BaseLib/BaseLib.inf +++ b/MdePkg/Library/BaseLib/BaseLib.inf @@ -552,7 +552,6 @@ [Sources.ARM] Arm/InternalSwitchStack.c Arm/Unaligned.c - Arm/SpeculationBarrier.c Math64.c | RVCT Math64.c | MSFT @@ -564,6 +563,7 @@ Arm/CpuPause.asm | RVCT Arm/CpuBreakpoint.asm | RVCT Arm/MemoryFence.asm | RVCT + Arm/SpeculationBarrier.S | RVCT Arm/SwitchStack.asm | MSFT Arm/SetJumpLongJump.asm | MSFT @@ -573,6 +573,7 @@ Arm/CpuPause.asm | MSFT Arm/CpuBreakpoint.asm | MSFT Arm/MemoryFence.asm | MSFT + Arm/SpeculationBarrier.asm | MSFT Arm/Math64.S | GCC Arm/SwitchStack.S | GCC @@ -582,11 +583,11 @@ Arm/SetJumpLongJump.S | GCC Arm/CpuBreakpoint.S | GCC Arm/MemoryFence.S | GCC + Arm/SpeculationBarrier.S | GCC [Sources.AARCH64] Arm/InternalSwitchStack.c Arm/Unaligned.c - Arm/SpeculationBarrier.c Math64.c AArch64/MemoryFence.S | GCC @@ -596,6 +597,7 @@ AArch64/GetInterruptsState.S | GCC AArch64/SetJumpLongJump.S | GCC AArch64/CpuBreakpoint.S | GCC + AArch64/SpeculationBarrier.S | GCC AArch64/MemoryFence.asm | MSFT AArch64/SwitchStack.asm | MSFT @@ -604,6 +606,7 @@ AArch64/GetInterruptsState.asm | MSFT AArch64/SetJumpLongJump.asm | MSFT AArch64/CpuBreakpoint.asm | MSFT + AArch64/SpeculationBarrier.asm | MSFT [Packages] MdePkg/MdePkg.dec