lkml.org 
[lkml]   [2016]   [May]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5 11/13] x86/xsaves: Add WARN_ON_FPU() when a disabled xstate component offset is requested for a compacted format
From
Date
On 05/09/2016 04:44 PM, Yu-cheng Yu wrote:
> On Mon, May 09, 2016 at 04:31:18PM -0700, Dave Hansen wrote:
>> On 05/09/2016 01:46 PM, Yu-cheng Yu wrote:
>>> Add a warning in case a disabled (not existing) xstate component offset
>>> is requested.
>> ...
>>> diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
>>> index 350814c..2e6dbfe 100644
>>> --- a/arch/x86/kernel/fpu/xstate.c
>>> +++ b/arch/x86/kernel/fpu/xstate.c
>>> @@ -756,6 +756,7 @@ void *__raw_xsave_addr(struct xregs_state *xsave, int xstate_feature_mask)
>>> {
>>> int feature_nr = fls64(xstate_feature_mask) - 1;
>>>
>>> + WARN_ON_FPU(using_compacted_format() && !xfeature_enabled(feature_nr));
>>> return (void *)xsave + xstate_comp_offsets[feature_nr];
>>> }
>>
>> Why the using_compacted_format()? Shouldn't this be an error, regardless.
>
> If the kernel is not using compacted format, I can get a component offset, no?

You can get it, but why would you? Let's say you were trying to get the
MPX contents. You'd either be guaranteed to be getting 0's or
uninitialized garbage (if we didn't zero it carefully).

The garbage could be kernel data (if we didn't zero carefully). So it
just seems dangerous to allow this for no apparent benefit.


\
 
 \ /
  Last update: 2016-05-10 02:21    [W:0.550 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site