[PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-10 Thread Borislav Petkov
From: Oleg Nesterov 

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 
Acked-by: Rik van Riel 
Cc: Andy Lutomirski 
Cc: Linus Torvalds 
Cc: Tavis Ormandy 
Cc: 
Link: http://lkml.kernel.org/r/20150302183257.gc23...@redhat.com
Signed-off-by: Borislav Petkov 
---
 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(>state->fxsave);
} else {
struct i387_fsave_struct *fp = >state->fsave;
-   memset(fp, 0, xstate_size);
fp->cwd = 0x037fu;
fp->swd = 0xu;
fp->twd = 0xu;
-- 
2.2.0.33.gc18b867

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-10 Thread Borislav Petkov
From: Oleg Nesterov o...@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 o...@redhat.com
Acked-by: Rik van Riel r...@redhat.com
Cc: Andy Lutomirski l...@amacapital.net
Cc: Linus Torvalds torva...@linux-foundation.org
Cc: Tavis Ormandy tav...@google.com
Cc: x...@kernel.org
Link: http://lkml.kernel.org/r/20150302183257.gc23...@redhat.com
Signed-off-by: Borislav Petkov b...@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 = 0x037fu;
fp-swd = 0xu;
fp-twd = 0xu;
-- 
2.2.0.33.gc18b867

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-04 Thread Borislav Petkov
On Mon, Mar 02, 2015 at 07:32:57PM +0100, Oleg Nesterov wrote:
> 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 

Applied, thanks.

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-04 Thread Borislav Petkov
On Mon, Mar 02, 2015 at 07:32:57PM +0100, Oleg Nesterov wrote:
 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 o...@redhat.com

Applied, thanks.

-- 
Regards/Gruss,
Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-03 Thread Rik van Riel
On 03/02/2015 01:32 PM, Oleg Nesterov wrote:
> 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 

Acked-by: Rik van Riel 

-- 
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-03 Thread Rik van Riel
On 03/02/2015 01:32 PM, Oleg Nesterov wrote:
 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 o...@redhat.com

Acked-by: Rik van Riel r...@redhat.com

-- 
All rights reversed
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-02 Thread Oleg Nesterov
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(>state->fxsave);
} else {
struct i387_fsave_struct *fp = >state->fsave;
-   memset(fp, 0, xstate_size);
fp->cwd = 0x037fu;
fp->swd = 0xu;
fp->twd = 0xu;
-- 
1.5.5.1


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths

2015-03-02 Thread Oleg Nesterov
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 o...@redhat.com
---
 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 = 0x037fu;
fp-swd = 0xu;
fp-twd = 0xu;
-- 
1.5.5.1


--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/