]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Fix 32bit PC wrap-around
authorMarc Zyngier <maz@kernel.org>
Wed, 29 Apr 2020 10:21:55 +0000 (11:21 +0100)
committerMarc Zyngier <maz@kernel.org>
Fri, 1 May 2020 08:51:08 +0000 (09:51 +0100)
commitf2ab2b1e1e7442c798f10bdc6ac3d8cb3ec096e8
tree8b5e04a3ff18733f18b68a7157e1884ab9eec0b9
parent20ee664c399168f7d395ba86b86ac9bc14cf3fef
KVM: arm64: Fix 32bit PC wrap-around

In the unlikely event that a 32bit vcpu traps into the hypervisor
on an instruction that is located right at the end of the 32bit
range, the emulation of that instruction is going to increment
PC past the 32bit range. This isn't great, as userspace can then
observe this value and get a bit confused.

Conversly, userspace can do things like (in the context of a 64bit
guest that is capable of 32bit EL0) setting PSTATE to AArch64-EL0,
set PC to a 64bit value, change PSTATE to AArch32-USR, and observe
that PC hasn't been truncated. More confusion.

Fix both by:
- truncating PC increments for 32bit guests
- sanitizing all 32bit regs every time a core reg is changed by
  userspace, and that PSTATE indicates a 32bit mode.

Cc: stable@vger.kernel.org
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/guest.c
virt/kvm/arm/hyp/aarch32.c