Skip to contentSkip to conversation

Debugging with a HW probe.

RFC In review Jimi Xenidis 5 participants 9 messages Aug 7, 2006 – Aug 22, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 Debugging with a HW probe.

On the XenPPC project we've been playing around with using GDB to source debug Linux (and Xen) using a RiscWatch HW probe.

On IBM POWER4 and greater processors (and possibly POWER3 and *Star) there is an instruction called ATTN (asm (".long 0x200")) that will have the process call out to the HW probe. This instruction is used by RiscWatch software to set "soft breakpoints".

We have found it useful to teach xmon to make this call so we can then debug the SW thru the probe. Is this useful to anyone else?

Below is a quick attempt at a formalized patch, tho' I am torn between making it ATTN specific or just making a generic HW Probe Service.

All comments welcome.

BTW: We even have some python that will let GDB "talk to" a RiscWatch
probe and fully source-level debug a Linux kernel (even the initial relocatable parts with a few tricks), this code is currently part of the our Xen tree (you need mercurial to get it):
http://xenbits.xensource.com/ext/xenppc-unstable.hg

The python is self contained and in:
tools/gpproxy

-JX
----

arch/powerpc/Kconfig.debug +7 -0
index 8d48e9e..b84f03d 100644
@@ -82,6 +82,13 @@ config XMON_DEFAULT
 	  xmon is normally disabled unless booted with 'xmon=on'.
 	  Use 'xmon=off' to disable xmon init during runtime.
 
+config XMON_ATTN
+       bool "Use Support Processor Attention Instruction"
+       depends on XMON && PPC64
+       help
+         If you have a hardware probe attached to your processor you
+         can 'contact' it with a the 'A' command at the xmon prompt.
+
 config IRQSTACKS
 	bool "Use separate kernel stacks when processing interrupts"
 	depends on PPC64
arch/powerpc/xmon/xmon.c +77 -1

108 lines not on this page · raw message

drivers/net/pcmcia/axnet_cs.c +0 -0
index 2ea66ac..33a7922 100644
include/asm-powerpc/reg.h +2 -0
index bd467bf..ce82965 100644
@@ -207,6 +207,8 @@ #define SPRN_EAR	0x11A		/* External Addr
 #define SPRN_HASH1	0x3D2		/* Primary Hash Address Register */
 #define SPRN_HASH2	0x3D3		/* Secondary Hash Address Resgister */
 #define SPRN_HID0	0x3F0		/* Hardware Implementation Register 0 */
+#define HID0_QATTN	(1UL<<35)	/* Sup. Proc. attn insn all threads */
+#define HID0_ATTN	(1UL<<32)	/* Sup. Proc. attn insn */
 #define HID0_EMCP	(1<<31)		/* Enable Machine Check pin */
 #define HID0_EBA	(1<<29)		/* Enable Bus Address Parity */
 #define HID0_EBD	(1<<28)		/* Enable Bus Data Parity */
include/asm-powerpc/xmon.h +7 -0
index 43f7129..cd8f48e 100644
@@ -8,5 +8,12 @@ extern int xmon(struct pt_regs *excp);
 extern void xmon_printf(const char *fmt, ...);
 extern void xmon_init(int);
 
