From: David Daney <ddaney.cavm@gmail.com>
To: Bruce Korb <bruce.korb@gmail.com>
Cc: gdb@sourceware.org, linux-mips <linux-mips@linux-mips.org>
Subject: Re: Hardware breakpoints on MIPS
Date: Thu, 29 Jan 2015 15:01:23 -0800 [thread overview]
Message-ID: <54CABBC3.6000006@gmail.com> (raw)
In-Reply-To: <CAKRnqN+Js_zDn==T0+-EGzyTSW4P-dpvB7jKsLmFJEbKhxifJw@mail.gmail.com>
On 01/29/2015 02:05 PM, Bruce Korb wrote:
> FSF's Position regarding SCO's attacks on Free Software
>
> This comes from gdb's GNU.org web page.
> I think SCO has stopped attacking now. :)
>
> Anyway, I need to set a hardware breakpoint on a Mips CPU on a "Cavium" platform
> in a kernel module. As I read the data sheet, I should need to write
> to CP0 registers
> 18 and 19, with 18 containing a kernel virtual address plus three bits
> for indicating
> an instruction, write access or read access; then I need to write 0x40000007 to
> register 19. Except the interrupt doesn't fire and I've been unable
> to figure out
> what I've got wrong. Code follows, for folks that can follow it and know how it
> ought to work. I surely do thank you for any hints you can give:
>
This would appear to be for the most part, completely independent of
GDB, and thus perhaps not a good candidate for the gdb@mailing list.
What happens inside of the Linux kernel running on a MIPS{,64} CPU is
often discussed on linux-mips@linux-mips.org.
Since many years ago, WatchLo and WatchHi have been under the control of
the Linux kernel. If you set these registers and a Watch Exception is
triggered, it will cause the registers to be cleared and the exception
will be ignored, unless they were configured via ptrace(2) for userspace
addresses.
For debugging kernel space with watchpoint registers on OCTEON it is
probably best to use the facilities in the EJTAG unit.
David Daney
>
> #define WW_W_BIT 0
> #define WW_R_BIT 1
> #define WW_I_BIT 2
>
> #define WW_W_MASK (1UL << WW_W_BIT)
> #define WW_R_MASK (1UL << WW_R_BIT)
> #define WW_I_MASK (1UL << WW_I_BIT)
>
> #define WW_IRW_MASK (WW_I_MASK | WW_R_MASK | WW_W_MASK)
>
> static inline void watch_word(void * addr, unsigned int mask)
> {
> typedef struct {
> unsigned is_inst_watch : 1; // true --> instruction watch
> unsigned do_exception : 1;
> unsigned unused_29_24 : 6;
> unsigned asid : 8; // IFF "do_exception" is false
> unsigned unused_15_12 : 4;
> unsigned mask : 9;
> unsigned found_ins : 1;
> unsigned found_read : 1;
> unsigned found_write : 1;
> } watch_lo_bits_t;
>
> U64 watchlo;
> union {
> watch_lo_bits_t bits;
> U32 word;
> } watchhi;
>
> watchlo = (U64)addr;
> watchlo = (watchlo & ~WW_IRW_MASK) | mask; // watch for write access
>
> watchhi.bits = (watch_lo_bits_t) {
> .do_exception = 1,
> .found_ins = 1,
> .found_read = 1,
> .found_write = 1
> };
> assert(watchhi.word == 0x40000007);
>
> if ((mask & WW_I_MASK) != 0) {
> write_c0_watchlo0(watchlo); // macro from asm/mipsregs.h
> write_c0_watchhi0(watchhi.word);
> } else {
> write_c0_watchlo1(watchlo);
> write_c0_watchhi1(watchhi.word);
> }
> }
>
>
next parent reply other threads:[~2015-01-29 23:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKRnqN+Js_zDn==T0+-EGzyTSW4P-dpvB7jKsLmFJEbKhxifJw@mail.gmail.com>
2015-01-29 23:01 ` David Daney [this message]
2015-01-29 23:43 ` Hardware breakpoints on MIPS Bruce Korb
2015-01-29 23:51 ` David Daney
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=54CABBC3.6000006@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=bruce.korb@gmail.com \
--cc=gdb@sourceware.org \
--cc=linux-mips@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.