public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/102952] New code-gen options for retpolines and straight line speculation Date: Wed, 27 Oct 2021 15:03:26 +0000 [thread overview] Message-ID: <bug-102952-4-yYukk4bXsv@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102952-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102952 H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |WAITING --- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> --- (In reply to Andrew Cooper from comment #0) > Hello > > [FYI, this is being cross-requested of Clang too] > > Linux and other kernel level software makes use of > -mindirect-branch=thunk-extern to be able to alter the handling of indirect > branches at boot. It turns out to be advantageous to inline the thunks when > retpoline is not in use. > https://lore.kernel.org/lkml/20211026120132.613201817@infradead.org/ is some > infrastructure to make this work. > > In some cases, we want to be able to inline an `lfence; jmp *%reg` thunk. > This is fine for the low 8 registers, but not fine for %r{8..15} where the > REX prefix pushes the replacement size to being 6 bytes. > > It would be very useful to have a code-gen option to write out `call > %cs:__x86_indirect_thunk_r{8..15}` where the redundant %cs prefix will > increase the instruction length to 6, allowing the non-retpoline form to be > inlined. > -mindirect-branch-cs-prefix > Relatedly, x86 straight line speculation has been discussed before, but > without any action taken. It would be helpful to have a code gen option > which would emit `int3` following any `ret` instruction, and any indirect > jump, as neither of these two cases have following architectural execution. > > The reason these two are related is that if both options are in use, we want > an extra byte of replacement space to be able to inline `lfence; jmp *%reg; > int3`. > -mharden-sls=[none|all|return|indirect-branch] Let me know if they work. I also need testcases. > Third (and possibly only for future optimisations), Clang has been observed > to spot conditional tail calls as `Jcc __x86_indirect_thunk_*`. This is a 6 > byte source size, but needs up to 9 bytes of space for inlining including an > `int3` for straight line speculation reasons (See > https://lore.kernel.org/lkml/20211026120310.359986601@infradead.org/ for > full details). It might be enough to simply prohibit an optimisation like > this when trying to pad retpolines for inlineability. I don't think GCC does that at all.
next prev parent reply other threads:[~2021-10-27 15:03 UTC|newest] Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-26 15:54 [Bug c/102952] New: " andrew.cooper3 at citrix dot com 2021-10-26 15:56 ` [Bug c/102952] " andrew.cooper3 at citrix dot com 2021-10-26 17:11 ` [Bug target/102952] " andrew.cooper3 at citrix dot com 2021-10-27 7:00 ` rguenth at gcc dot gnu.org 2021-10-27 14:50 ` hjl.tools at gmail dot com 2021-10-27 15:01 ` hjl.tools at gmail dot com 2021-10-27 15:03 ` hjl.tools at gmail dot com [this message] 2021-10-27 17:55 ` hjl.tools at gmail dot com 2021-10-27 19:59 ` peterz at infradead dot org 2021-10-27 20:00 ` hjl.tools at gmail dot com 2021-10-27 20:14 ` peterz at infradead dot org 2021-10-27 20:20 ` peterz at infradead dot org 2021-10-27 21:42 ` hjl.tools at gmail dot com 2021-10-27 21:42 ` hjl.tools at gmail dot com 2021-10-27 22:07 ` peterz at infradead dot org 2021-10-27 22:12 ` hjl.tools at gmail dot com 2021-10-27 22:16 ` andrew.cooper3 at citrix dot com 2021-10-27 22:39 ` hjl.tools at gmail dot com 2021-10-27 22:42 ` hjl.tools at gmail dot com 2021-10-27 22:46 ` andrew.cooper3 at citrix dot com 2021-10-27 22:53 ` hjl.tools at gmail dot com 2021-10-28 7:30 ` peterz at infradead dot org 2021-10-28 7:43 ` peterz at infradead dot org 2021-10-28 22:07 ` andrew.cooper3 at citrix dot com 2021-10-28 22:26 ` hjl.tools at gmail dot com 2021-11-15 14:27 ` hjl.tools at gmail dot com 2021-11-16 12:57 ` peterz at infradead dot org 2021-11-16 18:52 ` hjl.tools at gmail dot com 2021-11-17 21:35 ` cvs-commit at gcc dot gnu.org 2021-11-18 16:26 ` cvs-commit at gcc dot gnu.org 2021-11-18 18:30 ` hjl.tools at gmail dot com 2022-01-06 9:51 ` andrew.cooper3 at citrix dot com 2022-01-06 13:21 ` hjl.tools at gmail dot com 2022-01-06 13:23 ` hjl.tools at gmail dot com 2022-01-06 18:13 ` andrew.cooper3 at citrix dot com 2022-01-06 19:53 ` cvs-commit at gcc dot gnu.org 2022-01-06 20:12 ` hjl.tools at gmail dot com 2022-01-31 8:04 ` rguenth at gcc dot gnu.org 2022-01-31 13:34 ` hjl.tools at gmail dot com 2022-01-31 15:43 ` hjl.tools at gmail dot com 2022-01-31 18:56 ` hjl.tools at gmail dot com 2022-02-07 23:06 ` andrew.cooper3 at citrix dot com 2022-02-16 14:01 ` cvs-commit at gcc dot gnu.org 2022-02-16 14:01 ` cvs-commit at gcc dot gnu.org 2022-02-16 14:01 ` cvs-commit at gcc dot gnu.org
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=bug-102952-4-yYukk4bXsv@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).