From patchwork Thu Sep 18 00:09:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37567 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 527362057E for ; Thu, 18 Sep 2014 00:12:17 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id d1sf125745wiv.11 for ; Wed, 17 Sep 2014 17:12:16 -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=4SNHHnHZ9Fy5SHB1WNvUq8EXz1zTC/2ItsBh9RKvFVw=; b=TfdNRXszvyOvYcysjT/d1SBIUDt8bssfhDYb8z9tlC1f2YKmhy/3WO56W0xRnMzJIz Ogs/e3UgYoSYubRDQ2z5ux3VOh1w2O6iTxwFJ3NWU67dr2xC552rKm6ubricD0iWR0zq vQMRFNDUiYuAtNJyhzjDuNGw8GLoI84SIUTdWsKOy6Fp2gn84aZ+J01Mvxv2+I6uyt3E PezTCw5E2ETHhv4cqI5/VITE/ByRvkVFpauZduYbK5qdVW9Fx9H4PmPS5Zsc79MRtmrs TW66T4eFYzKxlHm8GzypfGYVodzY4E5k0ZRVxr4r4sh0ThBYtd7z2zQJ9Nnbv1AP26Z9 /ulQ== X-Gm-Message-State: ALoCoQltnKocuFctV3Fkzzx4ymXfyAOlZvvW6Jw1m4o76sVqkjBHk4UfAY0C/KQ5B4Rr0y4kwhik X-Received: by 10.112.155.133 with SMTP id vw5mr5880lbb.14.1410999136527; Wed, 17 Sep 2014 17:12:16 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.73 with SMTP id c9ls85721lae.37.gmail; Wed, 17 Sep 2014 17:12:16 -0700 (PDT) X-Received: by 10.152.204.231 with SMTP id lb7mr1049718lac.44.1410999136263; Wed, 17 Sep 2014 17:12:16 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx.google.com with ESMTPS id ud4si2265292lbb.132.2014.09.17.17.12.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Sep 2014 17:12:16 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id w7so124359lbi.32 for ; Wed, 17 Sep 2014 17:12:16 -0700 (PDT) X-Received: by 10.112.24.104 with SMTP id t8mr670898lbf.46.1410999136161; Wed, 17 Sep 2014 17:12:16 -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 of9csp673256lbb; Wed, 17 Sep 2014 17:12:15 -0700 (PDT) X-Received: by 10.180.99.168 with SMTP id er8mr21245051wib.78.1410999135456; Wed, 17 Sep 2014 17:12:15 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id j2si30154015wjf.11.2014.09.17.17.12.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 17 Sep 2014 17:12:15 -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 1XUPIp-0006m8-0S; Thu, 18 Sep 2014 00:10:27 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XUPIj-0006ey-RM for xen-devel@lists.xen.org; Thu, 18 Sep 2014 00:10:22 +0000 Received: from [85.158.143.35:10718] by server-3.bemta-4.messagelabs.com id 84/9D-06192-AE22A145; Thu, 18 Sep 2014 00:10:18 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1410999015!14504934!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 27317 invoked from network); 18 Sep 2014 00:10:17 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 18 Sep 2014 00:10:17 -0000 X-IronPort-AV: E=Sophos;i="5.04,542,1406592000"; d="scan'208";a="172653391" 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:10:04 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XUPIQ-0000tE-Pu; Thu, 18 Sep 2014 01:10:03 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Thu, 18 Sep 2014 01:10:02 +0100 From: Ian Campbell To: Date: Thu, 18 Sep 2014 01:09:54 +0100 Message-ID: <1410998995-27449-8-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: MIA2 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 8/9] xen: arm: support for up to 48-bit physical addressing on arm64 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.217.173 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: This only affects Xen's own stage one paging. - Use symbolic names for TCR bits for clarity. - Update PADDR_BITS - Base field of LPAE PT structs is now 36 bits (and therefore unsigned long long for arm32 compatibility) - TCR_EL2.PS is set from ID_AA64MMFR0_EL1.PASize. - Provide decode of ID_AA64MMFR0_EL1 in CPU info Parts of this are derived from "xen/arm: Add 4-level page table for stage 2 translation" by Vijaya Kumar K. Signed-off-by: Ian Campbell Reviewed-by: Julien Grall --- v2: - TCR_{PS,TBI} under CONFIG_ARM_64 --- xen/arch/arm/arm32/head.S | 2 +- xen/arch/arm/arm64/head.S | 10 +++++--- xen/include/asm-arm/page.h | 16 ++++++++----- xen/include/asm-arm/processor.h | 48 ++++++++++++++++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 16d76f4..5c0263e 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -227,7 +227,7 @@ cpu_init_done: * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 32-bit address space goes through this table. */ - ldr r0, =0x80003500 + ldr r0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(0)) mcr CP32(r0, HTCR) /* Set up the HSCTLR: diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 43b5e72..d22af1c 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -224,13 +224,17 @@ skip_bss: ldr x0, =MAIRVAL msr mair_el2, x0 - /* Set up the HTCR: - * PASize -- 40 bits / 1TB + /* Set up TCR_EL2: + * PS -- Based on ID_AA64MMFR0_EL1.PARange * Top byte is used * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, * Full 64-bit address space goes through this table. */ - ldr x0, =0x80823500 + ldr x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(0)) + /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */ + mrs x1, ID_AA64MMFR0_EL1 + bfi x0, x1, #16, #3 + msr tcr_el2, x0 /* Set up the SCTLR_EL2: diff --git a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h index 773822f..d758b61 100644 --- a/xen/include/asm-arm/page.h +++ b/xen/include/asm-arm/page.h @@ -6,7 +6,11 @@ #include #include +#ifdef CONFIG_ARM_64 +#define PADDR_BITS 48 +#else #define PADDR_BITS 40 +#endif #define PADDR_MASK ((1ULL << PADDR_BITS)-1) #define VADDR_BITS 32 @@ -114,8 +118,8 @@ typedef struct __packed { unsigned long ng:1; /* Not-Global */ /* The base address must be appropriately aligned for Block entries */ - unsigned long base:28; /* Base address of block or next table */ - unsigned long sbz:12; /* Must be zero */ + unsigned long long base:36; /* Base address of block or next table */ + unsigned long sbz:4; /* Must be zero */ /* These seven bits are only used in Block entries and are ignored * in Table entries. */ @@ -149,8 +153,8 @@ typedef struct __packed { unsigned long sbz4:1; /* The base address must be appropriately aligned for Block entries */ - unsigned long base:28; /* Base address of block or next table */ - unsigned long sbz3:12; + unsigned long long base:36; /* Base address of block or next table */ + unsigned long sbz3:4; /* These seven bits are only used in Block entries and are ignored * in Table entries. */ @@ -174,9 +178,9 @@ typedef struct __packed { unsigned long pad2:10; /* The base address must be appropriately aligned for Block entries */ - unsigned long base:28; /* Base address of block or next table */ + unsigned long long base:36; /* Base address of block or next table */ - unsigned long pad1:24; + unsigned long pad1:16; } lpae_walk_t; typedef union { diff --git a/xen/include/asm-arm/processor.h b/xen/include/asm-arm/processor.h index 4aab823..17f61fe 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -100,6 +100,41 @@ #define HCR_SWIO (_AC(1,UL)<<1) /* Set/Way Invalidation Override */ #define HCR_VM (_AC(1,UL)<<0) /* Virtual MMU Enable */ +/* TCR: Stage 1 Translation Control */ + +#define TCR_T0SZ(x) ((x)<<0) + +#define TCR_IRGN0_NC (_AC(0x0,UL)<<8) +#define TCR_IRGN0_WBWA (_AC(0x1,UL)<<8) +#define TCR_IRGN0_WT (_AC(0x2,UL)<<8) +#define TCR_IRGN0_WB (_AC(0x3,UL)<<8) + +#define TCR_ORGN0_NC (_AC(0x0,UL)<<10) +#define TCR_ORGN0_WBWA (_AC(0x1,UL)<<10) +#define TCR_ORGN0_WT (_AC(0x2,UL)<<10) +#define TCR_ORGN0_WB (_AC(0x3,UL)<<10) + +#define TCR_SH0_NS (_AC(0x0,UL)<<12) +#define TCR_SH0_OS (_AC(0x2,UL)<<12) +#define TCR_SH0_IS (_AC(0x3,UL)<<12) + +#define TCR_TG0_4K (_AC(0x0,UL)<<14) +#define TCR_TG0_64K (_AC(0x1,UL)<<14) +#define TCR_TG0_16K (_AC(0x2,UL)<<14) + +#ifdef CONFIG_ARM_64 + +#define TCR_PS(x) ((x)<<16) +#define TCR_TBI (_AC(0x1,UL)<<20) + +#define TCR_RES1 (_AC(1,UL)<<31|_AC(1,UL)<<23) + +#else + +#define TCR_RES1 (_AC(1,UL)<<31) + +#endif + /* HCPTR Hyp. Coprocessor Trap Register */ #define HCPTR_TTA ((_AC(1,U)<<20)) /* Trap trace registers */ #define HCPTR_CP(x) ((_AC(1,U)<<(x))) /* Trap Coprocessor x */ @@ -204,8 +239,19 @@ struct cpuinfo_arm { uint64_t bits[2]; } aux64; - struct { + union { uint64_t bits[2]; + struct { + unsigned long pa_range:4; + unsigned long asid_bits:4; + unsigned long bigend:4; + unsigned long secure_ns:4; + unsigned long bigend_el0:4; + unsigned long tgranule_16K:4; + unsigned long tgranule_64K:4; + unsigned long tgranule_4K:4; + unsigned long __res0:32; + }; } mm64; struct {