public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alex Coplan <acoplan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/morello)] aarch64: -mtrack-speculation pass capability enablement Date: Fri, 24 Feb 2023 17:34:38 +0000 (GMT) [thread overview] Message-ID: <20230224173438.0898E3857C45@sourceware.org> (raw) https://gcc.gnu.org/g:ce2e4f958b407ae0bb9a66c34a708c74ba15eb3f commit ce2e4f958b407ae0bb9a66c34a708c74ba15eb3f Author: Victor Do Nascimento <victor.donascimento@arm.com> Date: Mon Jan 16 17:09:32 2023 +0000 aarch64: -mtrack-speculation pass capability enablement Fix the code sequence generated for speculative execution tracking so that it uses the proper capability-handling instructions, thus preventing the invalidation of the CSP stack pointer capability when the speculation tracking state is encoded into the stack pointer. For capability-enabled targets, we see the following change in the generated tracking code from: mov tmp, sp and tmp, tmp, tracker mov SP, tmp to: mov tmp, sp and tmp, tmp, tracker scvalue CSP, CSP, tmp Diff: --- gcc/config/aarch64/aarch64-speculation.cc | 9 ++++++--- .../gcc.target/aarch64/morello/mtrack-speculation.c | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/gcc/config/aarch64/aarch64-speculation.cc b/gcc/config/aarch64/aarch64-speculation.cc index f490b64ae61..2453f62c96c 100644 --- a/gcc/config/aarch64/aarch64-speculation.cc +++ b/gcc/config/aarch64/aarch64-speculation.cc @@ -141,14 +141,17 @@ static rtx_insn * aarch64_speculation_clobber_sp () { - rtx sp = gen_rtx_REG (DImode, SP_REGNUM); + rtx sp = gen_rtx_REG (Pmode, SP_REGNUM); rtx tracker = gen_rtx_REG (DImode, SPECULATION_TRACKER_REGNUM); rtx scratch = gen_rtx_REG (DImode, SPECULATION_SCRATCH_REGNUM); start_sequence (); - emit_insn (gen_rtx_SET (scratch, sp)); + emit_insn (gen_rtx_SET (scratch, drop_capability (sp))); emit_insn (gen_anddi3 (scratch, scratch, tracker)); - emit_insn (gen_rtx_SET (sp, scratch)); + if (CAPABILITY_MODE_P (Pmode)) + emit_insn (gen_replace_address_value_cadi (sp, sp, scratch)); + else + emit_insn (gen_rtx_SET (sp, scratch)); rtx_insn *seq = get_insns (); end_sequence (); return seq; diff --git a/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c b/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c new file mode 100644 index 00000000000..ec7f3ba6a53 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/morello/mtrack-speculation.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-additional-options "-mtrack-speculation" } */ +/* Ensure the speculation tracker code does not invalidate the + stack pointer capability. */ + +int +main() { + int a = 10; + while (a) + a--; + return 0; +}
reply other threads:[~2023-02-24 17:34 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230224173438.0898E3857C45@sourceware.org \ --to=acoplan@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).