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

[Xen-devel] [PATCH v3 26/38] arm/p2m: Introduce helpers managing altp2m entries



This commit introduces the following functions:
* remove_altp2m_entry
* modify_altp2m_entry

These functions are responsible to manage an altp2m view's entries and
their attributes.

Signed-off-by: Sergej Proskurin <proskurin@xxxxxxxxxxxxx>
---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Julien Grall <julien.grall@xxxxxxx>
---
v3: Changed the function prototype of "modify_altp2m_entry" and
    "remove_altp2m_entry" to hold arguments of type gfn_t/mfn_t instead
    of addresses.

    Remove the argument of type "struct domain*" from the function's
    prototypes.

    Remove the function "modify_altp2m_range".
---
 xen/arch/arm/p2m.c        | 36 ++++++++++++++++++++++++++++++++++++
 xen/include/asm-arm/p2m.h | 14 ++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index ca5ae97..1d3df0f 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -1165,6 +1165,42 @@ void guest_physmap_remove_page(struct domain *d,
     p2m_remove_mapping(p2m_get_hostp2m(d), gfn, (1 << page_order), mfn);
 }
 
+int remove_altp2m_entry(struct p2m_domain *ap2m,
+                        gfn_t gfn,
+                        mfn_t mfn,
+                        unsigned int page_order)
+{
+    ASSERT(p2m_is_altp2m(ap2m));
+
+    /* Align the gfn and mfn to the given pager order. */
+    gfn = _gfn(gfn_x(gfn) & ~((1UL << page_order)-1));
+    mfn = _mfn(mfn_x(mfn) & ~((1UL << page_order)-1));
+
+    return p2m_remove_mapping(ap2m, gfn, (1UL << page_order), mfn);
+}
+
+int modify_altp2m_entry(struct p2m_domain *ap2m,
+                        gfn_t gfn,
+                        mfn_t mfn,
+                        p2m_type_t t,
+                        p2m_access_t a,
+                        unsigned int page_order)
+{
+    int rc;
+
+    ASSERT(p2m_is_altp2m(ap2m));
+
+    /* Align the gfn and mfn to the given pager order. */
+    gfn = _gfn(gfn_x(gfn) & ~((1UL << page_order)-1));
+    mfn = _mfn(mfn_x(mfn) & ~((1UL << page_order)-1));
+
+    p2m_write_lock(ap2m);
+    rc = p2m_set_entry(ap2m, gfn, (1UL << page_order), mfn, t, a);
+    p2m_write_unlock(ap2m);
+
+    return rc;
+}
+
 static int p2m_alloc_table(struct p2m_domain *p2m)
 {
     struct page_info *page;
diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h
index 978125a..e02f69e 100644
--- a/xen/include/asm-arm/p2m.h
+++ b/xen/include/asm-arm/p2m.h
@@ -196,6 +196,20 @@ void p2m_dump_info(struct domain *d);
 /* Look up the MFN corresponding to a domain's GFN. */
 mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t);
 
+/* Remove an altp2m view's entry. */
+int remove_altp2m_entry(struct p2m_domain *p2m,
+                        gfn_t gfn,
+                        mfn_t mfn,
+                        unsigned int page_order);
+
+/* Modify an altp2m view's entry or its attributes. */
+int modify_altp2m_entry(struct p2m_domain *p2m,
+                        gfn_t gfn,
+                        mfn_t mfn,
+                        p2m_type_t t,
+                        p2m_access_t a,
+                        unsigned int page_order);
+
 /* Clean & invalidate caches corresponding to a region of guest address space 
*/
 int p2m_cache_flush(struct domain *d, gfn_t start, unsigned long nr);
 
-- 
2.9.0


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

 


Rackspace

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