[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210120102238.GA825@zn.tnic>
Date: Wed, 20 Jan 2021 11:22:38 +0100
From: Borislav Petkov <bp@...en8.de>
To: Yejune Deng <yejune.deng@...il.com>
Cc: tglx@...utronix.de, mingo@...hat.com, x86@...nel.org,
hpa@...or.com, dave.hansen@...ux.intel.com, yu-cheng.yu@...el.com,
tony.luck@...el.com, fenghua.yu@...el.com,
kan.liang@...ux.intel.com, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/fpu/xstate: calculate the number by sizeof and
offsetof
On Wed, Jan 20, 2021 at 02:44:15PM +0800, Yejune Deng wrote:
> In fpstate_sanitize_xstate(), use memset and offsetof instead of '= 0',
> and use sizeof instead of a constant.
>
> Signed-off-by: Yejune Deng <yejune.deng@...il.com>
> ---
> arch/x86/kernel/fpu/xstate.c | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
> index 5d8047441a0a..2e75630c86e9 100644
> --- a/arch/x86/kernel/fpu/xstate.c
> +++ b/arch/x86/kernel/fpu/xstate.c
> @@ -161,20 +161,16 @@ void fpstate_sanitize_xstate(struct fpu *fpu)
> * FP is in init state
> */
> if (!(xfeatures & XFEATURE_MASK_FP)) {
> + memset(fx, 0, offsetof(struct fxregs_state, mxcsr));
I'd prefer the explicit zeroing instead of having to look at
fxregs_state and where the offset of mxcsr is.
> + memset(fx->st_space, 0, sizeof(fx->st_space));
This is ok I guess.
> fx->cwd = 0x37f;
> - fx->swd = 0;
> - fx->twd = 0;
> - fx->fop = 0;
> - fx->rip = 0;
> - fx->rdp = 0;
> - memset(&fx->st_space[0], 0, 128);
> }
>
> /*
> * SSE is in init state
> */
> if (!(xfeatures & XFEATURE_MASK_SSE))
> - memset(&fx->xmm_space[0], 0, 256);
> + memset(fx->xmm_space, 0, sizeof(fx->xmm_space));
This too.
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists