public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ardb@kernel.org>
To: devel@edk2.groups.io
Cc: "Ard Biesheuvel" <ardb@kernel.org>,
	"Michael Kinney" <michael.d.kinney@intel.com>,
	"Liming Gao" <gaoliming@byosoft.com.cn>,
	"Jiewen Yao" <jiewen.yao@intel.com>,
	"Michael Kubacki" <michael.kubacki@microsoft.com>,
	"Sean Brogan" <sean.brogan@microsoft.com>,
	"Rebecca Cran" <quic_rcran@quicinc.com>,
	"Leif Lindholm" <quic_llindhol@quicinc.com>,
	"Sami Mujawar" <sami.mujawar@arm.com>,
	"Taylor Beebe" <t@taylorbeebe.com>,
	"Marvin Häuser" <mhaeuser@posteo.de>,
	"Bob Feng" <bob.c.feng@intel.com>
Subject: [PATCH v2 05/17] MdePkg/BaseLib AARCH64: Make asm files BTI compatible
Date: Mon, 27 Mar 2023 13:01:00 +0200	[thread overview]
Message-ID: <20230327110112.262503-6-ardb@kernel.org> (raw)
In-Reply-To: <20230327110112.262503-1-ardb@kernel.org>

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>
---
 MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S      | 1 +
 MdePkg/Library/BaseLib/AArch64/DisableInterrupts.S  | 1 +
 MdePkg/Library/BaseLib/AArch64/EnableInterrupts.S   | 1 +
 MdePkg/Library/BaseLib/AArch64/GetInterruptsState.S | 1 +
 MdePkg/Library/BaseLib/AArch64/MemoryFence.S        | 1 +
 MdePkg/Library/BaseLib/AArch64/SetJumpLongJump.S    | 2 ++
 MdePkg/Library/BaseLib/AArch64/SpeculationBarrier.S | 1 +
 MdePkg/Library/BaseLib/AArch64/SwitchStack.S        | 2 ++
 8 files changed, 10 insertions(+)

diff --git a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S
index 7524fb18820c2fa3..24a1ac371884bb1d 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 f0faf16b06a3fcae..3f562461614ad294 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 97eeb13fbe5d2145..0f1377f51c7e88f7 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 bf8b829bb2b1749d..26787a5b9bddcd7e 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 e553bd2dc9fcf63f..ad5b92a9a72bd65c 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 1d5cfbf64470452f..0d902d94d31c4a35 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 a20d6aed0cdd5284..248ee01e52c27367 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 f3bce6a09bc2d555..837c65b45e73024e 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
-- 
2.39.2


  parent reply	other threads:[~2023-03-27 11:01 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 11:00 [PATCH v2 00/17] Enable BTI support in memory attributes table Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 01/17] MdePkg/ProcessorBind AARCH64: Add asm macro to emit GNU BTI note Ard Biesheuvel
2023-03-27 11:52   ` Leif Lindholm
2023-03-27 12:15     ` Ard Biesheuvel
2023-03-27 12:56       ` Leif Lindholm
2023-03-27 12:45   ` Leif Lindholm
2023-03-27 12:46     ` [edk2-devel] " Ard Biesheuvel
2023-03-27 12:49       ` Leif Lindholm
2023-03-27 14:12   ` Pedro Falcato
2023-03-27 14:24     ` Leif Lindholm
2023-03-30  7:28       ` Ard Biesheuvel
2023-03-30 10:47         ` Leif Lindholm
2023-03-27 11:00 ` [PATCH v2 02/17] MdePkg/BaseCpuLib AARCH64: Make asm files BTI compatible Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 03/17] MdePkg/BaseIoLibIntrinsic " Ard Biesheuvel
2023-03-27 11:00 ` [PATCH v2 04/17] MdePkg/BaseLib AARCH64: Make LongJump() " Ard Biesheuvel
2023-03-27 11:01 ` Ard Biesheuvel [this message]
2023-03-27 11:01 ` [PATCH v2 06/17] MdePkg/BaseMemoryLibOptDxe AARCH64: Make asm files " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 07/17] MdePkg/BaseSynchronizationLib " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 08/17] MdePkg/BaseRngLib " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 09/17] ArmPkg: Emit BTI opcodes when BTI codegen is enabled Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 10/17] ArmPkg/GccLto AARCH64: Add BTI note to LTO helper library Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 11/17] ArmPkg, BaseTools AARCH64: Add BTI ELF note to .hii objects Ard Biesheuvel
2023-03-27 13:09   ` Leif Lindholm
2023-03-27 13:16     ` [edk2-devel] " Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 12/17] ArmPlatformPkg/PrePeiCore: Make vector table object BTI compatible Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 13/17] BaseTools/GenFw: Parse IBT/BTI support status from ELF note Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 14/17] BaseTools/GenFw: Add DllCharacteristicsEx field to debug data Ard Biesheuvel
2023-03-27 15:46   ` Marvin Häuser
2023-03-27 16:41     ` Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 15/17] MdePkg: Update MemoryAttributesTable to v2.10 Ard Biesheuvel
2023-03-27 13:29   ` Leif Lindholm
2023-03-29 16:47     ` [edk2-devel] " Ard Biesheuvel
2023-03-29 18:07       ` Leif Lindholm
2023-03-27 11:01 ` [PATCH v2 16/17] MdePkg/PeCoffLib: Capture DLL characteristics fieldis in image context Ard Biesheuvel
2023-03-30 14:44   ` [edk2-devel] " Michael Kubacki
2023-03-30 14:53     ` Ard Biesheuvel
2023-03-27 11:01 ` [PATCH v2 17/17] MdeModulePkg: Enable forward edge CFI in mem attributes table Ard Biesheuvel
2023-03-28 22:59   ` [edk2-devel] " Oliver Smith-Denny
2023-04-03 15:48   ` osde
2023-04-04 10:41     ` Ard Biesheuvel
2023-04-04 15:00       ` Oliver Smith-Denny
2023-04-04 15:30         ` Ard Biesheuvel
2023-03-27 11:43 ` [PATCH v2 00/17] Enable BTI support in memory " Leif Lindholm
2023-03-27 12:54   ` [edk2-devel] " Ard Biesheuvel
2023-03-27 13:37     ` Gerd Hoffmann
2023-03-28 23:00 ` Oliver Smith-Denny
2023-03-29 16:31 ` Leif Lindholm
2023-03-30  7:41   ` [edk2-devel] " Ard Biesheuvel

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=20230327110112.262503-6-ardb@kernel.org \
    --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