+/*
+ * Support Processor Attention Instruction introduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile(".long 0x00000200; nop")
+
 #endif
 #endif
#1 lore raw

Hi,

Quoted 7 lines · Jimi Xenidis

On IBM POWER4 and greater processors (and possibly POWER3 and *Star) there is an instruction called ATTN (asm (".long 0x200")) that will have the process call out to the HW probe. This instruction is used by RiscWatch software to set "soft breakpoints".

We have found it useful to teach xmon to make this call so we can then debug the SW thru the probe. Is this useful to anyone else?

Being able to correlate software events with the hardware debugger looks quite useful, yes.

Quoted 2 lines

Below is a quick attempt at a formalized patch, tho' I am torn between making it ATTN specific or just making a generic HW Probe Service.

I would say make it generic, maybe with cputables entry or ppc_md member, especially with the powerpc merge and other platforms coming in, having it more generic could be useful.

Also, that way you could get rid of the PVR check within xmon.

Quoted 1 line

All comments welcome.

A couple below.

Quoted 10 lines
arch/powerpc/xmon/xmon.c +10 -0
+static void xmon_en_hw_probe(int enable)
+{
+	ulong hid0;
+	int threaded = 0;
+
+	/* hopefully the hypervisor has set us up */
+	if (firmware_has_feature(FW_FEATURE_LPAR))
+		return;
+	/* should this be a feature? */
+	switch (PVR_VER(mfspr(SPRN_PVR))) {

arch/powerpc/xmon/xmon.c #endif · line 261

Quoted 10 lines
arch/powerpc/xmon/xmon.c +10 -0
+	default:
+		return;
+
+	case PV_POWER4:
+	case PV_POWER4p:
+	case PV_POWER5:
+	case PV_POWER5p:
+	case PV_BE:
+		/* stop both threads */
+		threaded = 1;

POWER4 multithreaded? I don't think so?

arch/powerpc/xmon/xmon.c #endif · line 262

Quoted 1 line
arch/powerpc/xmon/xmon.c +1 -0
+	case PV_SSTAR:		

Trailing whitespace. Also, doesn't sstar have HMT?

Quoted 49 lines
arch/powerpc/xmon/xmon.c +38 -0
+	case PV_970:
+	case PV_970FX:
+	case PV_970MP:
+		break;
+	}
+	hid0 = mfspr(SPRN_HID0);
+	if (enable) {
+		/* make sure that on threaded processors we stop both
+		 * threads */
+		hid0 |= HID0_ATTN | (threaded ? HID0_QATTN : 0);
+		xmon_hw_probe_enabled = 1;
+	} else {
+		/* only turn the feature off */
+		hid0 &= ~HID0_ATTN;
+		xmon_hw_probe_enabled = 0;
+	}
+	/* many processors require the following sequence */
+	asm volatile(
+		"sync\n"
+		"mtspr     %1, %0\n"
+		"mfspr     %0, %1\n"
+		"mfspr     %0, %1\n"
+		"mfspr     %0, %1\n"
+		"mfspr     %0, %1\n"
+		"mfspr     %0, %1\n"
+		"mfspr     %0, %1\n"
+		"isync" : "=&r" (hid0) : "i" (SPRN_HID0), "0" (hid0):
+		"memory");
+}
+#else
+#define xmon_en_hw_probe(x)
+#endif
+
 static inline void sync(void)
 {
 	asm volatile("sync; isync");
@@ -834,6 +904,11 @@ #ifdef CONFIG_PPC_STD_MMU
 			dump_segments();
 			break;
 #endif
+#ifdef CONFIG_XMON_ATTN
+		case 'A':
+			xmon_hw_probe();
+			break;
+#endif
 		default:
 			printf("Unrecognized command: ");
 		        do {

arch/powerpc/xmon/xmon.c void xmon_init(int enable) · line 2643

Quoted 4 lines
arch/powerpc/xmon/xmon.c +1 -0
@@ -2565,6 +2640,7 @@ void xmon_init(int enable)
 		__debugger_dabr_match = NULL;
 		__debugger_fault_handler = NULL;
 	}
+	xmon_en_hw_probe(enable);

Please only enable this right before the call.

Quoted 23 lines
arch/powerpc/xmon/xmon.c +0 -0
 	xmon_map_scc();
 }
 
drivers/net/pcmcia/axnet_cs.c +0 -0
index 2ea66ac..33a7922 100644
include/asm-powerpc/reg.h +2 -0
index bd467bf..ce82965 100644
@@ -207,6 +207,8 @@ #define SPRN_EAR	0x11A		/* External Addr
 #define SPRN_HASH1	0x3D2		/* Primary Hash Address Register */
 #define SPRN_HASH2	0x3D3		/* Secondary Hash Address Resgister */
 #define SPRN_HID0	0x3F0		/* Hardware Implementation Register 0 */
+#define HID0_QATTN	(1UL<<35)	/* Sup. Proc. attn insn all threads */
+#define HID0_ATTN	(1UL<<32)	/* Sup. Proc. attn insn */
 #define HID0_EMCP	(1<<31)		/* Enable Machine Check pin */
 #define HID0_EBA	(1<<29)		/* Enable Bus Address Parity */
 #define HID0_EBD	(1<<28)		/* Enable Bus Data Parity */
include/asm-powerpc/xmon.h +0 -0
index 43f7129..cd8f48e 100644

include/asm-powerpc/xmon.h extern int xmon(struct pt_regs *excp); · line 16

