Re: [PATCH v4 2/2] arm64: Don't read GMID_EL1 when MTE is disabled

From: Catalin Marinas

Date: Wed Aug 26 2026 - 09:57:10 EST


On Tue, Aug 25, 2026 at 05:42:19PM +0100, Fuad Tabba wrote:
> __cpuinfo_store_cpu() gates the GMID_EL1 read on the raw
> ID_AA64PFR1_EL1, so it reads the register even when the kernel has
> disabled MTE (CONFIG_ARM64_MTE=n or arm64.nomte). KVM sets HCR_EL2.TID5
> in that case, and pKVM injects an UNDEF the host cannot handle:
>
> Internal error: Oops - Undefined instruction: 0000000002000000 [#1] SMP
> pc : __cpuinfo_store_cpu+0xf4/0x264
> Kernel panic - not syncing: Attempted to kill the idle task!
>
> Only pKVM reaches it, and only after a CPU is offlined and brought back
> online: its CPU_ON relay sets the host HCR before the CPU enters EL1,
> while plain nVHE sets it at CPUHP_AP_KVM_ONLINE.
>
> Gate the read on __read_sysreg_by_encoding(), which applies the cmdline
> override, and on CONFIG_ARM64_MTE, which no register reflects.
>
> Fixes: f35abcbb8a084 ("KVM: arm64: Trap MTE access and discovery when MTE is disabled")
> Cc: stable@xxxxxxxxxxxxxxx # needs "arm64: Apply overrides to CPU local capabilities"
> Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>

Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>