public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: "H.J. Lu via Libc-alpha" <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203]
Date: Fri, 18 Sep 2020 06:55:19 -0700	[thread overview]
Message-ID: <CAMe9rOqDjDeyWyAvrXpG7zdmAS79c_a+8DvEPbuvL0E+UrE2uQ@mail.gmail.com> (raw)
In-Reply-To: <874knva4r6.fsf@oldenburg2.str.redhat.com>

On Fri, Sep 18, 2020 at 1:06 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > X86 CPU features in ld.so are initialized by init_cpu_features, which is
> > invoked by DL_PLATFORM_INIT from _dl_sysdep_start.  But when ld.so is
> > loaded by static executable, DL_PLATFORM_INIT is never called.
>
> I don't think that's accurate.  It's called from elf/dl-support.c in the
> static case.  But I agree that it's too late in this case.

I was referring to the ld.so case.  elf/dl-support.c isn't used for ld.so.

> > Also x86 cache info in libc.o and libc.a is initialized by a
> > constructor which may be called too late.  Instead, we should
> > initialize x86 CPU features and cache info by initializing dummy
> > function pointers via IFUNC relocation.
>
> Why would ld put this special IRELATIVE relocation first?  I'm sorry,
> but this looks very brittle.

This is for ld.so.  ld.so doesn't assume that IFUNC is usable before everything
is setted up properly.   This IRELATIVE relocation is not different from other
dynamic relocations,  IRELATIVE or not.  The key here is that we want to call
init_cacheinfo as early as possible.  Calling from _dl_relocate_object is as
early as we can get.

> I think there's an existing mechanism for this corner case,
> ARCH_SETUP_IREL.  Could you use that?
>

ARCH_SETUP_IREL is for static executable, not ld.so.

-- 
H.J.

  reply	other threads:[~2020-09-18 13:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 13:44 [PATCH 0/3] ld.so: Add --list-tunables to print tunable values H.J. Lu
2020-09-12 13:44 ` [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] H.J. Lu
2020-09-18  8:06   ` Florian Weimer
2020-09-18 13:55     ` H.J. Lu [this message]
2020-09-18 13:59       ` Florian Weimer
2020-09-18 14:18         ` H.J. Lu
2020-09-18 14:22           ` Florian Weimer
2020-09-18 14:30             ` H.J. Lu
2020-09-21  8:21               ` Florian Weimer
2020-09-21 11:31                 ` H.J. Lu
2020-09-25 12:55                   ` Florian Weimer
2020-09-12 13:44 ` [PATCH 2/3] Set tunable value as well as min/max values H.J. Lu
2020-09-18  8:29   ` Florian Weimer
2020-09-18 15:11     ` H.J. Lu
2020-09-12 13:44 ` [PATCH 3/3] ld.so: Add --list-tunables to print tunable values H.J. Lu
2020-09-18  8:13   ` Florian Weimer
2020-09-18 15:24     ` H.J. Lu
  -- strict thread matches above, loose matches on Subject: below --
2020-07-12 14:24 [PATCH 0/3] " H.J. Lu
2020-07-12 14:24 ` [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] H.J. Lu

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=CAMe9rOqDjDeyWyAvrXpG7zdmAS79c_a+8DvEPbuvL0E+UrE2uQ@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@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).