Commit e1281f56 authored by James Morse's avatar James Morse Committed by Catalin Marinas

arm64: uaccess: Add PAN helper

Add __uaccess_{en,dis}able_hw_pan() helpers to set/clear the PSTATE.PAN
bit.
Signed-off-by: default avatarJames Morse <james.morse@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent ed8b20d4
...@@ -168,6 +168,18 @@ static inline bool uaccess_ttbr0_enable(void) ...@@ -168,6 +168,18 @@ static inline bool uaccess_ttbr0_enable(void)
} }
#endif #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) \ #define __uaccess_disable(alt) \
do { \ do { \
if (!uaccess_ttbr0_disable()) \ if (!uaccess_ttbr0_disable()) \
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/ftrace.h> #include <linux/ftrace.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/uaccess.h>
#include <asm/alternative.h> #include <asm/alternative.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/cpufeature.h> #include <asm/cpufeature.h>
...@@ -51,8 +52,7 @@ void notrace __cpu_suspend_exit(void) ...@@ -51,8 +52,7 @@ void notrace __cpu_suspend_exit(void)
* PSTATE was not saved over suspend/resume, re-enable any detected * PSTATE was not saved over suspend/resume, re-enable any detected
* features that might not have been set correctly. * features that might not have been set correctly.
*/ */
asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN, __uaccess_enable_hw_pan();
CONFIG_ARM64_PAN));
uao_thread_switch(current); uao_thread_switch(current);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment