KVM: arm64: Only sign-extend MMIO up to register width
authorChristoffer Dall <christoffer.dall@arm.com>
Thu, 12 Dec 2019 19:50:55 +0000 (20:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Feb 2020 12:33:58 +0000 (04:33 -0800)
commitce94e646aa5275a7e41f46967fd0262aa7059a38
tree33b8dd0aaf30cd0fda418d53aef2630f7c4d433e
parentc1ed7347130c000552394fb53b5227d9a487df36
KVM: arm64: Only sign-extend MMIO up to register width

commit b6ae256afd32f96bec0117175b329d0dd617655e upstream.

On AArch64 you can do a sign-extended load to either a 32-bit or 64-bit
register, and we should only sign extend the register up to the width of
the register as specified in the operation (by using the 32-bit Wn or
64-bit Xn register specifier).

As it turns out, the architecture provides this decoding information in
the SF ("Sixty-Four" -- how cute...) bit.

Let's take advantage of this with the usual 32-bit/64-bit header file
dance and do the right thing on AArch64 hosts.

Signed-off-by: Christoffer Dall <christoffer.dall@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20191212195055.5541-1-christoffer.dall@arm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm/include/asm/kvm_emulate.h
arch/arm/include/asm/kvm_mmio.h
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/include/asm/kvm_mmio.h
virt/kvm/arm/mmio.c