[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170124001447.GD15017@pek-khao-d1>
Date: Tue, 24 Jan 2017 08:14:47 +0800
From: Kevin Hao <haokexin@...il.com>
To: Yu-cheng Yu <yu-cheng.yu@...el.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>, fenghua.yu@...el.com,
dvlasenk@...hat.com, peterz@...radead.org, oleg@...hat.com,
mingo@...nel.org, linux-kernel@...r.kernel.org, brgerst@...il.com,
luto@...nel.org, bp@...en8.de, jpoimboe@...hat.com, hpa@...or.com,
quentin.casasnovas@...cle.com, tglx@...utronix.de,
torvalds@...ux-foundation.org, riel@...hat.com,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:x86/urgent] x86/fpu: Set the xcomp_bv when we fake up a
XSAVES area
On Mon, Jan 23, 2017 at 01:16:40PM -0800, Yu-cheng Yu wrote:
> On Mon, Jan 23, 2017 at 01:10:20PM -0800, Dave Hansen wrote:
> > The code is:
> >
> > > void fpstate_init(union fpregs_state *state)
> > > {
> > > if (!static_cpu_has(X86_FEATURE_FPU)) {
> > > fpstate_init_soft(&state->soft);
> > > return;
> > > }
> > >
> > > memset(state, 0, fpu_kernel_xstate_size);
> > >
> > > /*
> > > * XRSTORS requires that this bit is set in xcomp_bv, or
> > > * 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;
> >
> > That seems to set it unconditionally. What am I missing?
>
> The fix I am proposing is...
>
> state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
> xfeatures_mask;
Actually I thought about this change before I made this patch, but I don't this
is the right fix. It is always error prone to init the xcomp_bv to all the
supported feature. In case like copyin_to_xsaves(), it is possible that the
features which should be set in xcomp_bv do not equal to all the supported
features. Please see the following codes in copyin_to_xsaves():
/*
* The state that came in from userspace was user-state only.
* Mask all the user states out of 'xfeatures':
*/
xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR;
/*
* Add back in the features that came in from userspace:
*/
xsave->header.xfeatures |= xfeatures;
Thanks,
Kevin
Download attachment "signature.asc" of type "application/pgp-signature" (474 bytes)
Powered by blists - more mailing lists