Quoted 9 lines
include/asm-powerpc/xmon.h +6 -0
@@ -8,5 +8,12 @@ extern int xmon(struct pt_regs *excp);
 extern void xmon_printf(const char *fmt, ...);
 extern void xmon_init(int);
 
+/*
+ * Support Processor Attention Instruction introduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile(".long 0x00000200; nop")

At least my toolchain understands "attn ; nop"?

-Olof

#2 lore raw
Quoted 6 lines · Olof Johansson
Quoted 6 lines
include/asm-powerpc/xmon.h +0 -0
@@ -8,5 +8,12 @@ extern int xmon(struct pt_regs *excp);
 extern void xmon_printf(const char *fmt, ...);
 extern void xmon_init(int);
 
Quoted 8 lines

include/asm-powerpc/xmon.h extern int xmon(struct pt_regs *excp); · line 16

Quoted 6 lines
include/asm-powerpc/xmon.h +6 -0
+/*
+ * Support Processor Attention Instruction introduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile(".long 0x00000200; nop")

At least my toolchain understands "attn ; nop"?

looks like it was added in 2003:
2003-06-10 Gary Hade <[email protected]>
Alan Modra <[email protected]>

* ppc-opc.c (DQ, RAQ, RSQ, RTQ): Define.
(insert_dq, extract_dq, insert_raq, insert_rtq, insert_rsq): New. (powerpc_opcodes): Add "attn", "lq" and "stq".

am happy to put in symbolically.

#3 lore raw

Take 2: [RFC] Debugging with a HW probe.

In reply to Olof Johansson

A rework of the original patch, some on and off list comments had suggested that this be a generic service, and to make it very hard to unintentionally turn it on. I fact we should make sure that the feature is indeed turned off.

Any suggestions on how to operate on the HID bits of all CPUs based on the value of the config _and_ 'hw_probe_enabled' would be welcom.

I'd also like to wait for Olof's:
http://ozlabs.org/pipermail/linuxppc-dev/2006-August/025024.html
patch to make it to the tree (or not).

---

arch/powerpc/Kconfig.debug +11 -0
index e29ef77..bc4cdf9 100644
@@ -61,6 +61,17 @@ config KGDB_CONSOLE
 	  over the gdb stub.
 	  If unsure, say N.
 
+config ENABLE_HW_PROBE
+       bool "Allow instructions that contact a hardware probe (dangerous)"
+       depends on PPC64
+       help
+         If you enable this AND you add "hwprobe" to the cmdline, the
+         processor will enable instructions that contact the hardware
+         probe.  These instructions ca be used in all processor modes
+         _including_ user mode and are only useful for kernel
+         development and debugging.  DO NOT enable this unless you
+         plan to use it.
+
 config XMON
 	bool "Include xmon kernel debugger"
 	depends on DEBUGGER && !PPC_ISERIES
arch/powerpc/kernel/prom.c +8 -0
index bf2005b..02c5b83 100644
@@ -68,6 +68,9 @@ int __initdata iommu_is_off;
 int __initdata iommu_force_on;
 unsigned long tce_alloc_start, tce_alloc_end;
 #endif
+#ifdef CONFIG_ENABLE_HW_PROBE
+int hw_probe_enabled;
+#endif
 
 typedef u32 cell_t;
 
@@ -693,6 +696,11 @@ #ifdef CONFIG_PPC64
 	if (of_get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != NULL)
 		iommu_force_on = 1;
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+	if (of_get_flat_dt_prop(node, "linux,hw-probe-enable", NULL) != NULL) {
+		hw_probe_enabled = 1;
+		DBG("HW Probe will be enabled\n");
+#endif
 
 	/* mem=x on the command line is the preferred mechanism */
  	lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
arch/powerpc/kernel/prom_init.c +8 -0
index 90972ef..26428de 100644
@@ -587,6 +587,14 @@ #ifdef CONFIG_PPC64
 			RELOC(iommu_force_on) = 1;
 	}
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+	opt = strstr(RELOC(prom_cmd_line), RELOC("hwprobe"));
+	if (opt) {
+		prom_printf("WARNING! HW Probe will be activated!\n");
+		prom_setprop(_prom->chosen, "/chosen",
+			     "linux,hw-probe-enable", NULL, 0);
+	}
+#endif
 }
 
 #ifdef CONFIG_PPC_PSERIES
