PATCH [1/10] arm: add 'bti' instruction for Armv8.1-M pacbti extension

Message ID gkr5yx5ov03.fsf@arm.com
State New
Headers show
Series
  • PATCH [1/10] arm: add 'bti' instruction for Armv8.1-M pacbti extension
Related show

Commit Message

Luis Machado via Binutils July 20, 2021, 3:38 p.m.
Hi all,

first patch of the series adding support for PACBTI for Cortex-M.

This is to add the 'bti' instruction.

See:
- Armv8.1-M Pointer Authentication and Branch Target Identification Extension [1]
- Armv8-M Architecture Reference Manual [2]

The series was tested and does not introduce regressions.

Regards

  Andrea

[1] <https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension>
[2] <https://developer.arm.com/documentation/ddi0553/latest>
From a0404601c17994dbbf49a152daf316731161ca68 Mon Sep 17 00:00:00 2001
From: Andrea Corallo <andrea.corallo@arm.com>

Date: Fri, 14 May 2021 16:19:39 +0200
Subject: [PATCH 01/10] PATCH [1/10] arm: add 'bti' instruction for Armv8.1-M
 pacbti extension

gas/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* config/tc-arm.c (insns): Add 'bti' insn.
	* testsuite/gas/arm/armv8_1-m-pacbti.d: New file.
	* testsuite/gas/arm/armv8_1-m-pacbti.s: Likewise.

opcodes/
2021-06-11  Andrea Corallo  <andrea.corallo@arm.com>

	* arm-dis.c (thumb32_opcodes): Add bti instruction.
---
 gas/config/tc-arm.c                      |  1 +
 gas/testsuite/gas/arm/armv8_1-m-pacbti.d | 10 ++++++++++
 gas/testsuite/gas/arm/armv8_1-m-pacbti.s |  5 +++++
 opcodes/arm-dis.c                        |  5 +++++
 4 files changed, 21 insertions(+)
 create mode 100644 gas/testsuite/gas/arm/armv8_1-m-pacbti.d
 create mode 100644 gas/testsuite/gas/arm/armv8_1-m-pacbti.s

-- 
2.20.1

Comments

Luis Machado via Binutils July 21, 2021, 2:31 p.m. | #1
Hi Andrea,

> The series was tested and does not introduce regressions.


I found one regression with this series applied:

   GAS REGRESSION: Valid Armv8.1-M pointer authentication and branch target identification extention

Admittedly this was with a toolchain configure for "arm-wince-pe", but still
please could you add an exception for PE format targets to this test.

The patch series (with that change) is approved - please apply.

Cheers
   Nick
Luis Machado via Binutils July 21, 2021, 3:12 p.m. | #2
Nick Clifton <nickc@redhat.com> writes:

> Hi Andrea,

>

>> The series was tested and does not introduce regressions.

>

> I found one regression with this series applied:

>

>   GAS REGRESSION: Valid Armv8.1-M pointer authentication and branch target identification extention

>

> Admittedly this was with a toolchain configure for "arm-wince-pe", but still

> please could you add an exception for PE format targets to this test.

>

> The patch series (with that change) is approved


Hi Nick,

Thanks for reviewing, I've posted the updated patch (2/10).

> - please apply.


I've GCC write access but not the binutils one, is there a way I can ask
for it?

Best Regards

  Andrea
Luis Machado via Binutils July 26, 2021, 12:32 p.m. | #3
Nick Clifton <nickc@redhat.com> writes:

> Hi Andrea,

>

>> The series was tested and does not introduce regressions.

>

> I found one regression with this series applied:

>

>   GAS REGRESSION: Valid Armv8.1-M pointer authentication and branch target identification extention

>

> Admittedly this was with a toolchain configure for "arm-wince-pe", but still

> please could you add an exception for PE format targets to this test.

>

> The patch series (with that change) is approved - please apply.

>

> Cheers

>   Nick


Hi Nick & all,

The patchset is upstreamed as:

0264bf6fe30 * PATCH [10/10] arm: Alias 'ra_auth_code' to r12 for pacbti.
5c43020d83f * PATCH [9/10] arm: add 'pacg' instruction for Armv8.1-M pacbti extension
be05908c0c0 * PATCH [8/10] arm: add 'autg' instruction for Armv8.1-M pacbti extension
e07352fa4fb * PATCH [7/10] arm: add 'bxaut' instruction for Armv8.1-M pacbti extension
5a0c7a819f1 * PATCH [6/10] arm: Add -march=armv8.1-m.main+pacbti flag
2c6ccfcfdde * PATCH [5/10] arm: Extend again arm_feature_set struct to provide more bits
ce537a7db78 * PATCH [4/10] arm: add 'pac' instruction for Armv8.1-M pacbti extension
e43ca2cbaea * PATCH [3/10] arm: add 'aut' instruction for Armv8.1-M pacbti extension
f1e1d7f305e * PATCH [2/10] arm: add 'pacbti' instruction for Armv8.1-M pacbti extension
3751264cdd1 * PATCH [1/10] arm: add 'bti' instruction for Armv8.1-M pacbti extension

Thanks and Best Regards!

  Andrea

Patch

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index fa023b4461e..d7f8fca803b 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -26305,6 +26305,7 @@  static const struct asm_opcode insns[] =
  /* Armv8.1-M Mainline instructions.  */
 #undef  THUMB_VARIANT
 #define THUMB_VARIANT & arm_ext_v8_1m_main
+ ToU("bti",   f3af800f, 0, (), noargs),
  toU("cinc",  _cinc,  3, (RRnpcsp, RR_ZR, COND),	t_cond),
  toU("cinv",  _cinv,  3, (RRnpcsp, RR_ZR, COND),	t_cond),
  toU("cneg",  _cneg,  3, (RRnpcsp, RR_ZR, COND),	t_cond),
diff --git a/gas/testsuite/gas/arm/armv8_1-m-pacbti.d b/gas/testsuite/gas/arm/armv8_1-m-pacbti.d
new file mode 100644
index 00000000000..3c693728468
--- /dev/null
+++ b/gas/testsuite/gas/arm/armv8_1-m-pacbti.d
@@ -0,0 +1,10 @@ 
+#name: Valid Armv8.1-M pointer authentication and branch target identification extention
+#source: armv8_1-m-pacbti.s
+#as: -march=armv8.1-m.main
+#objdump: -dr --prefix-addresses --show-raw-insn
+
+.*: +file format .*arm.*
+
+Disassembly of section .text:
+0[0-9a-f]+ <[^>]+> f3af 800f 	bti
+#...
diff --git a/gas/testsuite/gas/arm/armv8_1-m-pacbti.s b/gas/testsuite/gas/arm/armv8_1-m-pacbti.s
new file mode 100644
index 00000000000..38929e3dd02
--- /dev/null
+++ b/gas/testsuite/gas/arm/armv8_1-m-pacbti.s
@@ -0,0 +1,5 @@ 
+	.syntax unified
+	.text
+	.thumb
+.Lstart:
+	bti
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 92cd098d6c9..1e096997543 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -4652,6 +4652,11 @@  static const struct opcode16 thumb_opcodes[] =
    makes heavy use of special-case bit patterns.  */
 static const struct opcode32 thumb32_opcodes[] =
 {
+  /* Arm v8.1-M Mainline Pointer Authentication and Branch Target
+     Identification Extension.  */
+  {ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN),
+   0xf3af800f, 0xffffffff, "bti"},
+
   /* Armv8.1-M Mainline and Armv8.1-M Mainline Security Extensions
      instructions.  */
   {ARM_FEATURE_CORE_HIGH (ARM_EXT2_V8_1M_MAIN),