Commit b672534f authored by Evgenii Stepanov's avatar Evgenii Stepanov Committed by Treehugger Robot
Browse files

BACKPORT: arm64: mte: move register initialization to C



If FEAT_MTE2 is disabled via the arm64.nomte command line argument on a
CPU that claims to support FEAT_MTE2, the kernel will use Tagged Normal
in the MAIR. If we interpret arm64.nomte to mean that the CPU does not
in fact implement FEAT_MTE2, setting the system register like this may
lead to UNSPECIFIED behavior. Fix it by arranging for MAIR to be set
in the C function cpu_enable_mte which is called based on the sanitized
version of the system register.

There is no need for the rest of the MTE-related system register
initialization to happen from assembly, with the exception of TCR_EL1,
which must be set to include at least TBI1 because the secondary CPUs
access KASan-allocated data structures early. Therefore, make the TCR_EL1
initialization unconditional and move the rest of the initialization to
cpu_enable_mte so that we no longer have a dependency on the unsanitized
ID register value.

Signed-off-by: default avatarPeter Collingbourne <pcc@google.com>
Signed-off-by: default avatarEvgenii Stepanov <eugenis@google.com>
Signed-off-by: default avatarQun-Wei Lin <qun-wei.lin@mediatek.corp-partner.google.com>
Suggested-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Reported-by: default avatarkernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/linux-arm-kernel/20220907003630.1115439-1-eugenis@google.com/
Bug: 239834217
Change-Id: I7bd247ae5802295c198bac42df86fab9e9e9cefd
(cherry picked from commit 6a2905d3)
parent b00ff95c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment