From 29bd9d94144ecb7025f98b13913f9676756f1735 Mon Sep 17 00:00:00 2001 From: bouyer Date: Mon, 24 Sep 2007 18:34:01 +0000 Subject: [PATCH] %fs has to be initialized before mutexes are used; consinit() may end up calling mutex_enter(). So call initgdt() ASAP, and consinit() right after initgdt(). Fix Dom0 crash reported by Mikolaj Golub and others when using the VGA console. --- sys/arch/xen/i386/machdep.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/arch/xen/i386/machdep.c b/sys/arch/xen/i386/machdep.c index 09e8321b3ef3..9e5d37d16118 100644 --- a/sys/arch/xen/i386/machdep.c +++ b/sys/arch/xen/i386/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.41 2007/07/08 10:19:24 pooka Exp $ */ +/* $NetBSD: machdep.c,v 1.42 2007/09/24 18:34:01 bouyer Exp $ */ /* NetBSD: machdep.c,v 1.559 2004/07/22 15:12:46 mycroft Exp */ /*- @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.41 2007/07/08 10:19:24 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.42 2007/09/24 18:34:01 bouyer Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -1436,7 +1436,6 @@ init386(paddr_t first_avail) #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 @@ init386(paddr_t first_avail) 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 @@ init386(paddr_t first_avail) #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);