From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: [PATCH 5/8] xen/arm: p2m: Add p2m_get_entry Date: Thu, 5 Dec 2013 15:42:08 +0000 Message-ID: <1386258131-755-6-git-send-email-julien.grall@linaro.org> References: <1386258131-755-1-git-send-email-julien.grall@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vob4U-0001tY-Pe for xen-devel@lists.xenproject.org; Thu, 05 Dec 2013 15:42:34 +0000 Received: by mail-we0-f169.google.com with SMTP id w61so11246380wes.0 for ; Thu, 05 Dec 2013 07:42:33 -0800 (PST) In-Reply-To: <1386258131-755-1-git-send-email-julien.grall@linaro.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xenproject.org Cc: Julien Grall , stefano.stabellini@citrix.com, ian.campbell@citrix.com, time@xen.org, patches@linaro.org List-Id: xen-devel@lists.xenproject.org Reuse the code of p2m_lookup and add an argument to retrieve the p2m type. Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 11 ++++++++++- xen/include/asm-arm/p2m.h | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 5449a35..1ae2521 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -71,11 +71,17 @@ static lpae_t *p2m_map_first(struct p2m_domain *p2m, paddr_t addr) * There are no processor functions to do a stage 2 only lookup therefore we * do a a software walk. */ -paddr_t p2m_lookup(struct domain *d, paddr_t paddr) +paddr_t p2m_get_entry(struct domain *d, paddr_t paddr, p2m_type_t *t) { struct p2m_domain *p2m = &d->arch.p2m; lpae_t pte, *first = NULL, *second = NULL, *third = NULL; paddr_t maddr = INVALID_PADDR; + p2m_type_t _t; + + /* Allow t to be NULL */ + t = t ?: &_t; + + *t = p2m_invalid; spin_lock(&p2m->lock); @@ -99,7 +105,10 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr) done: if ( pte.p2m.valid ) + { maddr = (pte.bits & PADDR_MASK & PAGE_MASK) | (paddr & ~PAGE_MASK); + *t = pte.p2m.avail; + } if (third) unmap_domain_page(third); if (second) unmap_domain_page(second); diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 1cf7d36..3de69c4 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -49,7 +49,12 @@ int p2m_alloc_table(struct domain *d); void p2m_load_VTTBR(struct domain *d); /* Look up the MFN corresponding to a domain's PFN. */ -paddr_t p2m_lookup(struct domain *d, paddr_t gpfn); +paddr_t p2m_get_entry(struct domain *d, paddr_t gpfn, p2m_type_t *t); + +static inline paddr_t p2m_lookup(struct domain *d, paddr_t gpfn) +{ + return p2m_get_entry(d, gpfn, NULL); +} /* Setup p2m RAM mapping for domain d from start-end. */ int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end); -- 1.7.10.4