Skip to contentSkip to conversation

Question about DBCR0 initialization for 440

DISCUSSION John Linn 6 participants 15 messages Apr 14, 2009 – Apr 17, 2009

lore
Share & tools
lore

John Linn

author
#0 lore raw

The kernel does not initialize the PPC440 DBCR0 register. This prevents (among other things) the use of software breakpoints with GDB. I realize that boot loaders probably do initialize this but we run a lot without a boot loader and so do our customers.

The file, head_fsl_booke.S, does initialize the register for the freescale specific code (as shown at the end of the message).

We are needing this also for Xilinx. What's the best method to incorporate this, is it possible to add to head_44x.S?

Thanks,

John

#if !defined(CONFIG_BDI_SWITCH)

            /*

             * The Abatron BDI JTAG debugger does not tolerate others

             * mucking with the debug registers.

             */

            lis     r2,DBCR0_IDM@h

            mtspr   SPRN_DBCR0,r2

            isync

            /* clear any residual debug events */

            li      r2,-1

            mtspr   SPRN_DBSR,r2

#endif

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#1 lore raw

Some debuggers like BDI(Abatron) they setup the debug registers. If you have different debugger which doesn't support configuring debug registers I suggest you to program then in the head_44x.S file.

From: [email protected] [mailto:[email protected]] On Behalf Of John Linn
Sent: Tuesday, April 14, 2009 1:33 PM
To: [email protected]; [email protected]; [email protected]
Subject: Question about DBCR0 initialization for 440

The kernel does not initialize the PPC440 DBCR0 register. This prevents (among other things) the use of software breakpoints with GDB. I realize that boot loaders probably do initialize this but we run a lot without a boot loader and so do our customers.

The file, head_fsl_booke.S, does initialize the register for the freescale specific code (as shown at the end of the message).

We are needing this also for Xilinx. What's the best method to incorporate this, is it possible to add to head_44x.S?

Thanks,

John

#if !defined(CONFIG_BDI_SWITCH)

            /*

             * The Abatron BDI JTAG debugger does not tolerate others

             * mucking with the debug registers.

             */

            lis     r2,DBCR0_IDM@h

            mtspr   SPRN_DBCR0,r2

            isync

            /* clear any residual debug events */

            li      r2,-1

            mtspr   SPRN_DBSR,r2

#endif

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

author
#2 lore raw

Josh, any thoughts on putting this into head_44x.S?

Thanks,

John

________________________________

From: [email protected] [mailto:[email protected]] On Behalf Of Tirumala Reddy Marri
Sent: Wednesday, April 15, 2009 10:24 AM
To: John Linn; [email protected]; [email protected]; [email protected]
Subject: RE: Question about DBCR0 initialization for 440

Some debuggers like BDI(Abatron) they setup the debug registers. If you have different debugger which doesn't support configuring debug registers I suggest you to program then in the head_44x.S file.

From: [email protected] [mailto:[email protected]] On Behalf Of John Linn
Sent: Tuesday, April 14, 2009 1:33 PM
To: [email protected]; [email protected]; [email protected]
Subject: Question about DBCR0 initialization for 440

The kernel does not initialize the PPC440 DBCR0 register. This prevents (among other things) the use of software breakpoints with GDB. I realize that boot loaders probably do initialize this but we run a lot without a boot loader and so do our customers.

The file, head_fsl_booke.S, does initialize the register for the freescale specific code (as shown at the end of the message).

We are needing this also for Xilinx. What's the best method to incorporate this, is it possible to add to head_44x.S?

Thanks,

John

#if !defined(CONFIG_BDI_SWITCH)

            /*

             * The Abatron BDI JTAG debugger does not tolerate others

             * mucking with the debug registers.

             */

            lis     r2,DBCR0_IDM@h

            mtspr   SPRN_DBCR0,r2

            isync

            /* clear any residual debug events */

            li      r2,-1

            mtspr   SPRN_DBSR,r2

#endif

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

#3 lore raw
Quoted 1 line · John Linn

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. I do have an odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. Namely, that config option doesn't cover RiscWatch in an obvious manner.

I also wonder if it's possible to have a host system be setting those registers in a guest KVM system so the guest could be debugged with gdb... Hollis, any idea on that?

josh

#4 lore raw
Quoted 7 lines · On Friday 17 April 2009 12:22:37 Josh Boyer wrote:
Quoted 1 line · John Linn

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. I do have an odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. Namely, that config option doesn't cover RiscWatch in an obvious manner.

