Patchwork [15/22] x86/entry: Add TIF_NEED_FPU_LOAD

login
register
mail settings
Submitter Sebastian Andrzej Siewior
Date Feb. 7, 2019, 11:49 a.m.
Message ID <20190207114941.jzydrry5xpjngyiv@linutronix.de>
Download mbox | patch
Permalink /patch/720335/
State New
Headers show

Comments

Sebastian Andrzej Siewior - Feb. 7, 2019, 11:49 a.m.
On 2019-01-30 12:55:07 [+0100], Borislav Petkov wrote:
> This definitely needs to be written somewhere in
> 
> arch/x86/include/asm/fpu/internal.h
> 
> or where we decide to put the FPU handling rules.

Added:


Sebastian
Borislav Petkov - Feb. 13, 2019, 9:35 a.m.
On Thu, Feb 07, 2019 at 12:49:42PM +0100, Sebastian Andrzej Siewior wrote:
> On 2019-01-30 12:55:07 [+0100], Borislav Petkov wrote:
> > This definitely needs to be written somewhere in
> > 
> > arch/x86/include/asm/fpu/internal.h
> > 
> > or where we decide to put the FPU handling rules.
> 
> Added:
> 
> Index: staging/arch/x86/include/asm/fpu/internal.h
> ===================================================================
> --- staging.orig/arch/x86/include/asm/fpu/internal.h
> +++ staging/arch/x86/include/asm/fpu/internal.h
> @@ -537,6 +537,12 @@ static inline void __fpregs_load_activat
>   *
>   * The FPU context is only stored/restore for user task and ->mm is used to
>   * distinguish between kernel and user threads.
> + *
> + * If TIF_NEED_FPU_LOAD is cleared then CPU's FPU registers are holding the
> + * current content of current()'s FPU register state.

"current content of current" - that's a lot of c...

Make that

"... then the CPU's FPU registers are mirrored in the current thread's
FPU registers state."

> + * If TIF_NEED_FPU_LOAD is set then CPU's FPU registers may not hold current()'s
> + * FPU registers. It is required to load the register before returning to
						^^^^^^^^

s/register/registers/ - plural.

Thx.
Sebastian Andrzej Siewior - Feb. 14, 2019, 3:28 p.m.
On 2019-02-13 10:35:53 [+0100], Borislav Petkov wrote:
…
> > + *
> > + * If TIF_NEED_FPU_LOAD is cleared then CPU's FPU registers are holding the
> > + * current content of current()'s FPU register state.
> 
> "current content of current" - that's a lot of c...
> 
> Make that
> 
> "... then the CPU's FPU registers are mirrored in the current thread's
> FPU registers state."

Replaced `mirrored' with saved:

+ * If TIF_NEED_FPU_LOAD is cleared then the CPU's FPU registers are saved in
+ * the current thread's FPU registers state.
+ * If TIF_NEED_FPU_LOAD is set then CPU's FPU registers may not hold current()'s
+ * FPU registers. It is required to load the registers before returning to
+ * userland or using the content otherwise.

Sebastian

Patch

Index: staging/arch/x86/include/asm/fpu/internal.h
===================================================================
--- staging.orig/arch/x86/include/asm/fpu/internal.h
+++ staging/arch/x86/include/asm/fpu/internal.h
@@ -537,6 +537,12 @@  static inline void __fpregs_load_activat
  *
  * The FPU context is only stored/restore for user task and ->mm is used to
  * distinguish between kernel and user threads.
+ *
+ * If TIF_NEED_FPU_LOAD is cleared then CPU's FPU registers are holding the
+ * current content of current()'s FPU register state.
+ * If TIF_NEED_FPU_LOAD is set then CPU's FPU registers may not hold current()'s
+ * FPU registers. It is required to load the register before returning to
+ * userland or using the content otherwise.
  */
 static inline void
 switch_fpu_prepare(struct fpu *old_fpu, int cpu)