arch/powerpc/xmon/xmon.c +23 -1
index 179b10c..51a1e4e 100644
@@ -189,7 +189,12 @@ #endif
   dd	dump double values\n\
   dr	dump stream of raw bytes\n\
   e	print exception information\n\
-  f	flush cache\n\
+  f	flush cache\n"
+#ifdef CONFIG_ENABLE_HW_PROBE
+  "\
+  H     Contact hardware probe, if available\n"
+#endif
+  "\
   la	lookup symbol+offset of specified address\n\
   ls	lookup address of specified symbol\n\
   m	examine/change memory\n\
@@ -217,6 +222,18 @@ #endif
   zh	halt\n"
 ;
 
+#ifdef CONFIG_ENABLE_HW_PROBE
+/* try to keep this funtion from being inlined so its easier to move
+ * around the ATTN instruction */
+extern int hw_probe_enabled;
+static noinline void xmon_hw_probe(void)
+{
+	if (!hw_probe_enabled)
+		return;
+	ATTN();
+}
+#endif
+
 static struct pt_regs *xmon_regs;
 
 static inline void sync(void)
@@ -819,6 +836,11 @@ #endif /* CONFIG_SMP */
 			if (cpu_cmd())
 				return 0;
 			break;
+#ifdef CONFIG_ENABLE_HW_PROBE
+		case 'H':
+			xmon_hw_probe();
+			break;
+#endif
 		case 'z':
 			bootcmds();
 			break;
include/asm-powerpc/reg.h +14 -0
index cf73475..478097e 100644
@@ -207,6 +207,13 @@ #define SPRN_EAR	0x11A		/* External Addr
 #define SPRN_HASH1	0x3D2		/* Primary Hash Address Register */
 #define SPRN_HASH2	0x3D3		/* Secondary Hash Address Resgister */
 #define SPRN_HID0	0x3F0		/* Hardware Implementation Register 0 */
+#ifdef __ASSEMBLY__
+#define HID0_QATTN	(1<<35)		/* Sup. Proc. attn insn all threads */
+#define HID0_ATTN	(1<<32)		/* Sup. Proc. attn insn */
+#else
+#define HID0_QATTN	(1UL<<35)	/* Sup. Proc. attn insn all threads */
+#define HID0_ATTN	(1UL<<32)	/* Sup. Proc. attn insn */
+#endif
 #define HID0_EMCP	(1<<31)		/* Enable Machine Check pin */
 #define HID0_EBA	(1<<29)		/* Enable Bus Address Parity */
 #define HID0_EBD	(1<<28)		/* Enable Bus Data Parity */
@@ -641,6 +648,13 @@ extern void ppc64_runlatch_off(void);
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
 
