[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <EBB61776-1C55-4C2E-9BA8-4F5D890A589F@intel.com>
Date: Wed, 18 Aug 2021 19:47:11 +0000
From: "Bae, Chang Seok" <chang.seok.bae@...el.com>
To: Borislav Petkov <bp@...en8.de>
CC: "Lutomirski, Andy" <luto@...nel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...nel.org" <mingo@...nel.org>,
"x86@...nel.org" <x86@...nel.org>,
"Brown, Len" <len.brown@...el.com>,
"Hansen, Dave" <dave.hansen@...el.com>,
"Macieira, Thiago" <thiago.macieira@...el.com>,
"Liu, Jing2" <jing2.liu@...el.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v9 11/26] x86/fpu/xstate: Update the XSTATE context copy
function to support dynamic states
On Aug 18, 2021, at 05:03, Borislav Petkov <bp@...en8.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
Powered by blists - more mailing lists