aboutsummaryrefslogtreecommitdiff
path: root/arch/arm64/mm/fault.c
diff options
context:
space:
mode:
authorKevin Hilman <khilman@linaro.org>2015-12-10 17:09:33 -0800
committerKevin Hilman <khilman@linaro.org>2015-12-10 17:09:33 -0800
commit9f41e6b222c4a04c7b46068df82842a6188b4a57 (patch)
tree66c636a716a29ce087d781744ab1710232f21764 /arch/arm64/mm/fault.c
parent8eec3ec7b6576a80fbeda89beed8f9f667f9dc7b (diff)
parentf45972d0017cff35d576e10f1e276f9f3991bea6 (diff)
Merge branch 'v4.1/topic/PAN' into linux-linaro-lsk-v4.1lsk-v4.1-15.12
* v4.1/topic/PAN: arm64: kernel: Add support for Privileged Access Never arm64: kernel: Add optional CONFIG_ parameter to ALTERNATIVE() arm64: alternative: Provide if/else/endif assembler macros arm64: alternative: Work around .inst assembler bugs arm64: alternative: Merge alternative-asm.h into alternative.h arm64: Generalise msr_s/mrs_s operations arm64: kernel: Add min_field_value and use '>=' for feature detection arm64: kernel: Add cpufeature 'enable' callback arm64: kernel: Add cpuid_feature_extract_field() for 4bit sign extension arm64: kernel: Move config_sctlr_el1 arm64: lib: use pair accessors for copy_*_user routines arm64: alternative: Introduce feature for GICv3 CPU interface
Diffstat (limited to 'arch/arm64/mm/fault.c')
-rw-r--r--arch/arm64/mm/fault.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index fa5efaa5c3ac..10a1fc5004dc 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -30,9 +30,11 @@
#include <linux/highmem.h>
#include <linux/perf_event.h>
+#include <asm/cpufeature.h>
#include <asm/exception.h>
#include <asm/debug-monitors.h>
#include <asm/esr.h>
+#include <asm/sysreg.h>
#include <asm/system_misc.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
@@ -225,6 +227,13 @@ static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
}
/*
+ * PAN bit set implies the fault happened in kernel space, but not
+ * in the arch's user access functions.
+ */
+ if (IS_ENABLED(CONFIG_ARM64_PAN) && (regs->pstate & PSR_PAN_BIT))
+ goto no_context;
+
+ /*
* As per x86, we may deadlock here. However, since the kernel only
* validly references user space from well defined areas of the code,
* we can bug out early if this is from code which shouldn't.
@@ -531,3 +540,10 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
return 0;
}
+
+#ifdef CONFIG_ARM64_PAN
+void cpu_enable_pan(void)
+{
+ config_sctlr_el1(SCTLR_EL1_SPAN, 0);
+}
+#endif /* CONFIG_ARM64_PAN */