From patchwork Thu Sep 4 16:14:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 36737 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA241202E4 for ; Thu, 4 Sep 2014 16:16:27 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf52266762ieb.10 for ; Thu, 04 Sep 2014 09:16:27 -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=XBPhtZ2aU4Vc6GzTcdqqEOKpAyJTmiF816R7aDKP3Wo=; b=m1Oczfgy4LkxDHuXl56TK4VhyGqW7yBeg+dVQ/6sHBN4m/eY5ecOZZJKFQMpDKi1GN PlCiag4Ghb5TfHIKkjSFfWWCX1GOQlM37oQ+RJt5tmwipjswwHSmNeog8JHlbiZdb/47 RWjz7aIsjrMci0K4KrjcTYNcIFCtmcg7MHYgDUMDwZ4Xm7AsVEh4AkziHPjEX/L7NDg5 3T4yLsT9+9Nz/IR4FTW+wXnzoLUK5AMyKPJ0P8XuKGmG0vG9YyNnYvx2ZQXreVmCtokj /6hpfvepGcrkTc1kmc4FaAwITPYepEU2rCIcj/+fM78gVpBxXnr7KUKopQPnoc1CUoHV s3gA== X-Gm-Message-State: ALoCoQmVaU5bdhZtDV26ZiI111lSJ94RAECrzEzTgWwhjwP1a7JBozc4Xhaf4dILIxYaC1Rh1Cci X-Received: by 10.182.18.8 with SMTP id s8mr2699298obd.21.1409847387552; Thu, 04 Sep 2014 09:16:27 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.5 with SMTP id u5ls339422qgd.72.gmail; Thu, 04 Sep 2014 09:16:27 -0700 (PDT) X-Received: by 10.52.28.198 with SMTP id d6mr2095272vdh.68.1409847387367; Thu, 04 Sep 2014 09:16:27 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id i9si6031903vca.73.2014.09.04.09.16.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 09:16:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so10904804vcb.37 for ; Thu, 04 Sep 2014 09:16:27 -0700 (PDT) X-Received: by 10.220.77.65 with SMTP id f1mr2541391vck.48.1409847387269; Thu, 04 Sep 2014 09:16:27 -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 uj3csp863204vcb; Thu, 4 Sep 2014 09:16:26 -0700 (PDT) X-Received: by 10.52.145.204 with SMTP id sw12mr2075136vdb.79.1409847386662; Thu, 04 Sep 2014 09:16:26 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id pr2si3310856vdb.23.2014.09.04.09.16.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 04 Sep 2014 09:16:26 -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-0001UD-Uz; 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 1XPZg5-0001Sj-7E for xen-devel@lists.xen.org; Thu, 04 Sep 2014 16:14:29 +0000 Received: from [85.158.143.35:14582] by server-3.bemta-4.messagelabs.com id 1C/6A-06192-4EF88045; Thu, 04 Sep 2014 16:14:28 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1409847265!13627072!3 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 21685 invoked from network); 4 Sep 2014 16:14:28 -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:28 -0000 X-IronPort-AV: E=Sophos;i="5.04,467,1406592000"; d="scan'208";a="168408707" 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:26 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XPZg1-0004Qh-0H; Thu, 04 Sep 2014 17:14:26 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Thu, 04 Sep 2014 17:14:24 +0100 From: Ian Campbell To: Date: Thu, 4 Sep 2014 17:14:16 +0100 Message-ID: <54fd061a6a8fd684f24402d1c431090b292b5126.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: MIA2 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , vijay.kilari@gmail.com, stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH v2 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.220.178 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 0cc5b6d..044bd98 100644 --- a/xen/include/asm-arm/processor.h +++ b/xen/include/asm-arm/processor.h @@ -87,6 +87,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 */ @@ -191,8 +226,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 {