Merge remote-tracking branch 'ftrace/for-next'
[deliverable/linux.git] / arch / x86 / include / asm / string_64.h
index 90dbbd9666d43cef657542251b4824d29c0fa7b9..a164862d77e3b4573e7a264c8712fac06ef7a830 100644 (file)
@@ -2,6 +2,7 @@
 #define _ASM_X86_STRING_64_H
 
 #ifdef __KERNEL__
+#include <linux/jump_label.h>
 
 /* Written 2002 by Andi Kleen */
 
@@ -78,6 +79,9 @@ int strcmp(const char *cs, const char *ct);
 #define memset(s, c, n) __memset(s, c, n)
 #endif
 
+__must_check int memcpy_mcsafe_unrolled(void *dst, const void *src, size_t cnt);
+DECLARE_STATIC_KEY_FALSE(mcsafe_key);
+
 /**
  * memcpy_mcsafe - copy memory with indication if a machine check happened
  *
@@ -86,10 +90,23 @@ int strcmp(const char *cs, const char *ct);
  * @cnt:       number of bytes to copy
  *
  * Low level memory copy function that catches machine checks
+ * We only call into the "safe" function on systems that can
+ * actually do machine check recovery. Everyone else can just
+ * use memcpy().
  *
  * Return 0 for success, -EFAULT for fail
  */
-int memcpy_mcsafe(void *dst, const void *src, size_t cnt);
+static __always_inline __must_check int
+memcpy_mcsafe(void *dst, const void *src, size_t cnt)
+{
+#ifdef CONFIG_X86_MCE
+       if (static_branch_unlikely(&mcsafe_key))
+               return memcpy_mcsafe_unrolled(dst, src, cnt);
+       else
+#endif
+               memcpy(dst, src, cnt);
+       return 0;
+}
 
 #endif /* __KERNEL__ */
 
This page took 0.033452 seconds and 5 git commands to generate.