public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Cc: Indu Bhagat <indu.bhagat@oracle.com>
Subject: [COMMITTED, V2 1/6] sframe.h: add support for .cfi_negate_ra_state
Date: Fri, 16 Dec 2022 22:41:23 -0800	[thread overview]
Message-ID: <20221217064128.11326-2-indu.bhagat@oracle.com> (raw)
In-Reply-To: <20221217064128.11326-1-indu.bhagat@oracle.com>

[No Changes in V2]

Use the last remaining bit in the 'SFrame FRE info' word to store whether
the RA is signed/unsigned with PAC authorization code: this bit is named
as the "mangled RA" bit.  This bit is still unused for x86-64.

The behaviour of the mangled-RA info bit in SFrame format closely
follows the behaviour of DW_CFA_AARCH64_negate_ra_state in DWARF.  During
unwinding, whenever an SFrame FRE with non-zero "mangled RA" bit is
encountered, it means the upper bits of the return address contain Pointer
Authentication code.  The unwinder, hence, must use appropriate means to
restore LR correctly in such cases.

include/ChangeLog:

	* sframe.h (SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P): New macro.
	(SFRAME_V1_FRE_MANGLED_RA_P): Likewise.
---
 include/sframe.h | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/include/sframe.h b/include/sframe.h
index 03a2d75dfd3..b2bd41a724e 100644
--- a/include/sframe.h
+++ b/include/sframe.h
@@ -227,11 +227,12 @@ typedef struct sframe_fre_info
      - 2 bits: information about size of the offsets (S) in bytes.
      Valid values are SFRAME_FRE_OFFSET_1B, SFRAME_FRE_OFFSET_2B,
      SFRAME_FRE_OFFSET_4B
-     - 1 bit: Unused.
-     -----------------------------------------------------------------------
-     |  Unused  |  Size of offsets   |   Number of offsets    |   base_reg |
-     -----------------------------------------------------------------------
-     8          7                    5                        1            0
+     - 1 bit: Mangled RA state bit (aarch64 only).
+     ----------------------------------------------------------------------------------
+     | Mangled-RA (aarch64) |  Size of offsets   |   Number of offsets    |   base_reg |
+     |  Unused (amd64)      |                    |                        |            |
+     ----------------------------------------------------------------------------------
+     8                     7                    5                        1            0
 
      */
   uint8_t fre_info;
@@ -239,13 +240,19 @@ typedef struct sframe_fre_info
 
 /* Macros to compose and decompose FRE info.  */
 
+/* Note: Set mangled_ra_p to zero by default.  */
 #define SFRAME_V1_FRE_INFO(base_reg_id, offset_num, offset_size) \
-  ((((offset_size) & 0x3) << 5) | (((offset_num) & 0xf) << 1) | \
-   ((base_reg_id) & 0x1))
+  (((0 & 0x1) << 7) | (((offset_size) & 0x3) << 5) | \
+   (((offset_num) & 0xf) << 1) | ((base_reg_id) & 0x1))
+
+/* Set the mangled_ra_p bit as indicated.  */
+#define SFRAME_V1_FRE_INFO_UPDATE_MANGLED_RA_P(mangled_ra_p, fre_info) \
+  ((((mangled_ra_p) & 0x1) << 7) | ((fre_info) & 0x7f))
 
 #define SFRAME_V1_FRE_CFA_BASE_REG_ID(data)	  ((data) & 0x1)
 #define SFRAME_V1_FRE_OFFSET_COUNT(data)	  (((data) >> 1) & 0xf)
-#define SFRAME_V1_FRE_OFFSET_SIZE(data)	  (((data) >> 5) & 0x3)
+#define SFRAME_V1_FRE_OFFSET_SIZE(data)		  (((data) >> 5) & 0x3)
+#define SFRAME_V1_FRE_MANGLED_RA_P(data)	  (((data) >> 7) & 0x1)
 
 /* SFrame Frame Row Entry definitions.
 
-- 
2.37.2


  reply	other threads:[~2022-12-17  6:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-17  6:41 [COMMITTED, V2 0/6] SFrame: support for .cfi_negate_ra_state in aarch64 Indu Bhagat
2022-12-17  6:41 ` Indu Bhagat [this message]
2022-12-17  6:41 ` [COMMITTED, V2 2/6] gas: sframe: add support for .cfi_negate_ra_state Indu Bhagat
2022-12-17  6:41 ` [COMMITTED, V2 3/6] libsframe: provide new access API for mangled RA bit Indu Bhagat
2022-12-17  6:41 ` [COMMITTED, V2 4/6] objdump/readelf: sframe: emit marker for FREs with mangled RA Indu Bhagat
2022-12-17  6:41 ` [COMMITTED, V2 5/6] gas: sframe: testsuite: add testcase for .cfi_negate_ra_state Indu Bhagat
2022-12-17  6:41 ` [COMMITTED, V2 6/6] sframe: doc: update spec for the mangled-RA bit in FRE Indu Bhagat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221217064128.11326-2-indu.bhagat@oracle.com \
    --to=indu.bhagat@oracle.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).