Yeah, setting DBCR0 would interfere with all JTAG probes. The ifdef meands you can't support both a JTAG debugger and hardware breakpoints in the same binary? Now that's an annoying restriction.

Quoted 3 lines

I also wonder if it's possible to have a host system be setting those registers in a guest KVM system so the guest could be debugged with gdb... Hollis, any idea on that?

You mean is KVM currently doing that, and would this patch conflict with that behavior?

Right now KVM (on 440) context switches the necessary DB* registers for out- of-band debugging. That is, qemu sends a "set breakpoint in guest" ioctl to KVM, and then when switching from host to guest mode, KVM will save the old DB* values, put in some new ones, and swap them back again when re-entering the host. So I *think* the answer to your question is "yes, KVM messes with these registers to enable software breakpoints when debugging a guest with gdb." That code path isn't heavily tested, but the values put into DB* by other host code shouldn't matter.

However, KVM doesn't support in-band breakpoints, i.e. it doesn't emulate the setting of those registers from within the guest. It's basically a no-op. So whether the kernel sets them or not, in-band debugging won't work with the current KVM code.

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#13 lore raw
In reply to Josh Boyer

Hey John

We just discussed this on IRC. Go ahead and generate a patch to unconditionally turn on DBCR0[IDM] in head_44x.S. Don't even bother wrapping it in an #ifdef CONFIG_somthing block. It should be safe, but we'll throw it into -next and see if anyone complains. If it does cause problems, then it can be reworked to something a wee bit more conservative.

g.

On Fri, Apr 17, 2009 at 11:22 AM, Josh Boyer <[email protected]> w= rote:

Quoted 8 lines · John Linn
Quoted 1 line

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. =A0I do have an odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. =A0Namely, that config option doesn't cover RiscWatch in an obvious manner.

Quoted 6 lines

I also wonder if it's possible to have a host system be setting those registers in a guest KVM system so the guest could be debugged with gdb... =A0Hollis, any idea on that?

josh

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

#5 lore raw
In reply to Hollis Blanchard
Quoted 4 lines · Hollis Blanchard
Quoted 3 lines · On Friday 17 April 2009 12:22:37 Josh Boyer wrote:
Quoted 1 line · John Linn

Josh, any thoughts on putting this into head_44x.S?

Quoted 8 lines
Quoted 4 lines

The code in the fsl file looks like the right solution. I do have an odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. Namely, that config option doesn't cover RiscWatch in an obvious manner.

Yeah, setting DBCR0 would interfere with all JTAG probes. The ifdef meands you can't support both a JTAG debugger and hardware breakpoints in the same binary? Now that's an annoying restriction.

Might be worth checking if external debug is enabled, and override it only if it's not.

Ben.

#6 lore raw
Quoted 3 lines · Benjamin Herrenschmidt
Quoted 2 lines · Hollis Blanchard
Quoted 1 line · On Friday 17 April 2009 12:22:37 Josh Boyer wrote:

On Fri, Apr 17, 2009 at 11:46 AM, John Linn <[email protected]> wro=

te:

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. =A0I do have a=

n

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. =A0Namely, that config option doesn't cover RiscWatch in an obvious manner.

Yeah, setting DBCR0 would interfere with all JTAG probes. The ifdef mean=

ds you

Quoted 5 lines
Quoted 2 lines

can't support both a JTAG debugger and hardware breakpoints in the same binary? Now that's an annoying restriction.

Might be worth checking if external debug is enabled, and override it only if it's not.

ppc440x5_um.pdf says that both can be enabled.

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

author
#14 lore raw
In reply to Grant Likely

Thanks everyone, will do.

Quoted 5 lines

-----Original Message-----
From: Grant Likely [mailto:[email protected]]
Sent: Friday, April 17, 2009 12:58 PM
To: Josh Boyer
Cc: John Linn; Tirumala Reddy Marri; [email protected]; hollisb@us.=

ibm.com

Quoted 18 lines

Subject: Re: Question about DBCR0 initialization for 440 =

Hey John
=

We just discussed this on IRC. Go ahead and generate a patch to unconditionally turn on DBCR0[IDM] in head_44x.S. Don't even bother wrapping it in an #ifdef CONFIG_somthing block. It should be safe, but we'll throw it into -next and see if anyone complains. If it does cause problems, then it can be reworked to something a wee bit more conservative.
=

