arm64: uaccess: Add PAN helper
authorJames Morse <james.morse@arm.com>
Mon, 8 Jan 2018 15:38:11 +0000 (15:38 +0000)
committerCatalin Marinas <catalin.marinas@arm.com>
Sat, 13 Jan 2018 10:45:10 +0000 (10:45 +0000)
Add __uaccess_{en,dis}able_hw_pan() helpers to set/clear the PSTATE.PAN
bit.

Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/uaccess.h
arch/arm64/kernel/suspend.c

index 6eadf55ebaf042fac833638939e45818c25c3cd4..3821fab01d7d59085bc1d377e71aa268303baf76 100644 (file)
@@ -168,6 +168,18 @@ static inline bool uaccess_ttbr0_enable(void)
 }
 #endif
 
+static inline void __uaccess_disable_hw_pan(void)
+{
+       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN,
+                       CONFIG_ARM64_PAN));
+}
+
+static inline void __uaccess_enable_hw_pan(void)
+{
+       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
+                       CONFIG_ARM64_PAN));
+}
+
 #define __uaccess_disable(alt)                                         \
 do {                                                                   \
        if (!uaccess_ttbr0_disable())                                   \
index 3fe5ad884418698648812a63402ecb63a6a131b6..a307b9e1339293d57010619857c5e8f2e32fdbfc 100644 (file)
@@ -2,6 +2,7 @@
 #include <linux/ftrace.h>
 #include <linux/percpu.h>
 #include <linux/slab.h>
+#include <linux/uaccess.h>
 #include <asm/alternative.h>
 #include <asm/cacheflush.h>
 #include <asm/cpufeature.h>
@@ -51,8 +52,7 @@ void notrace __cpu_suspend_exit(void)
         * PSTATE was not saved over suspend/resume, re-enable any detected
         * features that might not have been set correctly.
         */
-       asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
-                       CONFIG_ARM64_PAN));
+       __uaccess_enable_hw_pan();
        uao_thread_switch(current);
 
        /*