linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: gdb@sourceware.org, linuxppc-embedded@ozlabs.org
Subject: Re: Apparent kernel bug with GDB on ppc405
Date: Wed, 24 Oct 2007 17:32:50 -0500	[thread overview]
Message-ID: <20071024223250.GI19691@waste.org> (raw)
In-Reply-To: <fa686aa40710241527j1a316760lf36d512eb625810f@mail.gmail.com>

On Wed, Oct 24, 2007 at 04:27:52PM -0600, Grant Likely wrote:
> On 10/24/07, Matt Mackall <mpm@selenic.com> wrote:
> > On Wed, Oct 24, 2007 at 03:42:16PM -0500, Matt Mackall wrote:
> > > On Wed, Oct 24, 2007 at 02:28:14PM -0600, Grant Likely wrote:
> > > > On 10/24/07, Matt Mackall <mpm@selenic.com> wrote:
> > > > > I'm trying to debug a trivial statically-linked hello world program on
> > > > > a Xilinx PPC 405 and I'm seeing the following behavior:
> > > > >
> > > > <snip>
> > > > >
> > > > > Any suggestions?
> > > >
> > > > http://thread.gmane.org/gmane.linux.ports.ppc.embedded/11202
> > > >
> > > > I was fighting with a similar problem almost 2 years ago.  Looks like
> > > > it might be related.  At some point the problem seemed to go away and
> > > > I determined what the root cause was.  :-(
> > > >
> > > > I haven't been using gdb lately, so I don't know if it's the same
> > > > problem.  Nobody I had talked to had seen the issue on other 405
> > > > platforms.  It could very well be something virtex-specific.
> > >
> > > Could be the same problem, but I'm seeing only your symptom 3 so far.
> > >
> > > I've tried throwing some larger hammers at the problem. Flushing all
> > > of the dcache and icache (flush_dcache_all and
> > > flush_instruction_cache) isn't helping. But printk(".") does!
> >
> > Well there was one remaining cache - the TLB. This patch seems to make
> > things work, but don't ask me why:
> >
> > --- include/asm-ppc/cacheflush.h        (revision 10439)
> > +++ include/asm-ppc/cacheflush.h        (working copy)
> > @@ -11,6 +11,7 @@
> >  #define _PPC_CACHEFLUSH_H
> >
> >  #include <linux/mm.h>
> > +#include <asm/tlbflush.h>
> >
> >  /*
> >   * No cache flushing is required when address mappings are
> > @@ -35,10 +36,23 @@
> >  extern void flush_icache_user_range(struct vm_area_struct *vma,
> >                 struct page *page, unsigned long addr, int len);
> >
> >  #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
> >  do { memcpy(dst, src, len); \
> >       flush_icache_user_range(vma, page, vaddr, len); \
> > +     _tlbia(); \
> >  } while (0)
> 
> Hmmm; thinking out loud here...
> 
> - so tlbia invalidates all TLB entries
> - When gdb inserts a breakpoint the .text pages are marked as read
> only, so the kernel does a copy on write so that gdb can modify the
> instruction.  The kernel also updates the page tables so that the test
> process now uses the new page.
> - This means that there are now 2 pages for that one section of
> executable code; the original and the one with the breakpoint.
> - However, the program is still in memory, and there is probably
> already a TLB entry pointing to the original page for that range of
> addresses.
> 
> Could it be that the kernel page tables are getting updated to the new
> page; but active set of TLB entries is not getting updated?
> 
> If so, then printk(".") probably solves the problem simply because it
> touches enough pages in its execution path that the old TLB entry gets
> overwritten?  There are only 64 TLB entries afterall.
> 
> Thoughts?

Not completely implausible, but a) why isn't this seen on basically
every machine with software TLB? b) why does -local- GDB, which is
presumably doing much less work than gdbserver + network stack, not fail?

-- 
Mathematics is the supreme nostalgia of our time.

  reply	other threads:[~2007-10-24 22:33 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 19:46 Apparent kernel bug with GDB on ppc405 Matt Mackall
2007-10-24 20:28 ` Grant Likely
2007-10-24 20:42   ` Matt Mackall
2007-10-24 20:46     ` Grant Likely
2007-10-24 21:54     ` Matt Mackall
2007-10-24 22:27       ` Grant Likely
2007-10-24 22:32         ` Matt Mackall [this message]
2007-10-24 22:39           ` Grant Likely
2007-10-24 22:40             ` Grant Likely
2007-10-26  1:50               ` Benjamin Herrenschmidt
2007-10-24 22:41           ` Daniel Jacobowitz
2007-10-26  1:51             ` Benjamin Herrenschmidt
2007-10-26 20:41               ` Josh Boyer
2007-10-27  1:36                 ` Benjamin Herrenschmidt
2007-10-27  1:27                   ` Josh Boyer
2007-10-24 20:34 ` David Daney
2007-10-26  1:52   ` Benjamin Herrenschmidt
2007-10-26  1:46 ` Benjamin Herrenschmidt
2007-10-26  2:45   ` Grant Likely
2007-10-26  3:23     ` Benjamin Herrenschmidt
2007-10-26 14:41       ` Matt Mackall
2007-10-27  1:30         ` Benjamin Herrenschmidt
2007-10-27  7:32           ` [PATCH/RFC] powerpc: Pass PID argument to _tlbie (WAS: Apparent kernel bug with GDB on ppc405) Benjamin Herrenschmidt
2007-10-29 12:08             ` Josh Boyer
2007-10-29 20:15               ` Josh Boyer
2007-10-29 20:35                 ` Benjamin Herrenschmidt
2007-10-29 21:13                   ` Matt Mackall

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=20071024223250.GI19691@waste.org \
    --to=mpm@selenic.com \
    --cc=gdb@sourceware.org \
    --cc=grant.likely@secretlab.ca \
    --cc=linuxppc-embedded@ozlabs.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).