From patchwork Mon Dec 16 17:37:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22534 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D31C523FC6 for ; Mon, 16 Dec 2013 17:37:46 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wo20sf18527120obc.1 for ; Mon, 16 Dec 2013 09:37:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=nz7YgXy4/Qqk2A184OgmBHVOy2m5gAJkYqctRr2lDpQ=; b=S/TmRu8NZSQFQsu4QBMwruP3YZhJdEGjcKCqVowiF05CSoWIQRjoe8Oy7ayJ6nbLko 6r6bDvYuWOVdGKOrehQT1a7b4j45PJHx1g4dtVe31funG8qE+h5M1rQffjozX4lPKbbY uGq7xr6llRSD7MCLFzH2pzXPeGbXgwxzIay1+til7lacJ8tq/NhXhvE9my8EDkfcCjTX CJY35rs81V655icbWUl3MkIp1LEwVd3w80ay5oNKBtS0NzVmwrn9c6v+a39SxDSQ6BXi UC77ILwnl//tPluJUcKJzn2hWmKd8yyRLaluI9qkvxNeDtfdIe6QHmIslBv+XjjwnO0v p/OQ== X-Gm-Message-State: ALoCoQnZkQwWOrLPKX2ZLoL3TIjss6Sy3LO+fL8kDyVtZLUGYfZiXP/VWdZLqotRaG931ACDfpvs X-Received: by 10.43.102.136 with SMTP id de8mr5651445icc.20.1387215466382; Mon, 16 Dec 2013 09:37:46 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.228 with SMTP id k4ls2258881qer.93.gmail; Mon, 16 Dec 2013 09:37:46 -0800 (PST) X-Received: by 10.58.187.129 with SMTP id fs1mr2301150vec.45.1387215466257; Mon, 16 Dec 2013 09:37:46 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id ed9si4156391vcb.81.2013.12.16.09.37.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:46 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id w5so3418793vbf.29 for ; Mon, 16 Dec 2013 09:37:46 -0800 (PST) X-Received: by 10.52.0.174 with SMTP id 14mr46096vdf.86.1387215466172; Mon, 16 Dec 2013 09:37:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp6119vcz; Mon, 16 Dec 2013 09:37:45 -0800 (PST) X-Received: by 10.14.215.67 with SMTP id d43mr10176597eep.108.1387215465207; Mon, 16 Dec 2013 09:37:45 -0800 (PST) Received: from mail-ee0-f42.google.com (mail-ee0-f42.google.com [74.125.83.42]) by mx.google.com with ESMTPS id j47si1734030eeo.53.2013.12.16.09.37.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 09:37:45 -0800 (PST) Received-SPF: neutral (google.com: 74.125.83.42 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.83.42; Received: by mail-ee0-f42.google.com with SMTP id e53so2359593eek.15 for ; Mon, 16 Dec 2013 09:37:44 -0800 (PST) X-Received: by 10.15.54.72 with SMTP id s48mr17931407eew.3.1387215464588; Mon, 16 Dec 2013 09:37:44 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm44674680eeg.11.2013.12.16.09.37.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Dec 2013 09:37:43 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, tim@xen.org, stefano.stabellini@citrix.com, Julien Grall Subject: [PATCH v5 05/10] xen/arm: p2m: Extend p2m_lookup parameters to retrieve the p2m type Date: Mon, 16 Dec 2013 17:37:27 +0000 Message-Id: <1387215452-10951-6-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387215452-10951-1-git-send-email-julien.grall@linaro.org> References: <1387215452-10951-1-git-send-email-julien.grall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Signed-off-by: Julien Grall Acked-by: Ian Campbell --- Changes in v3: - 'p2mt' field was renamed in 'type' - missing one p2m_lookup Changes in v2: - This patch was "Add p2m_get_entry" on the previous version - Don't add a new function but only extend p2m_lookup --- xen/arch/arm/mm.c | 2 +- xen/arch/arm/p2m.c | 13 +++++++++++-- xen/arch/arm/traps.c | 6 +++--- xen/include/asm-arm/p2m.h | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 654281a..b1222be 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1032,7 +1032,7 @@ static int xenmem_add_to_physmap_one( return rc; } - maddr = p2m_lookup(od, pfn_to_paddr(idx)); + maddr = p2m_lookup(od, pfn_to_paddr(idx), NULL); if ( maddr == INVALID_PADDR ) { dump_p2m_lookup(od, pfn_to_paddr(idx)); diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 17d6620..9bdcacd 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -72,11 +72,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_lookup(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); @@ -102,7 +108,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.type; + } if (third) unmap_domain_page(third); if (second) unmap_domain_page(second); @@ -511,7 +520,7 @@ err: unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn) { - paddr_t p = p2m_lookup(d, pfn_to_paddr(gpfn)); + paddr_t p = p2m_lookup(d, pfn_to_paddr(gpfn), NULL); return p >> PAGE_SHIFT; } diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index e01045e..7c5ab19 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1421,7 +1421,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) printk("dom%d VA 0x%08"PRIvaddr"\n", d->domain_id, addr); printk(" TTBCR: 0x%08"PRIregister"\n", ttbcr); printk(" TTBR0: 0x%016"PRIx64" = 0x%"PRIpaddr"\n", - ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK)); + ttbr0, p2m_lookup(d, ttbr0 & PAGE_MASK, NULL)); if ( ttbcr & TTBCR_EAE ) { @@ -1434,7 +1434,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) return; } - paddr = p2m_lookup(d, ttbr0 & PAGE_MASK); + paddr = p2m_lookup(d, ttbr0 & PAGE_MASK, NULL); if ( paddr == INVALID_PADDR ) { printk("Failed TTBR0 maddr lookup\n"); @@ -1449,7 +1449,7 @@ void dump_guest_s1_walk(struct domain *d, vaddr_t addr) !(first[offset] & 0x2) ) goto done; - paddr = p2m_lookup(d, first[offset] & PAGE_MASK); + paddr = p2m_lookup(d, first[offset] & PAGE_MASK, NULL); if ( paddr == INVALID_PADDR ) { diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index 5742bbc..9d0d1e7 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -58,7 +58,7 @@ 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_lookup(struct domain *d, paddr_t gpfn, p2m_type_t *t); /* Setup p2m RAM mapping for domain d from start-end. */ int p2m_populate_ram(struct domain *d, paddr_t start, paddr_t end);