arm64: mm: Set PSTATE.PAN from the cpu_enable_pan() call
Commit 338d4f49d6
("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>
This commit is contained in:
parent
2a6dcb2b5f
commit
7209c86860
|
@ -29,7 +29,9 @@
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/highmem.h>
|
#include <linux/highmem.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
|
#include <linux/preempt.h>
|
||||||
|
|
||||||
|
#include <asm/bug.h>
|
||||||
#include <asm/cpufeature.h>
|
#include <asm/cpufeature.h>
|
||||||
#include <asm/exception.h>
|
#include <asm/exception.h>
|
||||||
#include <asm/debug-monitors.h>
|
#include <asm/debug-monitors.h>
|
||||||
|
@ -672,7 +674,14 @@ NOKPROBE_SYMBOL(do_debug_exception);
|
||||||
#ifdef CONFIG_ARM64_PAN
|
#ifdef CONFIG_ARM64_PAN
|
||||||
int cpu_enable_pan(void *__unused)
|
int cpu_enable_pan(void *__unused)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* We modify PSTATE. This won't work from irq context as the PSTATE
|
||||||
|
* is discarded once we return from the exception.
|
||||||
|
*/
|
||||||
|
WARN_ON_ONCE(in_interrupt());
|
||||||
|
|
||||||
config_sctlr_el1(SCTLR_EL1_SPAN, 0);
|
config_sctlr_el1(SCTLR_EL1_SPAN, 0);
|
||||||
|
asm(SET_PSTATE_PAN(1));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_ARM64_PAN */
|
#endif /* CONFIG_ARM64_PAN */
|
||||||
|
|
Loading…
Reference in New Issue