]> xenbits.xensource.com Git - ovmf.git/commitdiff
ArmPkg: Emit BTI opcodes when BTI codegen is enabled
authorArd Biesheuvel <ardb@kernel.org>
Mon, 27 Mar 2023 10:10:06 +0000 (12:10 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 30 Mar 2023 11:05:22 +0000 (11:05 +0000)
When building with -mbranch-protection=bti, which affects the compiler
codegen only, ensure that the assembler based codegen is aligned with
this, by emitting the BTI C opcode at the start of each exported
function. While most exported functions are not in fact ever called
indirectly, whether or not this is the case is a property of the caller
so annotating every exported function is a reasonable default.

While at it, fix two occurrences in ArmPkg of exported functions that
did not use the ASM_FUNC() macro.

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>
ArmPkg/Include/AsmMacroIoLibV8.h
ArmPkg/Library/ArmExceptionLib/AArch64/ExceptionSupport.S
ArmPkg/Library/ArmSvcLib/AArch64/ArmSvc.S

index 2c2b1cabd053767107d475cae85de6b67d75869b..135aaeca5d0b986d74be1c4b12ac2bf262087b32 100644 (file)
@@ -38,7 +38,8 @@
   .global   Name                  ; \\r
   .section  #Section, "ax"        ; \\r
   .type     Name, %function       ; \\r
-  Name:\r
+  Name:                           ; \\r
+  AARCH64_BTI(c)\r
 \r
 #define ASM_FUNC(Name)  _ASM_FUNC(ASM_PFX(Name), .text. ## Name)\r
 \r
index 9202952ee9c0d4e5fcb5d82ed3f768b7d67a1354..cd9437b6aab828898c301cc943592153b5b3102b 100644 (file)
@@ -94,7 +94,6 @@
 \r
 GCC_ASM_EXPORT(ExceptionHandlersEnd)\r
 GCC_ASM_EXPORT(CommonCExceptionHandler)\r
-GCC_ASM_EXPORT(RegisterEl0Stack)\r
 \r
 .text\r
 \r
@@ -387,6 +386,6 @@ ASM_PFX(CommonExceptionEntry):
 \r
   eret\r
 \r
-ASM_PFX(RegisterEl0Stack):\r
+ASM_FUNC(RegisterEl0Stack)\r
   msr     sp_el0, x0\r
   ret\r
index 1a7c10cb793183e7158851e8b8c668658e12987e..bdba9d7fe941b8c43ad9abd4d2386b17856684b9 100644 (file)
@@ -5,12 +5,12 @@
 //\r
 //\r
 \r
+#include <AsmMacroIoLibV8.h>\r
+\r
 .text\r
 .align 3\r
 \r
-GCC_ASM_EXPORT(ArmCallSvc)\r
-\r
-ASM_PFX(ArmCallSvc):\r
+ASM_FUNC(ArmCallSvc)\r
   // Push frame pointer and return address on the stack\r
   stp   x29, x30, [sp, #-32]!\r
   mov   x29, sp\r