From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Rob Herring" <rob.herring@linaro.org>,
"Laurent Desnogues" <laurent.desnogues@gmail.com>,
"Patch Tracking" <patches@linaro.org>,
"Michael Matz" <matz@suse.de>, "Alexander Graf" <agraf@suse.de>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
"Claudio Fontana" <claudio.fontana@linaro.org>,
"Dirk Mueller" <dmueller@suse.de>,
"Will Newton" <will.newton@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"kvmarm@lists.cs.columbia.edu" <kvmarm@lists.cs.columbia.edu>,
"Christoffer Dall" <christoffer.dall@linaro.org>,
"Richard Henderson" <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v2 30/35] target-arm: Implement AArch64 TTBR*
Date: Sun, 9 Feb 2014 12:38:36 +1000 [thread overview]
Message-ID: <CAEgOgz7p+mocWgQTCexhgW=Xx9j2NPoZe3WGN1B0xEHV5PA7Bw@mail.gmail.com> (raw)
In-Reply-To: <1391183143-30724-31-git-send-email-peter.maydell@linaro.org>
On Sat, Feb 1, 2014 at 1:45 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> Implement the AArch64 TTBR* registers. For v7 these were already 64 bits
> to handle LPAE, but implemented as two separate uint32_t fields.
> Combine them into a single uint64_t which can be used for all purposes.
> Since this requires touching every use, take the opportunity to rename
> the field to the architectural name.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> hw/arm/pxa2xx.c | 2 +-
> target-arm/cpu.h | 6 ++--
> target-arm/helper.c | 89 ++++++++++++++++++-----------------------------------
> 3 files changed, 33 insertions(+), 64 deletions(-)
>
> diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
> index bf9416a..88f0988 100644
> --- a/hw/arm/pxa2xx.c
> +++ b/hw/arm/pxa2xx.c
> @@ -276,7 +276,7 @@ static void pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri,
> ARM_CPU_MODE_SVC | CPSR_A | CPSR_F | CPSR_I;
> s->cpu->env.cp15.c1_sys = 0;
> s->cpu->env.cp15.c1_coproc = 0;
> - s->cpu->env.cp15.c2_base0 = 0;
> + s->cpu->env.cp15.ttbr0_el1 = 0;
> s->cpu->env.cp15.c3 = 0;
> s->pm_regs[PSSR >> 2] |= 0x8; /* Set STS */
> s->pm_regs[RCSR >> 2] |= 0x8; /* Set GPR */
> diff --git a/target-arm/cpu.h b/target-arm/cpu.h
> index 270e51e..3151329 100644
> --- a/target-arm/cpu.h
> +++ b/target-arm/cpu.h
> @@ -173,10 +173,8 @@ typedef struct CPUARMState {
> uint32_t c1_coproc; /* Coprocessor access register. */
> uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */
> uint32_t c1_scr; /* secure config register. */
> - uint32_t c2_base0; /* MMU translation table base 0. */
> - uint32_t c2_base0_hi; /* MMU translation table base 0, high 32 bits */
> - uint32_t c2_base1; /* MMU translation table base 0. */
> - uint32_t c2_base1_hi; /* MMU translation table base 1, high 32 bits */
> + uint64_t ttbr0_el1; /* MMU translation table base 0. */
> + uint32_t ttbr1_el1; /* MMU translation table base 1. */
> uint64_t c2_control; /* MMU translation table base control. */
> uint32_t c2_mask; /* MMU translation table base selection mask. */
> uint32_t c2_base_mask; /* MMU translation table base 0 mask. */
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 0dcd5de..a23b40d 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -1230,6 +1230,18 @@ static void vmsa_tcr_el1_write(CPUARMState *env, const ARMCPRegInfo *ri,
> env->cp15.c2_control = value;
> }
>
> +static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,
> + uint64_t value)
> +{
> + /* 64 bit accesses to the TTBRs can change the ASID and so we
> + * must flush the TLB.
> + */
> + if (cpreg_field_is_64bit(ri)) {
> + tlb_flush(env, 1);
> + }
> + raw_write(env, ri, value);
> +}
> +
> static const ARMCPRegInfo vmsa_cp_reginfo[] = {
> { .name = "DFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 0,
> .access = PL1_RW,
> @@ -1237,12 +1249,14 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
> { .name = "IFSR", .cp = 15, .crn = 5, .crm = 0, .opc1 = 0, .opc2 = 1,
> .access = PL1_RW,
> .fieldoffset = offsetof(CPUARMState, cp15.c5_insn), .resetvalue = 0, },
> - { .name = "TTBR0", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
> - .access = PL1_RW,
> - .fieldoffset = offsetof(CPUARMState, cp15.c2_base0), .resetvalue = 0, },
> - { .name = "TTBR1", .cp = 15, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 1,
> - .access = PL1_RW,
> - .fieldoffset = offsetof(CPUARMState, cp15.c2_base1), .resetvalue = 0, },
> + { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH,
> + .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
> + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el1),
> + .writefn = vmsa_ttbr_write, .resetvalue = 0 },
> + { .name = "TTBR1_EL1", .state = ARM_CP_STATE_BOTH,
> + .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 1,
> + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el1),
> + .writefn = vmsa_ttbr_write, .resetvalue = 0 },
> { .name = "TCR_EL1", .state = ARM_CP_STATE_AA64,
> .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 2,
> .access = PL1_RW, .writefn = vmsa_tcr_el1_write,
> @@ -1459,50 +1473,6 @@ static void par64_reset(CPUARMState *env, const ARMCPRegInfo *ri)
> env->cp15.c7_par = 0;
> }
>
> -static uint64_t ttbr064_read(CPUARMState *env, const ARMCPRegInfo *ri)
> -{
> - return ((uint64_t)env->cp15.c2_base0_hi << 32) | env->cp15.c2_base0;
> -}
> -
> -static void ttbr064_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
> - uint64_t value)
> -{
> - env->cp15.c2_base0_hi = value >> 32;
> - env->cp15.c2_base0 = value;
> -}
> -
> -static void ttbr064_write(CPUARMState *env, const ARMCPRegInfo *ri,
> - uint64_t value)
> -{
> - /* Writes to the 64 bit format TTBRs may change the ASID */
> - tlb_flush(env, 1);
> - ttbr064_raw_write(env, ri, value);
> -}
> -
> -static void ttbr064_reset(CPUARMState *env, const ARMCPRegInfo *ri)
> -{
> - env->cp15.c2_base0_hi = 0;
> - env->cp15.c2_base0 = 0;
> -}
> -
> -static uint64_t ttbr164_read(CPUARMState *env, const ARMCPRegInfo *ri)
> -{
> - return ((uint64_t)env->cp15.c2_base1_hi << 32) | env->cp15.c2_base1;
> -}
> -
> -static void ttbr164_write(CPUARMState *env, const ARMCPRegInfo *ri,
> - uint64_t value)
> -{
> - env->cp15.c2_base1_hi = value >> 32;
> - env->cp15.c2_base1 = value;
> -}
> -
> -static void ttbr164_reset(CPUARMState *env, const ARMCPRegInfo *ri)
> -{
> - env->cp15.c2_base1_hi = 0;
> - env->cp15.c2_base1 = 0;
> -}
> -
> static const ARMCPRegInfo lpae_cp_reginfo[] = {
> /* NOP AMAIR0/1: the override is because these clash with the rather
> * broadly specified TLB_LOCKDOWN entry in the generic cp_reginfo.
> @@ -1524,12 +1494,13 @@ static const ARMCPRegInfo lpae_cp_reginfo[] = {
> .access = PL1_RW, .type = ARM_CP_64BIT,
> .readfn = par64_read, .writefn = par64_write, .resetfn = par64_reset },
> { .name = "TTBR0", .cp = 15, .crm = 2, .opc1 = 0,
> - .access = PL1_RW, .type = ARM_CP_64BIT, .readfn = ttbr064_read,
> - .writefn = ttbr064_write, .raw_writefn = ttbr064_raw_write,
> - .resetfn = ttbr064_reset },
> + .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_NO_MIGRATE,
> + .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el1),
> + .writefn = vmsa_ttbr_write, .resetfn = arm_cp_reset_ignore },
> { .name = "TTBR1", .cp = 15, .crm = 2, .opc1 = 1,
> - .access = PL1_RW, .type = ARM_CP_64BIT, .readfn = ttbr164_read,
> - .writefn = ttbr164_write, .resetfn = ttbr164_reset },
> + .access = PL1_RW, .type = ARM_CP_64BIT | ARM_CP_NO_MIGRATE,
> + .fieldoffset = offsetof(CPUARMState, cp15.ttbr1_el1),
> + .writefn = vmsa_ttbr_write, .resetfn = arm_cp_reset_ignore },
> REGINFO_SENTINEL
> };
>
> @@ -2939,9 +2910,9 @@ static uint32_t get_level1_table_address(CPUARMState *env, uint32_t address)
> uint32_t table;
>
> if (address & env->cp15.c2_mask)
> - table = env->cp15.c2_base1 & 0xffffc000;
> + table = env->cp15.ttbr1_el1 & 0xffffc000;
> else
> - table = env->cp15.c2_base0 & env->cp15.c2_base_mask;
> + table = env->cp15.ttbr0_el1 & env->cp15.c2_base_mask;
>
> table |= (address >> 18) & 0x3ffc;
> return table;
> @@ -3214,11 +3185,11 @@ static int get_phys_addr_lpae(CPUARMState *env, uint32_t address,
> * we will always flush the TLB any time the ASID is changed).
> */
> if (ttbr_select == 0) {
> - ttbr = ((uint64_t)env->cp15.c2_base0_hi << 32) | env->cp15.c2_base0;
> + ttbr = env->cp15.ttbr0_el1;
> epd = extract32(env->cp15.c2_control, 7, 1);
> tsz = t0sz;
> } else {
> - ttbr = ((uint64_t)env->cp15.c2_base1_hi << 32) | env->cp15.c2_base1;
> + ttbr = env->cp15.ttbr1_el1;
> epd = extract32(env->cp15.c2_control, 23, 1);
> tsz = t1sz;
> }
> --
> 1.8.5
>
>
next prev parent reply other threads:[~2014-02-09 2:38 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 ` [Qemu-devel] [PATCH v2 19/35] target-arm: A64: Make cache ID registers visible to AArch64 Peter Maydell
2014-02-07 7:35 ` 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 [this message]
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='CAEgOgz7p+mocWgQTCexhgW=Xx9j2NPoZe3WGN1B0xEHV5PA7Bw@mail.gmail.com' \
--to=peter.crosthwaite@xilinx.com \
--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.maydell@linaro.org \
--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).