qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Blue Swirl <blauwirbel@gmail.com>
Cc: qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
	Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH 10/33] target-arm: Convert WFI/barriers special cases to cp_reginfo
Date: Wed, 20 Jun 2012 13:26:58 +0100	[thread overview]
Message-ID: <1340195241-16620-11-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1340195241-16620-1-git-send-email-peter.maydell@linaro.org>

Convert the various WFI and barrier instruction special cases to use
cp_reginfo infrastructure.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/helper.c    |   42 +++++++++++++++++++++++++++++++++++++++
 target-arm/translate.c |   51 ------------------------------------------------
 2 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/target-arm/helper.c b/target-arm/helper.c
index c003fe0..c7addea 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -66,6 +66,38 @@ static const ARMCPRegInfo cp_reginfo[] = {
     REGINFO_SENTINEL
 };
 
+static const ARMCPRegInfo not_v6_cp_reginfo[] = {
+    /* Not all pre-v6 cores implemented this WFI, so this is slightly
+     * over-broad.
+     */
+    { .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2,
+      .access = PL1_W, .type = ARM_CP_WFI },
+    REGINFO_SENTINEL
+};
+
+static const ARMCPRegInfo not_v7_cp_reginfo[] = {
+    /* Standard v6 WFI (also used in some pre-v6 cores); not in v7 (which
+     * is UNPREDICTABLE; we choose to NOP as most implementations do).
+     */
+    { .name = "WFI_v6", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4,
+      .access = PL1_W, .type = ARM_CP_WFI },
+    REGINFO_SENTINEL
+};
+
+static const ARMCPRegInfo v6_cp_reginfo[] = {
+    /* prefetch by MVA in v6, NOP in v7 */
+    { .name = "MVA_prefetch",
+      .cp = 15, .crn = 7, .crm = 13, .opc1 = 0, .opc2 = 1,
+      .access = PL1_W, .type = ARM_CP_NOP },
+    { .name = "ISB", .cp = 15, .crn = 7, .crm = 5, .opc1 = 0, .opc2 = 4,
+      .access = PL0_W, .type = ARM_CP_NOP },
+    { .name = "ISB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 4,
+      .access = PL0_W, .type = ARM_CP_NOP },
+    { .name = "ISB", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 5,
+      .access = PL0_W, .type = ARM_CP_NOP },
+    REGINFO_SENTINEL
+};
+
 static const ARMCPRegInfo v7_cp_reginfo[] = {
     /* DBGDRAR, DBGDSAR: always RAZ since we don't implement memory mapped
      * debug components
@@ -74,6 +106,9 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
       .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
     { .name = "DBGDRAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
       .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
+    /* the old v6 WFI, UNPREDICTABLE in v7 but we choose to NOP */
+    { .name = "NOP", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4,
+      .access = PL1_W, .type = ARM_CP_NOP },
     REGINFO_SENTINEL
 };
 
@@ -129,8 +164,15 @@ void register_cp_regs_for_features(ARMCPU *cpu)
     }
 
     define_arm_cp_regs(cpu, cp_reginfo);
+    if (arm_feature(env, ARM_FEATURE_V6)) {
+        define_arm_cp_regs(cpu, v6_cp_reginfo);
+    } else {
+        define_arm_cp_regs(cpu, not_v6_cp_reginfo);
+    }
     if (arm_feature(env, ARM_FEATURE_V7)) {
         define_arm_cp_regs(cpu, v7_cp_reginfo);
+    } else {
+        define_arm_cp_regs(cpu, not_v7_cp_reginfo);
     }
     if (arm_feature(env, ARM_FEATURE_THUMB2EE)) {
         define_arm_cp_regs(cpu, t2ee_cp_reginfo);
diff --git a/target-arm/translate.c b/target-arm/translate.c
index ba1bb94..a4429ea 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -2541,57 +2541,6 @@ static int disas_cp15_insn(CPUARMState *env, DisasContext *s, uint32_t insn)
         /* cdp */
         return 1;
     }
