@@ -1381,7 +1381,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
13811381 int ret = 0 ;
13821382 bool write_fault , writable , force_pte = false;
13831383 bool exec_fault , mte_allowed ;
1384- bool device = false;
1384+ bool device = false, vfio_allow_any_uc = false ;
13851385 unsigned long mmu_seq ;
13861386 struct kvm * kvm = vcpu -> kvm ;
13871387 struct kvm_mmu_memory_cache * memcache = & vcpu -> arch .mmu_page_cache ;
@@ -1472,6 +1472,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14721472 gfn = fault_ipa >> PAGE_SHIFT ;
14731473 mte_allowed = kvm_vma_mte_allowed (vma );
14741474
1475+ vfio_allow_any_uc = vma -> vm_flags & VM_ALLOW_ANY_UNCACHED ;
1476+
14751477 /* Don't use the VMA after the unlock -- it may have vanished */
14761478 vma = NULL ;
14771479
@@ -1557,10 +1559,14 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
15571559 if (exec_fault )
15581560 prot |= KVM_PGTABLE_PROT_X ;
15591561
1560- if (device )
1561- prot |= KVM_PGTABLE_PROT_DEVICE ;
1562- else if (cpus_have_final_cap (ARM64_HAS_CACHE_DIC ))
1562+ if (device ) {
1563+ if (vfio_allow_any_uc )
1564+ prot |= KVM_PGTABLE_PROT_NORMAL_NC ;
1565+ else
1566+ prot |= KVM_PGTABLE_PROT_DEVICE ;
1567+ } else if (cpus_have_final_cap (ARM64_HAS_CACHE_DIC )) {
15631568 prot |= KVM_PGTABLE_PROT_X ;
1569+ }
15641570
15651571 /*
15661572 * Under the premise of getting a FSC_PERM fault, we just need to relax
0 commit comments