qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
	"patches@linaro.org" <patches@linaro.org>
Subject: Re: [Qemu-devel] [RFC] target/microblaze: Switch to transaction_failed hook
Date: Fri, 4 Jan 2019 12:57:32 +0100	[thread overview]
Message-ID: <20190104115732.GP1148@toto> (raw)
In-Reply-To: <CAFEAcA8n1g4CFkOYt9+L9CmgVeE7V7BhD+K8hR0X0tQ4GJoLOg@mail.gmail.com>

On Mon, Dec 10, 2018 at 06:32:49PM +0000, Peter Maydell wrote:
> On Mon, 10 Dec 2018 at 18:31, Peter Maydell <peter.maydell@linaro.org> wrote:
> >
> > On Mon, 10 Dec 2018 at 17:57, Peter Maydell <peter.maydell@linaro.org> wrote:
> > >
> > > Switch the microblaze target from the old unassigned_access hook
> > > to the transaction_failed hook.
> > >
> > > The notable difference is that rather than it being called
> > > for all physical memory accesses which fail (including
> > > those made by DMA devices or by the gdbstub), it is only
> > > called for those made by the CPU via its MMU. For
> > > microblaze this makes no difference because none of the
> > > target CPU code needs to make loads or stores by physical
> > > address.


Thanks Peter, this looks good.

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Tested-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


Actually, upstream QEMU is lacking the necessary CPU cfg properties
to enable CPU exceptions for transaction errors. I'll post patches
to add those. On boards without those props enabled, the logging
happens but the error gets ignored by the core.

Cheers,
Edgar

> > >
> > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> > > ---
> > > A straightforward conversion, but tagged RFC because I don't have
> > > any microblaze test images and have tested only with "make check".
> > >
> > >  target/microblaze/cpu.h       |  7 ++++---
> > >  target/microblaze/cpu.c       |  2 +-
> > >  target/microblaze/op_helper.c | 20 ++++++++++----------
> > >  3 files changed, 15 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h
> > > index 3c4e0ba80ac..03ca91007d5 100644
> > > --- a/target/microblaze/cpu.h
> > > +++ b/target/microblaze/cpu.h
> > > @@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc,
> > >  }
> > >
> > >  #if !defined(CONFIG_USER_ONLY)
> > > -void mb_cpu_unassigned_access(CPUState *cpu, hwaddr addr,
> > > -                              bool is_write, bool is_exec, int is_asi,
> > > -                              unsigned size);
> > > +void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> > > +                               unsigned size, MMUAccessType access_type,
> > > +                               int mmu_idx, MemTxAttrs attrs,
> > > +                               MemTxResult response, uintptr_t retaddr);
> > >  #endif
> > >
> > >  #endif
> > > diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c
> > > index 9b546a2c18e..49876b19b38 100644
> > > --- a/target/microblaze/cpu.c
> > > +++ b/target/microblaze/cpu.c
> > > @@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)
> > >  #ifdef CONFIG_USER_ONLY
> > >      cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;
> > >  #else
> > > -    cc->do_unassigned_access = mb_cpu_unassigned_access;
> > > +    cc->do_transaction_failed = mb_cpu_transaction_failed;
> > >      cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;
> > >  #endif
> > >      dc->vmsd = &vmstate_mb_cpu;
> > > diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c
> > > index 7cdbbcccaef..d25d3b626c8 100644
> > > --- a/target/microblaze/op_helper.c
> > > +++ b/target/microblaze/op_helper.c
> > > @@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)
> > >      mmu_write(env, ext, rn, v);
> > >  }
> > >
> > > -void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr,
> > > -                              bool is_write, bool is_exec, int is_asi,
> > > -                              unsigned size)
> > > +void mb_cpu_transaction_failed(CPUState *cs, hwaddr physaddr, vaddr addr,
> > > +                               unsigned size, MMUAccessType access_type,
> > > +                               int mmu_idx, MemTxAttrs attrs,
> > > +                               MemTxResult response, uintptr_t retaddr)
> > >  {
> > >      MicroBlazeCPU *cpu;
> > >      CPUMBState *env;
> > > -
> > > -    qemu_log_mask(CPU_LOG_INT, "Unassigned " TARGET_FMT_plx " wr=%d exe=%d\n",
> > > -             addr, is_write ? 1 : 0, is_exec ? 1 : 0);
> > > -    if (cs == NULL) {
> > > -        return;
> > > -    }
> > > +    qemu_log_mask(CPU_LOG_INT, "Transaction failed: vaddr 0x%" VADDR_PRIx
> > > +                  " physaddr 0x" TARGET_FMT_plx "size %d access type %s\n",
> > > +                  addr, physaddr, size,
> > > +                  access_type == MMU_INST_FETCH ? "INST_FETCH" :
> > > +                  (access_type == MMU_DATA_LOAD ? "DATA_LOAD" : "DATA_STORE"));
> > >      cpu = MICROBLAZE_CPU(cs);
> > >      env = &cpu->env;
> 
> Oops. Here there should be
> 
>     cpu_restore_state(cs, retaddr, true);
> 
> > >      if (!(env->sregs[SR_MSR] & MSR_EE)) {
> > > @@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr,
> > >      }
> > >
> > >      env->sregs[SR_EAR] = addr;
> > > -    if (is_exec) {
> > > +    if (access_type == MMU_INST_FETCH) {
> > >          if ((env->pvr.regs[2] & PVR2_IOPB_BUS_EXC_MASK)) {
> > >              env->sregs[SR_ESR] = ESR_EC_INSN_BUS;
> > >              helper_raise_exception(env, EXCP_HW_EXCP);
> > > --
> > > 2.19.2
> 
> thanks
> -- PMM

  reply	other threads:[~2019-01-04 11:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 17:56 [Qemu-devel] [RFC] target/microblaze: Switch to transaction_failed hook Peter Maydell
2018-12-10 18:31 ` Peter Maydell
2018-12-10 18:32   ` Peter Maydell
2019-01-04 11:57     ` Edgar E. Iglesias [this message]
2019-01-04 13:18     ` Edgar E. Iglesias

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=20190104115732.GP1148@toto \
    --to=edgar.iglesias@gmail.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --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).