linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Anvin <hpa@zytor.com>, Denys Vlasenko <dvlasenk@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
	bp@alien8.de, Peter Zijlstra <a.p.zijlstra@chello.nl>,
	fenghua.yu@intel.com, x86@kernel.org,
	dave.hansen@linux.intel.com, Dave Hansen <dave@sr71.net>
Subject: Re: [PATCH] x86, fpu: correct XSAVE xstate size calculation
Date: Thu, 6 Aug 2015 10:27:46 +0200	[thread overview]
Message-ID: <20150806082746.GA10974@gmail.com> (raw)
In-Reply-To: <CA+55aFxzOj-Ee=DN-_3CMeDeYVsmvmmgoxd3hp4MpRSp+og7AQ@mail.gmail.com>


* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Aug 6, 2015 10:15 AM, "Ingo Molnar" <mingo@kernel.org> wrote:
> >
> > What sense does it make to have a blob we don't know the exact layout of? How 
> > will debuggers or user-space in general be able to print (and change) the 
> > register values if they don't know the layout?
> 
> The usage model is that you only use this for saving and restoring state.
> 
> If you look at the state, you restore the state and then you look at the 
> registers. You never look at the blob itself.

So we are relying on the saved structure already in a couple of cases, such as MPX 
exception handling:

        /*
         * We need to look at BNDSTATUS to resolve this exception.
         * A NULL here might mean that it is in its 'init state',
         * which is all zeros which indicates MPX was not
         * responsible for the exception.
         */
        bndcsr = get_xsave_field_ptr(XSTATE_BNDCSR);
        if (!bndcsr)
                goto exit_trap;

        trace_bounds_exception_mpx(bndcsr);

get_xsave_field_ptr() very much knows about the structure.

Currently the hardware enumerates to us the following details (simplified, omitted 
legacies):

   offset0, size0
   offset1, size1
   offset2, size2
   ...
   offsetN, sizeN

but the alignment of the final boundary of the xsave area is not given.

So as long as the limitation is that the final pair: offsetN + sizeN might not 
extend to the true end of the save area due to the end of the XSAVE area being 
extended to natural cache line boundary (or more) - I'm fine with that, it's not 
important to being able to read it, and it's OK for the CPU to have padding areas 
it doesn't write to but might need to read from.

But if the claim is that we don't know and shouldn't know about the structure of 
these blobs, I think that's generally a bad idea, even if in the normal case we 
don't touch the blobs and just pass them through to user-space.

Thanks,

	Ingo

  parent reply	other threads:[~2015-08-06  8:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-28 17:21 [PATCH] x86, fpu: correct XSAVE xstate size calculation Dave Hansen
2015-08-05 10:32 ` Ingo Molnar
2015-08-05 14:34   ` Dave Hansen
2015-08-06  7:15     ` Ingo Molnar
     [not found]       ` <CA+55aFxzOj-Ee=DN-_3CMeDeYVsmvmmgoxd3hp4MpRSp+og7AQ@mail.gmail.com>
2015-08-06  8:27         ` Ingo Molnar [this message]
2015-08-06  8:29           ` Ingo Molnar
2015-08-06 14:56           ` Dave Hansen
2015-08-06 16:03             ` Dave Hansen
2015-08-08  9:15             ` Ingo Molnar
2015-08-06 17:19       ` Dave Hansen
2015-08-08  9:06         ` Ingo Molnar
2015-08-10 21:14           ` Dave Hansen
2015-08-22 13:21             ` Ingo Molnar

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=20150806082746.GA10974@gmail.com \
    --to=mingo@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave@sr71.net \
    --cc=dvlasenk@redhat.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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).