From patchwork Thu Sep 4 16:14:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 36740 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f71.google.com (mail-oi0-f71.google.com [209.85.218.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2496202E4 for ; Thu, 4 Sep 2014 16:16:38 +0000 (UTC) Received: by mail-oi0-f71.google.com with SMTP id v63sf49286841oia.2 for ; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=LCbSbyAoSygjtopMerBGcKkXEV4WbrsjNraK2prE1kQ=; b=Qaj87jZkVu5jB4ijP8M+kLDa4hbJ2K7d1xfFc9FVq/HFyo2YJouY8T0JtfbdkenqFQ g5HoRwQ1cQc5zT2ct4uRv3P6QUZ3d0H3bhl72flEk7jNOFgZamcEw2GFQ3y+h5ep8JQG DESp8ec+geGzcN/44jtmI9fvpQNVHXdSuilU6AVQdb4dJE2VU455pgqoQCSVoblUa7ow Qqq8kuQI+NL8MezT0r7ztBbv67XrC8s1gpMjnqj3O+kB2rFiEAp5t3K0wm+UlVdY1F2E /ZHHc4w3sAMoaXLQAGPHR7jaKGdIt3TqgsAq6jhCatb4kWct5krpGGi+XxnGXf5Qoa6x wTtw== X-Gm-Message-State: ALoCoQkyqsm5QlB3/RMXvN0iJSct9rw6sAlMu1kUyPHwOFWonfEqyFtFrGalPH9MZx8kHQwEJyXB X-Received: by 10.182.251.135 with SMTP id zk7mr3029730obc.14.1409847398352; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.193 with SMTP id 59ls374463qgf.7.gmail; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) X-Received: by 10.220.190.134 with SMTP id di6mr2559102vcb.43.1409847398177; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id yo14si3317349vdc.12.2014.09.04.09.16.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 09:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hy4so10696041vcb.24 for ; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) X-Received: by 10.220.77.65 with SMTP id f1mr2543171vck.48.1409847398089; Thu, 04 Sep 2014 09:16:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp863235vcb; Thu, 4 Sep 2014 09:16:37 -0700 (PDT) X-Received: by 10.140.95.165 with SMTP id i34mr7235048qge.6.1409847397369; Thu, 04 Sep 2014 09:16:37 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l10si15138818qac.103.2014.09.04.09.16.37 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Sep 2014 09:16:37 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPZg6-0001Tb-AS; Thu, 04 Sep 2014 16:14:30 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPZg4-0001Sf-SN for xen-devel@lists.xen.org; Thu, 04 Sep 2014 16:14:29 +0000 Received: from [85.158.143.35:35136] by server-2.bemta-4.messagelabs.com id EF/D5-04525-3EF88045; Thu, 04 Sep 2014 16:14:27 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1409847265!13627072!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21556 invoked from network); 4 Sep 2014 16:14:27 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 4 Sep 2014 16:14:27 -0000 X-IronPort-AV: E=Sophos;i="5.04,467,1406592000"; d="scan'208";a="168408651" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.80) with Microsoft SMTP Server id 14.3.181.6; Thu, 4 Sep 2014 12:14:20 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XPZfv-0004QS-QT; Thu, 04 Sep 2014 17:14:20 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Thu, 04 Sep 2014 17:14:19 +0100 From: Ian Campbell To: Date: Thu, 4 Sep 2014 17:14:11 +0100 Message-ID: <18784a5341e9a17e5ae00d37a2a1339e8f1e4624.1409847257.git.ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <4427aba8dad3155fca151a0b63bfdf78e3a91033.1409847257.git.ian.campbell@citrix.com> References: <4427aba8dad3155fca151a0b63bfdf78e3a91033.1409847257.git.ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , vijay.kilari@gmail.com, stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v2 3/9] xen: arm: handle concatenated root tables in dump_pt_walk X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: ARM allows for the concatenation of pages at the root of a p2m (but not a regular page table) in order to support a larger IPA space than the number of levels in the P2M would normally support. We use this to support 40-bit guest addresses. Previously we were unable to dump IPAs which were outside the first page of the root. To fix this we adjust dump_pt_walk to take the machine address of the page table root instead of expecting the caller to have mapper it. This allows the walker code to select the correct page to map. Signed-off-by: Ian Campbell Reviewed-by: Julien Grall --- v2: - nr_root_tables is unsigned int - spell concatenate properly --- xen/arch/arm/mm.c | 47 ++++++++++++++++++++++++++++++-------------- xen/arch/arm/p2m.c | 13 +++--------- xen/include/asm-arm/page.h | 16 +++++++++++++-- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index ab91275..da4522c 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -167,32 +167,52 @@ static inline void check_memory_layout_alignment_constraints(void) { #endif } -void dump_pt_walk(lpae_t *root, paddr_t addr, - unsigned int root_level) +void dump_pt_walk(paddr_t ttbr, paddr_t addr, + unsigned int root_level, + unsigned int nr_root_tables) { static const char *level_strs[4] = { "0TH", "1ST", "2ND", "3RD" }; + const unsigned long root_pfn = paddr_to_pfn(ttbr); const unsigned int offsets[4] = { zeroeth_table_offset(addr), first_table_offset(addr), second_table_offset(addr), third_table_offset(addr) }; - lpae_t pte, *mappings[4] = { 0, }; - unsigned int level; + lpae_t pte, *mapping; + unsigned int level, root_table; - BUG_ON(!root); #ifdef CONFIG_ARM_32 BUG_ON(root_level < 1); #endif - mappings[root_level] = root; + if ( nr_root_tables > 1 ) + { + /* + * Concatenated root-level tables. The table number will be + * the offset at the previous level. It is not possible to + * concatenate a level-0 root. + */ + BUG_ON(root_level == 0); + root_table = offsets[root_level - 1]; + printk("Using concatenated root table %d\n", root_table); + if ( root_table >= nr_root_tables ) + { + printk("Invalid root table offset\n"); + return; + } + } + else + root_table = 0; + + mapping = map_domain_page(root_pfn + root_table); for ( level = root_level; ; level++ ) { if ( offsets[level] > LPAE_ENTRIES ) break; - pte = mappings[level][offsets[level]]; + pte = mapping[offsets[level]]; printk("%s[0x%x] = 0x%"PRIpaddr"\n", level_strs[level], offsets[level], pte.bits); @@ -200,15 +220,12 @@ void dump_pt_walk(lpae_t *root, paddr_t addr, if ( level == 3 || !pte.walk.valid || !pte.walk.table ) break; - mappings[level+1] = map_domain_page(pte.walk.base); + /* For next iteration */ + unmap_domain_page(mapping); + mapping = map_domain_page(pte.walk.base); } - /* mappings[root_level] is provided by the caller so don't unmap that */ - do - { - unmap_domain_page(mappings[level]); - } - while( level-- > root_level ); + unmap_domain_page(mapping); } void dump_hyp_walk(vaddr_t addr) @@ -224,7 +241,7 @@ void dump_hyp_walk(vaddr_t addr) BUG_ON( (lpae_t *)(unsigned long)(ttbr - phys_offset) != pgtable ); else BUG_ON( virt_to_maddr(pgtable) != ttbr ); - dump_pt_walk(pgtable, addr, HYP_PT_ROOT_LEVEL); + dump_pt_walk(ttbr, addr, HYP_PT_ROOT_LEVEL, 1); } /* Map a 4k page in a fixmap entry */ diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 6a19e37..62547f2 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -16,6 +16,7 @@ /* First level P2M is 2 consecutive pages */ #define P2M_ROOT_ORDER 1 #define P2M_ROOT_ENTRIES (LPAE_ENTRIES<arch.p2m; - lpae_t *first; printk("dom%d IPA 0x%"PRIpaddr"\n", d->domain_id, addr); - if ( first_linear_offset(addr) > LPAE_ENTRIES ) - { - printk("Cannot dump addresses in second of first level pages...\n"); - return; - } - printk("P2M @ %p mfn:0x%lx\n", p2m->root, page_to_mfn(p2m->root)); - first = __map_domain_page(p2m->root); - dump_pt_walk(first, addr, P2M_ROOT_LEVEL); - unmap_domain_page(first); + dump_pt_walk(page_to_maddr(p2m->root), addr, + P2M_ROOT_LEVEL, P2M_ROOT_PAGES); } static void p2m_load_VTTBR(struct domain *d) diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 4c21863..773822f 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -351,8 +351,20 @@ static inline void flush_xen_data_tlb_range_va(unsigned long va, /* Flush the dcache for an entire page. */ void flush_page_to_ram(unsigned long mfn); -/* Print a walk of an arbitrary page table */ -void dump_pt_walk(lpae_t *table, paddr_t addr, unsigned int root_level); +/* + * Print a walk of a page table or p2m + * + * ttbr is the base address register (TTBR0_EL2 or VTTBR_EL2) + * addr is the PA or IPA to translate + * root_level is the starting level of the page table + * (e.g. TCR_EL2.SL0 or VTCR_EL2.SL0 ) + * nr_root_tables is the number of concatenated tables at the root. + * this can only be != 1 for P2M walks starting at the first or + * subsequent level. + */ +void dump_pt_walk(paddr_t ttbr, paddr_t addr, + unsigned int root_level, + unsigned int nr_root_tables); /* Print a walk of the hypervisor's page tables for a virtual addr. */ extern void dump_hyp_walk(vaddr_t addr);