From patchwork Wed Apr 22 17:09:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 47419 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A1B1D2121F for ; Wed, 22 Apr 2015 17:11:18 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf53434979lbb.0 for ; Wed, 22 Apr 2015 10:11:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=zrUbQic420L6tVlcWs3ZpST1yZ3zOghZHrdp86Nal30=; b=XNlUiCoWYIjUrU2bc+DNWDIoTxW4k4vJFOFGJP+x9pKjAQKfG38zCnVDCiFnbRnjYg DJllOw7+pYXtyQ05Br/pCmxmmuFUNSQXM4i+TDITEkzJKZr3JKLHqwlEkQC7DDcKAE25 m/p8yD61SexYxjmOwxHLozWbcfw30JcrQh1RPWdMbpQGdFBm1DbtI40h48X7AIrksEQt rI1iKcySbbVM/dsKhE9XZMt7D5FIKDAvdF6Pvr83fpzu7NBJxgR1lQICtmYANAiCZ3jA GHY4YjNhsfdR757Fr3tivokzqLNyjtARsj+c0igkoWUB7L8hHlOe7sFvlB77mALeVSqf Jwig== X-Gm-Message-State: ALoCoQk6W1PbIHKA+O5WQLjalbuP4XDnA4nCzoehgh92Lobfbzct8WK/DZrYpalh7D+X4PaFt8p7 X-Received: by 10.112.118.162 with SMTP id kn2mr12212591lbb.22.1429722677653; Wed, 22 Apr 2015 10:11:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.229.129 with SMTP id sq1ls226972lac.4.gmail; Wed, 22 Apr 2015 10:11:17 -0700 (PDT) X-Received: by 10.112.134.167 with SMTP id pl7mr25344922lbb.50.1429722677369; Wed, 22 Apr 2015 10:11:17 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id vt12si4127290lac.164.2015.04.22.10.11.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2015 10:11:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbbqq2 with SMTP id qq2so185280543lbb.3 for ; Wed, 22 Apr 2015 10:11:17 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr26267831lbc.32.1429722677090; Wed, 22 Apr 2015 10:11:17 -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.67.65 with SMTP id l1csp68177lbt; Wed, 22 Apr 2015 10:11:16 -0700 (PDT) X-Received: by 10.141.23.200 with SMTP id z191mr16973300qhd.76.1429722662188; Wed, 22 Apr 2015 10:11:02 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w77si5631149qgw.25.2015.04.22.10.11.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Apr 2015 10:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:36227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkyAu-00007R-OD for patch@linaro.org; Wed, 22 Apr 2015 13:11:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yky9g-0007Eo-RE for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yky9c-0004oP-8Z for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:44 -0400 Received: from mail-ob0-f178.google.com ([209.85.214.178]:33359) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yky9c-0004nb-3J for qemu-devel@nongnu.org; Wed, 22 Apr 2015 13:09:40 -0400 Received: by oblw8 with SMTP id w8so176033079obl.0 for ; Wed, 22 Apr 2015 10:09:39 -0700 (PDT) X-Received: by 10.202.198.149 with SMTP id w143mr892816oif.72.1429722579738; Wed, 22 Apr 2015 10:09:39 -0700 (PDT) Received: from gbellows-linaro.gateway.pace.com (99-179-1-214.lightspeed.austtx.sbcglobal.net. [99.179.1.214]) by mx.google.com with ESMTPSA id w72sm3417636oie.28.2015.04.22.10.09.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 22 Apr 2015 10:09:38 -0700 (PDT) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, alex.bennee@linaro.org Date: Wed, 22 Apr 2015 12:09:16 -0500 Message-Id: <1429722561-12651-5-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1429722561-12651-1-git-send-email-greg.bellows@linaro.org> References: <1429722561-12651-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.214.178 Cc: serge.fdrv@gmail.com, Greg Bellows Subject: [Qemu-devel] [PATCH v2 4/9] target-arm: Add AArch64 CPTR registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org 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.172 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 Adds CPTR_EL2/3 system registers definitions and access function. Signed-off-by: Greg Bellows --- v2 -> v3 - Broke out cptr and cpacr access functions - Added HCPTR register entry as alias of CPTR_EL2 - Added HCPTR and CPTR_EL2 no_el2 register entries. - Fixed cptr_access comment --- target-arm/cpu.h | 5 +++++ target-arm/helper.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 2178a1f..d61bb3f 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -202,6 +202,7 @@ typedef struct CPUARMState { uint64_t sctlr_el[4]; }; uint64_t c1_coproc; /* Coprocessor access register. */ + uint64_t cptr_el[4]; /* ARMv8 feature trap registers */ uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */ uint64_t sder; /* Secure debug enable register. */ uint32_t nsacr; /* Non-secure access control register. */ @@ -575,6 +576,10 @@ void pmccntr_sync(CPUARMState *env); #define SCTLR_AFE (1U << 29) #define SCTLR_TE (1U << 30) +#define CPTR_TCPAC (1U << 31) +#define CPTR_TTA (1U << 20) +#define CPTR_TFP (1U << 10) + #define CPSR_M (0x1fU) #define CPSR_T (1U << 5) #define CPSR_F (1U << 6) diff --git a/target-arm/helper.c b/target-arm/helper.c index c83d9fc..e36c3d4 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -592,6 +592,34 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, env->cp15.c1_coproc = value; } +static CPAccessResult cpacr_access(CPUARMState *env, const ARMCPRegInfo *ri) +{ + if (arm_feature(env, ARM_FEATURE_V8) && arm_current_el(env) == 1) { + /* Check if CPACR accesses are to be trapped to EL2 */ + if ((env->cp15.cptr_el[2] & CPTR_TCPAC) && !arm_is_secure(env)) { + env->exception.target_el = 2; + return CP_ACCESS_TRAP; + /* Check if CPACR accesses are to be trapped to EL3 */ + } else if (env->cp15.cptr_el[3] & CPTR_TCPAC) { + env->exception.target_el = 3; + return CP_ACCESS_TRAP; + } + } + + return CP_ACCESS_OK; +} + +static CPAccessResult cptr_access(CPUARMState *env, const ARMCPRegInfo *ri) +{ + /* Check it CPTR accesses are set to trap to EL3 */ + if (arm_current_el(env) == 2 && (env->cp15.cptr_el[3] & CPTR_TCPAC)) { + env->exception.target_el = 3; + return CP_ACCESS_TRAP; + } + + return CP_ACCESS_OK; +} + static const ARMCPRegInfo v6_cp_reginfo[] = { /* prefetch by MVA in v6, NOP in v7 */ { .name = "MVA_prefetch", @@ -614,7 +642,7 @@ static const ARMCPRegInfo v6_cp_reginfo[] = { { .name = "WFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0, }, { .name = "CPACR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, - .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, + .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 2, .accessfn = cpacr_access, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_coproc), .resetvalue = 0, .writefn = cpacr_write }, REGINFO_SENTINEL @@ -2470,6 +2498,14 @@ static const ARMCPRegInfo v8_el3_no_el2_cp_reginfo[] = { .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 0, .access = PL2_RW, .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, + { .name = "CPTR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, + .access = PL2_RW, .accessfn = cptr_access, .resetvalue = 0, + .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, + { .name = "HCPTR", .type = ARM_CP_ALIAS, + .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, + .access = PL2_RW, .accessfn = cptr_access, .resetvalue = 0, + .readfn = arm_cp_read_zero, .writefn = arm_cp_write_ignore }, REGINFO_SENTINEL }; @@ -2537,6 +2573,14 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 1, .opc2 = 0, .access = PL3_RW, .type = ARM_CP_ALIAS, .fieldoffset = offsetof(CPUARMState, sp_el[2]) }, + { .name = "CPTR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, + .access = PL2_RW, .accessfn = cptr_access, .resetvalue = 0, + .fieldoffset = offsetof(CPUARMState, cp15.cptr_el[2]) }, + { .name = "HCPTR", .type = ARM_CP_ALIAS, + .cp = 15, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 2, + .access = PL2_RW, .accessfn = cptr_access, .resetvalue = 0, + .fieldoffset = offsetof(CPUARMState, cp15.cptr_el[2]) }, REGINFO_SENTINEL }; @@ -2598,6 +2642,10 @@ static const ARMCPRegInfo el3_cp_reginfo[] = { .access = PL3_RW, .writefn = vbar_write, .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[3]), .resetvalue = 0 }, + { .name = "CPTR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 1, .crm = 1, .opc2 = 2, + .access = PL3_RW, .accessfn = cptr_access, .resetvalue = 0, + .fieldoffset = offsetof(CPUARMState, cp15.cptr_el[3]) }, REGINFO_SENTINEL };