g.
=

On Fri, Apr 17, 2009 at 11:22 AM, Josh Boyer <[email protected]>=

Quoted 1 line · wrote:
Quoted 1 line

On Fri, Apr 17, 2009 at 11:46 AM, John Linn <[email protected]> wrot=

e:

Quoted 16 lines
Quoted 8 lines
Quoted 1 line

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. =A0I do have an=

odd question though, in that it's hard for the
kernel to really know if something like a BDI is running. =A0Namely, that config option doesn't cover RiscWatch in an obvious manner.

Quoted 6 lines

I also wonder if it's possible to have a host system be setting those registers in a guest KVM system so the guest could be debugged with gdb... =A0Hollis, any idea on that?

josh

=

Quoted 7 lines

=

=

--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately.

author
#7 lore raw
In reply to Grant Likely
Quoted 11 lines

-----Original Message-----
From: Grant Likely [mailto:[email protected]] =

Sent: Friday, April 17, 2009 1:10 PM
To: Benjamin Herrenschmidt
Cc: Hollis Blanchard; [email protected]; John Linn; =

Tirumala Reddy Marri
Subject: Re: Question about DBCR0 initialization for 440 =

Quoted 10 lines
Quoted 3 lines · Benjamin Herrenschmidt
Quoted 2 lines · Hollis Blanchard
Quoted 1 line · On Friday 17 April 2009 12:22:37 Josh Boyer wrote:

On Fri, Apr 17, 2009 at 11:46 AM, John Linn =

Quoted 3 lines · <[email protected]> wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

Josh, any thoughts on putting this into head_44x.S?

The code in the fsl file looks like the right solution. =A0

I do have an

Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

odd question though, in that it's hard for the kernel to really know if something like a BDI is =

running. =A0Namely,

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

that config option doesn't cover RiscWatch in an obvious manner.

Yeah, setting DBCR0 would interfere with all JTAG probes. =

The ifdef meands you

Quoted 1 line
Quoted 1 line

can't support both a JTAG debugger and hardware =

breakpoints in the same

Quoted 2 lines
Quoted 1 line

binary? Now that's an annoying restriction.

Quoted 8 lines
Quoted 1 line

Might be worth checking if external debug is enabled, and =

override it

Quoted 1 line

only if it's not.

=

ppc440x5_um.pdf says that both can be enabled.
=

The code that I started the thread with, from the fsl file, has conditional=
for the BDI around it.

We think that we still need that conditional as the code is not Oring in th= e enable such that it would
disable external debug mode for the BDI. But we need it this way for our Xi= linx pod.

#if !defined(CONFIG_BDI_SWITCH)
            /*
             * The Abatron BDI JTAG debugger does not tolerate others
             * mucking with the debug registers.
             */
            lis     r2,DBCR0_IDM@h
            mtspr   SPRN_DBCR0,r2
            isync
            /* clear any residual debug events */
            li      r2,-1
            mtspr   SPRN_DBSR,r2

#endif =

Quoted 10 lines

g.
=

-- =

Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
=

=

This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately.

#8 lore raw
Quoted 11 lines · John Linn
Quoted 6 lines
Quoted 1 line

Might be worth checking if external debug is enabled, and

override it

Quoted 1 line

only if it's not.

ppc440x5_um.pdf says that both can be enabled.

The code that I started the thread with, from the fsl file, has conditional for the BDI around it.

We think that we still need that conditional as the code is not Oring in the enable such that it would disable external debug mode for the BDI. But we need it this way for our Xilinx pod.

EDM is a read-only bit according to the docs I have. You can't set it (or clear it) at all. It's only set by external hardware.

josh

author
#9 lore raw

=

Quoted 31 lines

-----Original Message-----
From: Josh Boyer [mailto:[email protected]] =

Sent: Friday, April 17, 2009 2:36 PM
To: John Linn
Cc: [email protected]; Benjamin Herrenschmidt; =

[email protected]; Hollis Blanchard; Tirumala Reddy Marri
Subject: Re: Question about DBCR0 initialization for 440 =

Quoted 11 lines · John Linn
Quoted 8 lines
Quoted 1 line

Might be worth checking if external debug is enabled, and =

override it

Quoted 1 line

only if it's not.

=

ppc440x5_um.pdf says that both can be enabled.
=

The code that I started the thread with, from the fsl file, =

has conditional for the BDI around it.

Quoted 2 lines

