]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - arch/arm64/lib/copy_from_user.S
Merge tag 'nios2-v4.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/lftan...
[karo-tx-linux.git] / arch / arm64 / lib / copy_from_user.S
index 5e27add9d3624e653cab6cf9e583586112d14e02..1be9ef27be9704b2ae99bade58d36356a894e78b 100644 (file)
  */
 
 #include <linux/linkage.h>
+
+#include <asm/alternative.h>
 #include <asm/assembler.h>
+#include <asm/cpufeature.h>
+#include <asm/sysreg.h>
 
 /*
  * Copy from user space to a kernel buffer (alignment handled by the hardware)
  *     x0 - bytes not copied
  */
 ENTRY(__copy_from_user)
-       add     x4, x1, x2                      // upper user buffer boundary
-       subs    x2, x2, #8
+ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(0)), ARM64_HAS_PAN, \
+           CONFIG_ARM64_PAN)
+       add     x5, x1, x2                      // upper user buffer boundary
+       subs    x2, x2, #16
+       b.mi    1f
+0:
+USER(9f, ldp   x3, x4, [x1], #16)
+       subs    x2, x2, #16
+       stp     x3, x4, [x0], #16
+       b.pl    0b
+1:     adds    x2, x2, #8
        b.mi    2f
-1:
 USER(9f, ldr   x3, [x1], #8    )
-       subs    x2, x2, #8
+       sub     x2, x2, #8
        str     x3, [x0], #8
-       b.pl    1b
 2:     adds    x2, x2, #4
        b.mi    3f
 USER(9f, ldr   w3, [x1], #4    )
@@ -51,12 +62,14 @@ USER(9f, ldrh       w3, [x1], #2    )
 USER(9f, ldrb  w3, [x1]        )
        strb    w3, [x0]
 5:     mov     x0, #0
+ALTERNATIVE("nop", __stringify(SET_PSTATE_PAN(1)), ARM64_HAS_PAN, \
+           CONFIG_ARM64_PAN)
        ret
 ENDPROC(__copy_from_user)
 
        .section .fixup,"ax"
        .align  2
-9:     sub     x2, x4, x1
+9:     sub     x2, x5, x1
        mov     x3, x2
 10:    strb    wzr, [x0], #1                   // zero remaining buffer space
        subs    x3, x3, #1