Skip to content

arm64: Clamp ID overrides and gate the GMID_EL1 read

Fuad Tabba kvmarm linux-arm-kernel lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest2 patches 7 repliesIn review

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2arm64: Apply overrides to CPU local capabilitiesarch/arm64/kernel/cpufeature.c+34 -82 replies
2/2arm64: Don't read GMID_EL1 when MTE is disabledarch/arm64/include/asm/cpufeature.h arch/arm64/kernel/cpufeature.c arch/arm64/kernel/cpuinfo.c+12 -55 replies

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchCatalin Marinas
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/2] arm64: Clamp ID overrides and gate the GMID_EL1 read

Hi folks,

Changes since v3 [1]:
- Gate on __read_sysreg_by_encoding() and drop the helper's argument, so the command-line override is not open-coded in the header. (Catalin)
- Pick up Suzuki's override clamp as patch 1, rather than adding a raw-presence check to the gate. (Will)

Patch 2 fixes a GMID_EL1 read that traps to EL2 when the kernel has disabled MTE, panicking the host under pKVM on a CPU that is offlined and brought back online. It gates the read on __read_sysreg_by_encoding().

That needs patch 1, Suzuki's override clamp [2]. Without it __read_sysreg_by_encoding() applies the command-line override raw, so id_aa64pfr1.mte=2 on a CPU without FEAT_MTE2 makes the gate true and the kernel reads a GMID_EL1 that is not there. On the boot CPU that read comes before init_cpu_ftr_reg() strips the unsafe override, so the gate cannot rely on it.

Tested on QEMU under pKVM. With -machine virt,mte=on, offlining and onlining CPU1 with arm64.nomte panics an unpatched v7.2 in __cpuinfo_store_cpu() and does not with the series. Without tag memory, where QEMU implements no GMID_EL1, id_aa64pfr1.mte=2 covers the force-up case.

Based on Linux 7.2 (8d3ae59288f1e).

Cheers,
/fuad

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Fuad Tabba (1):
arm64: Don't read GMID_EL1 when MTE is disabled

Suzuki K Poulose (1):
arm64: Apply overrides to CPU local capabilities

 arch/arm64/include/asm/cpufeature.h |  9 ++++++
 arch/arm64/kernel/cpufeature.c      | 48 +++++++++++++++++++++--------
 arch/arm64/kernel/cpuinfo.c         |  2 +-
 3 files changed, 46 insertions(+), 13 deletions(-)
Signature · 1 line
2.39.5