]> Git Repo - linux.git/commitdiff
x86/fpu: Factor out memset(xstate, 0) in fpu_finit() paths
authorOleg Nesterov <[email protected]>
Tue, 10 Mar 2015 06:06:25 +0000 (07:06 +0100)
committerIngo Molnar <[email protected]>
Tue, 10 Mar 2015 06:14:31 +0000 (07:14 +0100)
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 <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Acked-by: Rik van Riel <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Tavis Ormandy <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/include/asm/fpu-internal.h
arch/x86/kernel/i387.c

index 61609b963eabc7a2f9ff3bd20a8ad1dba1e0806d..5fa1be21ac2a158557425e70cea0cb207fe132f3 100644 (file)
@@ -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;
 }
index 03cc0add869478ee03b3fa475745d9702cd6706c..0f3de6674ae39e30936829abb165ec5622d585e8 100644 (file)
@@ -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;
This page took 0.067541 seconds and 4 git commands to generate.