Subject: Re: recent dom0 kernels reboot on loading?
To: Mikolaj Golub <to.my.trociny@gmail.com>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: port-xen
Date: 09/23/2007 15:52:36
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Mon, Sep 17, 2007 at 09:30:13PM +0200, Manuel Bouyer wrote:
> [...]
> > (gdb) disassemble 0xc04cc344
> > Dump of assembler code for function mutex_enter:
> > 0xc04cc340 <mutex_enter+0>: mov 0x4(%esp),%edx
> > 0xc04cc344 <mutex_enter+4>: mov %fs:0x18,%ecx
> > 0xc04cc34b <mutex_enter+11>: xor %eax,%eax
> > 0xc04cc34d <mutex_enter+13>: cmpxchg %ecx,0x0(%edx)
> > 0xc04cc351 <mutex_enter+17>: jne,pn 0xc04161b0 <mutex_vector_enter>
> > 0xc04cc358 <mutex_enter+24>: ret
> > 0xc04cc359 <mutex_enter+25>: lea 0x0(%esi),%esi
> > End of assembler dump.
> >
> > Am I right interpreting it that `list *0xc04cc344' did not output because at
> > address 0xc04cc344 there is assembler function mutex_enter? So, crush is at
> > mutex_enter?
>
> Yes, on the mov %fs:0x18,%ecx intruction, or maybe the previous one.
> I'm not sure if it's OK for %fs to be 0 at this point. To me it looks like
> it should not.
So %fs has to point to a segment descriptor pointing to the cpu_info for
the local CPU and we're trying to use it before it was initialised.
Basically consinit() has to be called after initgdt(), the attached patch
does it (it calls initgdt() ASAP and then consinit, because consinit()
has to be called very early too).
Can someone please try this patch and see if it solves the problem ?
It doesn't seem to have bad effects on my systems, but I didn't see
the crash either before ...
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xencons.diff"
Index: sys/arch/xen/i386/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/xen/i386/machdep.c,v
retrieving revision 1.41
diff -u -r1.41 machdep.c
--- sys/arch/xen/i386/machdep.c 8 Jul 2007 10:19:24 -0000 1.41
+++ sys/arch/xen/i386/machdep.c 23 Sep 2007 13:41:24 -0000
@@ -1436,7 +1436,6 @@
#if defined(XEN) && (NISA > 0 || NPCI > 0)
x86_bus_space_init();
#endif
- consinit(); /* XXX SHOULD NOT BE DONE HERE */
xen_parse_cmdline(XEN_PARSE_BOOTFLAGS, NULL);
/*
* Initailize PAGE_SIZE-dependent variables.
@@ -1480,6 +1479,13 @@
physmem += xen_start_info.nr_pages;
uvmexp.wired += atop(avail_start);
#endif
+ /*
+ * initgdt() has to be done before consinit(), so that %fs is properly
+ * initialised. initgdt() uses pmap_kenter_pa so it can't be called
+ * before the above variables are set.
+ */
+ initgdt();
+ consinit(); /* XXX SHOULD NOT BE DONE HERE */
/*
* reserve memory for real-mode call
@@ -1879,8 +1885,6 @@
#endif
pmap_update(pmap_kernel());
- initgdt();
-
HYPERVISOR_set_callbacks(
GSEL(GCODE_SEL, SEL_KPL), (unsigned long)hypervisor_callback,
GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback);
--2fHTh5uZTiUOsy+g--