From patchwork Mon Jun 30 23:09:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 32824 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 50047203C0 for ; Tue, 1 Jul 2014 00:28:25 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id uy5sf55067746obc.1 for ; Mon, 30 Jun 2014 17:28:24 -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=dCO02h9UdrAFV/0yqrrQMyaAxQf76xjFVGIN7Ufwdic=; b=fVvb2QmCPTmlGDGuMmLOVZ4b9sjRmm3HyDEKCjMBX6MgfRpGhIHYd8XsR0KWVqesC9 KCiql0sbhXofPRWiA3eTx5G1dw1WqiJ48PApLio95TV7w5CFqGrkFbda0YCE/jJ0A0Vg IMMGXAbijUk5Ufliir+E2JxI0l8gkeB3A7lcQtpRNb8MU1EJas/jrXP49jaZS09bK8zQ cnYnuj+6rw9qrM504ZxUIaVIt7mYcJs9o8yoLLZ05MedI4F99C43KQo07mZtjJpi+aBX Gcr93z1/GcnYDtcnGOV6Kw6hr2qICtX4+YZu1trn1tKHhRedsJmGUUfvvnK0wma3a2oZ kKvA== X-Gm-Message-State: ALoCoQnYEBhgQef4yXCDvncwBfARDFMymK44RQfK2snx+hE2UZwjY5yPtxPLsSppMQVDOwqrAxPH X-Received: by 10.42.123.16 with SMTP id p16mr18146084icr.21.1404174504725; Mon, 30 Jun 2014 17:28:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.35 with SMTP id f32ls505948qga.54.gmail; Mon, 30 Jun 2014 17:28:24 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr40975780vcb.2.1404174504563; Mon, 30 Jun 2014 17:28:24 -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 ds1si10778803vec.32.2014.06.30.17.28.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 17:28:24 -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 ij19so8282648vcb.37 for ; Mon, 30 Jun 2014 17:28:24 -0700 (PDT) X-Received: by 10.58.37.106 with SMTP id x10mr1112197vej.2.1404174504455; Mon, 30 Jun 2014 17:28:24 -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 tc5csp178141vcb; Mon, 30 Jun 2014 17:28:24 -0700 (PDT) X-Received: by 10.140.86.139 with SMTP id p11mr41562890qgd.66.1404174503977; Mon, 30 Jun 2014 17:28:23 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id el9si27167940qcb.13.2014.06.30.17.28.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 30 Jun 2014 17:28:23 -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]:37110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kqa-00057m-L4 for patch@linaro.org; Mon, 30 Jun 2014 19:18:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kiy-0005uy-A5 for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:11:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1kit-0003Oq-2i for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:11:00 -0400 Received: from mail-oa0-f48.google.com ([209.85.219.48]:53510) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1kis-0003OU-TI for qemu-devel@nongnu.org; Mon, 30 Jun 2014 19:10:55 -0400 Received: by mail-oa0-f48.google.com with SMTP id m1so9513090oag.7 for ; Mon, 30 Jun 2014 16:10:54 -0700 (PDT) X-Received: by 10.182.134.164 with SMTP id pl4mr46125649obb.16.1404169854572; Mon, 30 Jun 2014 16:10:54 -0700 (PDT) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id cu7sm76370192oec.12.2014.06.30.16.10.52 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 30 Jun 2014 16:10:53 -0700 (PDT) From: greg.bellows@linaro.org To: qemu-devel@nongnu.org Date: Mon, 30 Jun 2014 18:09:15 -0500 Message-Id: <1404169773-20264-16-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404169773-20264-1-git-send-email-greg.bellows@linaro.org> References: <1404169773-20264-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.219.48 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, Sergey Fedorov , Fabian Aggeler , Greg Bellows , serge.fdrv@gmail.com, edgar.iglesias@gmail.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [PATCH v4 15/33] target-arm: add NSACR register 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.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 From: Fabian Aggeler Implements NSACR register with corresponding read/write functions for ARMv7 and ARMv8. Signed-off-by: Sergey Fedorov Signed-off-by: Fabian Aggeler Signed-off-by: Greg Bellows --- target-arm/cpu.h | 6 +++++ target-arm/helper.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 1e8d5ee..4625088 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -182,6 +182,7 @@ typedef struct CPUARMState { uint64_t c1_coproc; /* Coprocessor access register. */ uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */ uint32_t c1_scr; /* secure config register. */ + uint32_t c1_nsacr; /* Non-secure access control register. */ uint64_t ttbr0_el1; /* MMU translation table base 0. */ uint64_t ttbr1_el1; /* MMU translation table base 1. */ uint64_t c2_control; /* MMU translation table base control. */ @@ -609,6 +610,11 @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) #define SCR_RES1_MASK (3U << 4) #define SCR_MASK (0x3fff & ~SCR_RES1_MASK) +#define NSACR_NSTRCDIS (1U << 20) +#define NSACR_RFR (1U << 19) +#define NSACR_NSASEDIS (1U << 15) +#define NSACR_NSD32DIS (1U << 14) + /* Return the current FPSCR value. */ uint32_t vfp_get_fpscr(CPUARMState *env); void vfp_set_fpscr(CPUARMState *env, uint32_t val); diff --git a/target-arm/helper.c b/target-arm/helper.c index e43545a..6342dbf 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -489,7 +489,19 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, /* VFP coprocessor: cp10 & cp11 [23:20] */ mask |= (1 << 31) | (1 << 30) | (0xf << 20); - if (!arm_feature(env, ARM_FEATURE_NEON)) { + if (arm_feature(env, ARM_FEATURE_NEON)) { + /* NSACR can disable non-secure writes to + * ASEDIS [31] or D32DIS [30] + */ + if (arm_feature(env, ARM_FEATURE_EL3) && !arm_is_secure(env)) { + if ((env->cp15.c1_nsacr & NSACR_NSASEDIS)) { + mask &= ~(1 << 31); + } + if ((env->cp15.c1_nsacr & NSACR_NSD32DIS)) { + mask &= ~(1 << 30); + } + } + } else { /* ASEDIS [31] bit is RAO/WI */ value |= (1 << 31); } @@ -501,6 +513,7 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri, !arm_feature(env, ARM_FEATURE_VFP3)) { /* D32DIS [30] is RAO/WI if D16-31 are not implemented. */ value |= (1 << 30); + mask |= (1 << 30); } } value &= mask; @@ -2195,6 +2208,55 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) raw_write(env, ri, value); } +static void nsacr_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint32_t mask = 0; + + /* Pre ARMv8 some bits are RAO or UNK/SBZP */ + if (!arm_feature(env, ARM_FEATURE_V8)) { + + if (arm_feature(env, ARM_FEATURE_VFP)) { + mask |= NSACR_NSASEDIS | NSACR_NSD32DIS; + + if (!arm_feature(env, ARM_FEATURE_NEON)) { + /* NSASEDIS are RAO/WI */ + value |= NSACR_NSASEDIS; + } + + /* VFPv3 and upwards with NEON implement 32 double precision + * registers (D0-D31). + */ + if (!arm_feature(env, ARM_FEATURE_NEON) || + !arm_feature(env, ARM_FEATURE_VFP3)) { + /* NSD32DIS is RAO/WI if D16-31 are not implemented. */ + value |= NSACR_NSD32DIS; + } + } + + /* cpn bits [13:0] */ + mask = 0x3fff; + + value &= mask; + } + + raw_write(env, ri, value); +} + +static uint64_t nsacr_read(CPUARMState *env, const ARMCPRegInfo *ri) +{ + uint64_t ret = raw_read(env, ri); + + if (arm_feature(env, ARM_FEATURE_V8)) { + if (!arm_feature(env, ARM_FEATURE_EL3) || ( + arm_el_is_aa64(env, 3) && !is_a64(env) && + arm_current_pl(env) != 3)) { + ret = 0x0000C00; + } + } + return ret; +} + static const ARMCPRegInfo v8_el3_cp_reginfo[] = { { .name = "ELR_EL3", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, @@ -2228,6 +2290,10 @@ static const ARMCPRegInfo v7_el3_cp_reginfo[] = { { .name = "SCR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0, .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.scr_el3), .resetvalue = 0, }, + { .name = "NSACR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 2, + .access = PL3_RW | PL1_R, .resetvalue = 0, + .writefn = nsacr_write, .readfn = nsacr_read, + .fieldoffset = offsetof(CPUARMState, cp15.c1_nsacr) }, REGINFO_SENTINEL };