Daemon News Ezine BSD News BSD Mall BSD Support Forum BSD Advocacy BSD Updates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix BTX to handle early kernel traps

I managed to really hose my kernel by slightly breaking an assertion in
mtx_init() and calling panic() as a result.  The only problem is that the
mtx_init() in question was done in init386 before the kernel IDT was setup,
so the actual fault's that ensued ended up hitting the BTX exception handler.
This was all nice and good except that when BTX tried to halt it wound up
recursively page faulting on itself because the kernel had enabled paging, but
BTX was not compiled with paging.  Furthermore, the gdt had changed out from
under BTX, so during the exit: target I also had to reload the gdt descriptor
register before finessing the selectors and returning to real mode.  The
included patch does all of this and I'd like to commit it:

cvs diff: Diffing .
Index: btx.s
RCS file: /usr/cvs/src/sys/boot/i386/btx/btx/btx.s,v
retrieving revision 1.23
diff -u -r1.23 btx.s
--- btx.s       2000/08/24 20:57:44     1.23
+++ btx.s       2001/03/20 17:23:23
@@ -255,14 +255,14 @@
 # Turn off paging.
                movl %cr0,%eax                  # Get CR0
                andl $~0x80000000,%eax          # Disable
                movl %eax,%cr0                  #  paging
                xorl %ecx,%ecx                  # Zero
                movl %ecx,%cr3                  # Flush TLB
+# Restore the GDT in case we caught a kernel trap.
+               lgdt gdtdesc                    # Set GDT
 # To 16 bits.

Any objections?


John Baldwin <jhb@xxxxxxxxxxx> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.Baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to majordomo@xxxxxxxxxxx
with "unsubscribe freebsd-ia32" in the body of the message