From owner-freebsd-emulation@FreeBSD.ORG Mon Oct 12 22:22:53 2009 Return-Path: Delivered-To: freebsd-emulation@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27773106566B for ; Mon, 12 Oct 2009 22:22:53 +0000 (UTC) (envelope-from nox@jelal.kn-bremen.de) Received: from smtp.kn-bremen.de (gelbbaer.kn-bremen.de [78.46.108.116]) by mx1.freebsd.org (Postfix) with ESMTP id AA4CC8FC19 for ; Mon, 12 Oct 2009 22:22:52 +0000 (UTC) Received: by smtp.kn-bremen.de (Postfix, from userid 10) id B13E01E006EB; Tue, 13 Oct 2009 00:22:51 +0200 (CEST) Received: from triton8.kn-bremen.de (noident@localhost [127.0.0.1]) by triton8.kn-bremen.de (8.14.3/8.14.3) with ESMTP id n9CMKxlU043888; Tue, 13 Oct 2009 00:20:59 +0200 (CEST) (envelope-from nox@triton8.kn-bremen.de) Received: (from nox@localhost) by triton8.kn-bremen.de (8.14.3/8.14.3/Submit) id n9CMKxcK043887; Tue, 13 Oct 2009 00:20:59 +0200 (CEST) (envelope-from nox) From: Juergen Lock Date: Tue, 13 Oct 2009 00:20:58 +0200 To: Blue Swirl Message-ID: <20091012222058.GA43121@triton8.kn-bremen.de> References: <20091007220549.GA65997@triton8.kn-bremen.de> <20091011221840.GA55502@triton8.kn-bremen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Cc: freebsd-emulation@freebsd.org, Toni , Juergen Lock , Aleksej Saushev , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] Re: playing with qemu usermode emulation on FreeBSD... X-BeenThere: freebsd-emulation@freebsd.org X-Mailman-Version: 2.1.5 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: Mon, 12 Oct 2009 22:22:53 -0000 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 > >>       qemu-x86_64 -bsd freebsd /rescue/echo foo bar > >> here on FreeBSD 8/amd64 and it echoes foo bar as expected, but > >> segfaults afterwards. :)  (in pthread_setcancelstate() invoked from > >> a guest write() syscall, in case anyone is wondering.)  Other things > >> I tried either exit with errors or segfault as well, and i386 hosts > >> probably still don't work at all yet.  (qemu-i386 here on amd64 does > >> at least something, but probably needs lock_user() treatment for all > >> kinds of syscalls, I only tried adding that for sysctl so far.) > >> > >>  Anyway, here is an emulators/qemu-devel git head snapshot port > >> update with my current patches (files/patch-bsd-user), feel free to > >> test/debug/improve: > >>       http://people.freebsd.org/~nox/qemu/qemu-devel-20091007.patch > >> (For the folks reading this on the qemu list:  I shall start doing > >> `proper' patch submissions later, this is more for the FreeBSD folks > >> 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 segfaults > > in pthread_setcancelstate() invoked from the final writev() tho. > > Oh and I also uploaded the snapshot tarball so others can now actually > > build the port too... :)  And I have switched to the cpu-exec.c patch > > posted by Aleksej Saushev on the qemu list and added back amd64 > > code there. > > > >  Here 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... > > +    if (1 /* bsd_type == target_freebsd */) > > +        regs->rdi = infop->start_stack; > > Why the if and comment? > > > +        if (1 /* bsd_type == target_freebsd */) { > > +            regs->u_regs[8] = infop->start_stack; > > +            regs->u_regs[11] = infop->start_stack; > > Same here. > 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?) > >         case 0x100: > > +        /* FreeBSD uses 0x141 for syscalls too */ > > +        case 0x141: > > +            if (bsd_type != target_freebsd) > > +                goto badtrap; > > You are now also trapping on case 0x100 if bsd_type != target_freebsd, > which probably breaks other BSDs. > Right, thats broken, the 0x141 case should come before the 0x100 here of course. > > +/* XXX this needs to be emulated on non-FreeBSD hosts... */ > > +static abi_long do_freebsd_sysctl(abi_ulong namep, int32_t namelen, abi_ulong oldp, > > +                          abi_ulong oldlenp, abi_ulong newp, abi_ulong newlen) > > What kind of call is this, is it possible to emulate on other BSDs? Is > it important? Its used mostly for things that on linux is done by manipulating /proc or /sys, like getting the kernel version, number of cpus, pagesize, etc. - and there are also sysctls that can be written to, like to enable ip forwarding or change sysV ipc settings. Although changes are usually restriced to root so `regular' executables rarely do them and I'm not really handling those yet. See here: http://www.freebsd.org/cgi/man.cgi?query=sysctl&apropos=0&sektion=3&manpath=FreeBSD+7.2-RELEASE&format=html > I'm just wondering if the cross-BSD emulation makes > sense after all. It would make the emulator much simpler if we could > assume that host_bsdness == target_bsdness. Yeah I was wondering about that too... Cheers, Juergen