+/*
+ * Support Processor Attention Instruction instroduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile("attn; nop")
+
 #else
 #define ppc64_runlatch_on()
 #define ppc64_runlatch_off()
#4 lore raw
In reply to Jimi Xenidis

arch/powerpc/xmon/xmon.c #endif · line 241

Quoted 6 lines · Jimi Xenidis
arch/powerpc/xmon/xmon.c +6 -0
+static noinline void xmon_hw_probe(void)
+{
+	if (!xmon_hw_probe_enabled)
+		return;
+	ATTN();
+}

I can't see how we can get to call this routine with xmon_hw_probe_enabled equal to 0... What am I missing?

Paul.

#5 lore raw
Quoted 12 lines · Paul Mackerras

arch/powerpc/xmon/xmon.c #endif · line 241

Quoted 6 lines · Jimi Xenidis
arch/powerpc/xmon/xmon.c +6 -0
+static noinline void xmon_hw_probe(void)
+{
+	if (!xmon_hw_probe_enabled)
+		return;
+	ATTN();
+}

I can't see how we can get to call this routine with xmon_hw_probe_enabled equal to 0... What am I missing?

@@ -834,6 +904,11 @@ #ifdef CONFIG_PPC_STD_MMU
dump_segments();
break;
#endif
+#ifdef CONFIG_XMON_ATTN
+ case 'A':
+ xmon_hw_probe();
+ break;
+#endif
default:
printf("Unrecognized command: "); do {

The static is used to avoid the illegal instruction trap that will/should occur if we execute this instruction and the hid bit is not set.

-JX

#6 lore raw

Re: Take 2: [RFC] Debugging with a HW probe.

In reply to Jimi Xenidis
Quoted 5 lines · Jimi Xenidis jimix at watson.ibm.com

A rework of the original patch, some on and off list comments had suggested that this be a generic service, and to make it very hard to unintentionally turn it on. I fact we should make sure that the feature is indeed turned off.

Quoted 8 lines

Any suggestions on how to operate on the HID bits of all CPUs based on the value of the config _and_ 'hw_probe_enabled' would be welcom.

I'd also like to wait for Olof's:
http://ozlabs.org/pipermail/linuxppc-dev/2006-August/025024.html
patch to make it to the tree (or not).

Signed-off-by Jimi Xenidis <jimix at watson.ibm.com>

[sorry for the list archive patch munging]

Quoted 11 lines

---

arch/powerpc/Kconfig.debug +2 -0
index e29ef77..bc4cdf9 100644
@@ -61,6 +61,17 @@ config KGDB_CONSOLE
          over the gdb stub.
          If unsure, say N.
 
+config ENABLE_HW_PROBE
+       bool "Allow instructions that contact a hardware probe 
Quoted 2 lines

(dangerous)"
+ depends on PPC64

Not having this depend on DEBUGGER but in the middle of things that do will get you scorn from the auto-indenting police.

Since we can only call this from xmon, should it depend on XMON (and be placed after that)?

arch/powerpc/Kconfig.debug

Quoted 4 lines
arch/powerpc/Kconfig.debug +4 -0
+       help
+         If you enable this AND you add "hwprobe" to the cmdline, the
+         processor will enable instructions that contact the hardware
+         probe.  These instructions ca be used in all processor modes

can

Quoted 1 line

+ _including_ user mode and are only useful for kernel

not sure this _highlighting_ is used elsewhere in Kconfig help ...

Should we mention that a hardware probe is required to continue exectuion? In other words, its not just contact, but signal and wait for a hw probe?

Quoted 21 lines
arch/powerpc/Kconfig.debug +3 -0
+         development and debugging.  DO NOT enable this unless you
+         plan to use it.
+
 config XMON
        bool "Include xmon kernel debugger"
        depends on DEBUGGER && !PPC_ISERIES
arch/powerpc/kernel/prom.c +3 -0
index bf2005b..02c5b83 100644
@@ -68,6 +68,9 @@ int __initdata iommu_is_off;
 int __initdata iommu_force_on;
 unsigned long tce_alloc_start, tce_alloc_end;
 #endif
+#ifdef CONFIG_ENABLE_HW_PROBE
+int hw_probe_enabled;
+#endif
 
 typedef u32 cell_t;
 

arch/powerpc/kernel/prom.c #ifdef CONFIG_PPC64 · line 705

Quoted 10 lines
arch/powerpc/kernel/prom.c +5 -0
@@ -693,6 +696,11 @@ #ifdef CONFIG_PPC64
        if (of_get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != 
 NULL)
                iommu_force_on = 1;
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+       if (of_get_flat_dt_prop(node, "linux,hw-probe-enable", NULL) 
 != NULL) {
+               hw_probe_enabled = 1;
+               DBG("HW Probe will be enabled\n");
+#endif

No. [see next comment]

Quoted 10 lines
arch/powerpc/kernel/prom.c +0 -0
        /* mem=x on the command line is the preferred mechanism */
        lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
arch/powerpc/kernel/prom_init.c +0 -0
index 90972ef..26428de 100644
@@ -587,6 +587,14 @@ #ifdef CONFIG_PPC64
                        RELOC(iommu_force_on) = 1;
        }

arch/powerpc/kernel/prom_init.c #ifdef CONFIG_PPC64 · line 598

Quoted 10 lines
arch/powerpc/kernel/prom_init.c +8 -0
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+       opt = strstr(RELOC(prom_cmd_line), RELOC("hwprobe"));
+       if (opt) {
+               prom_printf("WARNING! HW Probe will be activated!\n");
+               prom_setprop(_prom->chosen, "/chosen",
+                            "linux,hw-probe-enable", NULL, 0);
+       }
+#endif
 }

Please, PLEASE do NOT do this.

prom_init.c is only used by one of the many flat device tree generators, namely the open-firmware client. Adding a property like this requires us to update all the other clients.

