Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Dimitar Dimitrov <dimitar@dinux.eu>
To: Mike Frysinger <vapier@gentoo.org>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] PRU Simulator port
Date: Sun, 18 Dec 2016 20:13:00 -0000	[thread overview]
Message-ID: <3424509.8t91nzmn7c@tpdeb> (raw)
In-Reply-To: <20161216203324.GA30602@vapier.lan>

On петък, 16 декември 2016 г. 15:33:24 EET Mike Frysinger wrote:
> On 09 Dec 2016 22:39, Dimitar Dimitrov wrote:
> > I'll change it. I assume my copyright papers for GDB will cover this
> > simulator patch?
> i think they want sep papers.  who knows!
> 
> try this small form (it has directions in it):
> http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;f=doc/Copyrigh
> t/request-assign.future;hb=HEAD
Thanks, I've started the process.

> > > > +static inline void
> > > > +pru_reg2dmem (SIM_CPU *cpu, uint32_t addr, unsigned int nbytes,
> > > > +	      int regn, int regb)
> > > > +{
> > > > +  if (abort_on_dmem_zero_access && addr < 4)
> > > > +    {
> > > > +      sim_core_signal (CPU_STATE (cpu), cpu, PC_byteaddr, write_map,
> > > > +		       nbytes, addr, write_transfer,
> > > > +		       SIM_SIGSEGV);
> > > > +    }
> > > > +  else if ((addr >= PC_ADDR_SPACE_MARKER)
> > > > +	   || (addr + nbytes > PC_ADDR_SPACE_MARKER))
> > > > +    {
> > > > +      sim_core_signal (CPU_STATE (cpu), cpu, PC_byteaddr, write_map,
> > > > +		       nbytes, addr, write_transfer,
> > > > +		       SIM_SIGSEGV);
> > > > +    }
> > > > +  else if ((regn * 4 + regb + nbytes) > (32 * 4))
> > > > +    {
> > > > +      /* Register and load size are not valid.  */
> > > > +      sim_core_signal (CPU_STATE (cpu), cpu, PC_byteaddr, write_map,
> > > > +		       nbytes, addr, write_transfer,
> > > > +		       SIM_SIGILL);
> > > > +    }
> > > 
> > > do you really need to do all this ?  seems like the existing
> > > sim_core_write_1 function already deals properly with writes
> > > to out-of-bind addresses.
> > 
> > I believe the checks are needed. I let sim_core_write_1 handle the Data RAM bounds checking. On top of that, I want to:
> >    - Ensure that instruction memory (PC_ADDR_SPACE_MARKER) is not accessed
> >    by the CPU data path.
> i don't believe this is possible today with gdb.  when gdb makes a request
> to the sim to do things like set breakpoints and decode instructinos, it
> follows the same paths as the sim which means it'll break gdb :(.
> 
> i wanted to do the same thing for Blackfin where there's a chunk of SRAM
> that can only be executed, but trying to do data reads/stores would fail.
May I conditionally enforce this restriction only if "(STATE_OPEN_KIND (sd) == SIM_OPEN_STANDALONE)" ? The standalone simulator is invaluable for regression checking Binutils and GCC, and I would like to catch those kinds of errors.

> 
> >    - Check that the load/store burst length is valid (i.e. do not access
> >    beyond the last CPU register).
> shouldn't this be handled by limiting the memory region addr+size ?
PRU LBBO instruction can load up to 120 bytes into a group of consecutive registers. This check guards the destination register group, not the source memory address.

Consider an example, where r10 holds a valid address in the middle of a large array. This would be a valid instruction for loading 32 bytes (8 words) into r20-r27:
    ldi &r20, r10, 0, 32
And this would be invalid because it would try to load 8 words into r29-r36, while PRU registers are only r0-r31:
    ldi &r29, r10, 0, 32


> 
> >    - Optionally catch NULL pointer dereferences.
> 
> hmm, seems like this would be better as a common sim option ?  but also,
> this runs into the same problems as i described above i think.
Again, may I enable it only for standalone simulator?

> 
> > > > +static void
> > > > +pru_sim_syscall (SIM_DESC sd, SIM_CPU *cpu)
> > > 
> > > seems like you should use sim_syscall instead of implementing your own
> > > ad-hoc syscall ABI
> > 
> > I'll fix libgloss to use more standard syscalls, and then I'll switch to
> > sim_syscall.
> that was going to be my next question :).  if you have time, then yeah,
> changing all your libgloss syscall #'s to use the default ones would be
> best.
I will do that.

> -mike



      reply	other threads:[~2016-12-18 20:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-05 21:11 Dimitar Dimitrov
2016-12-06 14:09 ` Mike Frysinger
2016-12-06 20:21   ` Dimitar Dimitrov
2016-12-06 14:10 ` Mike Frysinger
2016-12-06 23:17 ` Mike Frysinger
2016-12-09 20:40   ` Dimitar Dimitrov
2016-12-16 20:33     ` Mike Frysinger
2016-12-18 20:13       ` Dimitar Dimitrov [this message]

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=3424509.8t91nzmn7c@tpdeb \
    --to=dimitar@dinux.eu \
    --cc=gdb-patches@sourceware.org \
    --cc=vapier@gentoo.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