]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Return early from read_id_reg() if register is RAZ
authorAlexandru Elisei <alexandru.elisei@arm.com>
Mon, 11 Oct 2021 10:58:38 +0000 (11:58 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 11 Oct 2021 13:13:58 +0000 (14:13 +0100)
commit1c990003f92789c03f6dffd0b45862cf93425a40
treea384c14debab6892e1ab0ae5fd4261e01dec223c
parent87a799989d15ec119f470890374f7bd919def84c
KVM: arm64: Return early from read_id_reg() if register is RAZ

If read_id_reg() is called for an ID register which is Read-As-Zero (RAZ),
it initializes the return value to zero, then goes through a list of
registers which require special handling before returning the final value.

By not returning as soon as it checks that the register should be RAZ, the
function creates the opportunity for bugs, if, for example, a patch changes
a register to RAZ (like has happened with PMSWINC_EL0 in commit
07258a07d77a), but doesn't remove the special handling from read_id_reg();
or if a register is RAZ in certain situations, but readable in others.

Return early to make it impossible for a RAZ register to be anything other
than zero.

Reviewed-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20211011105840.155815-2-alexandru.elisei@arm.com
arch/arm64/kvm/sys_regs.c