]> xenbits.xensource.com Git - xen.git/commitdiff
arm: Implement get_page_from_gfn()
authorTim Deegan <tim@xen.org>
Thu, 17 May 2012 09:24:54 +0000 (10:24 +0100)
committerTim Deegan <tim@xen.org>
Thu, 17 May 2012 09:24:54 +0000 (10:24 +0100)
We will be calling this from common code, so add a basic
implementation to arch/arm.

After 4.2 we should reshuffle some of the p2m interface out of
arch/x86 into common headers; for now duplicate a little bit of it.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/include/asm-arm/p2m.h

index aec52f77a453a3e1076d09a1320e2a1827ded0c0..6bcdf02b79614169f20f503bf4e5fc64fef0faf2 100644 (file)
@@ -53,6 +53,28 @@ p2m_pod_decrease_reservation(struct domain *d,
                              xen_pfn_t gpfn,
                              unsigned int order);
 
+/* Look up a GFN and take a reference count on the backing page. */
+typedef int p2m_type_t;
+typedef unsigned int p2m_query_t;
+#define P2M_ALLOC    (1u<<0)   /* Populate PoD and paged-out entries */
+#define P2M_UNSHARE  (1u<<1)   /* Break CoW sharing */
+
+static inline struct page_info *get_page_from_gfn(
+    struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q)
+{
+    struct page_info *page;
+    unsigned long mfn = gmfn_to_mfn(d, gfn);
+
+    ASSERT(t == NULL);
+
+    if (!mfn_valid(mfn))
+        return NULL;
+    page = mfn_to_page(mfn);
+    if ( !get_page(page, d) )
+        return NULL;
+    return page;
+}
+
 /* Compatibility function exporting the old untyped interface */
 static inline unsigned long get_gfn_untyped(struct domain *d, unsigned long gpfn)
 {