xen/arm: Handle remove foreign mapping
authorJulien Grall <julien.grall@linaro.org>
Tue, 17 Dec 2013 16:27:55 +0000 (16:27 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 18 Dec 2013 14:32:48 +0000 (14:32 +0000)
Modify get_page_from_gfn to take reference on foreign mapping. This will avoid
specific handling in the common code.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/p2m.c
xen/include/asm-arm/p2m.h

index bc3293570268feefa40545a49e83852bcb1cbb2b..410acb67c02f266f5df5cba6f8875713dc8df8ac 100644 (file)
@@ -328,10 +328,21 @@ static int create_p2m_entries(struct domain *d,
                 break;
             case REMOVE:
                 {
-                    lpae_t pte;
+                    lpae_t pte = third[third_table_offset(addr)];
+                    unsigned long mfn = pte.p2m.base;
+
+                    if ( !pte.p2m.valid )
+                        break;
+
+                    /* TODO: Handle other p2m type */
+                    if ( p2m_is_foreign(pte.p2m.type) )
+                    {
+                        ASSERT(mfn_valid(mfn));
+                        put_page(mfn_to_page(mfn));
+                    }
+
                     memset(&pte, 0x00, sizeof(pte));
                     write_pte(&third[third_table_offset(addr)], pte);
-                    maddr += PAGE_SIZE;
                 }
                 break;
         }
index 0eb07a86681f2d54591d05b361448d3a0856828f..5ccfa7f22e4ac2426254d1383b9bdccd1a4b2f13 100644 (file)
@@ -122,6 +122,18 @@ static inline struct page_info *get_page_from_gfn(
     if ( !mfn_valid(mfn) )
         return NULL;
     page = mfn_to_page(mfn);
+
+    /* get_page won't work on foreign mapping because the page doesn't
+     * belong to the current domain.
+     */
+    if ( p2mt == p2m_map_foreign )
+    {
+        struct domain *fdom = page_get_owner_and_reference(page);
+        ASSERT(fdom != NULL);
+        ASSERT(fdom != d);
+        return page;
+    }
+
     if ( !get_page(page, d) )
         return NULL;
     return page;