public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH,V4 0/8] Add SCFI support for aarch64
@ 2024-07-01  2:53 Indu Bhagat
  2024-07-01  2:53 ` [PATCH,V4 1/8] gas: scfi: make scfi_state_restore_reg function more precise Indu Bhagat
                   ` (7 more replies)
  0 siblings, 8 replies; 29+ messages in thread
From: Indu Bhagat @ 2024-07-01  2:53 UTC (permalink / raw)
  To: binutils; +Cc: richard.sandiford, Richard.Earnshaw, Indu Bhagat

Hi,

This patch series extends GAS support for SCFI to aarch64.

For more details on background, motivation and short notes on design,
please see the link to V1 posting:
https://sourceware.org/pipermail/binutils/2024-April/133557.html

The V4 version addresses the review comments on the V3 series:

  - Subclass flags: Add subclass flags for only those iclasses where
    SCFI may need them.  All insns in these iclasses must have a
    non-zero subclass.  All other iclasses must have a zero subclass.
    Enforce these checks on subclass flags in aarch64-gen.c.

  - Include FP/Advanced SIMD registers into the set of callee-saved
    registers: D8-D15.  Ensure both D and Q registers are handled on
    little-endian and big-endian.  Z registers are skipped from handling at
    this time.  Added this to the set of known limitations to be addressed
    in a future patch.

  - Added more testcases. 

Link to V3 posting: https://sourceware.org/pipermail/binutils/2024-June/134842.html
The V3 version addressed the review comments on V2:
  - Use F_LDST_SWAP for lse_atomic ld/st ops.

Link to V2 posting: https://sourceware.org/pipermail/binutils/2024-June/134461.html
The V2 version addressed the review comments on V1:
  - Carve out the ginsn creation functionality for aarch64 in a separate file.
  - Add additional flags in aarch64 insn definition to indicate
    subclasses.

Although self-explanatory, here is the outline of the patches:
  - [Still needs global maintainer approval] Patch 1 fixes a bug I ran
    into while testing the series.
  - Patch 2 is new in V4.  It seemed more appropriate to carve out the
    new subclass flag definitions in a patch of its own.
  - Patch 3 to 5 now specify subclass flags only for instructions where
    SCFI needs further classfication within an iclass.
  - Patch 6 is new in V4.  This implements some checks in aarch64-gen.c
    around subclass flags in instructions of specific iclasses.
  - Patch 7 and 8 implement the aarch64 ginsn creation and SCFI
    testsuite respectively.

Known limitations
-----------------
These are planned to be worked on in the near future:

 - The current SCFI machinery does not currently synthesize the PAC-related
   aarch64-specific CFI directives: .cfi_b_key_frame.  Other opcodes used when
   pointer authentication is enabled also need to be handled (braa, brab,
   retaa, etc.).

 - Supporting the following pattern:
   mov x16,4266
   add sp, x16, sp
   ...

 - Not a limitation per se, but a note that ATM, that predicated insns are
   skipped from ginsn translation.  IIUC, these instructions are not such that
   can be used alongside stack management ops. To be double-checked.

 - Functions involving save / restore of Z registers are not allowed for
   SCFI.  The SCFI machinery currently issues an error as no ginsns are
   created for such insns (which may may cause incorrectly synthesized
   CFI, hence the error).  Need to address this for little-endian and
   big-endian.

