1 From 9839f6b9a91436708dc4912c681327bc1a7d5427 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Mon, 26 Oct 2020 16:54:07 +0530
4 Subject: KVM: arm64: Force PTE mapping on fault resulting in a device mapping
6 From: Santosh Shukla <sashukla@nvidia.com>
8 [ Upstream commit 91a2c34b7d6fadc9c5d9433c620ea4c32ee7cae8 ]
10 VFIO allows a device driver to resolve a fault by mapping a MMIO
11 range. This can be subsequently result in user_mem_abort() to
12 try and compute a huge mapping based on the MMIO pfn, which is
13 a sure recipe for things to go wrong.
15 Instead, force a PTE mapping when the pfn faulted in has a device
18 Fixes: 6d674e28f642 ("KVM: arm/arm64: Properly handle faulting of device mappings")
19 Suggested-by: Marc Zyngier <maz@kernel.org>
20 Signed-off-by: Santosh Shukla <sashukla@nvidia.com>
21 [maz: rewritten commit message]
22 Signed-off-by: Marc Zyngier <maz@kernel.org>
23 Reviewed-by: Gavin Shan <gshan@redhat.com>
24 Cc: stable@vger.kernel.org
25 Link: https://lore.kernel.org/r/1603711447-11998-2-git-send-email-sashukla@nvidia.com
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
28 arch/arm64/kvm/mmu.c | 1 +
29 1 file changed, 1 insertion(+)
31 diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
32 index 3d26b47a13430..7a4ad984d54e0 100644
33 --- a/arch/arm64/kvm/mmu.c
34 +++ b/arch/arm64/kvm/mmu.c
35 @@ -1920,6 +1920,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
36 if (kvm_is_device_pfn(pfn)) {
37 mem_type = PAGE_S2_DEVICE;
38 flags |= KVM_S2PTE_FLAG_IS_IOMAP;
40 } else if (logging_active) {
42 * Faults on pages in a memslot with logging enabled