From: Peter Maydell <peter.maydell@linaro.org>
To: Anthony Liguori <aliguori@amazon.com>
Cc: Blue Swirl <blauwirbel@gmail.com>,
qemu-devel@nongnu.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PULL 15/45] target-arm: A64: Make cache ID registers visible to AArch64
Date: Wed, 26 Feb 2014 18:02:05 +0000 [thread overview]
Message-ID: <1393437755-23586-16-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1393437755-23586-1-git-send-email-peter.maydell@linaro.org>
Make the cache ID system registers (CLIDR, CSSELR, 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>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
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 4473fad..8c4ed0f 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 965a338..2fdf3a7 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.9.0
next prev parent reply other threads:[~2014-02-26 18:02 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 18:01 [Qemu-devel] [PULL 00/45] target-arm queue Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 01/45] hw/misc/arm_sysctl: Fix bad boundary check on mb clock accesses Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 02/45] hw/net/stellaris_enet: Avoid unintended sign extension Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 03/45] hw/timer/arm_timer: Avoid array overrun for bad addresses Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 04/45] target-arm: Fix incorrect arithmetic constructing short-form PAR for ATS ops Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 05/45] hw/intc/exynos4210_combiner: Don't overrun output_irq array in init Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 06/45] hw/arm/musicpal: Remove nonexistent CDTP2, CDTP3 registers Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 07/45] target-arm: Load correct access bits from ARMv5 level 2 page table descriptors Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 08/45] hw/intc/arm_gic: Fix GIC_SET_LEVEL Peter Maydell
2014-02-26 18:01 ` [Qemu-devel] [PULL 09/45] linux-headers: Update from v3.14-rc3 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 10/45] kvm: Introduce kvm_arch_irqchip_create Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 11/45] kvm: Common device control API functions Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 12/45] arm: vgic device control api support Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 13/45] hw: arm_gic_kvm: Add KVM VGIC save/restore logic Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 14/45] target-arm: Fix raw read and write functions on AArch64 registers Peter Maydell
2014-02-26 18:02 ` Peter Maydell [this message]
2014-02-26 18:02 ` [Qemu-devel] [PULL 16/45] target-arm: Implement AArch64 CurrentEL sysreg Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 17/45] target-arm: Implement AArch64 MIDR_EL1 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 18/45] target-arm: Implement AArch64 cache invalidate/clean ops Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 19/45] target-arm: Implement AArch64 TLB invalidate ops Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 20/45] target-arm: Implement AArch64 dummy MDSCR_EL1 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 21/45] target-arm: Implement AArch64 memory attribute registers Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 22/45] target-arm: Implement AArch64 SCTLR_EL1 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 23/45] target-arm: Implement AArch64 TCR_EL1 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 24/45] target-arm: Implement AArch64 VBAR_EL1 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 25/45] target-arm: Implement AArch64 TTBR* Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 26/45] target-arm: Implement AArch64 MPIDR Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 27/45] target-arm: Implement AArch64 generic timers Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 28/45] target-arm: Implement AArch64 ID and feature registers Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 29/45] target-arm: Implement AArch64 dummy breakpoint and watchpoint registers Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 30/45] target-arm: Implement AArch64 OSLAR_EL1 sysreg as WI Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 31/45] target-arm: Get MMU index information correct for A64 code Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 32/45] target-arm: A64: Implement WFI Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 33/45] target-arm: Store AIF bits in env->pstate for AArch32 Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 34/45] target-arm: A64: Implement MSR (immediate) instructions Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 35/45] target-arm: Implement AArch64 view of CPACR Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 36/45] target-arm: Add utility function for checking AA32/64 state of an EL Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 37/45] include/qemu/crc32c.h: Rename include guards to match filename Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 38/45] target-arm: Add support for AArch32 ARMv8 CRC32 instructions Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 39/45] dma/pl330: Delete overly verbose debug printf Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 40/45] dma/pl330: Fix misleading type Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 41/45] dma/pl330: printf format type sweep Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 42/45] dma/pl330: Rename parent_obj Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 43/45] dma/pl330: Add event debugging printfs Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 44/45] dma/pl330: Fix buffer depth Peter Maydell
2014-02-26 18:02 ` [Qemu-devel] [PULL 45/45] dma/pl330: implement dmaadnh instruction Peter Maydell
2014-02-27 11:33 ` [Qemu-devel] [PULL 00/45] 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=1393437755-23586-16-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aliguori@amazon.com \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.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).