lkml.org 
[lkml]   [2021]   [Jun]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch V2 15/52] x86/fpu: Use copy_uabi_xstate_to_membuf() in xfpregs_get()
Use the new functionality of copy_uabi_xstate_to_membuf() to retrieve the
FX state when XSAVE* is in use. This avoids to overwrite the FPU state
buffer with fpstate_sanitize_xstate() which is error prone and duplicated
code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
V2: New patch
---
arch/x86/kernel/fpu/regset.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

--- a/arch/x86/kernel/fpu/regset.c
+++ b/arch/x86/kernel/fpu/regset.c
@@ -33,13 +33,18 @@ int xfpregs_get(struct task_struct *targ
{
struct fpu *fpu = &target->thread.fpu;

- if (!boot_cpu_has(X86_FEATURE_FXSR))
+ if (!static_cpu_has(X86_FEATURE_FXSR))
return -ENODEV;

fpu__prepare_read(fpu);
- fpstate_sanitize_xstate(fpu);

- return membuf_write(&to, &fpu->state.fxsave, sizeof(struct fxregs_state));
+ if (!use_xsave()) {
+ return membuf_write(&to, &fpu->state.fxsave,
+ sizeof(fpu->state.fxsave));
+ }
+
+ copy_uabi_xstate_to_membuf(to, &fpu->state.xsave, XSTATE_COPY_FX);
+ return 0;
}

int xfpregs_set(struct task_struct *target, const struct user_regset *regset,
\
 
 \ /
  Last update: 2021-06-14 18:38    [W:0.342 / U:0.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site