aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/lib
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2016-03-14 18:33:39 -0400
committerIngo Molnar <mingo@kernel.org>2016-03-16 04:02:18 -0400
commitcbf8b5a2b649a501758291cb4d4ba1e5711771ba (patch)
tree3d4f98e0dfff996531c295c8fbd95593f5f8ff1f /arch/x86/lib
parentba4e06d68ea4fd2be401d7226c68941892d6bbaf (diff)
x86/mm, x86/mce: Fix return type/value for memcpy_mcsafe()
Returning a 'bool' was very unpopular. Doubly so because the code was just wrong (returning zero for true, one for false; great for shell programming, not so good for C). Change return type to "int". Keep zero as the success indicator because it matches other similar code and people may be more comfortable writing: if (memcpy_mcsafe(to, from, count)) { printk("Sad panda, copy failed\n"); ... } Make the failure return value -EFAULT for now. Reported by: Mika Penttilä <mika.penttila@nextfour.com> Signed-off-by: Tony Luck <tony.luck@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: mika.penttila@nextfour.com Fixes: 92b0729c34ca ("x86/mm, x86/mce: Add memcpy_mcsafe()") Link: http://lkml.kernel.org/r/695f14233fa7a54fcac4406c706d7fec228e3f4c.1457993040.git.tony.luck@intel.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/lib')
-rw-r--r--arch/x86/lib/memcpy_64.S7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
index cbb8ee5830ff..2ec0b0abbfaa 100644
--- a/arch/x86/lib/memcpy_64.S
+++ b/arch/x86/lib/memcpy_64.S
@@ -1,6 +1,7 @@
1/* Copyright 2002 Andi Kleen */ 1/* Copyright 2002 Andi Kleen */
2 2
3#include <linux/linkage.h> 3#include <linux/linkage.h>
4#include <asm/errno.h>
4#include <asm/cpufeatures.h> 5#include <asm/cpufeatures.h>
5#include <asm/alternative-asm.h> 6#include <asm/alternative-asm.h>
6 7
@@ -268,16 +269,16 @@ ENTRY(memcpy_mcsafe)
268 decl %ecx 269 decl %ecx
269 jnz .L_copy_trailing_bytes 270 jnz .L_copy_trailing_bytes
270 271
271 /* Copy successful. Return true */ 272 /* Copy successful. Return zero */
272.L_done_memcpy_trap: 273.L_done_memcpy_trap:
273 xorq %rax, %rax 274 xorq %rax, %rax
274 ret 275 ret
275ENDPROC(memcpy_mcsafe) 276ENDPROC(memcpy_mcsafe)
276 277
277 .section .fixup, "ax" 278 .section .fixup, "ax"
278 /* Return false for any failure */ 279 /* Return -EFAULT for any failure */
279.L_memcpy_mcsafe_fail: 280.L_memcpy_mcsafe_fail:
280 mov $1, %rax 281 mov $-EFAULT, %rax
281 ret 282 ret
282 283
283 .previous 284 .previous