]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: use follow_pfnmap API
authorPeter Xu <peterx@redhat.com>
Mon, 26 Aug 2024 20:43:44 +0000 (16:43 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 17 Sep 2024 08:06:59 +0000 (01:06 -0700)
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/20240826204353.2228736-11-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Gavin Shan <gshan@redhat.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Niklas Schnelle <schnelle@linux.ibm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
virt/kvm/kvm_main.c

index cb2b78e92910fb1d6ebed0b73cf359e866f0a06b..f416d5e3f9c0b1853fab72c5e8c48db1c05f0caf 100644 (file)
@@ -2860,13 +2860,11 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma,
                               unsigned long addr, bool write_fault,
                               bool *writable, kvm_pfn_t *p_pfn)
 {
+       struct follow_pfnmap_args args = { .vma = vma, .address = addr };
        kvm_pfn_t pfn;
-       pte_t *ptep;
-       pte_t pte;
-       spinlock_t *ptl;
        int r;
 
-       r = follow_pte(vma, addr, &ptep, &ptl);
+       r = follow_pfnmap_start(&args);
        if (r) {
                /*
                 * 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,
                if (r)
                        return r;
 
-               r = follow_pte(vma, addr, &ptep, &ptl);
+               r = follow_pfnmap_start(&args);
                if (r)
                        return r;
        }
 
-       pte = ptep_get(ptep);
-
-       if (write_fault && !pte_write(pte)) {
+       if (write_fault && !args.writable) {
                pfn = KVM_PFN_ERR_RO_FAULT;
                goto out;
        }
 
        if (writable)
-               *writable = pte_write(pte);
-       pfn = pte_pfn(pte);
+               *writable = args.writable;
+       pfn = args.pfn;
 
        /*
         * 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,
         */
        if (!kvm_try_get_pfn(pfn))
                r = -EFAULT;
-
 out:
-       pte_unmap_unlock(ptep, ptl);
+       follow_pfnmap_end(&args);
        *p_pfn = pfn;
 
        return r;