summaryrefslogtreecommitdiff
path: root/MdePkg/Library
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2023-03-25 17:37:10 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-30 11:05:22 +0000
commitc4c7fb21744788e40de85630280e1c101b85294e (patch)
tree245cf60dd124fdbeb2e10f6312c9491f06caaab6 /MdePkg/Library
parente504b3917e2b5b0cdd6a381141efb7e303eeb6c1 (diff)
downloadedk2-c4c7fb21744788e40de85630280e1c101b85294e.zip
edk2-c4c7fb21744788e40de85630280e1c101b85294e.tar.gz
edk2-c4c7fb21744788e40de85630280e1c101b85294e.tar.bz2
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/Library')
-rw-r--r--MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/MemoryFence.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S2
-rw-r--r--MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S1
-rw-r--r--MdePkg/Library/BaseLib/AArch64/SwitchStack.S2
8 files changed, 10 insertions, 0 deletions
diff --git a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S
index 7524fb1..24a1ac3 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 f0faf16..3f56246 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 97eeb13..0f1377f 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 bf8b829..26787a5 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 e553bd2..ad5b92a 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 1d5cfbf..0d902d9 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 a20d6ae..248ee01 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 f3bce6a..837c65b 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