From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752478AbbCJKI7 (ORCPT ); Tue, 10 Mar 2015 06:08:59 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48134 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752328AbbCJKIz (ORCPT ); Tue, 10 Mar 2015 06:08:55 -0400 Date: Tue, 10 Mar 2015 03:08:19 -0700 From: tip-bot for Oleg Nesterov Message-ID: Cc: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, luto@amacapital.net, bp@alien8.de, bp@suse.de, taviso@google.com, oleg@redhat.com, hpa@zytor.com, mingo@kernel.org, riel@redhat.com Reply-To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org, tglx@linutronix.de, luto@amacapital.net, bp@alien8.de, bp@suse.de, taviso@google.com, oleg@redhat.com, hpa@zytor.com, mingo@kernel.org, riel@redhat.com In-Reply-To: <20150302183257.GC23085@redhat.com> References: <1425967585-4725-2-git-send-email-bp@alien8.de> <20150302183257.GC23085@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Factor out memset(xstate, 0) in fpu_finit( ) paths Git-Commit-ID: 1d23c4518b1f3a03c278f23333149245c178d2a6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1d23c4518b1f3a03c278f23333149245c178d2a6 Gitweb: http://git.kernel.org/tip/1d23c4518b1f3a03c278f23333149245c178d2a6 Author: Oleg Nesterov AuthorDate: Tue, 10 Mar 2015 07:06:25 +0100 Committer: Ingo Molnar CommitDate: Tue, 10 Mar 2015 07:14:31 +0100 x86/fpu: Factor out memset(xstate, 0) in fpu_finit() paths fx_finit() has two users but only fpu_finit() needs to clear 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 cleaner to turn them into a single memset() which zeroes fpu->state. Signed-off-by: Oleg Nesterov Signed-off-by: Borislav Petkov Acked-by: Rik van Riel Cc: Andy Lutomirski Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Tavis Ormandy Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1425967585-4725-2-git-send-email-bp@alien8.de Link: http://lkml.kernel.org/r/20150302183257.GC23085@redhat.com Signed-off-by: Ingo Molnar --- 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 61609b9..5fa1be2 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 03cc0ad..0f3de66 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;