lkml.org 
[lkml]   [2015]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH Bugfix v2 2/4] x86/xsaves: Define and use user_xstate_size for xstate size in signal context
Date
> From: Hansen, Dave
> Sent: Wednesday, April 22, 2015 11:45 AM
> To: Yu, Fenghua; H. Peter Anvin; Ingo Molnar; Thomas Gleixner; Mallick, Asit
> K; Williamson, Glenn P
> Cc: linux-kernel; x86
> Subject: Re: [PATCH Bugfix v2 2/4] x86/xsaves: Define and use
> user_xstate_size for xstate size in signal context
>
> On 04/21/2015 09:51 PM, Fenghua Yu wrote:
> > + /*
> > + * Copy rest of xstates in compact format to user.
> > + */
> > + for (i = 2; i < xstate_features; i++) {
> > + if (test_bit(i, (unsigned long *)&pcntxt_mask)) {
> > + int user_offset, kernel_offset;
> > + int size;
> > +
> > + user_offset = xstate_offsets[i];
> > + kernel_offset = xstate_comp_offsets[i];
> > + size = xstate_sizes[i];
> > +
> > + if (__copy_to_user(buf_fx + user_offset,
> > + xsave + kernel_offset, size))
> > + return -1;
> > + }
> > + }
>
> Is this checking the right bitmap?
>
> The 'xsaves' documentation says: "If RFBM[i] = 1, XSTATE_BV[i] is set to the
> value of XINUSE[i]". Where "XINUSE denotes the state-component bitmap
> corresponding to the init optimization".
>
> So shouldn't this be checking xsave->xsave_hdr.xstate_bv instead of
> pcntxt_mask? The will be equal unless the "init optimization" is in play.

Xsave->xsave_hdr.xstate_bv is equal to pcntxt_mask (see setup_init_fpu_buf()).

And here XINUSE and RFBM are irrelevant because they are used in init or modified
optimization during xsave*/xrstore*. We only copy out the xstates from kernel
to user and XINUSE and RFBM are not in scope here.

So I would think pcntxt_mask is good to be used here.

Thanks.

-Fenghua


\
 
 \ /
  Last update: 2015-04-22 21:41    [W:0.131 / U:2.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site