]> xenbits.xensource.com Git - people/hx242/xen.git/commitdiff
x86/setup: do not map memory when passing to allocators directnonmap-v2.3
authorHongyan Xia <hongyax@amazon.com>
Wed, 9 Oct 2019 13:54:23 +0000 (14:54 +0100)
committerHongyan Xia <hongyax@amazon.com>
Wed, 16 Oct 2019 12:25:06 +0000 (13:25 +0100)
Also destroy the existing mappings to the direct map region when passing
to allocators.

Signed-off-by: Hongyan Xia <hongyax@amazon.com>
xen/arch/x86/setup.c

index e6d8dfb0b352e04796ebff326e5b2097b9dc0276..6a664d16c27bd9aa3914991745c612322b1c7e7c 100644 (file)
@@ -1346,6 +1346,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
         /* Pass mapped memory to allocator /before/ creating new mappings. */
         init_boot_pages(s, min(map_s, e));
+#ifndef CONFIG_DIRECTMAP
+        destroy_xen_mappings((unsigned long)__va(s),
+                             (unsigned long)__va(min(map_s, e)));
+#endif
         s = map_s;
         if ( s < map_e )
         {
@@ -1354,6 +1358,10 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             map_s = (s + mask) & ~mask;
             map_e &= ~mask;
             init_boot_pages(map_s, map_e);
+#ifndef CONFIG_DIRECTMAP
+            destroy_xen_mappings((unsigned long)__va(map_s),
+                                 (unsigned long)__va(map_e));
+#endif
         }
 
         if ( map_s > map_e )
@@ -1367,12 +1375,15 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
             if ( map_e < end )
             {
+#ifdef CONFIG_DIRECTMAP
                 map_pages_to_xen((unsigned long)__va(map_e), maddr_to_mfn(map_e),
                                  PFN_DOWN(end - map_e), PAGE_HYPERVISOR);
+#endif
                 init_boot_pages(map_e, end);
                 map_e = end;
             }
         }
+#ifdef CONFIG_DIRECTMAP
         if ( map_e < e )
         {
             /* This range must not be passed to the boot allocator and
@@ -1380,10 +1391,13 @@ void __init noreturn __start_xen(unsigned long mbi_p)
             map_pages_to_xen((unsigned long)__va(map_e), maddr_to_mfn(map_e),
                              PFN_DOWN(e - map_e), __PAGE_HYPERVISOR_RW);
         }
+#endif
         if ( s < map_s )
         {
+#ifdef CONFIG_DIRECTMAP
             map_pages_to_xen((unsigned long)__va(s), maddr_to_mfn(s),
                              PFN_DOWN(map_s - s), PAGE_HYPERVISOR);
+#endif
             init_boot_pages(s, map_s);
         }
     }