RE: [PATCH Bugfix v2 2/4] x86/xsaves: Define and use user_xstate_size for xstate size in signal context

From: Yu, Fenghua
Date: Tue Apr 28 2015 - 18:11:19 EST


> From: Hansen, Dave
> Sent: Tuesday, April 28, 2015 3:09 PM
> 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:
> > + /*
> > + * Clear xcomp_bv[63] in user's xsave area header to indicate
> > + * buf_fx is in standard format.
> > + */
> > + xcomp_bv = xsave->xsave_hdr.xcomp_bv;
> > + user_xsave = buf_fx;
> > + xcomp_bv &= ~((u64)1 << 63);
>
> I ran in to another bug. xrestor_user() is hitting a #GP with these values:
>
> [ 6.258743] xrestore_user() tmp: ffff88003f813000
> [ 6.261122] XCR0: 000000000000001f
> [ 6.261868] xstate_bv: 0000000000000003
> [ 6.262613] xcomp_bv: 000000000000001f
>
> I think it is because bit 63 is clear in xcomp_bv, but there are other bits set in
> there.
>
> I think the above needs to just do:
>
> /*
> * We are uncompacting the state for the user buffer. We need
> * to clear out the xcomp_bv field entirely. The uncompacted
> * form of xsave/xrstor treats this field as reserved.
> */
> if (__put_user(0, &user_xsave->xsave_hdr.xcomp_bv))
> return -1;

Yes, that makes sense. I will add this in v3 patchset.

Thanks.

-Fenghua
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/