From: Borislav Petkov <bp@alien8.de>
To: Yejune Deng <yejune.deng@gmail.com>
Cc: tglx@linutronix.de, mingo@redhat.com, x86@kernel.org,
hpa@zytor.com, dave.hansen@linux.intel.com,
yu-cheng.yu@intel.com, tony.luck@intel.com, fenghua.yu@intel.com,
kan.liang@linux.intel.com, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/fpu/xstate: calculate the number by sizeof and offsetof
Date: Wed, 20 Jan 2021 11:22:38 +0100 [thread overview]
Message-ID: <20210120102238.GA825@zn.tnic> (raw)
In-Reply-To: <20210120064415.16977-1-yejune.deng@gmail.com>
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@gmail.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
next prev parent reply other threads:[~2021-01-20 11:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-20 6:44 [PATCH] x86/fpu/xstate: calculate the number by sizeof and offsetof Yejune Deng
2021-01-20 6:49 ` Dave Hansen
2021-01-20 10:22 ` Borislav Petkov [this message]
2021-01-22 1:27 ` Yejune Deng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210120102238.GA825@zn.tnic \
--to=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=viro@zeniv.linux.org.uk \
--cc=x86@kernel.org \
--cc=yejune.deng@gmail.com \
--cc=yu-cheng.yu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox