All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Ingo Molnar <mingo@kernel.org>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths
Date: Tue, 10 Mar 2015 07:06:25 +0100	[thread overview]
Message-ID: <1425967585-4725-2-git-send-email-bp@alien8.de> (raw)
In-Reply-To: <1425967585-4725-1-git-send-email-bp@alien8.de>

From: Oleg Nesterov <oleg@redhat.com>

fx_finit() has 2 users but only fpu_finit() needs to nullify xstate,
alloc_bootmem_align() in setup_init_fpu_buf() returns zero-filled
memory.

And note that both memset()'s look confusing. Yes, offsetof() is 0
for ->fxsave or ->fsave, but it would be more clean to turn them into
a single memset() which nullifies fpu->state.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Rik van Riel <riel@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Tavis Ormandy <taviso@google.com>
Cc: <x86@kernel.org>
Link: http://lkml.kernel.org/r/20150302183257.GC23085@redhat.com
Signed-off-by: Borislav Petkov <bp@suse.de>
---
 arch/x86/include/asm/fpu-internal.h | 1 -
 arch/x86/kernel/i387.c              | 3 ++-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
index 61609b963eab..5fa1be21ac2a 100644
--- a/arch/x86/include/asm/fpu-internal.h
+++ b/arch/x86/include/asm/fpu-internal.h
@@ -135,7 +135,6 @@ static __always_inline __pure bool use_fxsr(void)
 
 static inline void fx_finit(struct i387_fxsave_struct *fx)
 {
-	memset(fx, 0, xstate_size);
 	fx->cwd = 0x37f;
 	fx->mxcsr = MXCSR_DEFAULT;
 }
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 03cc0add8694..0f3de6674ae3 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -224,11 +224,12 @@ void fpu_finit(struct fpu *fpu)
 		return;
 	}
 
+	memset(fpu->state, 0, xstate_size);
+
 	if (cpu_has_fxsr) {
 		fx_finit(&fpu->state->fxsave);
 	} else {
 		struct i387_fsave_struct *fp = &fpu->state->fsave;
-		memset(fp, 0, xstate_size);
 		fp->cwd = 0xffff037fu;
 		fp->swd = 0xffff0000u;
 		fp->twd = 0xffffffffu;
-- 
2.2.0.33.gc18b867


  reply	other threads:[~2015-03-10  6:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 18:08 [GIT PULL] x86/fpu cleanups Borislav Petkov
2015-03-10  6:06 ` [PATCH 1/2] x86/fpu: Change xstateregs_get()/set() to use ->xsave.i387 rather than ->fxsave Borislav Petkov
2015-03-10  6:06   ` Borislav Petkov [this message]
     [not found] <CAJ_zFkJkHpU4Y8wrrZjO0VnhzUVqJfyrLmNfRsBRT29bgbDSHg@mail.gmail.com>
     [not found] ` <20150301184650.GA12758@redhat.com>
     [not found]   ` <20150301185943.GA14318@redhat.com>
     [not found]     ` <20150302174818.GA16886@redhat.com>
2015-03-02 18:32       ` [PATCH 0/2] x86/fpu: minor cleanups Oleg Nesterov
2015-03-02 18:32         ` [PATCH 1/2] x86/regsets: change xstateregs_get/set to use ->xsave.i387 rather than ->fxsave Oleg Nesterov
2015-03-03 19:23           ` Rik van Riel
2015-03-04 10:30           ` Borislav Petkov
2015-03-10 10:08           ` [tip:x86/fpu] x86/fpu: Change xstateregs_get()/set() to use -> xsave.i387 " tip-bot for Oleg Nesterov
2015-03-02 18:32         ` [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths Oleg Nesterov
2015-03-03 22:01           ` Rik van Riel
2015-03-04 11:38           ` Borislav Petkov
2015-03-10 10:08           ` [tip:x86/fpu] x86/fpu: Factor out memset(xstate, 0) in fpu_finit( ) paths tip-bot for Oleg Nesterov

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=1425967585-4725-2-git-send-email-bp@alien8.de \
    --to=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=x86@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.