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>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: V6: [PATCH] x86: Install <sys/platform/x86.h> [BZ #26124]
Date: Mon, 29 Jun 2020 09:44:51 -0700	[thread overview]
Message-ID: <CAMe9rOqbiF2oSN8aQikYFvWxk4jeuqJMW64d=GBLkpO-P502=Q@mail.gmail.com> (raw)
In-Reply-To: <871rlxx326.fsf@oldenburg2.str.redhat.com>

On Mon, Jun 29, 2020 at 9:14 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu via Libc-alpha:
>
> > Small update:
> >
> > const struct cpu_features *
> > __x86_get_cpu_features (unsigned int max, int cpuid)
> > {
> >   if (cpuid)
> >     {
> >       if (max > COMMON_CPUID_INDEX_MAX)
> >       return NULL;
> >     }
> >   else if (max > USABLE_FEATURE_INDEX_MAX)
> >     return NULL;
> >   return &GLRO(dl_x86_cpu_features);
> > }
> >
> > Don't return NULL when checking the cpuid array when COMMON_CPUID_INDEX_MAX
> > is unchanged, but USABLE_FEATURE_INDEX_MAX is changed.
>
> I think these changes address the fundamental technical issues, thanks.
>
> The patch needs to be rebased on top of
> 4fdd4d41a17dda26c854ed935658154a17d4b906 ("x86: Detect Intel Advanced
> Matrix Extensions").

Yes, I have done that in my local repo.

> One thing I still dislike (sorry) is the asymmetry between the usable
> and feature checks.  For example, why is there are usability check for
> VAES, but not for AES?  I believe the reason is that VAES depends on
> AVX/AVX2, but AES only depends on SSE2.  But even that suggests to me
> that for 32-bit, there should be a usable gate for that (which is false
> if SSE2 support has been masked).

CPU with AES must have SSE2.  I don't think we need explicit check
for SSE2.

> I think it would be more consistent to expose the usable/feature
> distinction for all features, and carry that over to the internal ABI,
> too.  This way, we can give accurate reporting in cases where the
> usability turned out to be firmware-dependent in the end (as it happened
> with RDRAND).  That would need additional feature-specific work; by
> default, we would still report such features as unsupported at the CPU
> level.  Having both bits exposed in all cases also protects us against
> cases where we need to change the usability detection logic in a later
> release.

We can flip the bit on the usable array with a parallel unusable array
 of the cpuid array.  We can set the unusable bit if OS doesn't support
it.

> There is a bit of a tension here regarding agility because new usable
> bits will only become set after glibc update.  But I don't see a way to
> avoid this, not without teaching programmers to bypass the usable checks
> (which leads to bugs, of course).
>
> The interface with the max and cpuid arguments is quite close to the one
> I proposed further up-thread.  I still think it has quite a few
> advantages.  Should I implement it?  I could have something by the end
> of the week, so we should still be able to make the ABI freeze.

Let me rebase and change to the usable array.  We can go from there.

Thanks.

-- 
H.J.

  reply	other threads:[~2020-06-29 16:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-17 19:31 [PATCH] x86: Install <cpu-features.h> " H.J. Lu
2020-06-17 20:54 ` Joseph Myers
2020-06-18  0:08   ` [PATCH] x86: Install <sys/platform/x86.h> " H.J. Lu
2020-06-18  8:45     ` Florian Weimer
2020-06-18 16:14       ` V2: " H.J. Lu
2020-06-22  9:09         ` Florian Weimer
2020-06-22 20:25           ` V3: " H.J. Lu
2020-06-22 20:41             ` Florian Weimer
2020-06-22 20:53               ` H.J. Lu
2020-06-22 21:14                 ` Florian Weimer
2020-06-22 22:18                   ` H.J. Lu
2020-06-22 23:14                     ` V4: " H.J. Lu
2020-06-24 14:33                       ` Florian Weimer
2020-06-24 20:04                         ` Adhemerval Zanella
2020-06-24 21:10                           ` H.J. Lu
2020-06-25  7:33                             ` Florian Weimer
2020-06-25 12:30                               ` V5: " H.J. Lu
2020-06-25 13:20                                 ` V6: " H.J. Lu
2020-06-26 12:52                                   ` H.J. Lu
2020-06-26 13:20                                     ` Florian Weimer
2020-06-26 13:44                                       ` H.J. Lu
2020-06-29 16:13                                   ` Florian Weimer
2020-06-29 16:44                                     ` H.J. Lu [this message]
2020-06-29 16:49                                       ` Florian Weimer
2020-06-30  0:29                                         ` H.J. Lu
2020-06-30  9:46                                           ` Florian Weimer
2020-06-30 12:19                                             ` H.J. Lu
2020-06-24 22:07                           ` V4: " Joseph Myers

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='CAMe9rOqbiF2oSN8aQikYFvWxk4jeuqJMW64d=GBLkpO-P502=Q@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --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).