public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "matz at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/112980] 64-bit powerpc ELFv2 does not allow nops to be generated before function global entry point
Date: Tue, 09 Apr 2024 12:59:32 +0000	[thread overview]
Message-ID: <bug-112980-4-v8O8tXw2aH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112980-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112980

--- Comment #14 from Michael Matz <matz at gcc dot gnu.org> ---
(In reply to Kewen Lin from comment #13)
> (In reply to Giuliano Belinassi from comment #12)
> > With your patch we have:
> > 
> > > .LPFE0:
> > > ...
> > Which seems what is expected.
> 
> Hi Giuliano, thanks for your time on testing it!  Could you kindly help to
> explain a bit on why "In such way we can't use the this space to place a
> trampoline to the new function"? Is it due to inefficient code like needing
> more branches?
> 
> global entry:
>   [b localentry]
> L1:
>   [patched code]
> localentry:
>   [b L1]
> 
> Or some other reason which makes it unused at all?

Hmm?  But this is not how the global-to-local hand-off is implemented (and
expected by tooling): a fall-through.  The global entry sets up the GOT
register, there simply is no '[b localentry]'.

If you mean to imply that also the '[b localentry]' should be patched in at
live-patch application time (and hence the GOT setup would need to be moved
to still somewhere else), then you have the problem that (in the
not-yet-patched 
case) as long as the L1-nops sit between global and local entry they will
always 
be executed when the global entry is called.  That's wasteful.

Additionally tooling will be surprised if the address difference between
global and local entry isn't exactly 8 (i.e. two instructions).  The psABI
allows for different values, of course.  But I'm willing to bet that there are
bugs in the wild when different values would be actually used.

So, the nops-between-gep-and-lep could probably be somehow made to work with
userspace live patching, but your most recent patch here makes this all mood.
It generates exactly the sequence we want: a single nop at the LEP, and
a configurable patching area outside of, but near to, the function (here: in
front of the GEP).

  parent reply	other threads:[~2024-04-09 12:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12  9:22 [Bug target/112980] New: " naveen at kernel dot org
2024-01-18  5:15 ` [Bug target/112980] " linkw at gcc dot gnu.org
2024-01-18  9:44 ` naveen at kernel dot org
2024-01-18 13:36 ` matz at gcc dot gnu.org
2024-01-19  2:06 ` linkw at gcc dot gnu.org
2024-03-19 16:27 ` jamborm at gcc dot gnu.org
2024-03-20  9:05 ` linkw at gcc dot gnu.org
2024-03-25 13:31 ` naveen at kernel dot org
2024-04-01  7:30 ` linkw at gcc dot gnu.org
2024-04-01 14:03 ` giuliano.belinassi at gmail dot com
2024-04-02  8:21 ` linkw at gcc dot gnu.org
2024-04-02  8:24 ` linkw at gcc dot gnu.org
2024-04-04 18:24 ` giuliano.belinassi at gmail dot com
2024-04-09  3:02 ` linkw at gcc dot gnu.org
2024-04-09 12:59 ` matz at gcc dot gnu.org [this message]
2024-04-10  2:14 ` linkw at gcc dot gnu.org
2024-04-11 12:37 ` matz at gcc dot gnu.org
2024-04-12  3:48 ` linkw at gcc dot gnu.org
2024-05-29  2:21 ` linkw 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-112980-4-v8O8tXw2aH@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: 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).