From: Fabian Aggeler <aggelerf@ethz.ch>
To: qemu-devel@nongnu.org
Cc: edgar.iglesias@gmail.com, Sergey Fedorov <s.fedorov@samsung.com>,
Fabian Aggeler <aggelerf@ethz.ch>,
peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH v2 11/23] target-arm: add NSACR support
Date: Tue, 13 May 2014 18:15:56 +0200 [thread overview]
Message-ID: <1399997768-32014-12-git-send-email-aggelerf@ethz.ch> (raw)
In-Reply-To: <1399997768-32014-1-git-send-email-aggelerf@ethz.ch>
NSACR allows to control non-secure access to coprocessor interfaces 0-13
and CPACR bits.
Signed-off-by: Sergey Fedorov <s.fedorov@samsung.com>
Signed-off-by: Fabian Aggeler <aggelerf@ethz.ch>
---
target-arm/cpu.h | 1 +
target-arm/helper.c | 29 +++++++++++++++++++++++++++++
target-arm/translate.c | 7 +++++++
3 files changed, 37 insertions(+)
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index f86a101..fb72cfa 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -173,6 +173,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. */
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 4e82259..2c600ef 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -483,6 +483,23 @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
mask |= 0x00f00000; /* VFP coprocessor: cp10 & cp11 */
}
value &= mask;
+ /* In an implementation that includes Security Extensions access to CPACR
+ * can be restricted by NSACR.
+ */
+ if (arm_feature(env, ARM_FEATURE_SECURITY_EXTENSIONS)
+ && !arm_is_secure(env)) {
+ int cpnum;
+ mask = 0;
+ for (cpnum = 0; cpnum < 14; ++cpnum) {
+ if (env->cp15.c1_nsacr & (1 << cpnum)) {
+ /* Bits [20:21] of CPACR control access to cp10
+ * Bits [23:22] of CPACR control access to cp11 */
+ mask |= (3 << (cpnum * 2));
+ }
+ }
+ value &= mask;
+ value |= env->cp15.c1_coproc & ~mask;
+ }
if (env->cp15.c1_coproc != value) {
env->cp15.c1_coproc = value;
/* ??? Is this safe when called from within a TB? */
@@ -2100,11 +2117,23 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
tlb_flush(CPU(cpu), 1);
}
+#ifndef CONFIG_USER_ONLY
+
+static void nsacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
+ uint64_t value)
+{
+ env->cp15.c1_nsacr = value & 0x3fff;
+}
+#endif
+
static const ARMCPRegInfo tz_cp_reginfo[] = {
#ifndef CONFIG_USER_ONLY
{ .name = "SCR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0,
.access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_scr),
.resetvalue = 0, },
+ { .name = "NSACR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 2,
+ .access = PL3_RW | PL1_R, .resetvalue = 0, .writefn = nsacr_write,
+ .fieldoffset = offsetof(CPUARMState, cp15.c1_nsacr) },
#endif
REGINFO_SENTINEL
};
diff --git a/target-arm/translate.c b/target-arm/translate.c
index c815fb3..4ebd9f7 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -6872,6 +6872,13 @@ static int disas_coproc_insn(CPUARMState * env, DisasContext *s, uint32_t insn)
return 1;
}
} else {
+ /* If Security Extensions are implemented NSACR controls non-secure
+ * access to cp10/cp11 (Bits [11:10]) */
+ if (arm_feature(env, ARM_FEATURE_SECURITY_EXTENSIONS) && IS_NS(s)
+ && (~env->cp15.c1_nsacr & (1 << cpnum))) {
+ return 1;
+ }
+
/* Bits [20:21] of CPACR control access to cp10
* Bits [23:22] of CPACR control access to cp11 */
switch ((env->cp15.c1_coproc >> (cpnum * 2)) & 3) {
--
1.8.3.2
next prev parent reply other threads:[~2014-05-13 16:18 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 16:15 [Qemu-devel] [PATCH v2 00/23] target-arm: add Security Extensions for CPUs Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 01/23] target-arm: add new CPU feature for Security Extensions Fabian Aggeler
2014-05-21 14:46 ` Peter Maydell
2014-05-21 16:14 ` Christopher Covington
2014-05-21 16:33 ` Sergey Fedorov
2014-05-21 16:41 ` Peter Maydell
2014-05-21 16:47 ` Sergey Fedorov
2014-05-21 14:51 ` Peter Maydell
2014-05-22 9:09 ` Aggeler Fabian
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 02/23] target-arm: move SCR into Security Extensions register list Fabian Aggeler
2014-05-14 14:19 ` Greg Bellows
2014-05-15 9:28 ` Aggeler Fabian
2014-05-21 14:57 ` Peter Maydell
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 03/23] target-arm: adjust TTBCR for Security Extension feature Fabian Aggeler
2014-05-21 16:06 ` Peter Maydell
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 04/23] target-arm: preserve RAO/WI bits of ARMv7 SCTLR Fabian Aggeler
2014-05-14 5:43 ` Sergey Fedorov
2014-05-21 16:12 ` Peter Maydell
2014-05-22 8:58 ` Aggeler Fabian
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 05/23] target-arm: add CPU Monitor mode Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 06/23] target-arm: add arm_is_secure() function Fabian Aggeler
2014-05-14 5:53 ` Sergey Fedorov
2014-05-14 14:42 ` Greg Bellows
2014-05-14 18:35 ` Fedorov Sergey
2014-05-14 20:22 ` Greg Bellows
2014-05-14 21:29 ` Peter Maydell
2014-05-14 22:22 ` Greg Bellows
2014-05-15 13:00 ` Aggeler Fabian
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 07/23] target-arm: reject switching to monitor mode from non-secure state Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 08/23] target-arm: adjust arm_current_pl() for Security Extensions Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 09/23] target-arm: add non-secure Translation Block flag Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 10/23] target-arm: implement CPACR register logic Fabian Aggeler
2014-05-14 6:06 ` Sergey Fedorov
2014-05-14 18:39 ` Fedorov Sergey
2014-05-15 14:44 ` Fabian Aggeler
2014-05-15 15:06 ` Sergey Fedorov
2014-05-14 13:09 ` Peter Crosthwaite
2014-05-13 16:15 ` Fabian Aggeler [this message]
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 12/23] target-arm: add SDER definition Fabian Aggeler
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 13/23] target-arm: Split TLB for secure state and EL3 in Aarch64 Fabian Aggeler
2014-05-14 6:15 ` Sergey Fedorov
2014-05-13 16:15 ` [Qemu-devel] [PATCH v2 14/23] target-arm: add banked coprocessor register type and macros Fabian Aggeler
2014-05-14 16:42 ` Greg Bellows
2014-05-15 9:02 ` Aggeler Fabian
2014-05-15 18:42 ` Sergey Fedorov
2014-05-15 19:10 ` Aggeler Fabian
2014-05-16 7:06 ` Sergey Fedorov
2014-05-22 7:41 ` Edgar E. Iglesias
2014-05-22 11:49 ` Aggeler Fabian
2014-05-22 12:18 ` Sergey Fedorov
2014-05-22 12:50 ` Aggeler Fabian
2014-05-22 22:21 ` Greg Bellows
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 15/23] target-arm: Restrict EL3 to Aarch32 state Fabian Aggeler
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 16/23] target-arm: Use arm_current_sctlr to access SCTLR Fabian Aggeler
2014-05-22 7:33 ` Edgar E. Iglesias
2014-05-22 14:56 ` Aggeler Fabian
2014-05-22 21:24 ` Edgar E. Iglesias
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 17/23] target-arm: Use raw_write/raw_read whenever possible Fabian Aggeler
2014-05-14 17:32 ` Greg Bellows
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 18/23] target-arm: Convert banked coprocessor registers Fabian Aggeler
2014-05-14 19:47 ` Greg Bellows
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 19/23] target-arm: maintain common bits of banked CP registers Fabian Aggeler
2014-05-14 21:20 ` Greg Bellows
2014-05-15 13:10 ` Aggeler Fabian
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 20/23] target-arm: add MVBAR support Fabian Aggeler
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 21/23] target-arm: implement SMC instruction Fabian Aggeler
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 22/23] target-arm: implement IRQ/FIQ routing to Monitor mode Fabian Aggeler
2014-05-13 16:16 ` [Qemu-devel] [PATCH v2 23/23] target-arm: Respect SCR.FW, SCR.AW and SCTLR.NMFI Fabian Aggeler
2014-05-15 18:57 ` [Qemu-devel] [PATCH v2 00/23] target-arm: add Security Extensions for CPUs Sergey Fedorov
2014-05-16 6:00 ` Aggeler Fabian
2014-05-16 20:56 ` Greg Bellows
2014-05-20 10:00 ` Aggeler Fabian
2014-05-20 15:43 ` Greg Bellows
2014-05-21 14:04 ` Peter Maydell
2014-05-21 13:55 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399997768-32014-12-git-send-email-aggelerf@ethz.ch \
--to=aggelerf@ethz.ch \
--cc=edgar.iglesias@gmail.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=s.fedorov@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).