[PATCH,V6 0/9] Add experimental SCFI support for aarch64

Richard Sandiford richard.sandiford@arm.com
Thu Jul 18 10:50:01 GMT 2024


Indu Bhagat <indu.bhagat@oracle.com> writes:
> 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 V6 version addresses the review comments on V5:
>   - Use a different constant for invalid DWARF register number in
>     tc-aarch64-ginsn.c.  Adjust callers of ginsn_dw2_regnum () to take
>     appropriate action if invalid DWARF register number is seen.
>   - Other several comments around improving code quality and fixes for
>     issues identified during review.  More details in each commit log. 
>
> Link to V5 posting: https://sourceware.org/pipermail/binutils/2024-July/135678.html
> The V5 version addressed the review comments on V4:
>   - Subclass flags: Fix some mis-classifications.
>   - Ginsn creation: Code improvements and bugfixes.
>   - Testsuite: added more ops and testcases.
>   - Punt on S and W registers.
>
> Link to V4 posting: https://sourceware.org/pipermail/binutils/2024-July/135276.html
> The V4 version addressed 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:
>   - Patch 1 fixes a bug I ran into while testing the series.
>   - Patch 7 is new in V5. 
>   - Patch 3 to 6 now specify subclass flags only for instructions where
>     SCFI needs further classfication within an iclass.
>   - Patch 8 and 9 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 (9):
>   gas: scfi: make scfi_state_restore_reg function more precise
>   include: opcodes: aarch64: define new subclasses
>   opcodes: aarch64: add flags to denote subclasses of ldst insns
>   opcodes: aarch64: add flags to denote subclasses of arithmetic insns
>   opcodes: aarch64: add flags to denote subclasses of uncond branches
>   opcodes: aarch64: denote subclasses for insns of iclass dp_2src
>   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

Thanks for the updates.  The series is OK for trunk with the changes
mentioned for 3/9 and 8/9, if you agree with them.  There's no need
for another review cycle unless you'd prefer one.

Richard

>
>  gas/config/tc-aarch64-ginsn.c                 | 910 ++++++++++++++++++
>  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          |  40 +
>  .../gas/scfi/aarch64/ginsn-arith-1.s          |  19 +
>  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 |  89 ++
>  gas/testsuite/gas/scfi/aarch64/ginsn-ldst-1.s |  47 +
>  gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.l |  47 +
>  gas/testsuite/gas/scfi/aarch64/ginsn-misc-1.s |  32 +
>  .../gas/scfi/aarch64/scfi-aarch64.exp         |  74 ++
>  .../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  |   3 +
>  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/scfi/aarch64/scfi-ldstnap-1.d         |  39 +
>  .../gas/scfi/aarch64/scfi-ldstnap-1.l         |   2 +
>  .../gas/scfi/aarch64/scfi-ldstnap-1.s         |  30 +
>  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 +
>  .../gas/scfi/aarch64/scfi-unsupported-2.l     |   2 +
>  .../gas/scfi/aarch64/scfi-unsupported-2.s     |   8 +
>  include/opcode/aarch64.h                      |  35 +-
>  opcodes/aarch64-gen.c                         |  19 +
>  opcodes/aarch64-tbl.h                         | 202 ++--
>  66 files changed, 2585 insertions(+), 108 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-ldstnap-1.d
>  create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldstnap-1.l
>  create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-ldstnap-1.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
>  create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-unsupported-2.l
>  create mode 100644 gas/testsuite/gas/scfi/aarch64/scfi-unsupported-2.s


More information about the Binutils mailing list