We think that we still need that conditional as the code is =

not Oring in the enable such that it would

Quoted 1 line

disable external debug mode for the BDI. But we need it this =

Quoted 7 lines

way for our Xilinx pod.
=

EDM is a read-only bit according to the docs I have. You =

can't set it (or
clear it) at all. It's only set by external hardware.

That's strange, my 440x4_um.pdf does not say it's read-only unless it's in some obscure place.

Quoted 6 lines

=

josh
=

=

This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately.

#11 lore raw
In reply to John Linn
Quoted 1 line · On Friday 17 April 2009 15:30:45 John Linn wrote:

We think that we still need that conditional as the code is not Oring in the

enable such that it would

Quoted 1 line

disable external debug mode for the BDI. But we need it this way for our

Xilinx pod.

Quoted 12 lines
#if !defined(CONFIG_BDI_SWITCH)
            /*
             * The Abatron BDI JTAG debugger does not tolerate others
             * mucking with the debug registers.
             */
            lis     r2,DBCR0_IDM@h
            mtspr   SPRN_DBCR0,r2
            isync
            /* clear any residual debug events */
            li      r2,-1
            mtspr   SPRN_DBSR,r2
Quoted 1 line

#endif

So change the code to OR in your bits. What's the problem?

Signature · 2 lines
Hollis Blanchard
IBM Linux Technology Center
#10 lore raw
In reply to John Linn
Quoted 24 lines · John Linn
Quoted 24 lines

-----Original Message-----
From: Josh Boyer [mailto:[email protected]]
Sent: Friday, April 17, 2009 2:36 PM
To: John Linn
Cc: [email protected]; Benjamin Herrenschmidt; [email protected]; Hollis Blanchard; Tirumala Reddy Marri
Subject: Re: Question about DBCR0 initialization for 440

Quoted 8 lines · John Linn
Quoted 6 lines
Quoted 1 line

Might be worth checking if external debug is enabled, and

override it

Quoted 1 line

only if it's not.

ppc440x5_um.pdf says that both can be enabled.

The code that I started the thread with, from the fsl file,

has conditional for the BDI around it.

Quoted 2 lines

We think that we still need that conditional as the code is

not Oring in the enable such that it would

Quoted 1 line

disable external debug mode for the BDI. But we need it this

Quoted 8 lines
Quoted 5 lines

way for our Xilinx pod.

EDM is a read-only bit according to the docs I have. You can't set it (or
clear it) at all. It's only set by external hardware.

That's strange, my 440x4_um.pdf does not say it's read-only unless it's in some obscure place.

Gah. I think that was my mistake. I don't see that in x4 or x5 manuals, but it came up on IRC.

josh

author
#12 lore raw
In reply to Hollis Blanchard
Quoted 39 lines

-----Original Message-----
From: Hollis Blanchard [mailto:[email protected]] =

Sent: Friday, April 17, 2009 2:50 PM
To: John Linn
Cc: [email protected]; Benjamin Herrenschmidt; =

[email protected]; Tirumala Reddy Marri
Subject: Re: Question about DBCR0 initialization for 440 =

Quoted 1 line · On Friday 17 April 2009 15:30:45 John Linn wrote:

We think that we still need that conditional as the code is =

not Oring in the =

enable such that it would

Quoted 1 line

disable external debug mode for the BDI. But we need it =

this way for our =

Xilinx pod.

Quoted 5 lines

=

#if !defined(CONFIG_BDI_SWITCH)
/*
* The Abatron BDI JTAG debugger does not =

tolerate others

Quoted 9 lines
             * mucking with the debug registers.
             */
            lis     r2,DBCR0_IDM@h
            mtspr   SPRN_DBCR0,r2
            isync
            /* clear any residual debug events */
            li      r2,-1
            mtspr   SPRN_DBSR,r2

#endif

Quoted 3 lines

=

So change the code to OR in your bits. What's the problem?

The Xilinx pod uses external mode and we don't want it set when running Linux on the board. It is targeted more to stand alone (non-OS) applications with different debug requirements.

Quoted 9 lines

=

-- =

Hollis Blanchard
IBM Linux Technology Center
=

=

This email and any attachments are intended for the sole use of the named r= ecipient(s) and contain(s) confidential information that may be proprietary= , privileged or copyrighted under applicable law. If you are not the intend= ed recipient, do not read, copy, or forward this email message or any attac= hments. Delete this email message and any attachments immediately.