Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mzc7P-0004Dv-77 for qemu-devel@nongnu.org; Sun, 18 Oct 2009 16:12:43 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mzc7O-0004De-MW for qemu-devel@nongnu.org; Sun, 18 Oct 2009 16:12:42 -0400 Received: from [199.232.76.173] (port=46659 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mzc7O-0004Db-KI for qemu-devel@nongnu.org; Sun, 18 Oct 2009 16:12:42 -0400 Received: from gelbbaer.kn-bremen.de ([78.46.108.116]:44245 helo=smtp.kn-bremen.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mzc7O-0006xV-6C for qemu-devel@nongnu.org; Sun, 18 Oct 2009 16:12:42 -0400 From: Juergen Lock Date: Sun, 18 Oct 2009 22:10:11 +0200 Subject: Re: [Qemu-devel] Re: playing with qemu usermode emulation on FreeBSD... Message-ID: <20091018201011.GA52533@triton8.kn-bremen.de> References: <20091007220549.GA65997@triton8.kn-bremen.de> <20091011221840.GA55502@triton8.kn-bremen.de> <20091012222058.GA43121@triton8.kn-bremen.de> <20091013221932.GA32808@triton8.kn-bremen.de> <20091016223426.GA54110@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: freebsd-emulation@freebsd.org, Toni , Juergen Lock , Aleksej Saushev , qemu-devel@nongnu.org On Sun, Oct 18, 2009 at 09:26:00PM +0300, Blue Swirl wrote: > On Sat, Oct 17, 2009 at 1:34 AM, Juergen Lock = wrote: > > On Wed, Oct 14, 2009 at 12:19:32AM +0200, Juergen Lock wrote: > >> 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= totally > >> > > >> 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, bu= t > >> > > >> segfaults afterwards. :) =A0(in pthread_setcancelstate() invo= ked from > >> > > >> a guest write() syscall, in case anyone is wondering.) =A0Oth= er things > >> > > >> I tried either exit with errors or segfault as well, and i386= hosts > >> > > >> probably still don't work at all yet. =A0(qemu-i386 here on a= md64 does > >> > > >> at least something, but probably needs lock_user() treatment = for all > >> > > >> 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 f= ree to > >> > > >> test/debug/improve: > >> > > >> =A0 =A0 =A0 http://people.freebsd.org/~nox/qemu/qemu-devel-20= 091007.patch > >> > > >> (For the folks reading this on the qemu list: =A0I shall star= t doing > >> > > >> `proper' patch submissions later, this is more for the FreeBS= D folks > >> > > >> and because I was asked to send what I have...) > >> > > > > >> > > > New version at the same place, which now runs FreeBSD/{i386,sp= arc64} > >> > > > /rescue/echo on FreeBSD/amd64, the FreeBSD/amd64 target now se= gfaults > >> > > > in pthread_setcancelstate() invoked from the final writev() th= o. > >> > > > Oh and I also uploaded the snapshot tarball so others can now = actually > >> > > > build the port too... :) =A0And I have switched to the cpu-exe= c.c patch > >> > > > posted by Aleksej Saushev on the qemu list and added back amd6= 4 > >> > > > code there. > >> > > > > >> > > > =A0Here is the bsd-user patch again: > >> > > > >> > > Please add Signed-off-by: line and use 'diff -u' (or preferably = git diff). > >> > > > >> > Well I wasn't expecting this diff to be committed just yet anyway, > >> > it's still more a wip version... > >> > > >> > > > + =A0 =A0if (1 /* bsd_type =3D=3D target_freebsd */) > >> > > > + =A0 =A0 =A0 =A0regs->rdi =3D infop->start_stack; > >> > > > >> > > Why the if and comment? > >> > > > >> > > > + =A0 =A0 =A0 =A0if (1 /* bsd_type =3D=3D target_freebsd */) { > >> > > > + =A0 =A0 =A0 =A0 =A0 =A0regs->u_regs[8] =3D infop->start_stac= k; > >> > > > + =A0 =A0 =A0 =A0 =A0 =A0regs->u_regs[11] =3D infop->start_sta= ck; > >> > > > >> > > Same here. > >> > > > >> > =A0Because bsd_type isn't available at these places in the code bu= t > >> > probably should be checked, I still wanted to fix that. =A0(Maybe > >> > make it global?) > >> > > >> 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; > >> > > > >> > > You are now also trapping on case 0x100 if bsd_type !=3D target_= freebsd, > >> > > which probably breaks other BSDs. > >> > > > >> > =A0Right, thats broken, the 0x141 case should come before the 0x10= 0 > >> > here of course. > >> > > >> =A0...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.) > >> > >> =A0New version at the same place, > >> =A0 =A0 =A0 http://people.freebsd.org/~nox/qemu/qemu-devel-20091007.= patch > >> and I now also made a shar of the patched port: > >> =A0 =A0 =A0 http://people.freebsd.org/~nox/qemu/qemu-devel-20091007.= shar > > > > Updated again, among other things I added basic FreeBSD sysarch(2) > > handling, fixed syscall errno return (I had added code to set the > > carry bit for the x86 target before but the sign of the returned errn= o > > was still wrong), and I finally fixed the if (1) above (made bsd_type > > global.) > > > > =A0And, I now can run FreeBSD/amd64 /bin/sh and vim on same! :) =A0(z= sh > > not yet tho.) > > > > =A0Oh and Toni tested taking FreeBSD/i386's default linker script, > > changing only the load address to 0x60000000 as in qemu's and, > > using that as i386.ld, he now can run qemu-i386 on FreeBSD/i386 with > > simple executables too... =A0See files/patch-bsd-user-ld in the shar, > > which I also now moved the x86_64.ld patch to that I had talked about > > earlier. =A0It probably can't be used everywhere as is tho since it h= as: > > =A0 =A0 =A0 =A0OUTPUT_FORMAT("elf32-i386-freebsd", "elf32-i386-freebs= d", > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"elf32-i386-freebsd") > > (and I also don't know if the one currently in the tree has other > > features that are needed at least on Linux, any linker gurus care > > to comment?) > > > > =A0Here is the rest of the bsd-user patches again (files/patch-bsd-us= er > > in the shar), if you think they are ready to commit I'm not against i= t > > anymore :), comments are also welcome of course. >=20 > Thanks, applied. I made up a short commit message. Sorry, my fault, I should have supplied a `proper' one... :/ (sysarch(2) and errno were only the things I fixed since the last iteration, I guess its too late to add the rest now?) In other news... I have made another port update from today's git: http://people.freebsd.org/~nox/qemu/qemu-devel-20091018.patch resp. http://people.freebsd.org/~nox/qemu/qemu-devel-20091018.shar Enjoy, Juergen