arm64: Move BP hardening to check_and_switch_context
authorMarc Zyngier <marc.zyngier@arm.com>
Fri, 19 Jan 2018 15:42:09 +0000 (15:42 +0000)
committerHaibo Chen <haibo.chen@nxp.com>
Thu, 12 Apr 2018 10:46:26 +0000 (18:46 +0800)
commit2c52931bd1396bb5eb7e7047a391b700ffaa9175
tree3ac0835a12964722fdb665763957b5cb996515a4
parent5a007a361f8a17123aa16d508879fadff7cc2175
arm64: Move BP hardening to check_and_switch_context

commit a8e4c0a919ae upstream.

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>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Conflicts:
no sw pan in arch/arm64/mm/context.c
arch/arm64/mm/context.c