[PATCH] KVM: arm64: Handle trapped reads of SCTLR2_EL2
Mark Brown
broonie at kernel.org
Sat Nov 28 13:33:52 PST 2026
A read of SCTLR2_EL2 from virtual EL2 can trap to the hypervisor for
local emulation. The descriptor for it uses access_vm_reg(), which
is intended to handle writes trapped by HCR_EL2.TVM and calls BUG_ON()
for a read.
Use access_rw() for SCTLR2_EL2, as is done for SCTLR_EL2, which provides
a straightforward read path. For the write path this drops the use of
kvm_toggle_cache() which checks if cache flushes or disabling of
HCR_EL2.TVM are required. The cache state is not managed in SCTLR2_EL2
so a write to it cannot trigger a flush. If the caches were already on
we would delay disabling HCR_EL2.TVM. Since SCTLR2_EL2 should only be
present on systems with FEAT_S2FWB this should not occur, but in any
case it would be a performance rather than correctness issue.
Fixes: 81fbef164766 ("KVM: arm64: Wire up SCTLR2_ELx sysreg descriptors")
Signed-off-by: Mark Brown <broonie at kernel.org>
Cc: stable at vger.kernel.org
---
arch/arm64/kvm/sys_regs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c
index c7d91138a6d4..6bc0bccfcda4 100644
--- a/arch/arm64/kvm/sys_regs.c
+++ b/arch/arm64/kvm/sys_regs.c
@@ -3833,7 +3833,7 @@ static const struct sys_reg_desc sys_reg_descs[] = {
EL2_REG_VNCR(VMPIDR_EL2, reset_unknown, 0),
EL2_REG(SCTLR_EL2, access_rw, reset_val, SCTLR_EL2_RES1),
EL2_REG(ACTLR_EL2, access_rw, reset_val, 0),
- EL2_REG_FILTERED(SCTLR2_EL2, access_vm_reg, reset_val, 0,
+ EL2_REG_FILTERED(SCTLR2_EL2, access_rw, reset_val, 0,
sctlr2_el2_visibility),
EL2_REG_VNCR(HCR_EL2, reset_hcr, 0),
EL2_REG(MDCR_EL2, access_mdcr, reset_mdcr, 0),
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm master
change-id: 20261127-kvm-arm64-sctlr2-read-6e515f611614
Best regards,
--
Mark Brown <broonie at kernel.org>
More information about the linux-arm-kernel
mailing list