From patchwork Wed Jul 30 13:47: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: 34526 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f197.google.com (mail-ig0-f197.google.com [209.85.213.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5018020DCC for ; Wed, 30 Jul 2014 13:55:56 +0000 (UTC) Received: by mail-ig0-f197.google.com with SMTP id r2sf7793499igi.4 for ; Wed, 30 Jul 2014 06:55:55 -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=Qvo6BS4+ib2Pn3+LAfbkXDdMVSbR3P2Fv2kw+Nibdeg=; b=e9KvwfC6Gw6o+udxQAvWa0jxPDNhAgZeiga6RQeQjNCMKpxQ06zzkDSxtdWn6j0G/Q 2waooT7gDrmKXlSLD7GklzzRyiTw6gfERW4Y2hUFzK4czIQn7c4P3NmMvd83LzzwFQr4 bmJnFL8351NUg2HCfU8WWqnuhosqGZgB5cUYFcum5D8J0oLGXJNfw6sDq4DpnvJ3IHQi H5NSQk3jpQQ5WdOPzJhFDTlAlUO74LavSlBIO9yvtbPFVgQeiRadCqujxxStT9uMXOaZ 9eEGMcHhRfVjXEc6iPkvQ6xWcUZjcglJdHopbxNAoUNjcuTH8IvccNK4LITtkO83vTOa Y8FA== X-Gm-Message-State: ALoCoQnAqOYups16CVw8Z4LvMmcvc7kWsEa9WNCBLu+axqTq4ZmXGtbZypMQcrhw5Zqp7priEePK X-Received: by 10.182.213.105 with SMTP id nr9mr1836023obc.36.1406728555774; Wed, 30 Jul 2014 06:55:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.194 with SMTP id 60ls539899qgf.7.gmail; Wed, 30 Jul 2014 06:55:55 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr7933202vdb.27.1406728555584; Wed, 30 Jul 2014 06:55:55 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id kf20si1701338vdb.24.2014.07.30.06.55.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Jul 2014 06:55:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so1780514vcb.22 for ; Wed, 30 Jul 2014 06:55:55 -0700 (PDT) X-Received: by 10.221.26.10 with SMTP id rk10mr4794774vcb.0.1406728555476; Wed, 30 Jul 2014 06:55:55 -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.37.5 with SMTP id tc5csp29566vcb; Wed, 30 Jul 2014 06:55:55 -0700 (PDT) X-Received: by 10.50.43.193 with SMTP id y1mr7899598igl.32.1406728553731; Wed, 30 Jul 2014 06:55:53 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l3si6488020igx.12.2014.07.30.06.55.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 30 Jul 2014 06:55:53 -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 1XCUKq-0006H1-DV; Wed, 30 Jul 2014 13:54:28 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XCUKj-0006Ad-Is for xen-devel@lists.xen.org; Wed, 30 Jul 2014 13:54:21 +0000 Received: from [85.158.143.35:63985] by server-3.bemta-4.messagelabs.com id 4D/A4-06192-C09F8D35; Wed, 30 Jul 2014 13:54:20 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1406728457!12385597!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 7060 invoked from network); 30 Jul 2014 13:54:19 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jul 2014 13:54:19 -0000 X-IronPort-AV: E=Sophos;i="5.01,764,1400025600"; d="scan'208";a="157142868" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 30 Jul 2014 13:54:19 +0000 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; Wed, 30 Jul 2014 09:54:18 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XCUDv-0006vB-Av; Wed, 30 Jul 2014 14:47:20 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Wed, 30 Jul 2014 14:47:19 +0100 From: Ian Campbell To: Date: Wed, 30 Jul 2014 14:47:11 +0100 Message-ID: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <3ef2b68c511f3e31de409b76757b95c78b99d750.1406728037.git.ian.campbell@citrix.com> References: <3ef2b68c511f3e31de409b76757b95c78b99d750.1406728037.git.ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , vijay.kilari@gmail.com, stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH RFC 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.177 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 --- xen/arch/arm/mm.c | 45 +++++++++++++++++++++++++++++++------------- xen/arch/arm/p2m.c | 13 +++---------- xen/include/asm-arm/page.h | 15 +++++++++++++-- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index fa6a729..4ff783a 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -167,50 +167,69 @@ static inline void check_memory_layout_alignment_constraints(void) { #endif } -void dump_pt_walk(lpae_t *root, paddr_t addr, int root_level) +void dump_pt_walk(paddr_t ttbr, paddr_t addr, int root_level, 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, }; - int level; + lpae_t pte, *mapping; + int level, root_table; #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 + * concetenate 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 < 4; level++ ) { if ( offsets[level] > LPAE_ENTRIES ) break; - if ( !mappings[level] ) + if ( !mapping ) { printk("%s: Failed to map PT page\n", level_strs[level]); break; } - pte = mappings[level][offsets[level]]; + pte = mapping[offsets[level]]; printk("%s[0x%x] = 0x%"PRIpaddr"\n", level_strs[level], offsets[level], pte.bits); + if ( !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 */ - for ( level = root_level + 1 ; level < 4; level++ ) - { - unmap_domain_page(mappings[level]); - } + unmap_domain_page(mapping); } void dump_hyp_walk(vaddr_t addr) @@ -226,7 +245,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 64efdce..6839acf 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 d1f8d52..c1c8680 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -351,8 +351,19 @@ 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, 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, + int root_level, 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);