Commit 8c0817f4 authored by Ingo Molnar's avatar Ingo Molnar

x86/fpu: Simplify __copy_xstate_to_kernel() return values

__copy_xstate_to_kernel() can only return 0 (because kernel copies cannot fail),
simplify the code throughout.

No change in functionality.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Eric Biggers <ebiggers3@gmail.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yu-cheng Yu <yu-cheng.yu@intel.com>
Link: http://lkml.kernel.org/r/20170923130016.21448-11-mingo@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 6ff15f8d
...@@ -924,7 +924,7 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey, ...@@ -924,7 +924,7 @@ int arch_set_user_pkey_access(struct task_struct *tsk, int pkey,
* This is similar to user_regset_copyout(), but will not add offset to * This is similar to user_regset_copyout(), but will not add offset to
* the source data pointer or increment pos, count, kbuf, and ubuf. * the source data pointer or increment pos, count, kbuf, and ubuf.
*/ */
static inline int static inline void
__copy_xstate_to_kernel(void *kbuf, const void *data, __copy_xstate_to_kernel(void *kbuf, const void *data,
unsigned int offset, unsigned int size, unsigned int size_total) unsigned int offset, unsigned int size, unsigned int size_total)
{ {
...@@ -933,7 +933,6 @@ __copy_xstate_to_kernel(void *kbuf, const void *data, ...@@ -933,7 +933,6 @@ __copy_xstate_to_kernel(void *kbuf, const void *data,
memcpy(kbuf + offset, data, copy); memcpy(kbuf + offset, data, copy);
} }
return 0;
} }
/* /*
...@@ -946,8 +945,8 @@ __copy_xstate_to_kernel(void *kbuf, const void *data, ...@@ -946,8 +945,8 @@ __copy_xstate_to_kernel(void *kbuf, const void *data,
int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset_start, unsigned int size_total) int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int offset_start, unsigned int size_total)
{ {
unsigned int offset, size; unsigned int offset, size;
int ret, i;
struct xstate_header header; struct xstate_header header;
int i;
/* /*
* Currently copy_regset_to_user() starts from pos 0: * Currently copy_regset_to_user() starts from pos 0:
...@@ -968,9 +967,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of ...@@ -968,9 +967,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of
offset = offsetof(struct xregs_state, header); offset = offsetof(struct xregs_state, header);
size = sizeof(header); size = sizeof(header);
ret = __copy_xstate_to_kernel(kbuf, &header, offset, size, size_total); __copy_xstate_to_kernel(kbuf, &header, offset, size, size_total);
if (ret)
return ret;
for (i = 0; i < XFEATURE_MAX; i++) { for (i = 0; i < XFEATURE_MAX; i++) {
/* /*
...@@ -986,9 +983,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of ...@@ -986,9 +983,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of
if (offset + size > size_total) if (offset + size > size_total)
break; break;
ret = __copy_xstate_to_kernel(kbuf, src, offset, size, size_total); __copy_xstate_to_kernel(kbuf, src, offset, size, size_total);
if (ret)
return ret;
} }
} }
...@@ -999,9 +994,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of ...@@ -999,9 +994,7 @@ int copy_xstate_to_kernel(void *kbuf, struct xregs_state *xsave, unsigned int of
offset = offsetof(struct fxregs_state, sw_reserved); offset = offsetof(struct fxregs_state, sw_reserved);
size = sizeof(xstate_fx_sw_bytes); size = sizeof(xstate_fx_sw_bytes);
ret = __copy_xstate_to_kernel(kbuf, xstate_fx_sw_bytes, offset, size, size_total); __copy_xstate_to_kernel(kbuf, xstate_fx_sw_bytes, offset, size, size_total);
if (ret)
return ret;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment