Skip to content

Commit e1281f5

Browse files
James Morsectmarinas
authored andcommitted
arm64: uaccess: Add PAN helper
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>
1 parent ed8b20d commit e1281f5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎arch/arm64/include/asm/uaccess.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ static inline bool uaccess_ttbr0_enable(void)
168168
}
169169
#endif
170170

171+
static inline void __uaccess_disable_hw_pan(void)
172+
{
173+
asm(ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN,
174+
CONFIG_ARM64_PAN));
175+
}
176+
177+
static inline void __uaccess_enable_hw_pan(void)
178+
{
179+
asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
180+
CONFIG_ARM64_PAN));
181+
}
182+
171183
#define __uaccess_disable(alt) \
172184
do { \
173185
if (!uaccess_ttbr0_disable()) \

‎arch/arm64/kernel/suspend.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/ftrace.h>
33
#include <linux/percpu.h>
44
#include <linux/slab.h>
5+
#include <linux/uaccess.h>
56
#include <asm/alternative.h>
67
#include <asm/cacheflush.h>
78
#include <asm/cpufeature.h>
@@ -51,8 +52,7 @@ void notrace __cpu_suspend_exit(void)
5152
* PSTATE was not saved over suspend/resume, re-enable any detected
5253
* features that might not have been set correctly.
5354
*/
54-
asm(ALTERNATIVE("nop", SET_PSTATE_PAN(1), ARM64_HAS_PAN,
55-
CONFIG_ARM64_PAN));
55+
__uaccess_enable_hw_pan();
5656
uao_thread_switch(current);
5757

5858
/*

0 commit comments

Comments
 (0)