From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: Debugging Dom0 kernel over serial Date: Wed, 6 Jun 2012 17:25:38 -0400 Message-ID: <20120606212538.GG9472@phenom.dumpdata.com> References: <64CC3033-765F-450F-A262-B19676ECA99A@cs.wisc.edu> <1338974024.32319.29.camel@zakaz.uk.xensource.com> <20120606125047.GA12043@router-fw-old.local.net-space.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ben Guthro Cc: James Paton , Ian Campbell , Daniel Kiper , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Wed, Jun 06, 2012 at 04:54:56PM -0400, Ben Guthro wrote: > What kernel version? > = > Below is a patch against 3.2.y that allows for debug using kdb over hvc > = > Some bits of this were recently upstreamed as part of some perf-tools > work in pvops...but the debug_core.c, and=A0hvc_console.c didn't make > it. I would be interested in seeing them against v3.5-rc1.. > = > With this patch, you can add the kernel parameter > kgdboc=3Dhvc0 > = > Alternately, at runtime by doing the following: > echo hvc0 > /sys/module/kgdboc/parameters/kgdboc > = > To break into the debugger, you need to press the magic SysRq key > sequence "Alt+SysRq+g" > = > While you are in the debugger, you are in "polling" console mode. As > such, there seems to be a limitation on how fast you can type > commands. I found that when I typed two letters too fast, it just > printed the help text again. > = > = > = > diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c > index d5e0e0a..88815a1 100644 > --- a/arch/x86/xen/enlighten.c > +++ b/arch/x86/xen/enlighten.c > @@ -65,6 +65,7 @@ > = > =A0#include "xen-ops.h" > =A0#include "mmu.h" > +#include "smp.h" > =A0#include "multicalls.h" > = > =A0EXPORT_SYMBOL_GPL(hypercall_page); > @@ -768,6 +769,12 @@ static void set_xen_basic_apic_ops(void) > =A0 apic->icr_write =3D xen_apic_icr_write; > =A0 apic->wait_icr_idle =3D xen_apic_wait_icr_idle; > =A0 apic->safe_wait_icr_idle =3D xen_safe_apic_wait_icr_idle; > + > + apic->send_IPI_allbutself =3D xen_send_IPI_allbutself; > + apic->send_IPI_mask_allbutself =3D xen_send_IPI_mask_allbutself; > + apic->send_IPI_mask =3D xen_send_IPI_mask; > + apic->send_IPI_all =3D xen_send_IPI_all; > + apic->send_IPI_self =3D xen_send_IPI_self; > =A0} > = > =A0#endif > diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c > index 3061244..d8928a1 100644 > --- a/arch/x86/xen/smp.c > +++ b/arch/x86/xen/smp.c > @@ -436,8 +436,8 @@ static void xen_smp_send_reschedule(int cpu) > =A0 xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR); > =A0} > = > -static void xen_send_IPI_mask(const struct cpumask *mask, > - =A0 =A0 =A0enum ipi_vector vector) > +void xen_send_IPI_mask(const struct cpumask *mask, > + =A0 =A0 =A0int vector) > =A0{ > =A0 unsigned cpu; > = > @@ -466,6 +466,39 @@ static void xen_smp_send_call_function_single_ipi(in= t cpu) > =A0 =A0XEN_CALL_FUNCTION_SINGLE_VECTOR); > =A0} > = > +void xen_send_IPI_all(int vector) > +{ > + xen_send_IPI_mask(cpu_online_mask, vector); > +} > + > +void xen_send_IPI_self(int vector) > +{ > + xen_send_IPI_one(smp_processor_id(), vector); > +} > + > +void xen_send_IPI_mask_allbutself(const struct cpumask *mask, > + int vector) > +{ > + unsigned cpu; > + unsigned int this_cpu =3D smp_processor_id(); > + > + if (!(num_online_cpus() > 1)) > + return; > + > + for_each_cpu_and(cpu, mask, cpu_online_mask) { > + if (this_cpu =3D=3D cpu) > + continue; > + > + xen_smp_send_call_function_single_ipi(cpu); > + } > +} > + > +void xen_send_IPI_allbutself(int vector) > +{ > + xen_send_IPI_mask_allbutself(cpu_online_mask, vector); > +} > + > + > =A0static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id) > =A0{ > =A0 irq_enter(); > diff --git a/arch/x86/xen/smp.h b/arch/x86/xen/smp.h > new file mode 100644 > index 0000000..8981a76 > --- /dev/null > +++ b/arch/x86/xen/smp.h > @@ -0,0 +1,12 @@ > +#ifndef _XEN_SMP_H > + > +extern void xen_send_IPI_mask(const struct cpumask *mask, > + =A0 =A0 =A0int vector); > +extern void xen_send_IPI_mask_allbutself(const struct cpumask *mask, > + int vector); > +extern void xen_send_IPI_allbutself(int vector); > +extern void physflat_send_IPI_allbutself(int vector); > +extern void xen_send_IPI_all(int vector); > +extern void xen_send_IPI_self(int vector); > + > +#endif > diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c > index 58ca7ce..4addc80 100644 > --- a/drivers/tty/hvc/hvc_console.c > +++ b/drivers/tty/hvc/hvc_console.c > @@ -754,13 +754,10 @@ int hvc_poll_init(struct tty_driver *driver, int > line, char *options) > = > =A0static int hvc_poll_get_char(struct tty_driver *driver, int line) > =A0{ > - struct tty_struct *tty =3D driver->ttys[0]; > - struct hvc_struct *hp =3D tty->driver_data; > =A0 int n; > =A0 char ch; > = > - n =3D hp->ops->get_chars(hp->vtermno, &ch, 1); > - > + n =3D cons_ops[last_hvc]->get_chars(vtermnos[last_hvc], &ch, 1); > =A0 if (n =3D=3D 0) > =A0 return NO_POLL_CHAR; > = > @@ -769,12 +766,10 @@ static int hvc_poll_get_char(struct tty_driver > *driver, int line) > = > =A0static void hvc_poll_put_char(struct tty_driver *driver, int line, cha= r ch) > =A0{ > - struct tty_struct *tty =3D driver->ttys[0]; > - struct hvc_struct *hp =3D tty->driver_data; > =A0 int n; > = > =A0 do { > - n =3D hp->ops->put_chars(hp->vtermno, &ch, 1); > + n =3D cons_ops[last_hvc]->put_chars(vtermnos[last_hvc], &ch, 1); > =A0 } while (n <=3D 0); > =A0} > =A0#endif > diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c > index cefd4a1..df904a5 100644 > --- a/kernel/debug/debug_core.c > +++ b/kernel/debug/debug_core.c > @@ -581,12 +581,14 @@ return_normal: > =A0 kgdb_roundup_cpus(flags); > =A0#endif > = > +#ifndef CONFIG_XEN > =A0 /* > =A0 * Wait for the other CPUs to be notified and be waiting for us: > =A0 */ > =A0 while (kgdb_do_roundup && (atomic_read(&masters_in_kgdb) + > =A0 atomic_read(&slaves_in_kgdb)) !=3D online_cpus) > =A0 cpu_relax(); > +#endif > = > =A0 /* > =A0 * At this point the primary processor is completely > = > = > = > = > = > On Wed, Jun 6, 2012 at 3:55 PM, James Paton wrote: > > > > Thanks everyone for your help. > > > > I tried the suggestion of leaving ttyS1 out of the Xen boot options and= using that. I confirmed that I can echo things back and forth through that= connection from the host OS. I compiled a custom version of gdb to target = x86_64-linux-gnu so I could do remote debugging from the host. No luck. I a= lso tried setting console=3DttyS1 for the dom0 kernel -- same outcome. > > > > Next, using exactly the same settings, I booted the dom0 kernel bare (n= o Xen this time) and tried the same thing. This time, it worked. I can conn= ect the debugger and it breaks as expected. So I'm thinking debugging while= running Xen over serial is a dead end, unless I figure out a way to do it = over hvc. I think for now I'll just use printk. > > > > -- Jim > > _______________________________________________ > > Xen-devel mailing list > > Xen-devel@lists.xen.org > > http://lists.xen.org/xen-devel > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel