[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v3 07/10] xen/arm: Implement xen_rem_foreign_from_p2m



Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>

---
    Changes in v3:
        - Move put_page in create_p2m_entries
        - Move xenmem_rem_foreign_from_p2m in arch/arm/p2m.c
    Changes in v2:
        - Introduce the patch
---
 xen/arch/arm/p2m.c        |   19 ++++++++++++++++++-
 xen/include/asm-arm/p2m.h |    6 +-----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 39d8a03..72946c6 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -317,7 +317,14 @@ 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 = maddr >> PAGE_SHIFT;
+                    p2m_type_t t = pte.p2m.type;
+
+                    /* TODO: Handle other p2m type */
+                    if ( mfn_valid(mfn) && p2m_is_foreign(t) )
+                        put_page(mfn_to_page(mfn));
+
                     memset(&pte, 0x00, sizeof(pte));
                     write_pte(&third[third_table_offset(addr)], pte);
                     maddr += PAGE_SIZE;
@@ -380,6 +387,16 @@ void guest_physmap_remove_page(struct domain *d,
                        pfn_to_paddr(mfn), MATTR_MEM, p2m_invalid);
 }
 
+int xenmem_rem_foreign_from_p2m(struct domain *d, unsigned long gpfn)
+{
+    unsigned long mfn = gmfn_to_mfn(d, gpfn);
+
+    ASSERT(mfn_valid(mfn));
+    guest_physmap_remove_page(d, gpfn, mfn, 0);
+
+    return 0;
+}
+
 int p2m_alloc_table(struct domain *d)
 {
     struct p2m_domain *p2m = &d->arch.p2m;
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 52b33ce..3d1696c 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -144,11 +144,7 @@ static inline int get_page_and_type(struct page_info *page,
     return rc;
 }
 
-static inline int xenmem_rem_foreign_from_p2m(struct domain *d, 
-                                              unsigned long gpfn)
-{
-    return -ENOSYS;
-}
+int xenmem_rem_foreign_from_p2m(struct domain *d, unsigned long gpfn);
 
 #endif /* _XEN_P2M_H */
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.