]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors
authorMarc Zyngier <maz@kernel.org>
Sun, 12 Jan 2025 16:50:28 +0000 (16:50 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 14 Jan 2025 11:27:25 +0000 (11:27 +0000)
commitc139b6d1b4d27724987af5071177fb5f3d60c1e4
treec2e41529fb7f6c23863a6ee9b0824b7336311458
parent40384c840ea1944d7c5a392e8975ed088ecf0b37
KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors

A lot of the NV code depends on HCR_EL2.{E2H,TGE}, and we assume
in places that at least HCR_EL2.E2H is invariant for a given guest.

However, we make a point in *not* using the sanitising accessor
that would enforce this, and are at the mercy of the guest doing
stupid things. Clearly, that's not good.

Rework the HCR_EL2 accessors to use __vcpu_sys_reg() instead,
guaranteeing that the RESx settings get applied, specially
when HCR_EL2.E2H is evaluated. This results in fewer accessors
overall.

Huge thanks to Joey who spent a long time tracking this bug down.

Reported-by: Joey Gouly <Joey.Gouly@arm.com>
Tested-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Link: https://lore.kernel.org/r/20250112165029.1181056-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/hyp/vhe/sysreg-sr.c