Skip to content

Commit 1d6cf2e

Browse files
authored
[aadwarf64]] Add DW_CFA_AARCH64_set_ra_state stack frame operation (#346)
The DW_CFA_AARCH64_set_ra_state operation updates the RA_SIGN_STATE pseudo register with the current signing state. If the signing state includes signing is DW_AARCH64_RA_SIGNED_SP_PC, then it also provides the offset to the signing instruction so that the PC value used in the signing can be calculated. The DW_CFA_AARCH64_negate_ra_state_with_pc operation has been marked as deprecated. This is because it has been found that it is not suitable for describing all cases where the PC was used to sign the return address (see #327) The contents of the RA_SIGN_STATE pseudo register is also changed from being described in terms of a set of bits to being a series of defined values. Previously the state of the RA_SIGN_STATE pseudo register was changed implicitly by the DW_CFA_AARCH64_negate_ra_state and DW_CFA_AARCH64_set_ra_state operations. This meant that the actual encoding was actually internal to any implementation. Now with the introduction of the DW_CFA_AARCH64_set_ra_state operation the encoding has been made externally visible. So the opportunity has been taken now to change the encoding to a simpler form.
1 parent 576740d commit 1d6cf2e

File tree

1 file changed

+113
-76
lines changed

1 file changed

+113
-76
lines changed

aadwarf64/aadwarf64.rst

Lines changed: 113 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,23 @@ The following support level definitions are used by the Arm ABI specifications:
179179
The content of this specification is a draft, and Arm considers the
180180
likelihood of future incompatible changes to be significant.
181181

182-
Content relating to SVE should be considered as having **Beta** support level.
182+
Content relating to SVE should be considered as having **Beta** or **Alpha**
183+
support level.
183184
This includes:
184185

185186
* DWARF register names marked as **Beta** in `DWARF register names`_
186-
* Recommended expression of the vector types (`Vector types`_)
187+
* Recommended expression of the vector types marked as **Beta** in
188+
`Vector types`_
189+
* Changes in vector length marked as **Alpha**
190+
191+
Content relating to the return address state and instructions should be
192+
considered as having **Alpha** support level.
193+
This includes:
194+
195+
* The ``RA_SIGN_STATE`` pseudo register ra_state encoding marked as **Alpha**
196+
in `DWARF register names`_ `Note 8`_
197+
* The ``DW_CFA_AARCH64_set_ra_state`` instruction marked as as **Alpha**
198+
in `Call frame instructions`_
187199

188200
All other content in this document is at the **Release** quality level.
189201

@@ -197,43 +209,51 @@ changes to the content of the document for that release.
197209

198210
.. table::
199211

200-
+--------+-----------------------------+----------------------------------------+
201-
| Issue | Date | Change |
202-
+========+=============================+========================================+
203-
| 00bet3 | 16\ :sup:`th` December 2010 | Beta release. |
204-
+--------+-----------------------------+----------------------------------------+
205-
| 1.0 | 22\ :sup:`nd` May 2013 | First public release. |
206-
+--------+-----------------------------+----------------------------------------+
207-
| 2018Q4 | 31\ :sup:`st` December 2018 | Add SVE and pointer |
208-
| | | authentication support. |
209-
+--------+-----------------------------+----------------------------------------+
210-
| 2019Q4 | 30\ :sup:`th` January 2020 | Minor layout changes. |
211-
+--------+-----------------------------+----------------------------------------+
212-
| 2020Q2 | 1\ :sup:`st` June 2020 | Add requirements for unwinding MTE |
213-
| | | tagged stack. Describe DWARF |
214-
| | | representation of SVE vector types. |
215-
+--------+-----------------------------+----------------------------------------+
216-
| 2020Q4 | 21\ :sup:`st` December 2020 | - document released on Github |
217-
| | | - new Licence_: CC-BY-SA-4.0 |
218-
| | | - new sections on Contributions_, |
219-
| | | `Trademark notice`_, and Copyright_ |
220-
| | | - AArch64 DWARF pointer signing |
221-
| | | operations table columns switched |
222-
| | | - Add Thread ID register numbers. |
223-
+--------+-----------------------------+----------------------------------------+
224-
| 2022Q1 | 1\ :sup:`st` April 2022 | - Release of Pointer authentication. |
225-
| | | - In `Call frame instructions`_, |
226-
| | | document a limitation of |
227-
| | | DW_CFA_AARCH64_negate_ra_state. |
228-
+--------+-----------------------------+----------------------------------------+
229-
| 2022Q3 | 20\ :sup:`th` October 2022 | - Added `Changes in vector length`_ at |
230-
| | | **Alpha** quality. |
231-
+--------+-----------------------------+----------------------------------------+
232-
| 2024Q3 | 5\ :sup:`th` September 2024 | In `DWARF register names_` and |
233-
| | | `Call frame instructions`_, add Dwarf |
234-
| | | support for unwinding with |
235-
| | | FEAT_PAuth_LR enabled. |
236-
+--------+-----------------------------+----------------------------------------+
212+
+--------+-----------------------------+-------------------------------------------+
213+
| Issue | Date | Change |
214+
+========+=============================+===========================================+
215+
| 00bet3 | 16\ :sup:`th` December 2010 | Beta release. |
216+
+--------+-----------------------------+-------------------------------------------+
217+
| 1.0 | 22\ :sup:`nd` May 2013 | First public release. |
218+
+--------+-----------------------------+-------------------------------------------+
219+
| 2018Q4 | 31\ :sup:`st` December 2018 | Add SVE and pointer |
220+
| | | authentication support. |
221+
+--------+-----------------------------+-------------------------------------------+
222+
| 2019Q4 | 30\ :sup:`th` January 2020 | Minor layout changes. |
223+
+--------+-----------------------------+-------------------------------------------+
224+
| 2020Q2 | 1\ :sup:`st` June 2020 | Add requirements for unwinding MTE |
225+
| | | tagged stack. Describe DWARF |
226+
| | | representation of SVE vector types. |
227+
+--------+-----------------------------+-------------------------------------------+
228+
| 2020Q4 | 21\ :sup:`st` December 2020 | - document released on Github |
229+
| | | - new Licence_: CC-BY-SA-4.0 |
230+
| | | - new sections on Contributions_, |
231+
| | | `Trademark notice`_, and Copyright_ |
232+
| | | - AArch64 DWARF pointer signing |
233+
| | | operations table columns switched |
234+
| | | - Add Thread ID register numbers. |
235+
+--------+-----------------------------+-------------------------------------------+
236+
| 2022Q1 | 1\ :sup:`st` April 2022 | - Release of Pointer authentication. |
237+
| | | - In `Call frame instructions`_, |
238+
| | | document a limitation of |
239+
| | | DW_CFA_AARCH64_negate_ra_state. |
240+
+--------+-----------------------------+-------------------------------------------+
241+
| 2022Q3 | 20\ :sup:`th` October 2022 | - Added `Changes in vector length`_ at |
242+
| | | **Alpha** quality. |
243+
+--------+-----------------------------+-------------------------------------------+
244+
| 2024Q3 | 5\ :sup:`th` September 2024 | In `DWARF register names_` and |
245+
| | | `Call frame instructions`_, add Dwarf |
246+
| | | support for unwinding with |
247+
| | | FEAT_PAuth_LR enabled. |
248+
+--------+-----------------------------+-------------------------------------------+
249+
| | | - Added DW_CFA_AARCH64_set_ra_state at |
250+
| | | **Alpha** quality. |
251+
| | | - Deprecated |
252+
| | | DW_CFA_AARCH64_negate_ra_state_with_pc. |
253+
| | | - Redefined ra_state representation in |
254+
| | | the RA_SIGN_STATE pseudo register at |
255+
| | | **Alpha** quality. |
256+
+--------+-----------------------------+-------------------------------------------+
237257

238258

239259
References
@@ -478,33 +498,31 @@ integers.
478498
been signed with a PAC, and whether the value of PC has been used as a
479499
diversifier for the return address signing. This information can be used
480500
when unwinding. It is an unsigned integer with the same size as a general
481-
register. Only bit[0] and bit[1] are meaningful and are initialized to zero.
482-
483-
Bit[0] indicates whether the return address has been signed. A value of 0
484-
indicates the return address has not been signed. A value of 1 indicates
485-
the return address has been signed.
486-
487-
Bit[1] indicates whether the value of PC has been used as a diversifier for
488-
signing the return address. A value of 0 indicates the value of PC has not
489-
been used for return address signing. A value of 1 indicates the value of PC
490-
has been used for return address signing.
491-
492-
+--------+--------+----------------------------------+
493-
| Bit[1] | Bit[0] | State |
494-
+========+========+==================================+
495-
| 0 | 0 | Return address not signed |
496-
+--------+--------+----------------------------------+
497-
| 0 | 1 | Return address signed with SP |
498-
+--------+--------+----------------------------------+
499-
| 1 | 1 | Return address signed with SP+PC |
500-
+--------+--------+----------------------------------+
501-
| 1 | 0 | Invalid state |
502-
+--------+--------+----------------------------------+
501+
register.
502+
503+
(**Alpha**) Only bits[0-3] are meaningful and are initialized to
504+
``DW_AARCH64_RA_NOT_SIGNED``.
505+
506+
.. class:: aadwarf64-vendor-return-address-state
507+
508+
.. table:: AArch64 vendor return address state
509+
510+
+--------------------------------+--------+-----------------------------------------------------------------+
511+
| Return address state | Value | Description |
512+
+================================+========+=================================================================+
513+
| ``DW_AARCH64_RA_NOT_SIGNED`` | 0 | Return address not signed |
514+
+--------------------------------+--------+-----------------------------------------------------------------+
515+
| ``DW_AARCH64_RA_SIGNED_SP`` | 1 | Return address signed with SP |
516+
+--------------------------------+--------+-----------------------------------------------------------------+
517+
| ``DW_AARCH64_RA_SIGNED_SP_PC`` | 2 | Return address signed with SP+PC |
518+
+--------------------------------+--------+-----------------------------------------------------------------+
519+
| | 3 - 15 | (reserved for future use) |
520+
+--------------------------------+--------+-----------------------------------------------------------------+
503521

504522
.. _Note 9:
505523

506524
9. Normally, the program counter is restored from the return address, however
507-
having both LR and PC columns is useful for describing asynchronously
525+
having both LR and PC diversifiers is useful for describing asynchronously
508526
created stack frames. A DWARF expression may use this register to restore
509527
the context in case of a signal context.
510528

@@ -600,28 +618,47 @@ Call frame instructions
600618
-----------------------
601619

602620
This ABI defines the following vendor call frame instructions:
603-
``DW_CFA_AARCH64_negate_ra_state`` and ``DW_CFA_AARCH64_negate_ra_state_with_pc``.
621+
``DW_CFA_AARCH64_set_ra_state``, ``DW_CFA_AARCH64_negate_ra_state`` and ``DW_CFA_AARCH64_negate_ra_state_with_pc``.
604622

605623
.. class:: aadwarf64-vendor-cfa-operations
606624

607625
.. table:: AArch64 vendor CFA operations
608626

609-
+--------------------------------------------+-------------+------------+-----------+-----------+
610-
| Instruction | High 2 bits | Low 6 bits | Operand 1 | Operand 2 |
611-
+============================================+=============+============+===========+===========+
612-
| ``DW_CFA_AARCH64_negate_ra_state`` | 0 | ``0x2D`` | \- | \- |
613-
+--------------------------------------------+-------------+------------+-----------+-----------+
614-
| ``DW_CFA_AARCH64_negate_ra_state_with_pc`` | 0 | ``0x2C`` | \- | \- |
615-
+--------------------------------------------+-------------+------------+-----------+-----------+
616-
617-
The ``DW_CFA_AARCH64_negate_ra_state`` operation negates bit[0] of the
618-
RA_SIGN_STATE pseudo-register. It does not take any operands.
619-
620-
The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` operation negates bit[0] and
621-
bit[1] of the RA_SIGN_STATE pseudo-register, and instructs the unwinder to
627+
+-------------------------------------------------------------+-------------+------------+------------------+----------------+
628+
| Instruction | High 2 bits | Low 6 bits | Operand 1 | Operand 2 |
629+
+=============================================================+=============+============+==================+================+
630+
| ``DW_CFA_AARCH64_negate_ra_state`` | 0 | ``0x2D`` | \- | \- |
631+
+-------------------------------------------------------------+-------------+------------+------------------+----------------+
632+
| ``DW_CFA_AARCH64_negate_ra_state_with_pc`` (**Deprecated**) | 0 | ``0x2C`` | \- | \- |
633+
+-------------------------------------------------------------+-------------+------------+------------------+----------------+
634+
| ``DW_CFA_AARCH64_set_ra_state`` (**Alpha**) | 0 | ``0x2B`` | ULEB128 ra_state | SLEB128 offset |
635+
+-------------------------------------------------------------+-------------+------------+------------------+----------------+
636+
637+
The ``DW_CFA_AARCH64_negate_ra_state`` instruction toggles between the
638+
``DW_AARCH64_RA_NOT_SIGNED`` and ``DW_AARCH64_RA_SIGNED_SP`` return address
639+
states in RA_SIGN_STATE pseudo-register. It does not take any operands.
640+
641+
The ``DW_CFA_AARCH64_set_ra_state`` instruction takes two operands: an unsigned
642+
LEB128 value representing a return address state ra_state; and a signed LEB128
643+
factored offset. The required action is to set the RA_SIGN_STATE pseudo-register
644+
to the ra_state value and if the ra_state value is ``DW_AARCH64_RA_SIGNED_SP_PC``
645+
to capture the current code location + (offset * ``code_alignment_factor``)
646+
as the signing/authenticating PAC instruction, otherwise it is has the value 0.
647+
The code location information can be used for authenticating the return address.
648+
649+
The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` instruction toggles between the
650+
``DW_AARCH64_RA_NOT_SIGNED`` and ``DW_AARCH64_RA_SIGNED_SP_PC`` return
651+
address state in RA_SIGN_STATE pseudo-register, and instructs the unwinder to
622652
capture the current code location. The code location information can be used
623653
for authenticating the return address.
624654

655+
The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` instruction is **Deprecated**
656+
and the ``DW_CFA_AARCH64_set_ra_state`` instruction should be used instead.
657+
658+
*The ``DW_CFA_AARCH64_negate_ra_state`` instruction is deprecated because it is
659+
unable to correctly represent the return address signing state when the code
660+
flow is not linear between the signing/authenticating PAC instructions.*
661+
625662
The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` instruction must be placed within
626663
the debug frame in a position that refers to the exact code location of the
627664
signing/authenticating PAC instructions.

0 commit comments

Comments
 (0)