diff options
author | Ard Biesheuvel <ardb@kernel.org> | 2023-03-25 17:37:10 +0100 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-03-30 11:05:22 +0000 |
commit | c4c7fb21744788e40de85630280e1c101b85294e (patch) | |
tree | 245cf60dd124fdbeb2e10f6312c9491f06caaab6 /MdePkg | |
parent | e504b3917e2b5b0cdd6a381141efb7e303eeb6c1 (diff) | |
download | edk2-c4c7fb21744788e40de85630280e1c101b85294e.tar.gz |
MdePkg/BaseLib AARCH64: Make asm files BTI compatible
Add the BTI instructions and the associated note to make the AArch64 asm
objects compatible with BTI enforcement.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Leif Lindholm <quic_llindhol@quicinc.com>
Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
Diffstat (limited to 'MdePkg')
8 files changed, 10 insertions, 0 deletions
diff --git a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S index 7524fb1882..24a1ac3718 100644 --- a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S +++ b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S @@ -27,5 +27,6 @@ GCC_ASM_EXPORT(CpuBreakpoint) # );
#
ASM_PFX(CpuBreakpoint):
+ AARCH64_BTI(c)
svc 0xdbdb // Superviser exception. Takes 16bit arg -> Armv7 had 'swi' here.
ret
diff --git a/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S b/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S index f0faf16b06..3f56246161 100644 --- a/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S +++ b/MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S @@ -26,5 +26,6 @@ GCC_ASM_EXPORT(DisableInterrupts) # );
#
ASM_PFX(DisableInterrupts):
+ AARCH64_BTI(c)
msr daifset, #DAIF_WR_IRQ_BIT
ret
diff --git a/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S b/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S index 97eeb13fbe..0f1377f51c 100644 --- a/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S +++ b/MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S @@ -26,5 +26,6 @@ GCC_ASM_EXPORT(EnableInterrupts) # );
#
ASM_PFX(EnableInterrupts):
+ AARCH64_BTI(c)
msr daifclr, #DAIF_WR_IRQ_BIT
ret
diff --git a/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S b/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S index bf8b829bb2..26787a5b9b 100644 --- a/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S +++ b/MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S @@ -33,6 +33,7 @@ GCC_ASM_EXPORT(GetInterruptState) # );
#
ASM_PFX(GetInterruptState):
+ AARCH64_BTI(c)
mrs x0, daif
tst x0, #DAIF_RD_IRQ_BIT // Check IRQ mask; set Z=1 if clear/unmasked
cset w0, eq // if Z=1 (eq) return 1, else 0
diff --git a/MdePkg/Library/BaseLib/AArch64/MemoryFence.S b/MdePkg/Library/BaseLib/AArch64/MemoryFence.S index e553bd2dc9..ad5b92a9a7 100644 --- a/MdePkg/Library/BaseLib/AArch64/MemoryFence.S +++ b/MdePkg/Library/BaseLib/AArch64/MemoryFence.S @@ -28,6 +28,7 @@ GCC_ASM_EXPORT(MemoryFence) # );
#
ASM_PFX(MemoryFence):
+ AARCH64_BTI(c)
// System wide Data Memory Barrier.
dmb sy
ret
diff --git a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S index 1d5cfbf644..0d902d94d3 100644 --- a/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S +++ b/MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S @@ -46,6 +46,7 @@ GCC_ASM_EXPORT(InternalLongJump) # );
#
ASM_PFX(SetJump):
+ AARCH64_BTI(c)
mov x16, sp // use IP0 so save SP
#define REG_PAIR(REG1, REG2, OFFS) stp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) str REG1, [x0, OFFS]
@@ -75,6 +76,7 @@ ASM_PFX(SetJump): # );
#
ASM_PFX(InternalLongJump):
+ AARCH64_BTI(c)
#define REG_PAIR(REG1, REG2, OFFS) ldp REG1, REG2, [x0, OFFS]
#define REG_ONE(REG1, OFFS) ldr REG1, [x0, OFFS]
GPR_LAYOUT
diff --git a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S index a20d6aed0c..248ee01e52 100644 --- a/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S +++ b/MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S @@ -28,6 +28,7 @@ GCC_ASM_EXPORT(SpeculationBarrier) # );
#
ASM_PFX(SpeculationBarrier):
+ AARCH64_BTI(c)
dsb sy
isb
ret
diff --git a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S b/MdePkg/Library/BaseLib/AArch64/SwitchStack.S index f3bce6a09b..837c65b45e 100644 --- a/MdePkg/Library/BaseLib/AArch64/SwitchStack.S +++ b/MdePkg/Library/BaseLib/AArch64/SwitchStack.S @@ -35,6 +35,7 @@ GCC_ASM_EXPORT(CpuPause) # );
#
ASM_PFX(InternalSwitchStackAsm):
+ AARCH64_BTI(c)
mov x29, #0
mov x30, x0
mov sp, x3
@@ -57,6 +58,7 @@ ASM_PFX(InternalSwitchStackAsm): # )
#
ASM_PFX(CpuPause):
+ AARCH64_BTI(c)
nop
nop
nop
|