qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: "qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	Edgar Iglesias <edgar.iglesias@xilinx.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>,
	Francisco Iglesias <frasse.iglesias@gmail.com>,
	Alistair Francis <alistair@alistair23.me>,
	Richard Henderson <richard.henderson@linaro.org>,
	KONRAD Frederic <frederic.konrad@adacore.com>
Subject: Re: [Qemu-devel] [PATCH v3 29/38] target-microblaze: Add support for extended access to TLBLO
Date: Wed, 16 May 2018 16:48:41 -0700	[thread overview]
Message-ID: <CAKmqyKOMET_kAzCrf7jsUrW04Dni+9OsDR2CruqmmAv_Nq0Hmg@mail.gmail.com> (raw)
In-Reply-To: <20180516185146.30708-30-edgar.iglesias@gmail.com>

On Wed, May 16, 2018 at 11:51 AM, Edgar E. Iglesias
<edgar.iglesias@gmail.com> wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Add support for extended access to TLBLO's upper 32 bits.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/microblaze/helper.h    |  4 ++--
>  target/microblaze/mmu.c       | 18 ++++++++++++++----
>  target/microblaze/mmu.h       |  4 ++--
>  target/microblaze/op_helper.c |  8 ++++----
>  target/microblaze/translate.c | 19 +++++++++++++------
>  5 files changed, 35 insertions(+), 18 deletions(-)
>
> diff --git a/target/microblaze/helper.h b/target/microblaze/helper.h
> index ce70353936..2f8bdea22b 100644
> --- a/target/microblaze/helper.h
> +++ b/target/microblaze/helper.h
> @@ -25,8 +25,8 @@ DEF_HELPER_3(fcmp_ge, i32, env, i32, i32)
>
>  DEF_HELPER_FLAGS_2(pcmpbf, TCG_CALL_NO_RWG_SE, i32, i32, i32)
>  #if !defined(CONFIG_USER_ONLY)
> -DEF_HELPER_2(mmu_read, i32, env, i32)
> -DEF_HELPER_3(mmu_write, void, env, i32, i32)
> +DEF_HELPER_3(mmu_read, i32, env, i32, i32)
> +DEF_HELPER_4(mmu_write, void, env, i32, i32, i32)
>  #endif
>
>  DEF_HELPER_5(memalign, void, env, tl, i32, i32, i32)
> diff --git a/target/microblaze/mmu.c b/target/microblaze/mmu.c
> index 166c79908c..9ecffb2c9c 100644
> --- a/target/microblaze/mmu.c
> +++ b/target/microblaze/mmu.c
> @@ -180,7 +180,7 @@ done:
>  }
>
>  /* Writes/reads to the MMU's special regs end up here.  */
> -uint32_t mmu_read(CPUMBState *env, uint32_t rn)
> +uint32_t mmu_read(CPUMBState *env, bool ext, uint32_t rn)
>  {
>      unsigned int i;
>      uint32_t r = 0;
> @@ -189,6 +189,10 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)
>          qemu_log_mask(LOG_GUEST_ERROR, "MMU access on MMU-less system\n");
>          return 0;
>      }
> +    if (ext && rn != MMU_R_TLBLO) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "Extended access only to TLBLO.\n");
> +        return 0;
> +    }
>
>      switch (rn) {
>          /* Reads to HI/LO trig reads from the mmu rams.  */
> @@ -200,7 +204,7 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)
>              }
>
>              i = env->mmu.regs[MMU_R_TLBX] & 0xff;
> -            r = env->mmu.rams[rn & 1][i];
> +            r = extract64(env->mmu.rams[rn & 1][i], ext * 32, 32);
>              if (rn == MMU_R_TLBHI)
>                  env->mmu.regs[MMU_R_PID] = env->mmu.tids[i];
>              break;
> @@ -226,9 +230,10 @@ uint32_t mmu_read(CPUMBState *env, uint32_t rn)
>      return r;
>  }
>
> -void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)
> +void mmu_write(CPUMBState *env, bool ext, uint32_t rn, uint32_t v)
>  {
>      MicroBlazeCPU *cpu = mb_env_get_cpu(env);
> +    uint64_t tmp64;
>      unsigned int i;
>      D(qemu_log("%s rn=%d=%x old=%x\n", __func__, rn, v, env->mmu.regs[rn]));
>
> @@ -236,6 +241,10 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)
>          qemu_log_mask(LOG_GUEST_ERROR, "MMU access on MMU-less system\n");
>          return;
>      }
> +    if (ext && rn != MMU_R_TLBLO) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "Extended access only to TLBLO.\n");
> +        return;
> +    }
>
>      switch (rn) {
>          /* Writes to HI/LO trig writes to the mmu rams.  */
> @@ -250,7 +259,8 @@ void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)
>                  env->mmu.tids[i] = env->mmu.regs[MMU_R_PID] & 0xff;
>                  mmu_flush_idx(env, i);
>              }
> -            env->mmu.rams[rn & 1][i] = v;
> +            tmp64 = env->mmu.rams[rn & 1][i];
> +            env->mmu.rams[rn & 1][i] = deposit64(tmp64, ext * 32, 32, v);
>
>              D(qemu_log("%s ram[%d][%d]=%x\n", __func__, rn & 1, i, v));
>              break;
> diff --git a/target/microblaze/mmu.h b/target/microblaze/mmu.h
> index 9fbdf38f36..a4272b6356 100644
> --- a/target/microblaze/mmu.h
> +++ b/target/microblaze/mmu.h
> @@ -90,6 +90,6 @@ struct microblaze_mmu_lookup
>  unsigned int mmu_translate(struct microblaze_mmu *mmu,
>                             struct microblaze_mmu_lookup *lu,
>                             target_ulong vaddr, int rw, int mmu_idx);
> -uint32_t mmu_read(CPUMBState *env, uint32_t rn);
> -void mmu_write(CPUMBState *env, uint32_t rn, uint32_t v);
> +uint32_t mmu_read(CPUMBState *env, bool ea, uint32_t rn);
> +void mmu_write(CPUMBState *env, bool ea, uint32_t rn, uint32_t v);
>  void mmu_init(struct microblaze_mmu *mmu);
> diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
> index 4dc3aff84b..ddc1f71d62 100644
> --- a/target/microblaze/op_helper.c
> +++ b/target/microblaze/op_helper.c
> @@ -476,14 +476,14 @@ void helper_stackprot(CPUMBState *env, target_ulong addr)
>
>  #if !defined(CONFIG_USER_ONLY)
>  /* Writes/reads to the MMU's special regs end up here.  */
> -uint32_t helper_mmu_read(CPUMBState *env, uint32_t rn)
> +uint32_t helper_mmu_read(CPUMBState *env, uint32_t ext, uint32_t rn)
>  {
> -    return mmu_read(env, rn);
> +    return mmu_read(env, ext, rn);
>  }
>
> -void helper_mmu_write(CPUMBState *env, uint32_t rn, uint32_t v)
> +void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)
>  {
> -    mmu_write(env, rn, v);
> +    mmu_write(env, ext, rn, v);
>  }
>
>  void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr,
> diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c
> index cf1b87c09e..39c4d0654e 100644
> --- a/target/microblaze/translate.c
> +++ b/target/microblaze/translate.c
> @@ -459,7 +459,7 @@ static void dec_msr(DisasContext *dc)
>      CPUState *cs = CPU(dc->cpu);
>      TCGv_i32 t0, t1;
>      unsigned int sr, rn;
> -    bool to, clrset, extended;
> +    bool to, clrset, extended = false;
>
>      sr = extract32(dc->imm, 0, 14);
>      to = extract32(dc->imm, 14, 1);
> @@ -467,9 +467,14 @@ static void dec_msr(DisasContext *dc)
>      dc->type_b = 1;
>      if (to) {
>          dc->cpustate_changed = 1;
> -        extended = extract32(dc->imm, 24, 1);
> -    } else {
> -        extended = extract32(dc->imm, 19, 1);
> +    }
> +
> +    /* Extended MSRs are only available if addr_size > 32.  */
> +    if (dc->cpu->cfg.addr_size > 32) {
> +        /* The E-bit is encoded differently for To/From MSR.  */
> +        static const unsigned int e_bit[] = { 19, 24 };
> +
> +        extended = extract32(dc->imm, e_bit[to], 1);
>      }
>
>      /* msrclr and msrset.  */
> @@ -516,17 +521,19 @@ static void dec_msr(DisasContext *dc)
>  #if !defined(CONFIG_USER_ONLY)
>      /* Catch read/writes to the mmu block.  */
>      if ((sr & ~0xff) == 0x1000) {
> +        TCGv_i32 tmp_ext = tcg_const_i32(extended);
>          TCGv_i32 tmp_sr;
>
>          sr &= 7;
>          tmp_sr = tcg_const_i32(sr);
>          LOG_DIS("m%ss sr%d r%d imm=%x\n", to ? "t" : "f", sr, dc->ra, dc->imm);
>          if (to) {
> -            gen_helper_mmu_write(cpu_env, tmp_sr, cpu_R[dc->ra]);
> +            gen_helper_mmu_write(cpu_env, tmp_ext, tmp_sr, cpu_R[dc->ra]);
>          } else {
> -            gen_helper_mmu_read(cpu_R[dc->rd], cpu_env, tmp_sr);
> +            gen_helper_mmu_read(cpu_R[dc->rd], cpu_env, tmp_ext, tmp_sr);
>          }
>          tcg_temp_free_i32(tmp_sr);
> +        tcg_temp_free_i32(tmp_ext);
>          return;
>      }
>  #endif
> --
> 2.14.1
>
>

  reply	other threads:[~2018-05-16 23:49 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 18:51 [Qemu-devel] [PATCH v3 00/38] target-microblaze: Add support for Extended Addressing Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 01/38] target-microblaze: dec_load: Use bool instead of unsigned int Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 02/38] target-microblaze: dec_store: " Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 03/38] target-microblaze: compute_ldst_addr: Use bool instead of int Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 04/38] target-microblaze: Fallback to our latest CPU version Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 05/38] target-microblaze: Correct special register array sizes Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 06/38] target-microblaze: Correct the PVR array size Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 07/38] target-microblaze: Tighten up TCGv_i32 vs TCGv type usage Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 08/38] target-microblaze: Remove USE_MMU PVR checks Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 09/38] target-microblaze: Conditionalize setting of PVR11_USE_MMU Edgar E. Iglesias
