Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Andy Lutomirski
On Mon, Feb 22, 2016 at 2:53 PM, Dave Hansen wrote: > On 02/22/2016 02:45 PM, Andy Lutomirski wrote: >>> +/* >>> > + * Convert from kernel XSAVES compacted format to standard format and >>> > copy >>> > + * to a ptrace buffer. It supports partial copy but pos always starts >>> > from >>> > + * z

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Dave Hansen
On 02/22/2016 02:45 PM, Andy Lutomirski wrote: >> +/* >> > + * Convert from kernel XSAVES compacted format to standard format and copy >> > + * to a ptrace buffer. It supports partial copy but pos always starts from >> > + * zero. This is called from xstateregs_get() and there we check the cpu >> >

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Yu-cheng Yu
On Mon, Feb 22, 2016 at 02:45:54PM -0800, Andy Lutomirski wrote: > > +/* > > + * Convert from kernel XSAVES compacted format to standard format and copy > > + * to a ptrace buffer. It supports partial copy but pos always starts from > > + * zero. This is called from xstateregs_get() and there we ch

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Andy Lutomirski
On Mon, Feb 22, 2016 at 11:00 AM, Yu-cheng Yu wrote: > XSAVES uses compacted format and is a kernel instruction. The kernel > should use standard-format, non-supervisor state data for PTRACE. > > +/* > + * Convert from kernel XSAVES compacted format to standard format and copy > + * to a ptrace b

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Yu-cheng Yu
On Mon, Feb 22, 2016 at 02:19:05PM -0800, Dave Hansen wrote: > On 02/22/2016 12:48 PM, Yu-cheng Yu wrote: > > It should have been: > > > > xsave->header.xfeatures = xfeatures | > > (xsave->header.xfeatures & XFEATURE_MASK_SUPERVISOR); > > > > I'll fix it. > > Can we break it out

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Dave Hansen
On 02/22/2016 12:48 PM, Yu-cheng Yu wrote: > It should have been: > > xsave->header.xfeatures = xfeatures | > (xsave->header.xfeatures & XFEATURE_MASK_SUPERVISOR); > > I'll fix it. Can we break it out to make it more clear? /* * The state that came in from userspace was use

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Yu-cheng Yu
On Mon, Feb 22, 2016 at 12:00:02PM -0800, Dave Hansen wrote: > On 02/22/2016 11:00 AM, Yu-cheng Yu wrote: > > + if (xsave->header.xfeatures & XFEATURE_MASK_SUPERVISOR) > > + xsave->header.xfeatures = xfeatures | XFEATURE_MASK_SUPERVISOR; > > + else > > + xsave->header.xfeatu

Re: [PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Dave Hansen
On 02/22/2016 11:00 AM, Yu-cheng Yu wrote: > + if (xsave->header.xfeatures & XFEATURE_MASK_SUPERVISOR) > + xsave->header.xfeatures = xfeatures | XFEATURE_MASK_SUPERVISOR; > + else > + xsave->header.xfeatures = xfeatures; This is dangerous. It says, "if any supervis

[PATCH 08/10] x86/xsaves: Fix PTRACE frames for XSAVES

2016-02-22 Thread Yu-cheng Yu
XSAVES uses compacted format and is a kernel instruction. The kernel should use standard-format, non-supervisor state data for PTRACE. Signed-off-by: Yu-cheng Yu --- arch/x86/include/asm/fpu/xstate.h | 4 + arch/x86/kernel/fpu/regset.c | 56 + arch/x86/kernel/fpu/xstate.c