From: Indu Bhagat <indu.bhagat@oracle.com>
To: binutils@sourceware.org
Subject: Re: [PATCH, V4 1/8] gas: scfi: make scfi_state_restore_reg function more precise
Date: Fri, 12 Jul 2024 08:03:47 -0700 [thread overview]
Message-ID: <ca8ed673-71d4-5c89-b9ff-59e2e1944027@oracle.com> (raw)
In-Reply-To: <20240701025404.3361349-2-indu.bhagat@oracle.com>
[PING]
On 6/30/24 7:53 PM, Indu Bhagat wrote:
> [No changes in V3, V4]
> PS: This patch needs a global maintainer review/approval.
>
> [New in V2]
> - This patch is orthogonal to aarch64 support. It is included here
> because the testcase added for it is aarch64 specific. It is a
> bugfix really.
> [End of New in V2]
>
> When the SCFI machinery detects that a register has been restored from
> stack, it makes some state changes in the SCFI state object.
>
> Prior to the patch, scfi_state_restore_reg () was setting a value of
> (reg, CFI_IN_REG) for (base, state) respectively. This was causing
> issues in the cmp_scfi_state () function:
> - The default state of all (callee-saved) regs at the beginning of
> function is set to (0, CFI_UNDEFINED).
> - If a register is saved and restored on some control path, the state
> of reg is (reg, CFI_IN_REG) on that path.
> - On another control path where the register was perhaps not
> used (or saved/restored on stack) remains (0, CFI_UNDEFINED).
> - The two states should be treated equal, however, at the point in
> program after the register has been restored.
>
> Fix this by resetting the state to (0, CFI_UNDEFINED) in
> scfi_state_restore_reg ().
>
> A testcase (scfi-cfg-4.s) for this is added in a subsequent commit.
>
> gas/
> * scfi.c (scfi_state_restore_reg): Reset to 0, CFI_UNDEFINED
> for base, state.
> ---
> gas/scfi.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/gas/scfi.c b/gas/scfi.c
> index 744822d8102..5898a57b330 100644
> --- a/gas/scfi.c
> +++ b/gas/scfi.c
> @@ -223,11 +223,12 @@ scfi_state_restore_reg (scfi_stateS *state, unsigned int reg)
> gas_assert (state->regs[reg].state == CFI_ON_STACK);
> gas_assert (state->regs[reg].base == REG_CFA);
>
> - state->regs[reg].base = reg;
> + /* PS: the register may still be on stack much after the restore. Reset the
> + SCFI state to CFI_UNDEFINED, however, to indicate that the most updated
> + source of value is register itself from here onwards. */
> + state->regs[reg].base = 0;
> state->regs[reg].offset = 0;
> - /* PS: the register may still be on stack much after the restore, but the
> - SCFI state keeps the state as 'in register'. */
> - state->regs[reg].state = CFI_IN_REG;
> + state->regs[reg].state = CFI_UNDEFINED;
> }
>
> /* Identify if the given GAS instruction GINSN saves a register
>
next prev parent reply other threads:[~2024-07-12 15:03 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 2:53 [PATCH,V4 0/8] Add SCFI support for aarch64 Indu Bhagat
2024-07-01 2:53 ` [PATCH,V4 1/8] gas: scfi: make scfi_state_restore_reg function more precise Indu Bhagat
2024-07-12 15:03 ` Indu Bhagat [this message]
2024-07-01 2:53 ` [PATCH,V4 2/8] include: opcodes: aarch64: define new subclasses Indu Bhagat
2024-07-01 17:40 ` Richard Sandiford
2024-07-11 5:14 ` Indu Bhagat
2024-07-11 12:22 ` Richard Sandiford
2024-07-11 17:59 ` Indu Bhagat
2024-07-01 2:53 ` [PATCH,V4 3/8] opcodes: aarch64: flags to denote subclasses of ldst insns Indu Bhagat
2024-07-01 18:06 ` Richard Sandiford
2024-07-11 5:45 ` Indu Bhagat
2024-07-12 13:59 ` Indu Bhagat
2024-07-13 7:34 ` Indu Bhagat
2024-07-01 2:54 ` [PATCH,V4 4/8] opcodes: aarch64: flags to denote subclasses of arithmetic insns Indu Bhagat
2024-07-01 18:13 ` Richard Sandiford
2024-07-11 5:47 ` Indu Bhagat
2024-07-11 12:52 ` Richard Sandiford
2024-07-11 17:58 ` Indu Bhagat
2024-07-11 18:43 ` Richard Sandiford
2024-07-12 12:53 ` Indu Bhagat
2024-07-01 2:54 ` [PATCH,V4 5/8] opcodes: aarch64: flags to denote subclasses of uncond branches Indu Bhagat
2024-07-01 2:54 ` [PATCH,V4 6/8] opcodes: aarch64: enforce checks on subclass flags in aarch64-gen.c Indu Bhagat
2024-07-01 2:54 ` [PATCH,V4 7/8] gas: aarch64: add experimental support for SCFI Indu Bhagat
2024-07-01 19:49 ` Richard Sandiford
2024-07-11 6:30 ` Indu Bhagat
2024-07-11 13:15 ` Richard Sandiford
2024-07-11 19:07 ` Indu Bhagat
2024-07-11 20:10 ` Richard Sandiford
2024-07-01 2:54 ` [PATCH,V4 8/8] gas: aarch64: testsuite: add new tests " 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=ca8ed673-71d4-5c89-b9ff-59e2e1944027@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).