Skip to content

Commit 216887f

Browse files
ankita-nvoupton
authored andcommitted
KVM: arm64: Assume non-PFNMAP/MIXEDMAP VMAs can be mapped cacheable
Despite its name, kvm_is_device_pfn() is actually used to determine if a given PFN has a kernel mapping that can be used to perform cache maintenance, as it calls pfn_is_map_memory() internally. Expand the helper into its single callsite and further condition the check on the VMA having either VM_PFNMAP or VM_MIXEDMAP set. VMAs that set neither of these flags must always contain Normal, struct page backed memory with valid aliases in the kernel address space. Suggested-by: Jason Gunthorpe <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Tested-by: Donald Dutile <[email protected]> Signed-off-by: Ankit Agrawal <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Oliver: fixed typos, refined changelog ] Signed-off-by: Oliver Upton <[email protected]>
1 parent 8cc9dc1 commit 216887f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,6 @@ int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm,
193193
return 0;
194194
}
195195

196-
static bool kvm_is_device_pfn(unsigned long pfn)
197-
{
198-
return !pfn_is_map_memory(pfn);
199-
}
200-
201196
static void *stage2_memcache_zalloc_page(void *arg)
202197
{
203198
struct kvm_mmu_memory_cache *mc = arg;
@@ -1492,6 +1487,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
14921487
enum kvm_pgtable_prot prot = KVM_PGTABLE_PROT_R;
14931488
struct kvm_pgtable *pgt;
14941489
struct page *page;
1490+
vm_flags_t vm_flags;
14951491
enum kvm_pgtable_walk_flags flags = KVM_PGTABLE_WALK_HANDLE_FAULT | KVM_PGTABLE_WALK_SHARED;
14961492

14971493
if (fault_is_perm)
@@ -1619,6 +1615,8 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16191615

16201616
vfio_allow_any_uc = vma->vm_flags & VM_ALLOW_ANY_UNCACHED;
16211617

1618+
vm_flags = vma->vm_flags;
1619+
16221620
/* Don't use the VMA after the unlock -- it may have vanished */
16231621
vma = NULL;
16241622

@@ -1642,7 +1640,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
16421640
if (is_error_noslot_pfn(pfn))
16431641
return -EFAULT;
16441642

1645-
if (kvm_is_device_pfn(pfn)) {
1643+
if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP) && !pfn_is_map_memory(pfn)) {
16461644
/*
16471645
* If the page was identified as device early by looking at
16481646
* the VMA flags, vma_pagesize is already representing the

0 commit comments

Comments
 (0)