linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Andy Lutomirski <luto@kernel.org>, "H. J. Lu" <hjl.tools@gmail.com>
Cc: "Robert O'Callahan" <robert@ocallahan.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	X86 ML <x86@kernel.org>
Subject: Re: xgetbv nondeterminism
Date: Thu, 15 Jun 2017 16:37:09 -0700	[thread overview]
Message-ID: <b70b7639-3827-c0fc-f9b0-6c40d438b646@intel.com> (raw)
In-Reply-To: <CALCETrV61NBHndB-OBdHXH5TSRnnvo16Ea9JvczK-r1-UD207Q@mail.gmail.com>

On 06/15/2017 03:18 PM, Andy Lutomirski wrote:
>> As you pointed out, if you are using XSAVEC's compaction features by
>> leaving bits unset in the requested feature bitmap registers, you have
>> no idea how much data XSAVEC will write, unless you read XINUSE with
>> XGETBV.  But, you can get around *that* by just presizing the XSAVE
>> buffer to be big.
> I imagine that, if you're going to save, do something quick, and
> restore, you'd be better off allocating a big buffer rather than
> trying to find the smallest buffer you can get away with by reading
> XINUSE.  Also, what happens if XINUSE nondeterministically changes out
> from under you before you do XSAVEC?  I assume you can avoid this
> becoming a problem by using RFBM carefully.

That's a good point.  HJ, does your XGETBV1 code disable signals, btw?
A signal could theoretically change XINUSE if the handler modified the
on-stack XSAVE state before sigreturn.

Also, your glibc patch talks a lot about the upper parts of the register
being zeroed, but that isn't precisely what XGETBV1 does, right?  It
tells you whether the upper portion of the registers are in the init
state.  But, the high parts of the registers could be zero, and not in
the init state, rights?

I'm missing something, though...  Is the stuff in question here called
*every* time one of these AVX-using functions is called, or called only
the first time when the binding is done?

It's also bonkers that software has to go to this trouble.  This is
precisely what XSAVEOPT is supposed to do for us.

  parent reply	other threads:[~2017-06-15 23:37 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15  5:18 xgetbv nondeterminism Andy Lutomirski
2017-06-15 14:33 ` Dave Hansen
2017-06-15 22:18   ` Andy Lutomirski
2017-06-15 22:40     ` H.J. Lu
2017-06-15 22:45       ` Andy Lutomirski
2017-06-15 23:11         ` H.J. Lu
2017-06-15 23:28           ` Andy Lutomirski
2017-06-16  2:17             ` H.J. Lu
2017-06-16  3:05               ` Andy Lutomirski
2017-06-16  4:34                 ` H.J. Lu
2017-06-16 16:01                   ` Andy Lutomirski
2017-06-16 16:17                     ` H.J. Lu
2017-06-16 16:38                       ` Andy Lutomirski
2017-06-16 17:44                         ` H.J. Lu
2017-06-16 17:56                           ` Andy Lutomirski
2017-06-16 18:03                             ` H.J. Lu
2017-06-17  6:21                               ` Andy Lutomirski
2017-06-17 12:51                                 ` H.J. Lu
2017-06-17 16:32                                   ` Andy Lutomirski
2017-06-17 19:48                                     ` H.J. Lu
2017-06-15 23:37     ` Dave Hansen [this message]
2017-06-16  2:28       ` 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=b70b7639-3827-c0fc-f9b0-6c40d438b646@intel.com \
    --to=dave.hansen@intel.com \
    --cc=hjl.tools@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=robert@ocallahan.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 NNTP newsgroup(s).