]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/x86/xen/setup.c
xen/setup: update VA mapping when releasing memory during setup
[karo-tx-linux.git] / arch / x86 / xen / setup.c
index 30ac05a8d28f71cacbdf70c9c94e559f91671ff0..3ebba0753d3876b887875aaf53fdd461f544441c 100644 (file)
@@ -139,6 +139,13 @@ static unsigned long __init xen_do_chunk(unsigned long start,
 
        return len;
 }
+
+static unsigned long __init xen_release_chunk(unsigned long start,
+                                             unsigned long end)
+{
+       return xen_do_chunk(start, end, true);
+}
+
 static unsigned long __init xen_populate_chunk(
        const struct e820entry *list, size_t map_size,
        unsigned long max_pfn, unsigned long *last_pfn,
@@ -197,6 +204,29 @@ static unsigned long __init xen_populate_chunk(
        }
        return done;
 }
+
+static void __init xen_set_identity_and_release_chunk(
+       unsigned long start_pfn, unsigned long end_pfn, unsigned long nr_pages,
+       unsigned long *released, unsigned long *identity)
+{
+       unsigned long pfn;
+
+       /*
+        * If the PFNs are currently mapped, the VA mapping also needs
+        * to be updated to be 1:1.
+        */
+       for (pfn = start_pfn; pfn <= max_pfn_mapped && pfn < end_pfn; pfn++)
+               (void)HYPERVISOR_update_va_mapping(
+                       (unsigned long)__va(pfn << PAGE_SHIFT),
+                       mfn_pte(pfn, PAGE_KERNEL_IO), 0);
+
+       if (start_pfn < nr_pages)
+               *released += xen_release_chunk(
+                       start_pfn, min(end_pfn, nr_pages));
+
+       *identity += set_phys_range_identity(start_pfn, end_pfn);
+}
+
 static unsigned long __init xen_set_identity_and_release(
        const struct e820entry *list, size_t map_size, unsigned long nr_pages)
 {
@@ -226,14 +256,11 @@ static unsigned long __init xen_set_identity_and_release(
                        if (entry->type == E820_RAM)
                                end_pfn = PFN_UP(entry->addr);
 
-                       if (start_pfn < end_pfn) {
-                               if (start_pfn < nr_pages)
-                                       released += xen_do_chunk(
-                                               start_pfn, min(end_pfn, nr_pages), true);
+                       if (start_pfn < end_pfn)
+                               xen_set_identity_and_release_chunk(
+                                       start_pfn, end_pfn, nr_pages,
+                                       &released, &identity);
 
-                               identity += set_phys_range_identity(
-                                       start_pfn, end_pfn);
-                       }
                        start = end;
                }
        }