This is a note to let you know that I've just added the patch titled KVM: arm64: Set HCR_EL2.PTW to prevent AT taking synchronous exception to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: kvm-arm64-set-hcr_el2.ptw-to-prevent-at-taking-synchronous-exception.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Tue Sep 8 03:13:37 PM CEST 2020 From: Andre Przywara <andre.przywara@xxxxxxx> Date: Wed, 2 Sep 2020 11:08:21 +0100 Subject: KVM: arm64: Set HCR_EL2.PTW to prevent AT taking synchronous exception To: stable@xxxxxxxxxxxxxxx Cc: James Morse <james.morse@xxxxxxx>, Marc Zyngier <maz@xxxxxxxxxx>, Catalin Marinas <catalin.marinas@xxxxxxx> Message-ID: <20200902100821.149574-5-andre.przywara@xxxxxxx> From: James Morse <james.morse@xxxxxxx> commit 71a7f8cb1ca4ca7214a700b1243626759b6c11d4 upstream. AT instructions do a translation table walk and return the result, or the fault in PAR_EL1. KVM uses these to find the IPA when the value is not provided by the CPU in HPFAR_EL1. If a translation table walk causes an external abort it is taken as an exception, even if it was due to an AT instruction. (DDI0487F.a's D5.2.11 "Synchronous faults generated by address translation instructions") While we previously made KVM resilient to exceptions taken due to AT instructions, the device access causes mismatched attributes, and may occur speculatively. Prevent this, by forbidding a walk through memory described as device at stage2. Now such AT instructions will report a stage2 fault. Such a fault will cause KVM to restart the guest. If the AT instructions always walk the page tables, but guest execution uses the translation cached in the TLB, the guest can't make forward progress until the TLB entry is evicted. 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@xxxxxxxxxxxxxxx # v4.19 Signed-off-by: James Morse <james.morse@xxxxxxx> Reviewed-by: Marc Zyngier <maz@xxxxxxxxxx> Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- arch/arm64/include/asm/kvm_arm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/arm64/include/asm/kvm_arm.h +++ b/arch/arm64/include/asm/kvm_arm.h @@ -83,11 +83,12 @@ * IMO: Override CPSR.I and enable signaling with VI * FMO: Override CPSR.F and enable signaling with VF * SWIO: Turn set/way invalidates into set/way clean+invalidate + * PTW: Take a stage2 fault if a stage1 walk steps in device memory */ #define HCR_GUEST_FLAGS (HCR_TSC | HCR_TSW | HCR_TWE | HCR_TWI | HCR_VM | \ HCR_TVM | HCR_BSU_IS | HCR_FB | HCR_TAC | \ HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ - HCR_FMO | HCR_IMO) + HCR_FMO | HCR_IMO | HCR_PTW ) #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) #define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK) #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) Patches currently in stable-queue which might be from andre.przywara@xxxxxxx are queue-4.19/kvm-arm64-set-hcr_el2.ptw-to-prevent-at-taking-synchronous-exception.patch queue-4.19/kvm-arm64-survive-synchronous-exceptions-caused-by-at-instructions.patch queue-4.19/kvm-arm64-defer-guest-entry-when-an-asynchronous-exception-is-pending.patch queue-4.19/kvm-arm64-add-kvm_extable-for-vaxorcism-code.patch