]> xenbits.xensource.com Git - people/liuw/xen.git/commitdiff
XXX switch to using vmap to map pages from alloc_xenheap_pages
authorWei Liu <wei.liu2@citrix.com>
Wed, 12 Dec 2018 11:48:59 +0000 (11:48 +0000)
committerWei Liu <wei.liu2@citrix.com>
Tue, 18 Dec 2018 17:07:28 +0000 (17:07 +0000)
This is broken atm because vm_init depends on alloc_xenheap_pages to
be functional.

xen/common/page_alloc.c

index 2c6509e3a08f8e96b62d4b5c38f6aba0c62dafda..efd2b79a54cc9927e4bba515e8c5c07a3a8a4413 100644 (file)
@@ -2180,6 +2180,8 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
 {
     struct page_info *pg;
     unsigned int i;
+    mfn_t mfn;
+    void *v;
 
     ASSERT(!in_irq());
 
@@ -2195,23 +2197,42 @@ void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
     for ( i = 0; i < (1u << order); i++ )
         pg[i].count_info |= PGC_xen_heap;
 
-    return page_to_virt(pg);
+    mfn = page_to_mfn(pg);
+
+    v = vmap(&mfn, 1u << order);
+    /* The assumption is xenheap is always mapped */
+    ASSERT(v);
+    return v;
 }
 
 void free_xenheap_pages(void *v, unsigned int order)
 {
     struct page_info *pg;
     unsigned int i;
+    unsigned long va = (unsigned long)v;
 
     ASSERT(!in_irq());
+    ASSERT(va >= VMAP_VIRT_START && va < VMAP_VIRT_END);
 
     if ( v == NULL )
         return;
+    /*
+     * We need to fish the mfns out from the va supplied.  Only the
+     * first page_info is needed because we're sure they are
+     * contiguous.
+     *
+     * This needs to be done before vunmap because PTEs will have been
+     * clobbered after vunmap.
+     */
+    pg = vmap_to_page(va);
 
-    pg = virt_to_page(v);
+    vunmap(v);
 
     for ( i = 0; i < (1u << order); i++ )
+    {
+        ASSERT(pg[i].count_info & PGC_xen_heap);
         pg[i].count_info &= ~PGC_xen_heap;
+    }
 
     free_heap_pages(pg, order, true);
 }