linux-m68k.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Eager <eager@eagercon.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@lists.linux-m68k.org
Subject: Re: M68k ColdFire ptrace/cache fix
Date: Fri, 13 Jul 2012 13:18:23 -0700	[thread overview]
Message-ID: <5000828F.2090307@eagercon.com> (raw)
In-Reply-To: <CAMuHMdUgZBgKSZK1YJnvqvcF1M82Q6mHL41K-6hdvhM69JCB+w@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1548 bytes --]

On 07/13/2012 01:06 PM, Geert Uytterhoeven wrote:
> Hi Michael,
>
> On Fri, Jul 13, 2012 at 9:14 PM, Michael Eager <eager@eagercon.com> wrote:
>> I've tracked down a problem in gdb/gdbserver to ptrace() not
>> clearing the i/d cache after modifying memory.
>>
>> To reproduce:
>>    m68k-gcc -g -o cf-gdb-test-no-io cf-gdb-test-no-io.c
>>    scp cf-gdb-test-no-io <target>:/
>>    on target:   gdbserver :1234 cf-gdb-test-no-io
>>    m68k-gcc cf-gdb-test-no-io
>>    (gdb) b 8
>>    (gdb) b 10
>>    (gdb) tar rem <target>:1234
>>    (gdb) c
>>    (gdb) c
>>
>> Program will hit first breakpoint, but not second breakpoint.
>>
>> It appears that the instruction at the last breakpoint location
>> is in the icache and does not get flushed when the bp is written.
>>
>> After applying the attached patch, gdb/gdbserver behavior is correct.
>
> Thanks for your report and patch!

I attached the test program, which I previously forgot.

> Does this happen only in 2.6.29, or also in current kernels?
> The first hunk of your patch no longer applies, as the affected code is
> gone and those cases are now handled purely by the generic code.

I'm working with a client's environment using 2.6.29, so I can't verify
that the same failure occurs in recent kernels.  But I don't see anything
in ptrace.c in the latest kernel which would clear the i/d caches when
writing to memory.

>
> If yes, feel free to take this to linux-m68k@lists.linux-m68k.org.

Done.


-- 
Michael Eager	 eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



[-- Attachment #2: cf-gdb-test-no-io.c --]
[-- Type: text/x-csrc, Size: 135 bytes --]

int work (int a)
{
  return a * 2;
}

int main (void)
{
  int a = 10;
  int b = work (a);
  b = work (b);

  a = b * a;

  return 0;
}

[-- Attachment #3: ptrace-cache.patch --]
[-- Type: text/x-patch, Size: 944 bytes --]

--- linux-2.6.29/arch/m68k/kernel/ptrace.c-orig	2012-06-30 06:37:34.000000000 -0700
+++ linux-2.6.29/arch/m68k/kernel/ptrace.c	2012-07-13 11:25:24.000000000 -0700
@@ -24,6 +24,7 @@
 #include <asm/pgtable.h>
 #include <asm/system.h>
 #include <asm/processor.h>
+#include <asm/cacheflush_mm.h>
 
 /*
  * does not yet catch signals sent when the child dies.
@@ -157,6 +158,8 @@ long arch_ptrace(struct task_struct *chi
 	case PTRACE_POKETEXT:	/* write the word at location addr. */
 	case PTRACE_POKEDATA:
 		ret = generic_ptrace_pokedata(child, addr, data);
+		flush_dcache ();
+		flush_icache ();
 		break;
 
 	case PTRACE_POKEUSR:	/* write the word at location addr in the USER area */
@@ -183,6 +186,8 @@ long arch_ptrace(struct task_struct *chi
 			child->thread.fp[addr - 21] = data;
 		} else
 			goto out_eio;
+		flush_dcache ();
+		flush_icache ();
 		break;
 
 	case PTRACE_SYSCALL:	/* continue and stop at next (return from) syscall */

       reply	other threads:[~2012-07-13 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <500073A8.5090700@eagercon.com>
     [not found] ` <CAMuHMdUgZBgKSZK1YJnvqvcF1M82Q6mHL41K-6hdvhM69JCB+w@mail.gmail.com>
2012-07-13 20:18   ` Michael Eager [this message]
2012-07-15 11:54     ` M68k ColdFire ptrace/cache fix Geert Uytterhoeven
2012-07-15 17:10       ` Michael Eager
2012-07-16  6:02         ` Greg Ungerer

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=5000828F.2090307@eagercon.com \
    --to=eager@eagercon.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-m68k@lists.linux-m68k.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).