%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.
This commit is contained in:
bouyer 2007-09-24 18:34:01 +00:00
parent 43ed9716b7
commit 29bd9d9414

View File

@ -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 <sys/cdefs.h>
__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);