-    /* We special case a number of cp15 instructions which were used
-     * for things which are real instructions in ARMv7. This allows
-     * them to work in linux-user mode which doesn't provide functional
-     * get_cp15/set_cp15 helpers, and is more efficient anyway.
-     */
-    switch ((insn & 0x0fff0fff)) {
-    case 0x0e070f90:
-        /* 0,c7,c0,4: Standard v6 WFI (also used in some pre-v6 cores).
-         * In v7, this must NOP.
-         */
-        if (IS_USER(s)) {
-            return 1;
-        }
-        if (!arm_feature(env, ARM_FEATURE_V7)) {
-            /* Wait for interrupt.  */
-            gen_set_pc_im(s->pc);
-            s->is_jmp = DISAS_WFI;
-        }
-        return 0;
-    case 0x0e070f58:
-        /* 0,c7,c8,2: Not all pre-v6 cores implemented this WFI,
-         * so this is slightly over-broad.
-         */
-        if (!IS_USER(s) && !arm_feature(env, ARM_FEATURE_V6)) {
-            /* Wait for interrupt.  */
-            gen_set_pc_im(s->pc);
-            s->is_jmp = DISAS_WFI;
-            return 0;
-        }
-        /* Otherwise continue to handle via helper function.
-         * In particular, on v7 and some v6 cores this is one of
-         * the VA-PA registers.
-         */
-        break;
-    case 0x0e070f3d:
-        /* 0,c7,c13,1: prefetch-by-MVA in v6, NOP in v7 */
-        if (arm_feature(env, ARM_FEATURE_V6)) {
-            return IS_USER(s) ? 1 : 0;
-        }
-        break;
-    case 0x0e070f95: /* 0,c7,c5,4 : ISB */
-    case 0x0e070f9a: /* 0,c7,c10,4: DSB */
-    case 0x0e070fba: /* 0,c7,c10,5: DMB */
-        /* Barriers in both v6 and v7 */
-        if (arm_feature(env, ARM_FEATURE_V6)) {
-            return 0;
-        }
-        break;
-    default:
-        break;
-    }
 
     if (IS_USER(s) && !cp15_user_ok(env, insn)) {
         return 1;
-- 
1.7.1

  parent reply	other threads:[~2012-06-20 12:27 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-20 12:26 [Qemu-devel] [PULL 00/33] target-arm queue Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 01/33] target-arm: Fix 11MPCore cache type register value Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 02/33] target-arm: initial coprocessor register framework Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 03/33] hw/pxa2xx: Convert cp14 perf registers to new scheme Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 04/33] hw/pxa2xx.c: Convert CLKCFG and PWRMODE cp14 regs Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 05/33] hw/pxa2xx_pic: Convert coprocessor registers to new scheme Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 06/33] target-arm: Remove old cpu_arm_set_cp_io infrastructure Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 07/33] target-arm: Add register_cp_regs_for_features() Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 08/33] target-arm: Convert debug registers to cp_reginfo Peter Maydell
2012-06-20 12:26 ` [Qemu-devel] [PATCH 09/33] target-arm: Convert TEECR, TEEHBR to new scheme Peter Maydell
2012-06-20 12:26 ` Peter Maydell [this message]
2012-06-20 12:26 ` [Qemu-devel] [PATCH 11/33] target-arm: Convert TLS registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 12/33] target-arm: Convert performance monitor registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 13/33] target-arm: Convert generic timer cp15 regs Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 14/33] target-arm: Convert cp15 c3 register Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 15/33] target-arm: Convert MMU fault status cp15 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 16/33] target-arm: Convert cp15 crn=2 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 17/33] target-arm: Convert cp15 crn=13 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 18/33] target-arm: Convert cp15 crn=10 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 19/33] target-arm: Convert cp15 crn=15 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 20/33] target-arm: Convert cp15 MMU TLB control Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 21/33] target-arm: Convert cp15 VA-PA translation registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 22/33] target-arm: convert cp15 crn=7 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 23/33] target-arm: Convert cp15 crn=6 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 24/33] target-arm: Convert cp15 crn=9 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 25/33] target-arm: Convert cp15 crn=1 registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 26/33] target-arm: Convert cp15 crn=0 crm={1, 2} feature registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 27/33] target-arm: Convert cp15 cache ID registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 28/33] target-arm: Convert MPIDR Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 29/33] target-arm: Convert final ID registers Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 30/33] target-arm: Remove c0_cachetype CPUARMState field Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 31/33] target-arm: Move block cache ops to new cp15 framework Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 32/33] target-arm: Remove remaining old cp15 infrastructure Peter Maydell
2012-06-20 12:27 ` [Qemu-devel] [PATCH 33/33] target-arm: Remove ARM_CPUID_* macros Peter Maydell
2012-06-24 12:27 ` [Qemu-devel] [PULL 00/33] target-arm queue Blue Swirl

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=1340195241-16620-11-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=anthony@codemonkey.ws \
    --cc=blauwirbel@gmail.com \
    --cc=paul@codesourcery.com \
    --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 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).