From patchwork Thu Sep 18 00:09:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37565 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C0C232057E for ; Thu, 18 Sep 2014 00:12:10 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf48926lbd.11 for ; Wed, 17 Sep 2014 17:12:09 -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=FH+UKBY73HKs8cHfrWzIO0iLNYbmQRgpYDdD4wBxTnk=; b=iMWRV1Z9DBgvwHTqQ9K+UH00aD2SNyHma5f75azVHqVddQtkUx3wlhTsaIOkwI9sfI 3liFYOZB6zfmuu9p2UBDF1eX00gC8WFj4jad4ekKAITvQSKmmuQXPLEriOg9e9ue0/yA pwBg3TGibTtGQfVXkc7guOhytP2yVaE8SdaFqgLv+w+RmRk0Ksjt2jx+dpyHRZqqE8MF gpNfKYlG2VFx8F2sPrFic7ebYix3U3Ihi6A2zE5X98x+bGCGq35ytds2NQLWX55j0qGY +hi2DDP5rN5UV837jttQJ6Zun1ngfBm5elm3fhGfSZSSfTa4TgaydXss2+V33DwCl2Yn jl3Q== X-Gm-Message-State: ALoCoQl/kUIxVp/nA/32PQocB/v37W3/AeWNBcgcyeFPtBLmN1jjp1QlZyfLpDcxNuWXTYqv/jnd X-Received: by 10.180.198.172 with SMTP id jd12mr8265390wic.6.1410999129559; Wed, 17 Sep 2014 17:12:09 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.169 with SMTP id s9ls140511laa.47.gmail; Wed, 17 Sep 2014 17:12:09 -0700 (PDT) X-Received: by 10.152.10.203 with SMTP id k11mr1049496lab.30.1410999129373; Wed, 17 Sep 2014 17:12:09 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx.google.com with ESMTPS id uq6si3824825lbc.21.2014.09.17.17.12.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 17:12:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id ge10so130876lab.13 for ; Wed, 17 Sep 2014 17:12:09 -0700 (PDT) X-Received: by 10.152.45.8 with SMTP id i8mr944259lam.31.1410999129180; Wed, 17 Sep 2014 17:12:09 -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.112.130.169 with SMTP id of9csp673240lbb; Wed, 17 Sep 2014 17:12:08 -0700 (PDT) X-Received: by 10.220.119.8 with SMTP id x8mr17070vcq.62.1410999127780; Wed, 17 Sep 2014 17:12:07 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id lr17si9615059vdb.24.2014.09.17.17.12.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Sep 2014 17:12:07 -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 1XUPIk-0006gl-F3; Thu, 18 Sep 2014 00:10:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUPIg-0006ee-BQ for xen-devel@lists.xen.org; Thu, 18 Sep 2014 00:10:18 +0000 Received: from [193.109.254.147:63518] by server-2.bemta-14.messagelabs.com id 65/91-07861-9E22A145; Thu, 18 Sep 2014 00:10:17 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1410999014!16266718!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 2774 invoked from network); 18 Sep 2014 00:10:16 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 18 Sep 2014 00:10:16 -0000 X-IronPort-AV: E=Sophos;i="5.04,542,1406592000"; d="scan'208";a="172653379" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Wed, 17 Sep 2014 20:09:58 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XUPIL-0000sz-H9; Thu, 18 Sep 2014 01:09:58 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Thu, 18 Sep 2014 01:09:57 +0100 From: Ian Campbell To: Date: Thu, 18 Sep 2014 01:09:49 +0100 Message-ID: <1410998995-27449-3-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1410998960.1920.2.camel@citrix.com> References: <1410998960.1920.2.camel@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 v3 for-4.5 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.215.54 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 mapped it. This allows the walker code to select the correct page to map. Signed-off-by: Ian Campbell Reviewed-by: Julien Grall --- v3: - s/mapper/mapped/ - Use %u to print unsigned thing 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 207264e..0294fa8 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -167,33 +167,53 @@ 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 BUG_ON(root_level > 3); - 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 %u\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); @@ -201,15 +221,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) @@ -225,7 +242,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 660d4c5..fa64aa5 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);