And there is no reason to parse it this early.

Instead, parse it from the command line like the other early parsing.

I thing a generic early_param would be fine. However, xmon_init is an early_parm in setup-common, so if you really require it before the first call, then you could parse it next to mem= at the bottom of early_init_dt_scan_chosen.

Which .h is hw_probe_enabled in? (none?)

Quoted 7 lines
arch/powerpc/kernel/prom_init.c +0 -0
 #ifdef CONFIG_PPC_PSERIES
arch/powerpc/xmon/xmon.c +0 -0
index 179b10c..51a1e4e 100644

arch/powerpc/xmon/xmon.c #endif · line 197

Quoted 10 lines
arch/powerpc/xmon/xmon.c +6 -1
@@ -189,7 +189,12 @@ #endif
   dd   dump double values\n\
   dr   dump stream of raw bytes\n\
   e    print exception information\n\
-  f    flush cache\n\
+  f    flush cache\n"
+#ifdef CONFIG_ENABLE_HW_PROBE
+  "\
+  H     Contact hardware probe, if available\n"
+#endif
+  "\

While this style does keep the lines aligned in the source, it adds veritcal almost-whitespace. And I notice a different choice was made at the bottom.

Quoted 59 lines
arch/powerpc/xmon/xmon.c +17 -0
   la   lookup symbol+offset of specified address\n\
   ls   lookup address of specified symbol\n\
   m    examine/change memory\n\
@@ -217,6 +222,18 @@ #endif
   zh   halt\n"
 ;
 
+#ifdef CONFIG_ENABLE_HW_PROBE
+/* try to keep this funtion from being inlined so its easier to move
+ * around the ATTN instruction */
+extern int hw_probe_enabled;
+static noinline void xmon_hw_probe(void)
+{
+       if (!hw_probe_enabled)
+               return;
+       ATTN();
+}
+#endif
+
 static struct pt_regs *xmon_regs;
 
 static inline void sync(void)
@@ -819,6 +836,11 @@ #endif /* CONFIG_SMP */
                        if (cpu_cmd())
                                return 0;
                        break;
+#ifdef CONFIG_ENABLE_HW_PROBE
+               case 'H':
+                       xmon_hw_probe();
+                       break;
+#endif
                case 'z':
                        bootcmds();
                        break;
include/asm-powerpc/reg.h +0 -0
index cf73475..478097e 100644
@@ -207,6 +207,13 @@ #define SPRN_EAR   0x11A           /* External 

Addr
#define SPRN_HASH1 0x3D2 /* Primary Hash Address
Register */
#define SPRN_HASH2 0x3D3 /* Secondary Hash Address
Resgister */
#define SPRN_HID0 0x3F0 /* Hardware Implementation
Register 0 */

include/asm-powerpc/reg.h +2 -0
+#ifdef __ASSEMBLY__
+#define HID0_QATTN     (1<<35)         /* Sup. Proc. attn insn all 

threads */

include/asm-powerpc/reg.h +3 -0
+#define HID0_ATTN      (1<<32)         /* Sup. Proc. attn insn */
+#else
+#define HID0_QATTN     (1UL<<35)       /* Sup. Proc. attn insn all 

threads */

include/asm-powerpc/reg.h +2 -0
+#define HID0_ATTN      (1UL<<32)       /* Sup. Proc. attn insn */
+#endif
 #define HID0_EMCP      (1<<31)         /* Enable Machine Check pin */
 #define HID0_EBA       (1<<29)         /* Enable Bus Address Parity */
 #define HID0_EBD       (1<<28)         /* Enable Bus Data Parity */

include/asm-powerpc/reg.h extern void ppc64_runlatch_off(void); · line 657

Quoted 10 lines
include/asm-powerpc/reg.h +7 -0
@@ -641,6 +648,13 @@ extern void ppc64_runlatch_off(void);
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long value);
 
