Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mxpju-0006V7-It for qemu-devel@nongnu.org; Tue, 13 Oct 2009 18:21:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mxpjt-0006UN-V8 for qemu-devel@nongnu.org; Tue, 13 Oct 2009 18:21:06 -0400 Received: from [199.232.76.173] (port=46348 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mxpjt-0006UE-QL for qemu-devel@nongnu.org; Tue, 13 Oct 2009 18:21:05 -0400 Received: from gelbbaer.kn-bremen.de ([78.46.108.116]:48586 helo=smtp.kn-bremen.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mxpjt-0001EA-4V for qemu-devel@nongnu.org; Tue, 13 Oct 2009 18:21:05 -0400 From: Juergen Lock Date: Wed, 14 Oct 2009 00:19:32 +0200 Subject: Re: [Qemu-devel] Re: playing with qemu usermode emulation on FreeBSD... Message-ID: <20091013221932.GA32808@triton8.kn-bremen.de> References: <20091007220549.GA65997@triton8.kn-bremen.de> <20091011221840.GA55502@triton8.kn-bremen.de> <20091012222058.GA43121@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20091012222058.GA43121@triton8.kn-bremen.de> Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juergen Lock Cc: Blue Swirl , freebsd-emulation@freebsd.org, qemu-devel@nongnu.org, Aleksej Saushev , Toni On Tue, Oct 13, 2009 at 12:20:58AM +0200, Juergen Lock wrote: > On Mon, Oct 12, 2009 at 10:55:24PM +0300, Blue Swirl wrote: > > On Mon, Oct 12, 2009 at 1:18 AM, Juergen Lock wrote: > > > On Thu, Oct 08, 2009 at 12:05:49AM +0200, Juergen Lock wrote: > > >> I recently noticed there are x86 bsd-user targets now (yeah I tota= lly > > >> missed those commits...) and now got it working a tiny little bit: > > >> I can run > > >> =A0 =A0 =A0 qemu-x86_64 -bsd freebsd /rescue/echo foo bar > > >> here on FreeBSD 8/amd64 and it echoes foo bar as expected, but > > >> segfaults afterwards. :) =A0(in pthread_setcancelstate() invoked f= rom > > >> a guest write() syscall, in case anyone is wondering.) =A0Other th= ings > > >> I tried either exit with errors or segfault as well, and i386 host= s > > >> probably still don't work at all yet. =A0(qemu-i386 here on amd64 = does > > >> at least something, but probably needs lock_user() treatment for a= ll > > >> kinds of syscalls, I only tried adding that for sysctl so far.) > > >> > > >> =A0Anyway, here is an emulators/qemu-devel git head snapshot port > > >> update with my current patches (files/patch-bsd-user), feel free t= o > > >> test/debug/improve: > > >> =A0 =A0 =A0 http://people.freebsd.org/~nox/qemu/qemu-devel-2009100= 7.patch > > >> (For the folks reading this on the qemu list: =A0I shall start doi= ng > > >> `proper' patch submissions later, this is more for the FreeBSD fol= ks > > >> and because I was asked to send what I have...) > > > > > > New version at the same place, which now runs FreeBSD/{i386,sparc64= } > > > /rescue/echo on FreeBSD/amd64, the FreeBSD/amd64 target now segfaul= ts > > > in pthread_setcancelstate() invoked from the final writev() tho. > > > Oh and I also uploaded the snapshot tarball so others can now actua= lly > > > build the port too... :) =A0And I have switched to the cpu-exec.c p= atch > > > posted by Aleksej Saushev on the qemu list and added back amd64 > > > code there. > > > > > > =A0Here is the bsd-user patch again: > >=20 > > Please add Signed-off-by: line and use 'diff -u' (or preferably git d= iff). > >=20 > Well I wasn't expecting this diff to be committed just yet anyway, > it's still more a wip version... >=20 > > > + =A0 =A0if (1 /* bsd_type =3D=3D target_freebsd */) > > > + =A0 =A0 =A0 =A0regs->rdi =3D infop->start_stack; > >=20 > > Why the if and comment? > >=20 > > > + =A0 =A0 =A0 =A0if (1 /* bsd_type =3D=3D target_freebsd */) { > > > + =A0 =A0 =A0 =A0 =A0 =A0regs->u_regs[8] =3D infop->start_stack; > > > + =A0 =A0 =A0 =A0 =A0 =A0regs->u_regs[11] =3D infop->start_stack; > >=20 > > Same here. > >=20 > Because bsd_type isn't available at these places in the code but > probably should be checked, I still wanted to fix that. (Maybe > make it global?) >=20 I still haven't fixed this... > > > =A0 =A0 =A0 =A0 case 0x100: > > > + =A0 =A0 =A0 =A0/* FreeBSD uses 0x141 for syscalls too */ > > > + =A0 =A0 =A0 =A0case 0x141: > > > + =A0 =A0 =A0 =A0 =A0 =A0if (bsd_type !=3D target_freebsd) > > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto badtrap; > >=20 > > You are now also trapping on case 0x100 if bsd_type !=3D target_freeb= sd, > > which probably breaks other BSDs. > >=20 > Right, thats broken, the 0x141 case should come before the 0x100 > here of course. >=20 ...but this I just fixed, and I added the multiboot.S patch, and fixed the port's cdrom dma disable knob (files/cdrom-dma-patch). (And I added the cpu-exec.c whitspace fix that was already in the patch I posted in the BSD support thread.) New version at the same place, http://people.freebsd.org/~nox/qemu/qemu-devel-20091007.patch and I now also made a shar of the patched port: http://people.freebsd.org/~nox/qemu/qemu-devel-20091007.shar Cheers, Juergen