From owner-freebsd-emulation@FreeBSD.ORG Thu Feb 6 12:54:12 2014 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DEC911C4 for ; Thu, 6 Feb 2014 12:54:12 +0000 (UTC) Received: from isrv.corpit.ru (isrv.corpit.ru [86.62.121.231]) by mx1.freebsd.org (Postfix) with ESMTP id 6F86C1174 for ; Thu, 6 Feb 2014 12:54:11 +0000 (UTC) Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 6653740B79; Thu, 6 Feb 2014 16:44:49 +0400 (MSK) Received: from wh.tls.msk.ru (wh.tls.msk.ru [192.168.177.7]) by tsrv.corpit.ru (Postfix) with ESMTP id 2FCEB639; Thu, 6 Feb 2014 16:44:49 +0400 (MSK) Message-ID: <52F383C0.4030002@msgid.tls.msk.ru> Date: Thu, 06 Feb 2014 16:44:48 +0400 From: Michael Tokarev User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Kevin O'Connor Subject: Re: [Qemu-devel] *BSD kernel crash at boot in qemu with seabios 1.7.4 (bisected) References: <52F0DE0F.40507@msgid.tls.msk.ru> <20140205174406.GA26098@morn.localdomain> <20140206040442.GA5486@morn.localdomain> In-Reply-To: <20140206040442.GA5486@morn.localdomain> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Daniele Di Proietto , seabios , qemu-devel , freebsd-emulation@freebsd.org, Gerd Hoffmann , Julian Pidancet X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Development of Emulators of other operating systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Feb 2014 12:54:12 -0000 [Changing subject to reflect reality] I don't really understand what it is all about, as I initially said. But I've been told on freebsd IRC channels to post the issue to freebsd-emulation list, which I'm Cc'ing now, and if noone there answers, also to John Baldwin . To bring some context back, here are a few pointers: http://bugs.debian.org/737142 -- talking about pc-bsd, but it appears that the prob affects other BSD kernels too http://thread.gmane.org/gmane.comp.emulators.qemu/254074 -- this thread http://lists.gnu.org/archive/html/qemu-stable/2013-03/msg00037.html - a weird issue with freebsd reported last december If it's a bug in *BSD kernels, maybe someone there will be glad to fix it. And maybe together we can come out with a more elegant solution to this issue, or maybe to confirm (or deny) that the proposed patch is a right thing to do. Thanks, /mjt 06.02.2014 08:04, Kevin O'Connor wrote: > On Wed, Feb 05, 2014 at 12:44:06PM -0500, Kevin O'Connor wrote: >> On Tue, Feb 04, 2014 at 04:33:19PM +0400, Michael Tokarev wrote: >>> We have a bugreport in debian, http://bugs.debian.org/737142, >>> stating that PC-BSD does not work with seabios-1.7.4 anymore. >>> >>> I digged in, and found out that it fails only with -vga std >>> (cirrus works fine). So I bisected the issue - only changing >>> vgabios-stdvga.bin, and found this: > [...] >> This seems to be similar to the freebsd problem reported last year - >> see: >> http://lists.gnu.org/archive/html/qemu-stable/2013-03/msg00037.html > [...] >> (*) The best I can think of is to try and construct some hand crafted >> assembler that can catch buggy x86emu emulators and force a failure.. > > I have put together some assember to try and run-time test for known > broken versions of x86emu. This patch to SeaVGABIOS does seem to > catch the freebsd issue and in my tests it convinces freebsd to take a > different approach. The patch is a bit ugly though. > > Comments welcome. > -Kevin > > > commit e3caa553e940efb6184b30a5637134c4aa9f8b65 > Author: Kevin O'Connor > Date: Wed Feb 5 22:47:29 2014 -0500 > > vgabios: Attempt to detect old x86emu and force a fault. > > Check for cases where the leal instruction does not work. This > instruction is known to not be emulated properly on old versions of > x86emu. If a broken version of x86emu is found, force a fault that > x86emu will easily detect. This should help prevent soft failures > when running old software. > > Signed-off-by: Kevin O'Connor > > diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S > index 9854448..e246e7c 100644 > --- a/vgasrc/vgaentry.S > +++ b/vgasrc/vgaentry.S > @@ -45,9 +45,27 @@ _rom_header_signature: > * Entry points > ****************************************************************/ > > - // This macro is the same as ENTRY_ARG except the "calll" > - // instruction is avoided to work around known issues in the > - // emulation of some versions of x86emu. > + // Force a fault if found to be running on broken x86emu versions. > + DECLFUNC x86emu_fault > +x86emu_fault: > + int $0x03 > +1: hlt > + jmp 1b > + > + // This macro implements a call while avoiding instructions > + // that old versions of x86emu have problems with. > + .macro VGA_CALLL cfunc > + // Make sure leal instruction works. > + movl $0x8000, %ecx > + leal (%ecx, %ecx, 1), %ecx > + cmpl $0x10000, %ecx > + jne x86emu_fault > + // Use callw instead of calll > + push %ax > + callw \cfunc > + .endm > + > + // This macro is the same as ENTRY_ARG except VGA_CALLL is used. > .macro ENTRY_ARG_VGA cfunc > cli > cld > @@ -57,7 +75,7 @@ _rom_header_signature: > movl %esp, %ebx // Backup %esp, then zero high bits > movzwl %sp, %esp > movl %esp, %eax // First arg is pointer to struct bregs > - pushw %ax ; callw \cfunc > + VGA_CALLL \cfunc > movl %ebx, %esp // Restore %esp (including high bits) > POPBREGS > .endm > @@ -103,7 +121,7 @@ entry_10_extrastack: > movw %ds, %dx // Setup %ss/%esp and call function > movw %dx, %ss > movl %eax, %esp > - pushw %ax ; callw handle_10 > + VGA_CALLL handle_10 > > movl %esp, %eax // Restore registers and return > movw BREGS_size+4(%eax), %ss >