aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Morse <james.morse@arm.com>2016-10-18 06:27:47 -0400
committerWill Deacon <will.deacon@arm.com>2016-10-20 04:50:53 -0400
commit7209c868600bd8926e37c10b9aae83124ccc1dd8 (patch)
tree39995a8ef78a77bd77b9897da57c5b81aeba27f4
parent2a6dcb2b5f3e21592ca8dfa198dcce7bec09b020 (diff)
arm64: mm: Set PSTATE.PAN from the cpu_enable_pan() call
Commit 338d4f49d6f7 ("arm64: kernel: Add support for Privileged Access Never") enabled PAN by enabling the 'SPAN' feature-bit in SCTLR_EL1. This means the PSTATE.PAN bit won't be set until the next return to the kernel from userspace. On a preemptible kernel we may schedule work that accesses userspace on a CPU before it has done this. Now that cpufeature enable() calls are scheduled via stop_machine(), we can set PSTATE.PAN from the cpu_enable_pan() call. Add WARN_ON_ONCE(in_interrupt()) to check the PSTATE value we updated is not immediately discarded. Reported-by: Tony Thompson <anthony.thompson@arm.com> Reported-by: Vladimir Murzin <vladimir.murzin@arm.com> Signed-off-by: James Morse <james.morse@arm.com> [will: fixed typo in comment] Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/mm/fault.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 3e9ff9b0c78d..0f8788374815 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -29,7 +29,9 @@
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/perf_event.h> 31#include <linux/perf_event.h>
32#include <linux/preempt.h>
32 33
34#include <asm/bug.h>
33#include <asm/cpufeature.h> 35#include <asm/cpufeature.h>
34#include <asm/exception.h> 36#include <asm/exception.h>
35#include <asm/debug-monitors.h> 37#include <asm/debug-monitors.h>
@@ -672,7 +674,14 @@ NOKPROBE_SYMBOL(do_debug_exception);
672#ifdef CONFIG_ARM64_PAN 674#ifdef CONFIG_ARM64_PAN
673int cpu_enable_pan(void *__unused) 675int cpu_enable_pan(void *__unused)
674{ 676{
677 /*
678 * We modify PSTATE. This won't work from irq context as the PSTATE
679 * is discarded once we return from the exception.
680 */
681 WARN_ON_ONCE(in_interrupt());
682
675 config_sctlr_el1(SCTLR_EL1_SPAN, 0); 683 config_sctlr_el1(SCTLR_EL1_SPAN, 0);
684 asm(SET_PSTATE_PAN(1));
676 return 0; 685 return 0;
677} 686}
678#endif /* CONFIG_ARM64_PAN */ 687#endif /* CONFIG_ARM64_PAN */