From: Florian Weimer <fweimer@redhat.com>
To: Evan Green <evan@rivosinc.com>
Cc: Palmer Dabbelt <palmer@rivosinc.com>,
libc-alpha@sourceware.org, Vineet Gupta <vineetg@rivosinc.com>,
slewis@rivosinc.com
Subject: Re: [PATCH v5 3/4] riscv: Add ifunc-compatible hwprobe function
Date: Fri, 14 Jul 2023 08:54:03 +0200 [thread overview]
Message-ID: <87y1jjoues.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CALs-Hsuc6=DJxL1XqS4QxgsqceUmQ=pYJ0QuFFCMEwQSXRNsPQ@mail.gmail.com> (Evan Green's message of "Thu, 13 Jul 2023 11:21:22 -0700")
* Evan Green:
> Palmer and I chatted a bit more about this idea. The evolution of it
> was to define something like AT_RISCV_HWPROBE_FUNC whose value is a
> pointer to the vDSO function. The __riscv_hwprobe_early() in
> libc_nonshared can then just get the auxval and call it, with similar
> semantics as we have here of not setting errno, etc.
I don't think it can access the auxiliary vector without relocations.
> Florian, one question about your other possible solution suggestion,
> reproduced below:
>
>> You could pass the function pointer to the IFUNC resolver
>> (which may require a marker symbol and GCC changes).
>
> I'm unsure what a marker symbol is, so I'm having trouble following
> this suggestion. I'd like to understand what that suggestion was,
> especially if you think it's better than what we're planning above.
POWER does this to signal that a binary needs data in the TCB for use by
IFUNC resolvers:
/* Newer LIBCs explicitly export this symbol to declare that they provide
the AT_PLATFORM and AT_HWCAP/AT_HWCAP2 values in the TCB. We emit a
reference to this symbol whenever we expand a CPU builtin, so that
we never link against an old LIBC. */
const char *tcb_verification_symbol = "__parse_hwcap_and_convert_at_platform";
You are already passing an additional unused argument to IFUNC
resolvers, though:
static inline ElfW(Addr)
__attribute ((always_inline))
elf_ifunc_invoke (ElfW(Addr) addr)
{
/* The second argument is a void pointer to preserve the extension
fexibility. */
return ((ElfW(Addr) (*) (uint64_t, void *)) (addr))
(GLRO(dl_hwcap), NULL);
}
So you could pass something there (like the address of __riscv_hwprobe),
and add a third argument (NULL for now) for future extensions.
This change does not even have ABI impact, applications just need to
remember to check the function pointer for NULL. I haven't check if GCC
changes are needed before the compiler accepts the additional argument
in IFUNC resolvers.
Thanks,
Florian
next prev parent reply other threads:[~2023-07-14 6:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 19:36 [PATCH v5 0/4] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
2023-07-12 19:36 ` [PATCH v5 1/4] riscv: Add Linux hwprobe syscall support Evan Green
2023-07-19 22:44 ` Joseph Myers
2023-07-12 19:36 ` [PATCH v5 2/4] riscv: Add hwprobe vdso call support Evan Green
2023-07-12 19:36 ` [PATCH v5 3/4] riscv: Add ifunc-compatible hwprobe function Evan Green
2023-07-13 7:07 ` Florian Weimer
2023-07-13 16:33 ` Evan Green
2023-07-13 16:47 ` Palmer Dabbelt
2023-07-13 18:21 ` Evan Green
2023-07-14 6:54 ` Florian Weimer [this message]
2023-07-12 19:36 ` [PATCH v5 4/4] riscv: Add and use alignment-ignorant memcpy Evan Green
2023-07-12 22:35 ` [PATCH v5 0/4] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
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=87y1jjoues.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=evan@rivosinc.com \
--cc=libc-alpha@sourceware.org \
--cc=palmer@rivosinc.com \
--cc=slewis@rivosinc.com \
--cc=vineetg@rivosinc.com \
/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).