public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: "H.J. Lu" <hjl.tools@gmail.com>,
	libc-alpha@sourceware.org, bug-hurd@gnu.org,
	Samuel Thibault <samuel.thibault@gnu.org>, Luca <luca@orpolo.org>
Subject: Re: [VERY RFC PATCH 2/2] hurd: Make it possible to call memcpy very early
Date: Fri, 21 Apr 2023 11:28:23 -0300	[thread overview]
Message-ID: <4ab79698-7131-b5af-7368-7e0359dc5aaa@linaro.org> (raw)
In-Reply-To: <CAN9u=Hc5fCydr=9rAG7C0dSOms6_OJxr3VZ7hhGHfG3HOjRFQw@mail.gmail.com>



On 21/04/23 10:56, Sergey Bugaev wrote:
> On Fri, Apr 21, 2023 at 3:58 PM Adhemerval Zanella Netto
> <adhemerval.zanella@linaro.org> wrote:
>>> Yes, sure, I wasn't really suggesting we do that change. My point is,
>>> I would like to make the same memcpy callsites both work during early
>>> startup and start calling the more efficient implementation once early
>>> startup is done -- if that's possible.
>>
>> That's the whole idea of dl-symbol-redir-ifunc.h, since it is explicit
>> enable by TU.
> 
> Then I must be misunderstanding how dl-symbol-redir-ifunc.h works
> (please explain!),
> 
> because I don't see how it would achieve that. Doesn't it change all
> memcpy calls in the current translation unit (.c file) to always call
> the baseline memcpy -- not only during startup, but even after the
> startup has been completed?

Indeed dl-symbol-redir-ifunc.h does not allow redirect the symbol in 
this dynamic way. But you can't really accomplish it without either 
hacking the ABI or using an override scheme, as we do for loader
malloc (elf/dl-minimal.c) where the minimal malloc is replaced on
final relocation phase.

The memcpy/memset/memmove is tricky because since compiler is free to
auto-generate calls to it we need to redirect it on a more direct way
(as explicit inline asm alias).

> 
> To be clear, this is about memcpy calls made *during* very early
> startup, yes, but not *in* some special startup-only code (like
> init-first.c and hurdstartup.c for instance): that startup-specific
> code calls into the fairly generic code (mig_memcpy.c and the various
> MIG-generated RPC routines) that is used both during this very early
> startup and then much later during the normal runtime, and *that's*
> what calls memcpy. I'd like for memcpy calls in that generic code to
> both work during early startup and use the efficient memcpy
> implementation later. If dl-symbol-redir-ifunc.h can achieve that,
> please help me understand how.

For Linux, the redirection is only used on very specific TU that can't 
really work with ifunc, and it is used only during static process 
initialization (like dl-support.c).

The 56010b73e81e2 commit message describes what seems to be a really
wacky scenario: lib{mach,hurd}user.so is relocated *before* libc.so; 
but they still call the libc.so symbols (because which seems to be
the compiler generated memcpy call).  The __mig_memcpy solution 
might work, but it is *really* hacky; but at same time I don't really
have a solution for this Hurd mess...

  reply	other threads:[~2023-04-21 14:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-20 18:42 [PATCH 1/2] hurd: Don't migrate reply port into __init1_tcbhead Sergey Bugaev
2023-04-20 18:42 ` [VERY RFC PATCH 2/2] hurd: Make it possible to call memcpy very early Sergey Bugaev
2023-04-20 20:25   ` H.J. Lu
2023-04-20 20:38     ` Adhemerval Zanella Netto
2023-04-21  9:27       ` Sergey Bugaev
2023-04-21 11:50         ` Adhemerval Zanella Netto
2023-04-21 12:38           ` Sergey Bugaev
2023-04-21 12:58             ` Adhemerval Zanella Netto
2023-04-21 13:56               ` Sergey Bugaev
2023-04-21 14:28                 ` Adhemerval Zanella Netto [this message]
2023-04-22 11:59                 ` Samuel Thibault
2023-04-22 12:18                   ` Sergey Bugaev
2023-04-22 16:20                     ` Samuel Thibault
2023-04-22 17:04                       ` Sergey Bugaev
2023-04-21 11:51     ` Sergey Bugaev
2023-04-21  1:02 ` [PATCH 1/2] hurd: Don't migrate reply port into __init1_tcbhead Samuel Thibault

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=4ab79698-7131-b5af-7368-7e0359dc5aaa@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=bug-hurd@gnu.org \
    --cc=bugaevc@gmail.com \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=luca@orpolo.org \
    --cc=samuel.thibault@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).