qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Rob Herring" <rob.herring@linaro.org>,
	"Peter Crosthwaite" <peter.crosthwaite@xilinx.com>,
	patches@linaro.org, "Michael Matz" <matz@suse.de>,
	"Alexander Graf" <agraf@suse.de>,
	"Claudio Fontana" <claudio.fontana@linaro.org>,
	"Dirk Mueller" <dmueller@suse.de>,
	"Will Newton" <will.newton@linaro.org>,
	"Laurent Desnogues" <laurent.desnogues@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	kvmarm@lists.cs.columbia.edu,
	"Christoffer Dall" <christoffer.dall@linaro.org>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v2 19/35] target-arm: A64: Make cache ID registers visible to AArch64
Date: Fri, 31 Jan 2014 15:45:27 +0000	[thread overview]
Message-ID: <1391183143-30724-20-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1391183143-30724-1-git-send-email-peter.maydell@linaro.org>

Make the cache ID system registers (CLIDR, CCSELR, CCSIDR, CTR)
visible to AArch64. These are mostly simple 64-bit extensions of the
existing 32 bit system registers and so can share reginfo definitions.
CTR needs to have a split definition, but we can clean up the
temporary user-mode implementation in favour of using the CPU-specified
reset value, and implement the system-mode-required semantics of
restricting its EL0 accessibility if SCTLR.UCT is not set.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/cpu.c    |  2 ++
 target-arm/cpu.h    |  2 +-
 target-arm/cpu64.c  |  1 +
 target-arm/helper.c | 31 +++++++++++++++++++++----------
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index fe18b65..8fed098 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -91,6 +91,8 @@ static void arm_cpu_reset(CPUState *s)
         env->aarch64 = 1;
 #if defined(CONFIG_USER_ONLY)
         env->pstate = PSTATE_MODE_EL0t;
+        /* Userspace expects access to CTL_EL0 */
+        env->cp15.c1_sys |= SCTLR_UCT;
 #else
         env->pstate = PSTATE_D | PSTATE_A | PSTATE_I | PSTATE_F
             | PSTATE_MODE_EL1h;
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index d1ed423..f5b706e 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -166,7 +166,7 @@ typedef struct CPUARMState {
     /* System control coprocessor (cp15) */
     struct {
         uint32_t c0_cpuid;
-        uint32_t c0_cssel; /* Cache size selection.  */
+        uint64_t c0_cssel; /* Cache size selection.  */
         uint32_t c1_sys; /* System control register.  */
         uint32_t c1_coproc; /* Coprocessor access register.  */
         uint32_t c1_xscaleauxcr; /* XScale auxiliary control register.  */
diff --git a/target-arm/cpu64.c b/target-arm/cpu64.c
index a639c2e..8426bf1 100644
--- a/target-arm/cpu64.c
+++ b/target-arm/cpu64.c
@@ -45,6 +45,7 @@ static void aarch64_any_initfn(Object *obj)
     set_feature(&cpu->env, ARM_FEATURE_ARM_DIV);
     set_feature(&cpu->env, ARM_FEATURE_V7MP);
     set_feature(&cpu->env, ARM_FEATURE_AARCH64);
+    cpu->ctr = 0x80030003; /* 32 byte I and D cacheline size, VIPT icache */
 }
 #endif
 
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 06331dd..f46dd0f 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -629,9 +629,11 @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
     { .name = "SCR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0,
       .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_scr),
       .resetvalue = 0, },
-    { .name = "CCSIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0,
+    { .name = "CCSIDR", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 0,
       .access = PL1_R, .readfn = ccsidr_read, .type = ARM_CP_NO_MIGRATE },
-    { .name = "CSSELR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0,
+    { .name = "CSSELR", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 2, .opc2 = 0,
       .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c0_cssel),
       .writefn = csselr_write, .resetvalue = 0 },
     /* Auxiliary ID register: this actually has an IMPDEF value but for now
@@ -1524,13 +1526,6 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
     { .name = "FPSR", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 4, .crm = 4,
       .access = PL0_RW, .readfn = aa64_fpsr_read, .writefn = aa64_fpsr_write },
-    /* This claims a 32 byte cacheline size for icache and dcache, VIPT icache.
-     * It will eventually need to have a CPU-specified reset value.
-     */
-    { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64,
-      .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0,
-      .access = PL0_R, .type = ARM_CP_CONST,
-      .resetvalue = 0x80030003 },
     /* Prohibit use of DC ZVA. OPTME: implement DC ZVA and allow its use.
      * For system mode the DZP bit here will need to be computed, not constant.
      */
@@ -1550,6 +1545,17 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
     tlb_flush(env, 1);
 }
 
