linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
To: "mingo@kernel.org" <mingo@kernel.org>,
	"yu-cheng.yu@intel.com" <yu-cheng.yu@intel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"bp@suse.de" <bp@suse.de>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"fenghua.yu@intel.com" <fenghua.yu@intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"luto@kernel.org" <luto@kernel.org>,
	"ravi.v.shankar@intel.com" <ravi.v.shankar@intel.com>,
	"haokexin@gmail.com" <haokexin@gmail.com>
Subject: Re: [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
Date: Thu, 2 Feb 2017 20:18:56 +0000	[thread overview]
Message-ID: <1486066735.25199.12.camel@infinera.com> (raw)
In-Reply-To: <20170124080957.GB11694@gmail.com>

On Tue, 2017-01-24 at 09:09 +0100, Ingo Molnar wrote:
> * Yu-cheng Yu <yu-cheng.yu@intel.com> wrote:

This needs to go to stable too, 4.8 and 4.9

 Jocke

> 
> > The compacted-format XSAVES area is determined at boot time and
> > never changed after.  The field xsave.header.xcomp_bv indicates
> > which components are in the fixed XSAVES format.
> > 
> > In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
> > format since at the time there is no valid data.
> > 
> > However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
> > as in commit: b22cbe404a9cc3c7949e380fa1861e31934c8978, and when
> > __fpu_restore_sig() does fpu__restore() for a COMPAT-mode app,
> > a #GP occurs.  This can be easily triggered by doing valgrind on
> > a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
> > others:
> > 
> > 	https://bugzilla.kernel.org/show_bug.cgi?id=190061
> > 
> > Fix it by setting xcomp_bv correctly.
> > 
> > Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
> > Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
> > ---
> >  arch/x86/kernel/fpu/core.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
> > index c289e2f..e540dc1 100644
> > --- a/arch/x86/kernel/fpu/core.c
> > +++ b/arch/x86/kernel/fpu/core.c
> > @@ -9,6 +9,7 @@
> >  #include <asm/fpu/regset.h>
> >  #include <asm/fpu/signal.h>
> >  #include <asm/fpu/types.h>
> > +#include <asm/fpu/xstate.h>
> >  #include <asm/traps.h>
> >  
> >  #include <linux/hardirq.h>
> > @@ -235,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
> >  	 * it will #GP. Make sure it is replaced after the memset().
> >  	 */
> >  	if (static_cpu_has(X86_FEATURE_XSAVES))
> > -		state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
> > +		state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
> > +					       xfeatures_mask;
> 
> Ok, I have applied this - but it would be cleaner to go one step further and add a 
> fpstate_init_xstate() method that does this in xstate.c and hides the details from 
> arch/x86/kernel/fpu/core.c.
> 
> Similar to how the FX-state initialization is done today:
> 
> >  	if (static_cpu_has(X86_FEATURE_FXSR))
> >  		fpstate_init_fxstate(&state->fxsave);
> 
> Thanks,
> 
> 	Ingo

  reply	other threads:[~2017-02-02 20:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-23 22:54 [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Yu-cheng Yu
2017-01-24  8:09 ` Ingo Molnar
2017-02-02 20:18   ` Joakim Tjernlund [this message]
2017-01-24  8:46 ` [tip:x86/urgent] " tip-bot for Yu-cheng Yu
2017-02-14 21:26   ` Yu-cheng Yu
2017-02-14 22:53     ` Greg Kroah-Hartman
2017-02-16 17:51     ` Greg Kroah-Hartman
2017-02-16 17:51       ` Yu-cheng Yu
2017-02-16 22:14 [PATCH] " Yu-cheng Yu

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=1486066735.25199.12.camel@infinera.com \
    --to=joakim.tjernlund@infinera.com \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fenghua.yu@intel.com \
    --cc=haokexin@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=ravi.v.shankar@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yu-cheng.yu@intel.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 NNTP newsgroup(s).