From: Florian Weimer <fweimer@redhat.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: libc-alpha@sourceware.org, linux-api@vger.kernel.org,
x86@kernel.org, linux-arch@vger.kernel.org,
"H.J. Lu" <hjl.tools@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: x86 CPU features detection for applications (and AMX)
Date: Thu, 08 Jul 2021 16:31:28 +0200 [thread overview]
Message-ID: <87sg0oswqn.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <b3b104cd-72d9-7f5c-116b-414c6ebf448d@intel.com> (Dave Hansen's message of "Thu, 8 Jul 2021 07:19:21 -0700")
* Dave Hansen:
> On 7/7/21 11:05 PM, Florian Weimer wrote:
>>> This looks basically like someone dumped a bunch of CPUID bit values and
>>> exposed them to applications without considering whether applications
>>> would ever need them. For instance, why would an app ever care about:
>>>
>>> PKS – Protection keys for supervisor-mode pages.
>>>
>>> And how could glibc ever give applications accurate information about
>>> whether PKS "is supported by the operating system"? It just plain
>>> doesn't know, or at least only knows from a really weak ABI like
>>> /proc/cpuinfo.
>> glibc is expected to mask these bits for CPU_FEATURE_USABLE because they
>> have unknown semantics (to glibc).
>
> OK, so if I call CPU_FEATURE_USABLE(PKS) on a system *WITH* PKS
> supported in the operating system, I'll get false from an interface that
> claims to be:
>
>> This macro returns a nonzero value (true) if the processor has the
>> feature name and the feature is supported by the operating system.
>
> The interface just seems buggy by *design*.
Yes, but that is largely a documentation matter. We should have said
something about “userspace” there, and that the bit needs to be known to
glibc. There is another exception: FSGSBASE, and that's a real bug we
need to fix (it has to go through AT_HWCAP2).
If we want to avoid that, we need to go down the road of a curated set
of CPUID bits, where a bit only exists if we have taught glibc its
semantics. You still might get a false negative by running against an
older glibc than the application was built for. (We are not going to
force applications that e.g. look for FSGSBASE only run with a glibc
that is at least of that version which implemented semantics for the
FSGSBASE bit.)
Thanks,
Florian
next prev parent reply other threads:[~2021-07-08 14:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 15:04 Florian Weimer
2021-06-23 15:32 ` Dave Hansen
2021-07-08 6:05 ` Florian Weimer
2021-07-08 14:19 ` Dave Hansen
2021-07-08 14:31 ` Florian Weimer [this message]
2021-07-08 14:36 ` Dave Hansen
2021-07-08 14:41 ` Florian Weimer
2021-06-25 23:31 ` Thiago Macieira
[not found] ` <3c5c29e2-1b52-3576-eda2-018fb1e58ff9@metux.net>
2021-06-28 13:20 ` Peter Zijlstra
[not found] ` <534d0171-2cc5-cd0a-904f-cd3c499b55af@metux.net>
2021-06-30 15:36 ` Thiago Macieira
2021-06-28 15:08 ` Thiago Macieira
2021-06-28 15:27 ` Peter Zijlstra
2021-06-28 16:13 ` Thiago Macieira
2021-06-28 17:11 ` Peter Zijlstra
2021-06-28 17:23 ` Thiago Macieira
2021-06-28 19:08 ` Peter Zijlstra
2021-06-28 19:26 ` Thiago Macieira
2021-06-28 17:43 ` Peter Zijlstra
2021-06-28 19:05 ` Thiago Macieira
[not found] ` <e07294c9-b02a-e1c5-3620-7fae7269fdf1@metux.net>
2021-06-30 14:34 ` Florian Weimer
[not found] ` <030f1462-2bf9-39bc-d620-6d9fbe454a27@metux.net>
2021-06-30 15:38 ` Florian Weimer
[not found] ` <4ba30cb7-6854-0691-fad6-4ca9ce674ac2@metux.net>
2021-07-01 8:21 ` Florian Weimer
[not found] ` <034dcf9b-1f8c-23ee-86a6-791122bc0f8c@metux.net>
2021-07-06 12:57 ` Florian Weimer
2021-06-30 15:29 ` Thiago Macieira
2021-07-08 7:08 ` Florian Weimer
2021-07-08 15:13 ` Thiago Macieira
2021-07-08 17:56 ` Mark Brown
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=87sg0oswqn.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=dave.hansen@intel.com \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.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).