All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 05/33] target-arm: add banked register accessors
Date: Thu, 11 Dec 2014 12:19:27 +0000	[thread overview]
Message-ID: <1418300395-4348-6-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1418300395-4348-1-git-send-email-peter.maydell@linaro.org>

From: Fabian Aggeler <aggelerf@ethz.ch>

If EL3 is in AArch32 state certain cp registers are banked (secure and
non-secure instance). When reading or writing to coprocessor registers
the following macros can be used.

- A32_BANKED macros are used for choosing the banked register based on provided
  input security argument.  This macro is used to choose the bank during
  translation of MRC/MCR instructions that are dependent on something other
  than the current secure state.
- A32_BANKED_CURRENT macros are used for choosing the banked register based on
  current secure state.  This is NOT to be used for choosing the bank used
  during translation as it breaks monitor mode.

If EL3 is operating in AArch64 state coprocessor registers are not
banked anymore. The macros use the non-secure instance (_ns) in this
case, which is architecturally mapped to the AArch64 EL register.

Signed-off-by: Sergey Fedorov <s.fedorov@samsung.com>
Signed-off-by: Fabian Aggeler <aggelerf@ethz.ch>
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1416242878-876-4-git-send-email-greg.bellows@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/cpu.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 810cc0b..1ad5d38 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -817,6 +817,33 @@ static inline bool arm_el_is_aa64(CPUARMState *env, int el)
     return arm_feature(env, ARM_FEATURE_AARCH64);
 }
 
+/* Macros for accessing a specified CP register bank */
+#define A32_BANKED_REG_GET(_env, _regname, _secure)    \
+    ((_secure) ? (_env)->cp15._regname##_s : (_env)->cp15._regname##_ns)
+
+#define A32_BANKED_REG_SET(_env, _regname, _secure, _val)   \
+    do {                                                \
+        if (_secure) {                                   \
+            (_env)->cp15._regname##_s = (_val);            \
+        } else {                                        \
+            (_env)->cp15._regname##_ns = (_val);           \
+        }                                               \
+    } while (0)
+
+/* Macros for automatically accessing a specific CP register bank depending on
+ * the current secure state of the system.  These macros are not intended for
+ * supporting instruction translation reads/writes as these are dependent
+ * solely on the SCR.NS bit and not the mode.
+ */
+#define A32_BANKED_CURRENT_REG_GET(_env, _regname)        \
+    A32_BANKED_REG_GET((_env), _regname,                \
+                       ((!arm_el_is_aa64((_env), 3) && arm_is_secure(_env))))
+
+#define A32_BANKED_CURRENT_REG_SET(_env, _regname, _val)                       \
+    A32_BANKED_REG_SET((_env), _regname,                                    \
+                       ((!arm_el_is_aa64((_env), 3) && arm_is_secure(_env))),  \
+                       (_val))
+
 void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 unsigned int arm_excp_target_el(CPUState *cs, unsigned int excp_idx);
 
-- 
1.9.1

  parent reply	other threads:[~2014-12-11 12:20 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 12:19 [Qemu-devel] [PULL 00/33] target-arm queue Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 01/33] Pass semihosting exit code back to system Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 02/33] Add the "-semihosting-config" option Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 03/33] target-arm: extend async excp masking Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 04/33] target-arm: add async excp target_el function Peter Maydell
2014-12-11 12:19 ` Peter Maydell [this message]
2014-12-11 12:19 ` [Qemu-devel] [PULL 06/33] target-arm: add non-secure Translation Block flag Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 07/33] target-arm: add CPREG secure state support Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 08/33] target-arm: add secure state bit to CPREG hash Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 09/33] target-arm: insert AArch32 cpregs twice into hashtable Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 10/33] target-arm: move AArch32 SCR into security reglist Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 11/33] target-arm: implement IRQ/FIQ routing to Monitor mode Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 12/33] target-arm: add NSACR register Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 13/33] target-arm: add SDER definition Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 14/33] target-arm: add MVBAR support Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 15/33] target-arm: add SCTLR_EL3 and make SCTLR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 16/33] target-arm: respect SCR.FW, SCR.AW and SCTLR.NMFI Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 17/33] target-arm: make CSSELR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 18/33] target-arm: make TTBR0/1 banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 19/33] target-arm: make TTBCR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 20/33] target-arm: make DACR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 21/33] target-arm: make IFSR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 22/33] target-arm: make DFSR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 23/33] target-arm: make IFAR/DFAR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 24/33] target-arm: make PAR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 25/33] target-arm: make VBAR banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 26/33] target-arm: make c13 cp regs banked (FCSEIDR, ...) Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 27/33] target-arm: make MAIR0/1 banked Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 28/33] hw/arm/realview.c: Fix memory leak in realview_init() Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 29/33] hw/arm/boot: fix uninitialized scalar variable warning reported by coverity Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 30/33] arm_gic_kvm: Tell kernel about number of IRQs Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 31/33] target-arm/kvm: make reg sync code common between kvm32/64 Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 32/33] target-arm: Support save/load for 64 bit CPUs Peter Maydell
2014-12-11 12:19 ` [Qemu-devel] [PULL 33/33] target-arm: Check error conditions on kvm_arm_reset_vcpu Peter Maydell
2014-12-11 18:26 ` [Qemu-devel] [PULL 00/33] target-arm queue 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=1418300395-4348-6-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.