Subject: port-i386/1684: inability to boot -current i386 kernel
To: None <gnats-bugs@gnats.netbsd.org>
From: Alasdair Baird <alasdair@wildcat.demon.co.uk>
List: netbsd-bugs
Date: 10/24/1995 21:08:40
>Number:         1684
>Category:       port-i386
>Synopsis:       stray value in i386 segment register prevents startup
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 24 18:35:01 1995
>Last-Modified:
>Originator:     Alasdair Baird
>Organization:
Absolutely none whatsoever.
>Release:        NetBSD-current of 20/10/95
>Environment:
	
System: NetBSD wildcat.demon.co.uk 1.1_ALPHA NetBSD 1.1_ALPHA (WILDCAT) #6: Mon Oct 23 04:40:20 GMT 1995 root@:/usr/src/sys/arch/i386/compile/WILDCAT i386


>Description:

	It appears on my machine that the segment register fs
	has a value placed in it prior to NetBSD booting (perhaps
	by my boot selector) that never gets cleared.  This persists
	into process zero, whereupon it gets slavishly copied into
	process one and two through forking.  As soon as cpu_switch()
	in locore.s is called it hacks up a lung as the value in the
	register (0x7a00) is far too large wrt the limits imposed by
	the new i386 descriptor table mechanism.

	Typical symptoms of this problem are show in the following
	fragment:

>	...
>	biomask 4040 netmask 400 ttymask 101a
>	kernel: Protection fault trap.  code = 0
>	Stopped at _cpu_switch+0xc1	mov %ax,%fs



>How-To-Repeat:

	Try booting my machine without the following...

>Fix:

	This fix works.  Whether it is the most elegant way to do this
	or whether it is the correct place to fix it I don't pretend
	to have an opinion.

	The patch, to locore.s, in fact zeros two segment registers for
	no adequately explained reason except that I felt like it.

*** /sys/arch/i386/i386/locore.s.ORIG   Sat Oct 14 02:56:52 1995
--- /sys/arch/i386/i386/locore.s        Tue Oct 24 21:05:35 1995
***************
*** 477,482 ****
--- 477,490 ----
        call    _init386                # wire 386 chip for unix operation
        addl    $4,%esp
  
+       /*
+        * zero segment registers that may contain bogosity from
+        * time of bootstrap which could cause indigestion later
+        */
+       xorl    %eax,%eax
+       movl    %ax,%fs
+       movl    %ax,%gs
+ 
        call    _main
  
  ENTRY(proc_trampoline)

>Audit-Trail:
>Unformatted: