KVM: arm64: Don't write to Rt unless sys_reg emulation succeeds
authorOliver Upton <oupton@google.com>
Tue, 3 May 2022 06:02:00 +0000 (06:02 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 3 May 2022 10:14:33 +0000 (11:14 +0100)
commit28eda7b5e82489b9dcffc630af68c207552b4f4d
treee2b478c1412aa41a0149a68f6602f5303b2aedee
parent001bb819994cd1bd037b6aefdb233f1720ee2126
KVM: arm64: Don't write to Rt unless sys_reg emulation succeeds

emulate_sys_reg() returns 1 unconditionally, even though a a system
register access can fail. Furthermore, kvm_handle_sys_reg() writes to Rt
for every register read, regardless of if it actually succeeded.

Though this pattern is safe (as params.regval is initialized with the
current value of Rt) it is a bit ugly. Indicate failure if the register
access could not be emulated and only write to Rt on success.

Signed-off-by: Oliver Upton <oupton@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20220503060205.2823727-3-oupton@google.com
arch/arm64/kvm/sys_regs.c