Messages in this thread | | | From | "Bae, Chang Seok" <> | Subject | Re: [PATCH v9 11/26] x86/fpu/xstate: Update the XSTATE context copy function to support dynamic states | Date | Wed, 18 Aug 2021 19:47:11 +0000 |
| |
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
| |