diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2018-01-19 10:42:09 -0500 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2018-01-23 10:40:29 -0500 |
commit | a8e4c0a919ae310944ed2c9ace11cf3ccd8a609b (patch) | |
tree | 018cd8a8a9d560355830d94407d33d96355bb5d9 | |
parent | e9eaa8052fe71b95f4fea6072fa3e0b2cf0b620f (diff) |
arm64: Move BP hardening to check_and_switch_context
We call arm64_apply_bp_hardening() from post_ttbr_update_workaround,
which has the unexpected consequence of being triggered on every
exception return to userspace when ARM64_SW_TTBR0_PAN is selected,
even if no context switch actually occured.
This is a bit suboptimal, and it would be more logical to only
invalidate the branch predictor when we actually switch to
a different mm.
In order to solve this, move the call to arm64_apply_bp_hardening()
into check_and_switch_context(), where we're guaranteed to pick
a different mm context.
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r-- | arch/arm64/mm/context.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index ff99a880a730..301417ae2ba8 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c | |||
@@ -234,6 +234,9 @@ void check_and_switch_context(struct mm_struct *mm, unsigned int cpu) | |||
234 | raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); | 234 | raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); |
235 | 235 | ||
236 | switch_mm_fastpath: | 236 | switch_mm_fastpath: |
237 | |||
238 | arm64_apply_bp_hardening(); | ||
239 | |||
237 | /* | 240 | /* |
238 | * Defer TTBR0_EL1 setting for user threads to uaccess_enable() when | 241 | * Defer TTBR0_EL1 setting for user threads to uaccess_enable() when |
239 | * emulating PAN. | 242 | * emulating PAN. |
@@ -249,8 +252,6 @@ asmlinkage void post_ttbr_update_workaround(void) | |||
249 | "ic iallu; dsb nsh; isb", | 252 | "ic iallu; dsb nsh; isb", |
250 | ARM64_WORKAROUND_CAVIUM_27456, | 253 | ARM64_WORKAROUND_CAVIUM_27456, |
251 | CONFIG_CAVIUM_ERRATUM_27456)); | 254 | CONFIG_CAVIUM_ERRATUM_27456)); |
252 | |||
253 | arm64_apply_bp_hardening(); | ||
254 | } | 255 | } |
255 | 256 | ||
256 | static int asids_init(void) | 257 | static int asids_init(void) |