lkml.org 
[lkml]   [2021]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH v9 11/26] x86/fpu/xstate: Update the XSTATE context copy function to support dynamic states
Date
On Aug 18, 2021, at 05:03, Borislav Petkov <bp@alien8.de> wrote:
> On Fri, Jul 30, 2021 at 07:59:42AM -0700, Chang S. Bae wrote:
>>
>> - copy_feature(header.xfeatures & BIT_ULL(i), &to,
>> - __raw_xsave_addr(&tsk->thread.fpu, i),
>> - __raw_xsave_addr(NULL, i),
>> - xstate_sizes[i]);
>> + unsigned int size = xstate_sizes[i];
>> + void *from = NULL;
>> +
>> + /*
>> + * Copy the xstate if available. Otherwise, copy the
>> + * non-zero init states for legacy states (FP and
>> + * SSE) or fill zeros.
>> + */
>> +
>> + if (header.xfeatures & mask)
>> + from = __raw_xsave_addr(&tsk->thread.fpu, i);
>> + else if (XFEATURE_MASK_FPSSE & mask)
>
> The i loop variable above starts from FIRST_EXTENDED_XFEATURE - why is
> this XFEATURE_MASK_FPSSE check even here?

!(header.xfeatures & mask) means init-state should be copied. Except for
these, the init value is zero (as also noted here [1]). So, check this to copy
correct init data if the current iteration is for the legacy states.

At least, I may need to improve the readability here.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/kernel/fpu/xstate.c#n416

Thanks,
Chang

\
 
 \ /
  Last update: 2021-08-18 21:47    [W:0.335 / U:0.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site