提交 a2a8fd9a 编写于 作者: T Thomas Gleixner 提交者: Borislav Petkov

x86/fpu/signal: Change return code of restore_fpregs_from_user() to boolean

__fpu_sig_restore() only needs information about success or fail and no
real error code.

This cleans up the confusing conversion of the trap number, which is
returned by the *RSTOR() exception fixups, to an error code.
Suggested-by: NAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210908132526.084109938@linutronix.de
上级 be004014
...@@ -254,8 +254,8 @@ static int __restore_fpregs_from_user(void __user *buf, u64 xrestore, ...@@ -254,8 +254,8 @@ static int __restore_fpregs_from_user(void __user *buf, u64 xrestore,
* Attempt to restore the FPU registers directly from user memory. * Attempt to restore the FPU registers directly from user memory.
* Pagefaults are handled and any errors returned are fatal. * Pagefaults are handled and any errors returned are fatal.
*/ */
static int restore_fpregs_from_user(void __user *buf, u64 xrestore, static bool restore_fpregs_from_user(void __user *buf, u64 xrestore,
bool fx_only, unsigned int size) bool fx_only, unsigned int size)
{ {
struct fpu *fpu = &current->thread.fpu; struct fpu *fpu = &current->thread.fpu;
int ret; int ret;
...@@ -284,12 +284,11 @@ static int restore_fpregs_from_user(void __user *buf, u64 xrestore, ...@@ -284,12 +284,11 @@ static int restore_fpregs_from_user(void __user *buf, u64 xrestore,
/* Try to handle #PF, but anything else is fatal. */ /* Try to handle #PF, but anything else is fatal. */
if (ret != X86_TRAP_PF) if (ret != X86_TRAP_PF)
return -EINVAL; return false;
ret = fault_in_pages_readable(buf, size); if (!fault_in_pages_readable(buf, size))
if (!ret)
goto retry; goto retry;
return ret; return false;
} }
/* /*
...@@ -306,7 +305,7 @@ static int restore_fpregs_from_user(void __user *buf, u64 xrestore, ...@@ -306,7 +305,7 @@ static int restore_fpregs_from_user(void __user *buf, u64 xrestore,
fpregs_mark_activate(); fpregs_mark_activate();
fpregs_unlock(); fpregs_unlock();
return 0; return true;
} }
static bool __fpu_restore_sig(void __user *buf, void __user *buf_fx, static bool __fpu_restore_sig(void __user *buf, void __user *buf_fx,
...@@ -341,8 +340,8 @@ static bool __fpu_restore_sig(void __user *buf, void __user *buf_fx, ...@@ -341,8 +340,8 @@ static bool __fpu_restore_sig(void __user *buf, void __user *buf_fx,
* faults. If it does, fall back to the slow path below, going * faults. If it does, fall back to the slow path below, going
* through the kernel buffer with the enabled pagefault handler. * through the kernel buffer with the enabled pagefault handler.
*/ */
return !restore_fpregs_from_user(buf_fx, user_xfeatures, fx_only, return restore_fpregs_from_user(buf_fx, user_xfeatures, fx_only,
state_size); state_size);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册