Skip to content

Commit 1d23c45

Browse files
oleg-nesterovIngo Molnar
authored andcommitted
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 <oleg@redhat.com> Signed-off-by: Borislav Petkov <bp@suse.de> Acked-by: Rik van Riel <riel@redhat.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Borislav Petkov <bp@alien8.de> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Tavis Ormandy <taviso@google.com> Cc: Thomas Gleixner <tglx@linutronix.de> 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 <mingo@kernel.org>
1 parent e7f180d commit 1d23c45

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

arch/x86/include/asm/fpu-internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ static __always_inline __pure bool use_fxsr(void)
135135

136136
static inline void fx_finit(struct i387_fxsave_struct *fx)
137137
{
138-
memset(fx, 0, xstate_size);
139138
fx->cwd = 0x37f;
140139
fx->mxcsr = MXCSR_DEFAULT;
141140
}

arch/x86/kernel/i387.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,12 @@ void fpu_finit(struct fpu *fpu)
224224
return;
225225
}
226226

227+
memset(fpu->state, 0, xstate_size);
228+
227229
if (cpu_has_fxsr) {
228230
fx_finit(&fpu->state->fxsave);
229231
} else {
230232
struct i387_fsave_struct *fp = &fpu->state->fsave;
231-
memset(fp, 0, xstate_size);
232233
fp->cwd = 0xffff037fu;
233234
fp->swd = 0xffff0000u;
234235
fp->twd = 0xffffffffu;

0 commit comments

Comments
 (0)