[RFCv1 2/4] arm64: entry: Always apply workaround for contextidr_el1

From: Leo Yan
Date: Thu Oct 21 2021 - 09:45:51 EST


After introducing static key as the switch for tracing PID into
contextidr_el1, the kernel can dynamically turn on the static key to
use PID tracing to contextidr_el1. This means even the config
CONFIG_PID_IN_CONTEXTIDR is not selected, the kernel still can use
contextidr_el1.

When erratum 84571 is detected, the workaround should be always
applied on contextidr_el1, particularly if the static key is enabled
dynamically.

This patch would introduce minor overload by one extra instruction for
accessing system register contextidr_el1 and it only impacts platform
which erratum 84571. So it's expected to not cause any significant
regression.

Signed-off-by: Leo Yan <leo.yan@xxxxxxxxxx>
---
arch/arm64/kernel/entry.S | 4 ----
1 file changed, 4 deletions(-)

diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index bc6d5a970a13..c41a4cfff527 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -356,12 +356,8 @@ alternative_else_nop_endif

#ifdef CONFIG_ARM64_ERRATUM_845719
alternative_if ARM64_WORKAROUND_845719
-#ifdef CONFIG_PID_IN_CONTEXTIDR
mrs x29, contextidr_el1
msr contextidr_el1, x29
-#else
- msr contextidr_el1, xzr
-#endif
alternative_else_nop_endif
#endif
3:
--
2.25.1