+/*
+ * Support Processor Attention Instruction instroduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile("attn; nop")
+

Fairly certian POWER3 does NOT implement this, but I don't have book IV handy. Does one of the processors require the nop ?

include/asm-powerpc/reg.h extern void ppc64_runlatch_off(void); · line 660

Quoted 4 lines
include/asm-powerpc/reg.h +0 -0
 #else
 #define ppc64_runlatch_on()
 #define ppc64_runlatch_off()

milton

#7 lore raw

Re: Take 2: [RFC] Debugging with a HW probe.

Quoted 44 lines · Milton Miller

On Aug 14, 2006, at 5:16 AM, Jimi Xenidis jimix at watson.ibm.com

Review #ifdef CONFIG_PPC64 · line 705

Quoted 11 lines
(quoted diff) +5 -0
@@ -693,6 +696,11 @@ #ifdef CONFIG_PPC64
        if (of_get_flat_dt_prop(node, "linux,iommu-force-on", NULL) != 
 NULL)
                iommu_force_on = 1;
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+       if (of_get_flat_dt_prop(node, "linux,hw-probe-enable", NULL) 
 != NULL) {
+               hw_probe_enabled = 1;
+               DBG("HW Probe will be enabled\n");
+#endif

No. [see next comment]

Quoted 11 lines
(quoted diff) +0 -0
        /* mem=x on the command line is the preferred mechanism */
        lprop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
arch/powerpc/kernel/prom_init.c +0 -0
index 90972ef..26428de 100644
@@ -587,6 +587,14 @@ #ifdef CONFIG_PPC64
                        RELOC(iommu_force_on) = 1;
        }

arch/powerpc/kernel/prom_init.c #ifdef CONFIG_PPC64 · line 598

Quoted 10 lines
arch/powerpc/kernel/prom_init.c +8 -0
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+       opt = strstr(RELOC(prom_cmd_line), RELOC("hwprobe"));
+       if (opt) {
+               prom_printf("WARNING! HW Probe will be activated!\n");
+               prom_setprop(_prom->chosen, "/chosen",
+                            "linux,hw-probe-enable", NULL, 0);
+       }
+#endif
 }

Please, PLEASE do NOT do this.

prom_init.c is only used by one of the many flat device tree generators, namely the open-firmware client. Adding a property like this requires us
to update all the other clients.

Quoted 8 lines

And there is no reason to parse it this early.

Instead, parse it from the command line like the other early parsing.

I thing a generic early_param would be fine. However, xmon_init is an early_parm in setup-common, so if you really require it before the first call, then you could parse it next to mem= at the bottom of early_init_dt_scan_chosen.

What Milton said, we learnt that the hard way with kexec :)

Except that we don't do mem= in early_init_dt_scan_chosen anymore (get a newer kernel Milton!).

The early_param parsing is done very early, and the xmon= parsing does not jump into xmon, it waits until a little later before doing it. So an early_param should be fine, ie. it will be parsed before xmon ever runs.

cheers

Signature · 8 lines
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#8 lore raw

Re: Take 2: [RFC] Debugging with a HW probe.

In reply to Milton Miller
Quoted 16 lines · Milton Miller
Quoted 2 lines · Jimi Xenidis jimix at watson.ibm.com
Signed-off-by Jimi Xenidis <jimix at watson.ibm.com>

[sorry for the list archive patch munging]

Quoted 9 lines

---

arch/powerpc/Kconfig.debug +0 -0
index e29ef77..bc4cdf9 100644
@@ -61,6 +61,17 @@ config KGDB_CONSOLE
          over the gdb stub.
          If unsure, say N.
 
Quoted 7 lines
Quoted 4 lines
arch/powerpc/Kconfig.debug +2 -0
+config ENABLE_HW_PROBE
+       bool "Allow instructions that contact a hardware probe  

(dangerous)"
+ depends on PPC64

Not having this depend on DEBUGGER but in the middle of things that do will get you scorn from the auto-indenting police.

ACK

Quoted 3 lines

Since we can only call this from xmon, should it depend on XMON (and be placed after that)?

If the HW probe is available, XMON will use it.
However, enabling the HW probe also means that I can (as a developer) insert ATTN() anywhere in my code and have the probe stop there. I even have kernels where BUG() contains ATTN(), but thats another patch.

Quoted 10 lines
Quoted 8 lines
arch/powerpc/Kconfig.debug +2 -0
+       help
+         If you enable this AND you add "hwprobe" to the cmdline,  

the
+ processor will enable instructions that contact the
hardware
+ probe. These instructions ca be used in all processor
modes

can

ACK

Quoted 4 lines
Quoted 2 lines

+ _including_ user mode and are only useful for kernel

not sure this _highlighting_ is used elsewhere in Kconfig help ...

