Skip to content

Commit 5731aac

Browse files
xzpeterakpm00
authored andcommitted
KVM: use follow_pfnmap API
Use the new pfnmap API to allow huge MMIO mappings for VMs. The rest work is done perfectly on the other side (host_pfn_mapping_level()). Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 6da8e96 commit 5731aac

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

virt/kvm/kvm_main.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2860,13 +2860,11 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
28602860
unsigned long addr, bool write_fault,
28612861
bool *writable, kvm_pfn_t *p_pfn)
28622862
{
2863+
struct follow_pfnmap_args args = { .vma = vma, .address = addr };
28632864
kvm_pfn_t pfn;
2864-
pte_t *ptep;
2865-
pte_t pte;
2866-
spinlock_t *ptl;
28672865
int r;
28682866

2869-
r = follow_pte(vma, addr, &ptep, &ptl);
2867+
r = follow_pfnmap_start(&args);
28702868
if (r) {
28712869
/*
28722870
* get_user_pages fails for VM_IO and VM_PFNMAP vmas and does
@@ -2881,21 +2879,19 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
28812879
if (r)
28822880
return r;
28832881

2884-
r = follow_pte(vma, addr, &ptep, &ptl);
2882+
r = follow_pfnmap_start(&args);
28852883
if (r)
28862884
return r;
28872885
}
28882886

2889-
pte = ptep_get(ptep);
2890-
2891-
if (write_fault && !pte_write(pte)) {
2887+
if (write_fault && !args.writable) {
28922888
pfn = KVM_PFN_ERR_RO_FAULT;
28932889
goto out;
28942890
}
28952891

28962892
if (writable)
2897-
*writable = pte_write(pte);
2898-
pfn = pte_pfn(pte);
2893+
*writable = args.writable;
2894+
pfn = args.pfn;
28992895

29002896
/*
29012897
* Get a reference here because callers of *hva_to_pfn* and
@@ -2916,9 +2912,8 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
29162912
*/
29172913
if (!kvm_try_get_pfn(pfn))
29182914
r = -EFAULT;
2919-
29202915
out:
2921-
pte_unmap_unlock(ptep, ptl);
2916+
follow_pfnmap_end(&args);
29222917
*p_pfn = pfn;
29232918

29242919
return r;

0 commit comments

Comments
 (0)