2018-05-17 17:26   ` Richard Henderson
2018-05-17 18:00     ` Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 10/38] target-microblaze: Bypass MMU with MMU_NOMMU_IDX Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 11/38] target-microblaze: Make compute_ldst_addr always use a temp Edgar E. Iglesias
2018-05-17 14:39   ` Philippe Mathieu-Daudé
2018-05-17 16:41     ` Edgar E. Iglesias
2018-05-17 17:14       ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 12/38] target-microblaze: Remove pointer indirection for ld/st addresses Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 13/38] target-microblaze: Use TCGv for load/store addresses Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 14/38] target-microblaze: Name special registers we support Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 15/38] target-microblaze: Break out trap_userspace() Edgar E. Iglesias
2018-05-17 14:52   ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 16/38] target-microblaze: Break out trap_illegal() Edgar E. Iglesias
2018-05-17 14:56   ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 17/38] target-microblaze: dec_msr: Use bool and extract32 Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 18/38] target-microblaze: dec_msr: Reuse more code when reg-decoding Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 19/38] target-microblaze: dec_msr: Fix MTS to FSR Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 20/38] target-microblaze: Make special registers 64-bit Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 21/38] target-microblaze: Setup for 64bit addressing Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 23/38] target-microblaze: Implement MFSE EAR Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 24/38] target-microblaze: mmu: Add R_TBLX_MISS macros Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 25/38] target-microblaze: mmu: Remove unused register state Edgar E. Iglesias
2018-05-17 15:15   ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 26/38] target-microblaze: mmu: Prepare for 64-bit addresses Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 27/38] target-microblaze: mmu: Add a configurable output address mask Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 28/38] target-microblaze: dec_msr: Plug a temp leak Edgar E. Iglesias
2018-05-17 13:58   ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 29/38] target-microblaze: Add support for extended access to TLBLO Edgar E. Iglesias
2018-05-16 23:48   ` Alistair Francis [this message]
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 30/38] target-microblaze: Allow address sizes between 32 and 64 bits Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 31/38] target-microblaze: Simplify address computation using tcg_gen_addi_i32() Edgar E. Iglesias
2018-05-17 18:19   ` Philippe Mathieu-Daudé
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 32/38] target-microblaze: mmu: Cleanup debug log messages Edgar E. Iglesias
2018-05-16 23:42   ` Alistair Francis
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 33/38] target-microblaze: Use table based condition-codes conversion Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 34/38] target-microblaze: Remove argument b in eval_cc() Edgar E. Iglesias
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 35/38] target-microblaze: Convert env_btarget to i64 Edgar E. Iglesias
2018-05-17 14:28   ` Philippe Mathieu-Daudé
2018-05-17 17:34   ` Richard Henderson
2018-05-17 18:03     ` Edgar E. Iglesias
2018-05-17 20:48       ` Richard Henderson
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 36/38] target-microblaze: Use tcg_gen_movcond in eval_cond_jmp Edgar E. Iglesias
2018-05-17 14:22   ` Philippe Mathieu-Daudé
2018-05-17 14:48     ` Philippe Mathieu-Daudé
2018-05-17 16:42       ` Edgar E. Iglesias
2018-05-17 17:24         ` Philippe Mathieu-Daudé
2018-05-17 17:36   ` Richard Henderson
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 37/38] target-microblaze: cpu_mmu_index: Fixup indentation Edgar E. Iglesias
2018-05-16 23:49   ` Alistair Francis
2018-05-17 17:38   ` Richard Henderson
2018-05-16 18:51 ` [Qemu-devel] [PATCH v3 38/38] target-microblaze: Consolidate MMU enabled checks Edgar E. Iglesias
2018-05-16 23:51   ` Alistair Francis
2018-05-17 17:39   ` Richard Henderson

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=CAKmqyKOMET_kAzCrf7jsUrW04Dni+9OsDR2CruqmmAv_Nq0Hmg@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=edgar.iglesias@gmail.com \
    --cc=edgar.iglesias@xilinx.com \
    --cc=frasse.iglesias@gmail.com \
    --cc=frederic.konrad@adacore.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=sai.pavan.boddu@xilinx.com \
    --cc=sstabellini@kernel.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).