]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
KVM: arm64: Survive synchronous exceptions caused by AT instructions
authorJames Morse <james.morse@arm.com>
Fri, 21 Aug 2020 14:07:06 +0000 (15:07 +0100)
committerKelsey Skunberg <kelsey.skunberg@canonical.com>
Thu, 17 Sep 2020 06:47:01 +0000 (00:47 -0600)
commitb1ed46a6dee67b06d09c88d0294a41c495d45ac8
treeed2daaf9cbe35d253fcaee8e3e92fd25a49c6499
parent562415875ee83ee8691a92216124a70da5a0ec09
KVM: arm64: Survive synchronous exceptions caused by AT instructions

BugLink: https://bugs.launchpad.net/bugs/1895879
commit 88a84ccccb3966bcc3f309cdb76092a9892c0260 upstream.

KVM doesn't expect any synchronous exceptions when executing, any such
exception leads to a panic(). AT instructions access the guest page
tables, and can cause a synchronous external abort to be taken.

The arm-arm is unclear on what should happen if the guest has configured
the hardware update of the access-flag, and a memory type in TCR_EL1 that
does not support atomic operations. B2.2.6 "Possible implementation
restrictions on using atomic instructions" from DDI0487F.a lists
synchronous external abort as a possible behaviour of atomic instructions
that target memory that isn't writeback cacheable, but the page table
walker may behave differently.

Make KVM robust to synchronous exceptions caused by AT instructions.
Add a get_user() style helper for AT instructions that returns -EFAULT
if an exception was generated.

While KVM's version of the exception table mixes synchronous and
asynchronous exceptions, only one of these can occur at each location.

Re-enter the guest when the AT instructions take an exception on the
assumption the guest will take the same exception. This isn't guaranteed
to make forward progress, as the AT instructions may always walk the page
tables, but guest execution may use the translation cached in the TLB.

This isn't a problem, as since commit 5dcd0fdbb492 ("KVM: arm64: Defer guest
entry when an asynchronous exception is pending"), KVM will return to the
host to process IRQs allowing the rest of the system to keep running.

Cc: stable@vger.kernel.org # <v5.3: 5dcd0fdbb492 ("KVM: arm64: Defer guest entry when an asynchronous exception is pending")
Signed-off-by: James Morse <james.morse@arm.com>
Reviewed-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: William Breathitt Gray <william.gray@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
arch/arm64/include/asm/kvm_asm.h
arch/arm64/kvm/hyp/hyp-entry.S
arch/arm64/kvm/hyp/switch.c