I was looking for an example and found "_will not boot_" in this very file.

Quoted 3 lines

Should we mention that a hardware probe is required to continue exectuion? In other words, its not just contact, but signal and wait for a hw probe?

Hows this?
If you enable this AND you add "hwprobe" to the cmdline, the processor will enable instructions that signal and wait for the hardware probe, _stopping_ the processor. These instructions can be used in all processor modes _including_ user mode and are only useful for kernel development and debugging. DO NOT enable this unless you plan to use it. If you DO NOT have a hardware probe, answer N.

[snip]

Quoted 10 lines
Quoted 10 lines
arch/powerpc/kernel/prom_init.c +4 -0
@@ -587,6 +587,14 @@ #ifdef CONFIG_PPC64
                        RELOC(iommu_force_on) = 1;
        }
 #endif
+#ifdef CONFIG_HW_PROBE_ENABLE
+       opt = strstr(RELOC(prom_cmd_line), RELOC("hwprobe"));
+       if (opt) {
+               prom_printf("WARNING! HW Probe will be activated! 
Quoted 8 lines

arch/powerpc/kernel/prom_init.c #ifdef CONFIG_PPC64 · line 599

Quoted 6 lines
arch/powerpc/kernel/prom_init.c +4 -0
 \n");
+               prom_setprop(_prom->chosen, "/chosen",
+                            "linux,hw-probe-enable", NULL, 0);
+       }
+#endif
 }

Please, PLEASE do NOT do this.

Ok, I won't. I somehow missed "early_param()" that should do just fine.

Quoted 2 lines

Which .h is hw_probe_enabled in? (none?)

Correct, this RFC is to get valuable feedback (thank you), the setting the global is the current goal, I'm waiting for some other patches from other people to get in before we start going after HID bits that this global, may or may not be part of.

Quoted 13 lines
Quoted 13 lines
arch/powerpc/kernel/prom_init.c +0 -0
 #ifdef CONFIG_PPC_PSERIES
arch/powerpc/xmon/xmon.c +1 -1
index 179b10c..51a1e4e 100644
@@ -189,7 +189,12 @@ #endif
   dd   dump double values\n\
   dr   dump stream of raw bytes\n\
   e    print exception information\n\
-  f    flush cache\n\
+  f    flush cache\n"
Quoted 8 lines

arch/powerpc/xmon/xmon.c #define isalnum(c) (('0' <= (c) && (c) < · line 184

Quoted 5 lines
arch/powerpc/xmon/xmon.c +5 -0
+#ifdef CONFIG_ENABLE_HW_PROBE
+  "\
+  H     Contact hardware probe, if available\n"
+#endif
+  "\

While this style does keep the lines aligned in the source, it adds veritcal almost-whitespace.

Are you expressing "dislike"?

Quoted 1 line

And I notice a different choice was made at the bottom.

I borrowed from the CONFIG_SMP above and avoided putting '"' in col 0 but am happy to compress.

[snip]

Quoted 5 lines
Quoted 5 lines
arch/powerpc/xmon/xmon.c +0 -0
@@ -641,6 +648,13 @@ extern void ppc64_runlatch_off(void);
 extern unsigned long scom970_read(unsigned int address);
 extern void scom970_write(unsigned int address, unsigned long  
 value);
 
Quoted 10 lines

arch/powerpc/xmon/xmon.c extern void ppc64_runlatch_off(void); · line 658

Quoted 7 lines
arch/powerpc/xmon/xmon.c +7 -0
+/*
+ * Support Processor Attention Instruction instroduced in POWER
+ * architecture processors as of RS64, tho may not be supported by
+ * POWER 3.
+ */
+#define ATTN() asm volatile("attn; nop")
+

Fairly certian POWER3 does NOT implement this, but I don't have book IV handy.

The book4 mentions "BPUBKT" and when asked no one could give a definite answerm, I figured I'd try an see at some point. Having said that, you give me a s/Fairly/Absolutely/ and its GONE!

Quoted 1 line

Does one of the processors require the nop ?

The nop is there so that once in the probe, depending on your probe interface, you can easily skip it by adding 4 to the PC knowing you would get a nop. This is not entirely necessary but some processor/probes have a PC and a "next PC". I have had little experience with this probe and wanted to make sure I had something to set both to if it was needed.

Thanks for your feedback.
-JX