ARM: uaccess: integrate uaccess_save and uaccess_restore
authorRussell King <rmk+kernel@armlinux.org.uk>
Sun, 3 May 2020 12:14:09 +0000 (13:14 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Sun, 3 May 2020 16:30:26 +0000 (17:30 +0100)
Integrate uaccess_save / uaccess_restore macros into the new
uaccess_entry / uaccess_exit macros respectively.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/include/asm/uaccess-asm.h

index d475e3e8145d4fe6d5924388e3a62b81ed3c6024..e46468b91eaaae5c25921a47b4ca7e58bde527bc 100644 (file)
 #endif
        .endm
 
-       .macro  uaccess_save, tmp
 #ifdef CONFIG_CPU_SW_DOMAIN_PAN
-       mrc     p15, 0, \tmp, c3, c0, 0
-       str     \tmp, [sp, #SVC_DACR]
-#endif
-       .endm
-
-       .macro  uaccess_restore
-#ifdef CONFIG_CPU_SW_DOMAIN_PAN
-       ldr     r0, [sp, #SVC_DACR]
-       mcr     p15, 0, r0, c3, c0, 0
+#define DACR(x...)     x
+#else
+#define DACR(x...)
 #endif
-       .endm
 
        /*
         * Save the address limit on entry to a privileged exception and
         * if using PAN, save and disable usermode access.
         */
        .macro  uaccess_entry, tsk, tmp0, tmp1, tmp2, disable
-       ldr     \tmp0, [\tsk, #TI_ADDR_LIMIT]
-       mov     \tmp1, #TASK_SIZE
-       str     \tmp1, [\tsk, #TI_ADDR_LIMIT]
-       str     \tmp0, [sp, #SVC_ADDR_LIMIT]
-       uaccess_save \tmp0
+       ldr     \tmp1, [\tsk, #TI_ADDR_LIMIT]
+       mov     \tmp2, #TASK_SIZE
+       str     \tmp2, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mrc     p15, 0, \tmp0, c3, c0, 0)
+ DACR( str     \tmp0, [sp, #SVC_DACR])
+       str     \tmp1, [sp, #SVC_ADDR_LIMIT]
        .if \disable
        uaccess_disable \tmp0
        .endif
        /* Restore the user access state previously saved by uaccess_entry */
        .macro  uaccess_exit, tsk, tmp0, tmp1
        ldr     \tmp1, [sp, #SVC_ADDR_LIMIT]
-       uaccess_restore
+ DACR( ldr     \tmp0, [sp, #SVC_DACR])
        str     \tmp1, [\tsk, #TI_ADDR_LIMIT]
+ DACR( mcr     p15, 0, \tmp0, c3, c0, 0)
        .endm
 
+#undef DACR
+
 #endif /* __ASM_UACCESS_ASM_H__ */