From: Tim Deegan Date: Thu, 17 May 2012 09:24:54 +0000 (+0100) Subject: arm: Implement get_page_from_gfn() X-Git-Tag: 4.2.0-rc1~336 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=85e7d13b78b52992d00c457f22aaada15443feea;p=xen.git arm: Implement get_page_from_gfn() 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 Acked-by: Ian Campbell --- diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index aec52f77a4..6bcdf02b79 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -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) {