From patchwork Mon Jul 14 16:39:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 33621 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F109B20CAD for ; Mon, 14 Jul 2014 16:40:44 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf16484776oag.0 for ; Mon, 14 Jul 2014 09:40:44 -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=4f0mXSoyd5MudV3vUBHUnp0SGAPDF/LiprJmjhE3a80=; b=lsuKmb/Nai/JfovS2RHlHut/pD6+X7QPzW4UlGFz+hOE82W/4ZdA7xHs+Qb2gWC39k eDLfkkJ780OmPKptJQt22sEpShklw7n9kstrWMgs0Rb4J11YNwAkouqn9d3lnhUwBt+G 0Y0XiATRMx/ql4er4YtBGcf/wkyJToXz0KJOmwu5NFcXD9Rdfls/eVbpN1TP4WA+uOjG Oq28m5GXcqhCZtEnRZMeUIQCa8fa3Qa7wE/yE2vlszTb5HLe3lKgxFLG6SyDWjwZ2xFo KlMyAtMbx07xsNUG0THWZP9faHUrBOl7XZZqX4sUfK5DBP3WbcUweEi4xn6v+zeGZhjH 8o0A== X-Gm-Message-State: ALoCoQmPInLoTCZGhCoGEAIkXiVCMTM3RQ0o5DmITEZOC3wni5KugRYGChA0hy5dn8G90P/TuV4W X-Received: by 10.182.43.196 with SMTP id y4mr7819276obl.35.1405356044599; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.210 with SMTP id 76ls1103265qgp.33.gmail; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) X-Received: by 10.58.185.227 with SMTP id ff3mr1141681vec.45.1405356044516; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id or9si5541117vcb.81.2014.07.14.09.40.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Jul 2014 09:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id hu12so2643814vcb.14 for ; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) X-Received: by 10.220.166.9 with SMTP id k9mr17158266vcy.20.1405356044448; Mon, 14 Jul 2014 09:40:44 -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 tc5csp148835vcb; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) X-Received: by 10.140.109.118 with SMTP id k109mr25685007qgf.98.1405356044076; Mon, 14 Jul 2014 09:40:44 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j7si16072012qan.36.2014.07.14.09.40.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 14 Jul 2014 09:40:44 -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 1X6jHb-0007Ei-JJ; Mon, 14 Jul 2014 16:39:19 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X6jHZ-0007EL-Ti for xen-devel@lists.xen.org; Mon, 14 Jul 2014 16:39:18 +0000 Received: from [193.109.254.147:32487] by server-8.bemta-14.messagelabs.com id 48/16-14857-5B704C35; Mon, 14 Jul 2014 16:39:17 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1405355954!17377181!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22525 invoked from network); 14 Jul 2014 16:39:16 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 14 Jul 2014 16:39:16 -0000 X-IronPort-AV: E=Sophos;i="5.01,659,1400025600"; d="scan'208";a="152692654" Received: from accessns.citrite.net (HELO FTLPEX01CL03.citrite.net) ([10.9.154.239]) by FTLPIPO02.CITRIX.COM with ESMTP; 14 Jul 2014 16:39:15 +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; Mon, 14 Jul 2014 12:39:14 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1X6jHV-0008Rk-Gs; Mon, 14 Jul 2014 17:39:14 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Mon, 14 Jul 2014 17:39:13 +0100 From: Ian Campbell To: Date: Mon, 14 Jul 2014 17:39:09 +0100 Message-ID: <1405355950-6461-4-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1405355930.31863.5.camel@kazak.uk.xensource.com> References: <1405355930.31863.5.camel@kazak.uk.xensource.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 4/5] xen: arm: avoid unnecessary aliasing in boot page tables. 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.169 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: If the identity map is created at one level then avoid creating entries further down the boot page tables, since these will be aliases at strange virtual address i.e. if the load address is such that both first_table_offset and second_table_offset are non-zero then we should avoid creating a mapping in boot_second, because the proper mapping is already in boot_first. We still do not handle the case where the load address is within the 2MB range starting at XEN_VIRT_START. This is not a regression but this patch tries to provide a more useful diagnostic message. Signed-off-by: Ian Campbell --- xen/arch/arm/arm32/head.S | 14 +++++++++++++- xen/arch/arm/arm64/head.S | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 3a72195..348ca7d 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -45,7 +45,7 @@ * r3 - * r4 - * r5 - - * r6 - + * r6 - identity map in place * r7 - CPUID * r8 - DTB address (boot CPU only) * r9 - paddr(start) @@ -250,6 +250,8 @@ cpu_init_done: * mapping. So each CPU must rebuild the page tables here with * the 1:1 in place. */ + mov r6, #0 /* r6 := identity map not yet in place */ + /* Write Xen's PT's paddr into the HTTBR */ ldr r4, =boot_pgtable add r4, r4, r10 /* r4 := paddr (boot_pagetable) */ @@ -275,6 +277,7 @@ cpu_init_done: orr r2, r2, #PT_LOWER(MEM) lsl r1, r1, #3 /* r1 := Slot offset */ strd r2, r3, [r4, r1] /* Mapping of paddr(start) */ + mov r6, #1 /* r6 := identity map now in place */ 1: /* Setup boot_second: */ ldr r4, =boot_second @@ -290,6 +293,8 @@ cpu_init_done: strd r2, r3, [r4, #8] /* Map it in slot 1 */ /* ... map of paddr(start) in boot_second */ + cmp r6, #1 /* r6 is set if already created */ + beq 1f lsrs r1, r9, #SECOND_SHIFT /* Offset of base paddr in boot_second */ mov r2, #0x0ff /* r2 := LPAE entries mask */ orr r2, r2, #0x100 @@ -307,6 +312,7 @@ cpu_init_done: orr r2, r2, #PT_LOWER(MEM) lsl r1, r1, #3 /* r1 := Slot offset */ strd r2, r3, [r4, r1] /* Mapping of paddr(start) */ + mov r6, #1 /* r6 := identity map now in place */ /* Setup boot_third: */ 1: ldr r4, =boot_third @@ -330,6 +336,12 @@ cpu_init_done: /* boot pagetable setup complete */ + cmp r6, #1 /* Did we manage to create an identity mapping ? */ + beq 1f + PRINT("Unable to build boot page tables - Failed to identity map Xen.\r\n") + b fail + +1: PRINT("- Turning on paging -\r\n") ldr r1, =paging /* Explicit vaddr, not RIP-relative */ diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 023a9b9..7152d9c 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -62,7 +62,7 @@ * x22 - is_secondary_cpu * x23 - UART address * x24 - cpuid - * x25 - + * x25 - identity map in place * x26 - * x27 - * x28 - @@ -253,6 +253,8 @@ skip_bss: * mapping. So each CPU must rebuild the page tables here with * the 1:1 in place. */ + mov x25, #0 /* x25 := identity map not yet in place */ + /* Write Xen's PT's paddr into TTBR0_EL2 */ ldr x4, =boot_pgtable add x4, x4, x20 /* x4 := paddr (boot_pagetable) */ @@ -293,6 +295,7 @@ skip_bss: lsl x1, x1, #3 /* x1 := Slot offset */ str x2, [x4, x1] /* Mapping of paddr(start)*/ + mov x25, #1 /* x25 := identity map now in place */ 1: /* Setup boot_first: */ ldr x4, =boot_first /* Next level into boot_first */ @@ -306,6 +309,7 @@ skip_bss: str x2, [x4, #0] /* Map it in slot 0 */ /* ... map of paddr(start) in boot_first */ + cbnz x25, 1f /* x25 is set if already created */ lsr x2, x19, #FIRST_SHIFT /* x2 := Offset of base paddr in boot_first */ and x1, x2, 0x1ff /* x1 := Slot to use */ cbz x1, 1f /* It's in slot 0, map in boot_second */ @@ -315,6 +319,7 @@ skip_bss: orr x2, x2, x3 lsl x1, x1, #3 /* x1 := Slot offset */ str x2, [x4, x1] /* Create mapping of paddr(start)*/ + mov x25, #1 /* x25 := identity map now in place */ 1: /* Setup boot_second: */ ldr x4, =boot_second /* Next level into boot_second */ @@ -328,6 +333,7 @@ skip_bss: str x2, [x4, #8] /* Map it in slot 1 */ /* ... map of paddr(start) in boot_second */ + cbnz x25, 1f /* x25 is set if already created */ lsr x2, x19, #SECOND_SHIFT /* x2 := Offset of base paddr in boot_second */ and x1, x2, 0x1ff /* x1 := Slot to use */ cmp x1, #1 @@ -343,6 +349,7 @@ skip_bss: orr x2, x2, x3 lsl x1, x1, #3 /* x1 := Slot offset */ str x2, [x4, x1] /* Create mapping of paddr(start)*/ + mov x25, #1 /* x25 := identity map now in place */ 1: /* Setup boot_third: */ ldr x4, =boot_third @@ -366,6 +373,11 @@ skip_bss: /* boot pagetable setup complete */ + cbnz x25, 1f /* Did we manage to create an identity mapping ? */ + PRINT("Unable to build boot page tables - Failed to identity map Xen.\r\n") + b fail + +1: PRINT("- Turning on paging -\r\n") ldr x1, =paging /* Explicit vaddr, not RIP-relative */