[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87o87dezwo.ffs@tglx>
Date: Mon, 25 Oct 2021 20:13:11 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Mika Penttilä <mika.penttila@...tfour.com>,
"Chang S. Bae" <chang.seok.bae@...el.com>,
linux-kernel@...r.kernel.org
Cc: x86@...nel.org, dave.hansen@...ux.intel.com, arjan@...ux.intel.com,
ravi.v.shankar@...el.com
Subject: Re: [PATCH 15/23] x86/fpu: Add sanity checks for XFD
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=@...k
>> + * 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
Powered by blists - more mailing lists