From owner-freebsd-ia32 Tue Mar 20 11: 3:24 2001 Delivered-To: freebsd-ia32@freebsd.org Received: from pike.osd.bsdi.com (pike.osd.bsdi.com [204.216.28.222]) by hub.freebsd.org (Postfix) with ESMTP id 7334137B71B; Tue, 20 Mar 2001 11:03:15 -0800 (PST) (envelope-from jhb@foo.osd.bsdi.com) Received: from foo.osd.bsdi.com (root@foo.osd.bsdi.com [204.216.28.137]) by pike.osd.bsdi.com (8.11.1/8.9.3) with ESMTP id f2KJ3BK56203; Tue, 20 Mar 2001 11:03:11 -0800 (PST) (envelope-from jhb@foo.osd.bsdi.com) Received: (from jhb@localhost) by foo.osd.bsdi.com (8.11.1/8.11.1) id f2KJ0bp53633; Tue, 20 Mar 2001 11:00:37 -0800 (PST) (envelope-from jhb) Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Tue, 20 Mar 2001 11:00:36 -0800 (PST) Organization: BSD, Inc. From: John Baldwin To: rnordier@FreeBSD.org Subject: Fix BTX to handle early kernel traps Cc: ia32@FreeBSD.org Sender: owner-freebsd-ia32@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 -ifdef(`PAGING',` andl $~0x80000000,%eax # Disable movl %eax,%cr0 # paging -') xorl %ecx,%ecx # Zero -ifdef(`PAGING',` 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 -- 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@FreeBSD.org with "unsubscribe freebsd-ia32" in the body of the message From owner-freebsd-ia32 Wed Mar 21 11:32:41 2001 Delivered-To: freebsd-ia32@freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3DF7137B78D; Wed, 21 Mar 2001 11:32:19 -0800 (PST) (envelope-from rnordier@FreeBSD.org) Received: (from rnordier@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f2LIQDq98641; Wed, 21 Mar 2001 10:26:13 -0800 (PST) (envelope-from rnordier) From: Message-Id: <200103211826.f2LIQDq98641@freefall.freebsd.org> Subject: Re: Fix BTX to handle early kernel traps In-Reply-To: from John Baldwin at "Mar 20, 2001 11: 0:36 am" To: jhb@FreeBSD.org (John Baldwin) Date: Wed, 21 Mar 2001 10:26:03 -0800 (PST) Cc: rnordier@FreeBSD.org, ia32@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-ia32@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org John Baldwin wrote: > 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: > [ . . . ] > Any objections? Fine by me. -- Robert Nordier rnordier@nordier.com // Le monde est plein de fous, et qui n'en veut pas voir rnordier@FreeBSD.org // Doit se tenir tout seul, et casser son miroir. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ia32" in the body of the message