Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[aadwarf64] Add DWARF support for unwinding with FEAT_PAuth_LR enabled #245

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 48 additions & 16 deletions aadwarf64/aadwarf64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,31 @@ integers.
.. _Note 8:

8. The RA_SIGN_STATE pseudo-register records whether the return address has
been signed with a PAC. This information can be used when unwinding. It
is an unsigned integer with the same size as a general register. Only
bit[0] is meaningful and is initialized to zero. A value of 0 indicates
the return address has not been signed. A value of 1 indicates the return
address has been signed.
been signed with a PAC, and whether the value of PC has been used as a
diversifier for the return address signing. This information can be used
when unwinding. It is an unsigned integer with the same size as a general
register. Only bit[0] and bit[1] are meaningful and are initialized to zero.
pratlucas marked this conversation as resolved.
Show resolved Hide resolved

Bit[0] indicates whether the return address has been signed. A value of 0
indicates the return address has not been signed. A value of 1 indicates
the return address has been signed.

Bit[1] indicates whether the value of PC has been used as a diversifier for
signing the return address. A value of 0 indicates the value of PC has not
been used for return address signing. A value of 1 indicates the value of PC
has been used for return address signing.

+--------+--------+----------------------------------+
| Bit[1] | Bit[0] | State |
+========+========+==================================+
| 0 | 0 | Return address not signed |
+--------+--------+----------------------------------+
| 0 | 1 | Return address signed with SP |
+--------+--------+----------------------------------+
| 1 | 1 | Return address signed with SP+PC |
+--------+--------+----------------------------------+
| 1 | 0 | Invalid state |
+--------+--------+----------------------------------+

.. _Note 9:

Expand Down Expand Up @@ -574,25 +594,37 @@ a CIE augmentation string.
Call frame instructions
-----------------------

This ABI defines one vendor call frame instruction
``DW_CFA_AARCH64_negate_ra_state``.
This ABI defines the following vendor call frame instructions:
``DW_CFA_AARCH64_negate_ra_state`` and ``DW_CFA_AARCH64_negate_ra_state_with_pc``.

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

.. table:: AArch64 vendor CFA operations

+------------------------------------+-------------+------------+-----------+-----------+
| Instruction | High 2 bits | Low 6 bits | Operand 1 | Operand 2 |
+====================================+=============+============+===========+===========+
| ``DW_CFA_AARCH64_negate_ra_state`` | 0 | ``0x2D`` | \- | \- |
+------------------------------------+-------------+------------+-----------+-----------+
+--------------------------------------------+-------------+------------+-----------+-----------+
| Instruction | High 2 bits | Low 6 bits | Operand 1 | Operand 2 |
+============================================+=============+============+===========+===========+
| ``DW_CFA_AARCH64_negate_ra_state`` | 0 | ``0x2D`` | \- | \- |
+--------------------------------------------+-------------+------------+-----------+-----------+
| ``DW_CFA_AARCH64_negate_ra_state_with_pc`` | 0 | ``0x2C`` | \- | \- |
+--------------------------------------------+-------------+------------+-----------+-----------+

The ``DW_CFA_AARCH64_negate_ra_state`` operation negates bit[0] of the
RA_SIGN_STATE pseudo-register. It does not take any operands.
The ``DW_CFA_AARCH64_negate_ra_state`` must not be mixed with other DWARF
Register Rule Instructions (GDWARF_, §6.4.2.3) on the RA_SIGN_STATE
pseudo-register in one Common Information Entry (CIE) and Frame Descriptor
Entry (FDE) program sequence.

The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` operation negates bit[0] and
bit[1] of the RA_SIGN_STATE pseudo-register, and instructs the unwinder to
capture the current code location. The code location information can be used
for authenticating the return address.

The ``DW_CFA_AARCH64_negate_ra_state_with_pc`` instruction must be placed within
the debug frame in a position that refers to the exact code location of the
signing/authenticating PAC instructions.

The ``DW_CFA_AARCH64_negate_ra_state`` and ``DW_CFA_AARCH64_negate_ra_state_with_pc``
instructions must not be mixed with other DWARF Register Rule Instructions
(GDWARF_, §6.4.2.3) on the RA_SIGN_STATE pseudo-register in one Common
Information Entry (CIE) and Frame Descriptor Entry (FDE) program sequence.

.. _DWARF expression operations:

Expand Down
Loading