[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190607170949.GA648@sol.localdomain>
Date: Fri, 7 Jun 2019 10:09:49 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: x86-ml <x86@...nel.org>, Borislav Petkov <bp@...e.de>,
Dave Hansen <dave.hansen@...el.com>,
Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
Jann Horn <jannh@...gle.com>,
"Jason A. Donenfeld" <Jason@...c4.com>,
kvm ML <kvm@...r.kernel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
Rik van Riel <riel@...riel.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/fpu: Update kernel's FPU state before using for the
fsave header
On Fri, Jun 07, 2019 at 04:29:16PM +0200, Sebastian Andrzej Siewior wrote:
> In commit
>
> 39388e80f9b0c ("x86/fpu: Don't save fxregs for ia32 frames in copy_fpstate_to_sigframe()")
>
> I removed the statement
> | if (ia32_fxstate)
> | copy_fxregs_to_kernel(fpu);
>
> and argued that is was wrongly merged because the content was already
> saved in kernel's state and the content.
> This was wrong: It is required to write it back because it is only saved
> on the user-stack and save_fsave_header() reads it from task's
> FPU-state. I missed that part…
>
> Save x87 FPU state unless thread's FPU registers are already up to date.
>
> Fixes: 39388e80f9b0c ("x86/fpu: Don't save fxregs for ia32 frames in copy_fpstate_to_sigframe()")
> Reported-by: Eric Biggers <ebiggers@...nel.org>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
> ---
> arch/x86/kernel/fpu/signal.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
> index 060d6188b4533..0071b794ed193 100644
> --- a/arch/x86/kernel/fpu/signal.c
> +++ b/arch/x86/kernel/fpu/signal.c
> @@ -62,6 +62,11 @@ static inline int save_fsave_header(struct task_struct *tsk, void __user *buf)
> struct user_i387_ia32_struct env;
> struct _fpstate_32 __user *fp = buf;
>
> + fpregs_lock();
> + if (!test_thread_flag(TIF_NEED_FPU_LOAD))
> + copy_fxregs_to_kernel(&tsk->thread.fpu);
> + fpregs_unlock();
> +
> convert_from_fxsr(&env, tsk);
>
> if (__copy_to_user(buf, &env, sizeof(env)) ||
> --
> 2.20.1
>
Tested-by: Eric Biggers <ebiggers@...nel.org>
- Eric
Powered by blists - more mailing lists