From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754259AbbCBSe5 (ORCPT ); Mon, 2 Mar 2015 13:34:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35658 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbbCBSez (ORCPT ); Mon, 2 Mar 2015 13:34:55 -0500 Date: Mon, 2 Mar 2015 19:32:57 +0100 From: Oleg Nesterov To: Tavis Ormandy , Borislav Petkov , Ingo Molnar Cc: Rik van Riel , Andy Lutomirski , Linus Torvalds , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths Message-ID: <20150302183257.GC23085@redhat.com> References: <20150301184650.GA12758@redhat.com> <20150301185943.GA14318@redhat.com> <20150302174818.GA16886@redhat.com> <20150302183210.GA23085@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150302183210.GA23085@redhat.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 02f2e08..8809b5a 100644 --- a/arch/x86/include/asm/fpu-internal.h +++ b/arch/x86/include/asm/fpu-internal.h @@ -107,7 +107,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 4b12df8..9b7759f 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; -- 1.5.5.1