Thanks,
Indu Bhagat (8):
  gas: scfi: make scfi_state_restore_reg function more precise
  include: opcodes: aarch64: define new subclasses
  opcodes: aarch64: flags to denote subclasses of ldst insns
  opcodes: aarch64: flags to denote subclasses of arithmetic insns
  opcodes: aarch64: flags to denote subclasses of uncond branches
  opcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c
  gas: aarch64: add experimental support for SCFI
  gas: aarch64: testsuite: add new tests for SCFI

 gas/config/tc-aarch64-ginsn.c                 | 797 ++++++++++++++++++
 gas/config/tc-aarch64.c                       |  15 +
 gas/config/tc-aarch64.h                       |  21 +
 gas/scfi.c                                    |   9 +-
 gas/testsuite/gas/scfi/README                 |   2 +-
 .../gas/scfi/aarch64/ginsn-arith-1.l          |  35 +
 .../gas/scfi/aarch64/ginsn-arith-1.s          |  16 +
 gas/testsuite/gas/scfi/aarch64/ginsn-cofi-1.l |  30 +
 gas/testsuite/gas/scfi/aarch64/ginsn-cofi-1.s |  16 +
 gas/testsuite/gas/scfi/aarch64/ginsn-ldst-1.l |  78 ++
 gas/testsuite/gas/scfi/aarch64/ginsn-ldst-1.s |  34 +
 gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.l |  27 +
 gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.s |  13 +
 .../gas/scfi/aarch64/scfi-aarch64.exp         |  70 ++
 .../gas/scfi/aarch64/scfi-callee-saved-fp-1.d |  57 ++
 .../gas/scfi/aarch64/scfi-callee-saved-fp-1.l |   2 +
 .../gas/scfi/aarch64/scfi-callee-saved-fp-1.s |  50 ++
 .../gas/scfi/aarch64/scfi-callee-saved-fp-2.d |  57 ++
 .../gas/scfi/aarch64/scfi-callee-saved-fp-2.l |   2 +
 .../gas/scfi/aarch64/scfi-callee-saved-fp-2.s |  50 ++
 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.d    |  20 +
 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.l    |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.s    |  14 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.d   |  31 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.l   |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.s   |  46 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.d   |  40 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.l   |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.s   |  42 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.d   |  32 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.l   |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.s   |  34 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.d   |  41 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.l   |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.s   |  41 +
 .../gas/scfi/aarch64/scfi-cond-br-1.d         |  20 +
 .../gas/scfi/aarch64/scfi-cond-br-1.l         |   2 +
 .../gas/scfi/aarch64/scfi-cond-br-1.s         |  13 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-1.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-1.s  |   6 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-2.l  |   3 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-2.s  |  25 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-3.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-diag-3.s  |   8 +
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.d  |  59 ++
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.s  |  52 ++
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.d  |  33 +
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.s  |  26 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.d  |  39 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.s  |  37 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.d  |  35 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.l  |   2 +
 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.s  |  30 +
 .../gas/scfi/aarch64/scfi-unsupported-1.l     |   4 +
 .../gas/scfi/aarch64/scfi-unsupported-1.s     |  31 +
 include/opcode/aarch64.h                      |  35 +-
 opcodes/aarch64-gen.c                         |  19 +
 opcodes/aarch64-tbl.h                         | 146 ++--
 61 files changed, 2287 insertions(+), 80 deletions(-)
 create mode 100644 gas/config/tc-aarch64-ginsn.c
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-arith-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-arith-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-cofi-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-cofi-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-ldst-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-ldst-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-aarch64.exp
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-2.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-2.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-callee-saved-fp-2.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cb-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-2.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-3.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cfg-4.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cond-br-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cond-br-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-cond-br-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-2.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-2.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-3.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-diag-3.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldrp-2.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-1.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.d
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-strp-2.s
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-unsupported-1.l
 create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-unsupported-1.s

-- 
2.43.0


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2024-07-13  7:34 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-01  2:53 [PATCH,V4 0/8] Add SCFI support for aarch64 Indu Bhagat
2024-07-01  2:53 ` [PATCH,V4 1/8] gas: scfi: make scfi_state_restore_reg function more precise Indu Bhagat
2024-07-12 15:03   ` [PATCH, V4 " Indu Bhagat
2024-07-01  2:53 ` [PATCH,V4 2/8] include: opcodes: aarch64: define new subclasses Indu Bhagat
2024-07-01 17:40   ` Richard Sandiford
2024-07-11  5:14     ` Indu Bhagat
2024-07-11 12:22       ` Richard Sandiford
2024-07-11 17:59         ` Indu Bhagat
2024-07-01  2:53 ` [PATCH,V4 3/8] opcodes: aarch64: flags to denote subclasses of ldst insns Indu Bhagat
2024-07-01 18:06   ` Richard Sandiford
2024-07-11  5:45     ` Indu Bhagat
2024-07-12 13:59       ` Indu Bhagat
2024-07-13  7:34         ` Indu Bhagat
2024-07-01  2:54 ` [PATCH,V4 4/8] opcodes: aarch64: flags to denote subclasses of arithmetic insns Indu Bhagat
2024-07-01 18:13   ` Richard Sandiford
2024-07-11  5:47     ` Indu Bhagat
2024-07-11 12:52       ` Richard Sandiford
2024-07-11 17:58         ` Indu Bhagat
2024-07-11 18:43           ` Richard Sandiford
2024-07-12 12:53             ` Indu Bhagat
2024-07-01  2:54 ` [PATCH,V4 5/8] opcodes: aarch64: flags to denote subclasses of uncond branches Indu Bhagat
2024-07-01  2:54 ` [PATCH,V4 6/8] opcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c Indu Bhagat
2024-07-01  2:54 ` [PATCH,V4 7/8] gas: aarch64: add experimental support for SCFI Indu Bhagat
2024-07-01 19:49   ` Richard Sandiford
2024-07-11  6:30     ` Indu Bhagat
2024-07-11 13:15       ` Richard Sandiford
2024-07-11 19:07         ` Indu Bhagat
2024-07-11 20:10           ` Richard Sandiford
2024-07-01  2:54 ` [PATCH,V4 8/8] gas: aarch64: testsuite: add new tests " Indu Bhagat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).