]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - arch/x86/lib/copy_user_64.S
x86, smap: Add STAC and CLAC instructions to control user space access
[mirror_ubuntu-artful-kernel.git] / arch / x86 / lib / copy_user_64.S
index 5b2995f4557a8c6e8d38ba4461db8d5e34c983c6..a30ca15be21c8a182b3bb937ac612d1863a046ee 100644 (file)
@@ -17,6 +17,7 @@
 #include <asm/cpufeature.h>
 #include <asm/alternative-asm.h>
 #include <asm/asm.h>
+#include <asm/smap.h>
 
 /*
  * By placing feature2 after feature1 in altinstructions section, we logically
@@ -130,6 +131,7 @@ ENDPROC(bad_from_user)
  */
 ENTRY(copy_user_generic_unrolled)
        CFI_STARTPROC
+       ASM_STAC
        cmpl $8,%edx
        jb 20f          /* less then 8 bytes, go to byte copy loop */
        ALIGN_DESTINATION
@@ -177,6 +179,7 @@ ENTRY(copy_user_generic_unrolled)
        decl %ecx
        jnz 21b
 23:    xor %eax,%eax
+       ASM_CLAC
        ret
 
        .section .fixup,"ax"
@@ -232,6 +235,7 @@ ENDPROC(copy_user_generic_unrolled)
  */
 ENTRY(copy_user_generic_string)
        CFI_STARTPROC
+       ASM_STAC
        andl %edx,%edx
        jz 4f
        cmpl $8,%edx
@@ -246,6 +250,7 @@ ENTRY(copy_user_generic_string)
 3:     rep
        movsb
 4:     xorl %eax,%eax
+       ASM_CLAC
        ret
 
        .section .fixup,"ax"
@@ -273,12 +278,14 @@ ENDPROC(copy_user_generic_string)
  */
 ENTRY(copy_user_enhanced_fast_string)
        CFI_STARTPROC
+       ASM_STAC
        andl %edx,%edx
        jz 2f
        movl %edx,%ecx
 1:     rep
        movsb
 2:     xorl %eax,%eax
+       ASM_CLAC
        ret
 
        .section .fixup,"ax"