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 v3 01/31] target-arm: Fix raw read and write functions on AArch64 registers
Date: Sat, 15 Feb 2014 16:06:54 +0000 [thread overview]
Message-ID: <1392480444-25565-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1392480444-25565-1-git-send-email-peter.maydell@linaro.org>
The raw read and write functions were using the ARM_CP_64BIT flag in
ri->type to determine whether to treat the register's state field as
uint32_t or uint64_t; however AArch64 register info structs don't use
that flag. Abstract out the "how big is the field?" test into a
function and fix it to work for AArch64 registers. For this to work
we must ensure that the reginfo structs put into the hashtable have
the correct state field for their use, not the placeholder STATE_BOTH.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target-arm/cpu.c | 2 +-
target-arm/cpu.h | 8 ++++++++
target-arm/helper.c | 8 ++++++--
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/target-arm/cpu.c b/target-arm/cpu.c
index 6e7ce89..fe18b65 100644
--- a/target-arm/cpu.c
+++ b/target-arm/cpu.c
@@ -60,7 +60,7 @@ static void cp_reg_reset(gpointer key, gpointer value, gpointer opaque)
return;
}
- if (ri->type & ARM_CP_64BIT) {
+ if (cpreg_field_is_64bit(ri)) {
CPREG_FIELD64(&cpu->env, ri) = ri->resetvalue;
} else {
CPREG_FIELD32(&cpu->env, ri) = ri->resetvalue;
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 3c8a2db..4473fad 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -959,6 +959,14 @@ uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
*/
void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque);
+/* Return true if this reginfo struct's field in the cpu state struct
+ * is 64 bits wide.
+ */
+static inline bool cpreg_field_is_64bit(const ARMCPRegInfo *ri)
+{
+ return (ri->state == ARM_CP_STATE_AA64) || (ri->type & ARM_CP_64BIT);
+}
+
static inline bool cp_access_ok(int current_pl,
const ARMCPRegInfo *ri, int isread)
{
diff --git a/target-arm/helper.c b/target-arm/helper.c
index b547f04..1ecc55e 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -109,7 +109,7 @@ static int aarch64_fpu_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg)
static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
{
- if (ri->type & ARM_CP_64BIT) {
+ if (cpreg_field_is_64bit(ri)) {
return CPREG_FIELD64(env, ri);
} else {
return CPREG_FIELD32(env, ri);
@@ -119,7 +119,7 @@ static uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
static void raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
- if (ri->type & ARM_CP_64BIT) {
+ if (cpreg_field_is_64bit(ri)) {
CPREG_FIELD64(env, ri) = value;
} else {
CPREG_FIELD32(env, ri) = value;
@@ -1962,6 +1962,10 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
if (opaque) {
r2->opaque = opaque;
}
+ /* reginfo passed to helpers is correct for the actual access,
+ * and is never ARM_CP_STATE_BOTH:
+ */
+ r2->state = state;
/* Make sure reginfo passed to helpers for wildcarded regs
* has the correct crm/opc1/opc2 for this reg, not CP_ANY:
*/
--
1.8.5
next prev parent reply other threads:[~2014-02-15 16:07 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-15 16:06 [Qemu-devel] [PATCH v3 00/31] A64 system emulation prequisites Peter Maydell
2014-02-15 16:06 ` Peter Maydell [this message]
2014-02-26 0:17 ` [Qemu-devel] [PATCH v3 01/31] target-arm: Fix raw read and write functions on AArch64 registers Peter Crosthwaite
2014-02-15 16:06 ` [Qemu-devel] [PATCH v3 02/31] target-arm: A64: Make cache ID registers visible to AArch64 Peter Maydell
2014-02-15 16:06 ` [Qemu-devel] [PATCH v3 03/31] target-arm: Implement AArch64 CurrentEL sysreg Peter Maydell
2014-02-15 16:06 ` [Qemu-devel] [PATCH v3 04/31] target-arm: Implement AArch64 MIDR_EL1 Peter Maydell
2014-02-15 16:06 ` [Qemu-devel] [PATCH v3 05/31] target-arm: Implement AArch64 cache invalidate/clean ops Peter Maydell
2014-02-15 16:06 ` [Qemu-devel] [PATCH v3 06/31] target-arm: Implement AArch64 TLB invalidate ops Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 07/31] target-arm: Implement AArch64 dummy MDSCR_EL1 Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 08/31] target-arm: Implement AArch64 memory attribute registers Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 09/31] target-arm: Implement AArch64 SCTLR_EL1 Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 10/31] target-arm: Implement AArch64 TCR_EL1 Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 11/31] target-arm: Implement AArch64 VBAR_EL1 Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 12/31] target-arm: Implement AArch64 TTBR* Peter Maydell
2014-02-26 6:33 ` Hu Tao
2014-02-26 9:50 ` Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 13/31] target-arm: Implement AArch64 MPIDR Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 14/31] target-arm: Implement AArch64 generic timers Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 15/31] target-arm: Implement AArch64 ID and feature registers Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 16/31] target-arm: Implement AArch64 dummy breakpoint and watchpoint registers Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 17/31] target-arm: Implement AArch64 OSLAR_EL1 sysreg as WI Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 18/31] target-arm: Get MMU index information correct for A64 code Peter Maydell
2014-02-25 23:27 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 19/31] target-arm: A64: Implement WFI Peter Maydell
2014-02-25 23:20 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 20/31] target-arm: Store AIF bits in env->pstate for AArch32 Peter Maydell
2014-02-25 23:25 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 21/31] target-arm: Implement AArch64 DAIF system register Peter Maydell
2014-02-17 0:17 ` Peter Crosthwaite
2014-02-17 8:51 ` Peter Maydell
2014-02-28 13:48 ` Peter Maydell
2014-02-28 23:32 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 22/31] target-arm: A64: Implement MSR (immediate) instructions Peter Maydell
2014-02-25 8:32 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 23/31] target-arm: Implement AArch64 view of CPACR Peter Maydell
2014-02-25 8:34 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 24/31] target-arm: Add utility function for checking AA32/64 state of an EL Peter Maydell
2014-02-25 8:36 ` Peter Crosthwaite
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 25/31] target-arm: Define exception record for AArch64 exceptions Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 26/31] target-arm: Provide correct syndrome information for cpreg access traps Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 27/31] target-arm: Add support for generating exceptions with syndrome information Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 28/31] target-arm: A64: Correctly fault FP/Neon if CPACR.FPEN set Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 29/31] target-arm: A64: Add assertion that FP access was checked Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 30/31] target-arm: Fix VFP enables for AArch32 EL0 under AArch64 EL1 Peter Maydell
2014-02-15 16:07 ` [Qemu-devel] [PATCH v3 31/31] target-arm: Add v8 mmu translation support Peter Maydell
2014-02-26 2:49 ` Hu Tao
2014-02-26 3:32 ` Hu Tao
2014-02-26 10:31 ` Peter Maydell
2014-02-26 19:47 ` Rob Herring
2014-03-01 19:58 ` Peter Maydell
2014-02-25 20:16 ` [Qemu-devel] [PATCH v3 00/31] A64 system emulation prequisites 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=1392480444-25565-2-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).