From patchwork Mon Dec 9 03:34:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22152 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2B10E23FD2 for ; Mon, 9 Dec 2013 03:34:22 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id m10sf328219vbh.4 for ; Sun, 08 Dec 2013 19:34:22 -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=A1AbO8O6rlXmRi63Dt1UTdvDZ8Kcux5uisWVldSNt38=; b=VCne98B/ut5eMehSlCZ5sDBzMNajjy6Nkjr8T0UddhKFAQTlsgtKvx5qBQe3qKcC4M 7IrWlyxSsG2qWI2xB7+pC1Qg2aWeieh8BJ+MRzpng5uZjoVAYp0k0i2CrRG+nLZOa9pN YerHn+UM4YMKvDYmCRtK/3ahB6sCZcrbPxqQGVFZ0HgSIK5g27a27nMz9njt76fkylgk 4kB3QZvUB59im7SGEWCImxdiNvTY+P6879UykKmEQrF/4h2KW849OoWT6r4S5kmhkY9C IxPip9hlPg8I/Y8wUfcsQyngjtv2lUevkJWnvxIFUCgVLMz7Ae2daxn7KuzsTCyhvFqf 8RKQ== X-Gm-Message-State: ALoCoQnZYRrZlgLlM8opgK+tNrF2rhU3jLzIqiBO/oIZHGTU0gGDYpCrps3FS/h237AzPK2pltl+ X-Received: by 10.58.37.3 with SMTP id u3mr5982235vej.6.1386560061734; Sun, 08 Dec 2013 19:34:21 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.65 with SMTP id m1ls1985880qed.91.gmail; Sun, 08 Dec 2013 19:34:21 -0800 (PST) X-Received: by 10.52.162.74 with SMTP id xy10mr516902vdb.65.1386560061633; Sun, 08 Dec 2013 19:34:21 -0800 (PST) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id mh9si3180538vec.64.2013.12.08.19.34.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.44 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.44; Received: by mail-vb0-f44.google.com with SMTP id x8so133255vbf.3 for ; Sun, 08 Dec 2013 19:34:21 -0800 (PST) X-Received: by 10.52.98.132 with SMTP id ei4mr518244vdb.62.1386560061562; Sun, 08 Dec 2013 19:34:21 -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 u4csp75726vcz; Sun, 8 Dec 2013 19:34:21 -0800 (PST) X-Received: by 10.14.109.5 with SMTP id r5mr1132714eeg.110.1386560060638; Sun, 08 Dec 2013 19:34:20 -0800 (PST) Received: from mail-ea0-f178.google.com (mail-ea0-f178.google.com [209.85.215.178]) by mx.google.com with ESMTPS id a9si7706970eew.138.2013.12.08.19.34.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Dec 2013 19:34:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.178 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.178; Received: by mail-ea0-f178.google.com with SMTP id d10so1317401eaj.9 for ; Sun, 08 Dec 2013 19:34:20 -0800 (PST) X-Received: by 10.14.47.75 with SMTP id s51mr1339750eeb.97.1386560060222; Sun, 08 Dec 2013 19:34:20 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id g7sm23681234eet.12.2013.12.08.19.34.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2013 19:34:19 -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 v2 05/10] xen/arm: p2m: Extend p2m_lookup parameters to retrieve the p2m type Date: Mon, 9 Dec 2013 03:34:02 +0000 Message-Id: <1386560047-17500-6-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386560047-17500-1-git-send-email-julien.grall@linaro.org> References: <1386560047-17500-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.44 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 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/p2m.c | 13 +++++++++++-- xen/arch/arm/traps.c | 6 +++--- xen/include/asm-arm/p2m.h | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e43804c..f0bbaca 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_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); @@ -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.p2mt; + } if (third) unmap_domain_page(third); if (second) unmap_domain_page(second); @@ -502,7 +511,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 458128e..0a811e7 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1267,7 +1267,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 ) { @@ -1280,7 +1280,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"); @@ -1295,7 +1295,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 56bbf4d..f4bcd7d 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);