+static CPAccessResult ctr_el0_access(CPUARMState *env, const ARMCPRegInfo *ri)
+{
+    /* Only accessible in EL0 if SCTLR.UCT is set (and only in AArch64,
+     * but the AArch32 CTR has its own reginfo struct)
+     */
+    if (arm_current_pl(env) == 0 && !(env->cp15.c1_sys & SCTLR_UCT)) {
+        return CP_ACCESS_TRAP;
+    }
+    return CP_ACCESS_OK;
+}
+
 void register_cp_regs_for_features(ARMCPU *cpu)
 {
     /* Register all the coprocessor registers based on feature bits */
@@ -1634,7 +1640,8 @@ void register_cp_regs_for_features(ARMCPU *cpu)
             .raw_writefn = raw_write,
         };
         ARMCPRegInfo clidr = {
-            .name = "CLIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1,
+            .name = "CLIDR", .state = ARM_CP_STATE_BOTH,
+            .opc0 = 3, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = 1,
             .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->clidr
         };
         define_one_arm_cp_reg(cpu, &pmcr);
@@ -1713,6 +1720,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)
             { .name = "CTR",
               .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 1,
               .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = cpu->ctr },
+            { .name = "CTR_EL0", .state = ARM_CP_STATE_AA64,
+              .opc0 = 3, .opc1 = 3, .opc2 = 1, .crn = 0, .crm = 0,
+              .access = PL0_R, .accessfn = ctr_el0_access,
+              .type = ARM_CP_CONST, .resetvalue = cpu->ctr },
             { .name = "TCMTR",
               .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 2,
               .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
-- 
1.8.5

  parent reply	other threads:[~2014-01-31 15:58 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-31 15:45 [Qemu-devel] [PATCH v2 00/35] AArch64 system mode: system register rework Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 01/35] target-arm: Fix raw read and write functions on AArch64 registers Peter Maydell
2014-01-31 15:56   ` Rob Herring
2014-01-31 16:06     ` Peter Maydell
2014-01-31 16:38       ` Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 02/35] target-arm/kvm-consts.h: Define QEMU constants for known KVM CPUs Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 03/35] target-arm: Define names for SCTLR bits Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 04/35] target-arm: Restrict check_ap() use of S and R bits to v6 and earlier Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 05/35] target-arm: Remove unused ARMCPUState sr substruct Peter Maydell
2014-02-05  6:03   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 06/35] target-arm: Log bad system register accesses with LOG_UNIMP Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 07/35] target-arm: Add exception level to the AArch64 TB flags Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 08/35] target-arm: A64: Implement store-exclusive for system mode Peter Maydell
2014-02-11 18:43   ` Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 09/35] target-arm: A64: Implement MSR (immediate) instructions Peter Maydell
2014-02-05  6:23   ` Peter Crosthwaite
2014-02-05 10:55     ` Peter Maydell
2014-02-14 16:41     ` Peter Maydell
2014-02-14 23:07       ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 10/35] target-arm: Stop underdecoding ARM946 PRBS registers Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 11/35] target-arm: Split cpreg access checks out from read/write functions Peter Maydell
2014-02-09  2:50   ` Peter Crosthwaite
2014-02-09 12:02     ` Peter Maydell
2014-02-11  6:13       ` Peter Crosthwaite
2014-02-11  6:13   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 12/35] target-arm: Convert performance monitor reginfo to accesfn Peter Maydell
2014-02-05  6:59   ` Peter Crosthwaite
2014-02-05 11:01     ` Peter Maydell
2014-02-06  0:05       ` Alistair Francis
2014-02-09  2:59       ` Peter Crosthwaite
2014-02-09 12:04         ` Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 13/35] target-arm: Convert generic timer reginfo to accessfn Peter Maydell
2014-02-09  3:05   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 14/35] target-arm: Convert miscellaneous reginfo structs " Peter Maydell
2014-02-09  3:09   ` Peter Crosthwaite
2014-02-09 12:09     ` Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 15/35] target-arm: Drop success/fail return from cpreg read and write functions Peter Maydell
2014-02-09  3:27   ` Peter Crosthwaite
2014-02-09 12:15     ` Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 16/35] target-arm: Remove unnecessary code now read/write fns can't fail Peter Maydell
2014-02-09  3:29   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 17/35] target-arm: Remove failure status return from read/write_raw_cp_reg Peter Maydell
2014-02-09  3:32   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 18/35] target-arm: Fix incorrect type for value argument to write_raw_cp_reg Peter Maydell
2014-02-05  7:07   ` Peter Crosthwaite
2014-01-31 15:45 ` Peter Maydell [this message]
2014-02-07  7:35   ` [Qemu-devel] [PATCH v2 19/35] target-arm: A64: Make cache ID registers visible to AArch64 Hu Tao
2014-02-07 10:27     ` Peter Maydell
2014-02-11  8:38       ` Hu Tao
2014-02-09  2:15   ` Peter Crosthwaite
2014-02-09 11:52     ` Peter Maydell
2014-02-09 21:01       ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 20/35] target-arm: Implement AArch64 CurrentEL sysreg Peter Maydell
2014-02-09  2:17   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 21/35] target-arm: Implement AArch64 MIDR_EL1 Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 22/35] target-arm: Implement AArch64 DAIF system register Peter Maydell
2014-02-09  2:20   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 23/35] target-arm: Implement AArch64 cache invalidate/clean ops Peter Maydell
2014-02-06 11:45   ` Peter Maydell
2014-02-09  2:22   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 24/35] target-arm: Implement AArch64 TLB invalidate ops Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 25/35] target-arm: Implement AArch64 dummy MDSCR_EL1 Peter Maydell
2014-02-09  2:27   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 26/35] target-arm: Implement AArch64 memory attribute registers Peter Maydell
2014-02-09  2:31   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 27/35] target-arm: Implement AArch64 SCTLR_EL1 Peter Maydell
2014-02-09  2:32   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 28/35] target-arm: Implement AArch64 TCR_EL1 Peter Maydell
2014-02-09  2:35   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 29/35] target-arm: Implement AArch64 VBAR_EL1 Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 30/35] target-arm: Implement AArch64 TTBR* Peter Maydell
2014-02-09  2:38   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 31/35] target-arm: Implement AArch64 MPIDR Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 32/35] target-arm: Implement AArch64 generic timers Peter Maydell
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 33/35] target-arm: Implement AArch64 ID and feature registers Peter Maydell
2014-02-09  2:42   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 34/35] target-arm: Implement AArch64 dummy breakpoint and watchpoint registers Peter Maydell
2014-02-09  2:44   ` Peter Crosthwaite
2014-01-31 15:45 ` [Qemu-devel] [PATCH v2 35/35] target-arm: Implement AArch64 OSLAR_EL1 sysreg as WI Peter Maydell
2014-02-09  2:44   ` Peter Crosthwaite
2014-02-11  6:11 ` [Qemu-devel] [PATCH v2 00/35] AArch64 system mode: system register rework Peter Crosthwaite
2014-02-11  9:05   ` Peter Maydell
2014-02-11 17:12 ` 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=1391183143-30724-20-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=agraf@suse.de \
    --cc=alex.bennee@linaro.org \
    --cc=christoffer.dall@linaro.org \
    --cc=claudio.fontana@linaro.org \
    --cc=dmueller@suse.de \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=laurent.desnogues@gmail.com \
    --cc=matz@suse.de \
    --cc=patches@linaro.org \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rob.herring@linaro.org \
    --cc=rth@twiddle.net \
    --cc=will.newton@linaro.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).