lkml.org 
[lkml]   [2021]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 15/23] x86/fpu: Add sanity checks for XFD
Date
On Mon, Oct 25 2021 at 11:33, Mika Penttilä wrote:
> On 22.10.2021 1.55, Chang S. Bae wrote:
>> +#ifdef CONFIG_X86_DEBUG_FPU
>> +/*
>> + * Ensure that a subsequent XSAVE* or XRSTOR* instruction with RFBM=@mask
>> + * can safely operate on the @fpstate buffer.
>> + */
>> +static bool xstate_op_valid(struct fpstate *fpstate, u64 mask, bool rstor)
>> +{
>> + u64 xfd = __this_cpu_read(xfd_state);
>> +
>> + if (fpstate->xfd == xfd)
>> + return true;
>> +
>> + /* For current's fpstate the XFD state must be correct. */
>> + if (fpstate->xfd == current->thread.fpu.fpstate->xfd)
>> + return false;
>> +
> Should this return true or is the comment confusing?

Comment might be confusing. The logic here is:

If fpstate->xfd equal xfd then it's valid.

So the next check is whether fpstate is the same as current's
fpstate. If that's the case then the result is invalid because for
current's fpstate the first condition should be true. But if it is not
true then the state is not valid.

Thanks,

tglx

\
 
 \ /
  Last update: 2021-10-25 20:14    [W:0.119 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site