public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
	Richard Sandiford <Richard.Sandiford@arm.com>
Subject: Re: [PATCH] libgcc: Fix uninitialized RA signing on AArch64 [PR107678]
Date: Tue, 6 Dec 2022 21:33:34 +0000	[thread overview]
Message-ID: <Y4+1Locq8BcSoMu4@arm.com> (raw)
In-Reply-To: <PAWPR08MB898214F3635227E79D9721FC831B9@PAWPR08MB8982.eurprd08.prod.outlook.com>

The 12/06/2022 11:58, Wilco Dijkstra wrote:
> > i don't think how[*RA_STATE] can ever be set to REG_SAVED_OFFSET,
> > this pseudo reg is not spilled to the stack, it is reset to 0 in
> > each frame and then toggled within a frame.
> 
> It's is just a state, we can use any state we want since it is a pseudo reg.
> These registers are global and shared across all functions in an unwind,
> so their state or value isn't reset for each frame. So if we want to reset
> it in each frame then using a virtual register to hold per-function data
> seems like a bad design. I'm surprised nobody has ever tested it...

it was tested (and worked when the frame state was initialized).

in principle the CIE can contain instructions to initialize the
register state for a frame. the RA_STATE pseudo reg behaves as if
the CIE always set its value to 0 at the start of the frame.

the design has issues, but this is what we have now.

the toggle instruction for RA_STATE does not really fit the dwarf
model: the CFI instruction sequence is evaluated with a context
that is valid at the end of the sequence so an unwinder only wants
to evaluate a register's state at the end, not intermediate values
(where the context might not even be valid). so we limited the
instructions allowed for RA_STATE: only remember_/restore_state,
toggle and val_expression are supported and the latter two cannot
be mixed. we still have to use the existing struct for keeping
track of this hence reg[RA_STATE].loc.offset.

and of course the RA_STATE pseudo reg is only used for computing
the return address not propagated to the previous frame so it is
special in many ways. so we will need target hooks to fix this
and i think the cleanest is to initialize RA_STATE per frame and
leave the rest as is.


  reply	other threads:[~2022-12-06 21:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-01 16:55 Wilco Dijkstra
2022-12-05 19:04 ` Richard Sandiford
2022-12-06 10:50   ` Szabolcs Nagy
2022-12-06 11:58     ` Wilco Dijkstra
2022-12-06 21:33       ` Szabolcs Nagy [this message]
2023-01-03 17:27   ` Wilco Dijkstra
2023-01-05 14:57     ` Szabolcs Nagy
2023-01-10 16:33       ` Wilco Dijkstra
2023-01-10 18:12         ` Jakub Jelinek
2023-01-11 11:33           ` Martin Liška
2023-01-11 11:59             ` Wilco Dijkstra
2023-01-12 10:49               ` Jakub Jelinek
2023-01-12 12:05                 ` Richard Sandiford
2023-01-12 12:08                   ` Richard Sandiford
2023-01-12 12:28                   ` Jakub Jelinek
2023-01-12 14:39                     ` Jakub Jelinek
2023-01-12 15:22                       ` Richard Sandiford
2023-01-12 15:34                         ` Jakub Jelinek
2023-01-12 15:40                           ` Richard Sandiford
2023-01-12 18:57         ` Jakub Jelinek
2023-01-16 13:04           ` Martin Liška
2023-01-17 19:49             ` Wilco Dijkstra
2023-01-17 20:43               ` Richard Sandiford
2023-01-18 12:49                 ` Wilco Dijkstra

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=Y4+1Locq8BcSoMu4@arm.com \
    --to=szabolcs.nagy@arm.com \
    --cc=Richard.Sandiford@arm.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=gcc-patches@gcc.gnu.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).