From patchwork Tue Dec 17 16:27:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 22602 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8CDE523FC6 for ; Tue, 17 Dec 2013 16:28:32 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id r5sf11530492qcx.8 for ; Tue, 17 Dec 2013 08:28:32 -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=rvDi8/0Z+teKOj8y5dgIheR68sgBGMEkx3leLQR0eMk=; b=Ekf5ouWgaYHWqgHIpx5pJqSWVyClNqz34C+H9XBwAd8I+R3DU/7v7Mdyw+AG7QhvR4 kGcaDZ7tumzDFqOoqlF6XvB9y3iX/FgvyjIRLEQEbvV7zhjnz64XJb70lDbrFFDStGpY AkzzwssuXNUMMBhfwuVydZVBgyuqlgBHRYYrUkBGS7AiKF1oRimUGUXmi1bn3a5redW0 WdrC5dPSYJ8GWjnxKvb/H3avH0wSt4wq+c5FvoWrzoRD2RKaQuaUL+2XRcPix7uKvAeV PBd3JeCAlTNeeMenE8uybNvsN9ZQs9+hB3VVVOZ2mEXWN5kHzYvNgJ6bOkCtMpVPxiEY dW7A== X-Gm-Message-State: ALoCoQlYmykOPt4yBRyvGox+RAuHhkDE8yof4zIDg5G1um8fiajtD1p96TBE7uRb35YWD6V6OKvd X-Received: by 10.236.19.36 with SMTP id m24mr6927514yhm.14.1387297712317; Tue, 17 Dec 2013 08:28:32 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.106.70 with SMTP id gs6ls2498684qeb.17.gmail; Tue, 17 Dec 2013 08:28:32 -0800 (PST) X-Received: by 10.58.128.41 with SMTP id nl9mr796864veb.65.1387297712200; Tue, 17 Dec 2013 08:28:32 -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 sx7si5026050vdc.94.2013.12.17.08.28.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:32 -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 w5so4284390vbf.15 for ; Tue, 17 Dec 2013 08:28:32 -0800 (PST) X-Received: by 10.58.46.18 with SMTP id r18mr11227656vem.4.1387297712048; Tue, 17 Dec 2013 08:28:32 -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 u4csp79578vcz; Tue, 17 Dec 2013 08:28:30 -0800 (PST) X-Received: by 10.14.37.131 with SMTP id y3mr23708635eea.1.1387297710418; Tue, 17 Dec 2013 08:28:30 -0800 (PST) Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com [209.85.215.181]) by mx.google.com with ESMTPS id p9si19192963eew.76.2013.12.17.08.28.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 08:28:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.181 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.215.181; Received: by mail-ea0-f181.google.com with SMTP id m10so3027082eaj.12 for ; Tue, 17 Dec 2013 08:28:29 -0800 (PST) X-Received: by 10.15.45.135 with SMTP id b7mr24273164eew.88.1387297709869; Tue, 17 Dec 2013 08:28:29 -0800 (PST) Received: from belegaer.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id e3sm54411471eeg.11.2013.12.17.08.28.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2013 08:28:25 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: patches@linaro.org, ian.campbell@citrix.com, ian.jackson@eu.citrix.com, Julien Grall Subject: [PATCH v6 05/10] xen/arm: p2m: Extend p2m_lookup parameters to retrieve the p2m type Date: Tue, 17 Dec 2013 16:27:53 +0000 Message-Id: <1387297678-17762-6-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387297678-17762-1-git-send-email-julien.grall@linaro.org> References: <1387297678-17762-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 v6: - Add an ASSERT to check if p2mt != p2m_invalid 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 | 14 ++++++++++++-- xen/arch/arm/traps.c | 6 +++--- xen/include/asm-arm/p2m.h | 2 +- 4 files changed, 17 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 3dda5c2..bc32935 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,11 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr) done: if ( pte.p2m.valid ) + { + ASSERT(pte.p2m.type != p2m_invalid); 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); @@ -521,7 +531,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);