From owner-freebsd-emulation@FreeBSD.ORG Mon Oct 12 20:15:58 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 1AACA1065672 for ; Mon, 12 Oct 2009 20:15:58 +0000 (UTC) (envelope-from blauwirbel@gmail.com) Received: from mail-bw0-f223.google.com (mail-bw0-f223.google.com [209.85.218.223]) by mx1.freebsd.org (Postfix) with ESMTP id 894968FC12 for ; Mon, 12 Oct 2009 20:15:57 +0000 (UTC) Received: by bwz23 with SMTP id 23so2206592bwz.43 for ; Mon, 12 Oct 2009 13:15:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=g0yKBLwsTGAdIljkBTTVIWOd+Z2Ep4XAAg1aWeFRxt8=; b=bshGPBRpmmUD7xHAjrDGFMRlGt5ApxGvBXuGoD6EqNqvIwnFfoIE2hA3T6dVC25CdJ 0FOifQ26uVKYzPXPID9MkHhpd2aSj1pgXg5GM8tJ/hxb1ssXe/74Ap0RL8y38QlwWn/+ y42OqsntB9u0lLkqHg3zFmsRRthTHy/r5GsrU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=xMl0/VnRL+XCR08utdEftcMKpT51ZCpTMNS0i9xpv6d6TXlgpbPiSVPc7S5dIFWORo wykneHUTvw/HB0ZG0XXWorXnJJiykP55s00Ax/26cqrw7lN4mCyURiloRyo63q0gs0xs LQfZCRvqvL283MJzS+FaMovB+13OnsPg4t0+k= MIME-Version: 1.0 Received: by 10.223.5.77 with SMTP id 13mr1724543fau.86.1255377344626; Mon, 12 Oct 2009 12:55:44 -0700 (PDT) In-Reply-To: <20091011221840.GA55502@triton8.kn-bremen.de> References: <20091007220549.GA65997@triton8.kn-bremen.de> <20091011221840.GA55502@triton8.kn-bremen.de> From: Blue Swirl Date: Mon, 12 Oct 2009 22:55:24 +0300 Message-ID: To: Juergen Lock Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: freebsd-emulation@freebsd.org, qemu-devel@nongnu.org, Aleksej Saushev , Toni 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 20:15:58 -0000 On Mon, Oct 12, 2009 at 1:18 AM, Juergen Lock wrot= e: > 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 >> =C2=A0 =C2=A0 =C2=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. :) =C2=A0(in pthread_setcancelstate() invoked from >> a guest write() syscall, in case anyone is wondering.) =C2=A0Other thing= s >> I tried either exit with errors or segfault as well, and i386 hosts >> probably still don't work at all yet. =C2=A0(qemu-i386 here on amd64 doe= s >> at least something, but probably needs lock_user() treatment for all >> kinds of syscalls, I only tried adding that for sysctl so far.) >> >> =C2=A0Anyway, 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: >> =C2=A0 =C2=A0 =C2=A0 http://people.freebsd.org/~nox/qemu/qemu-devel-2009= 1007.patch >> (For the folks reading this on the qemu list: =C2=A0I 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... :) =C2=A0And I have switched to the cpu-exec.c patc= h > posted by Aleksej Saushev on the qemu list and added back amd64 > code there. > > =C2=A0Here is the bsd-user patch again: Please add Signed-off-by: line and use 'diff -u' (or preferably git diff). > + =C2=A0 =C2=A0if (1 /* bsd_type =3D=3D target_freebsd */) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0regs->rdi =3D infop->start_stack; Why the if and comment? > + =C2=A0 =C2=A0 =C2=A0 =C2=A0if (1 /* bsd_type =3D=3D target_freebsd */) = { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0regs->u_regs[8] =3D infop->sta= rt_stack; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0regs->u_regs[11] =3D infop->st= art_stack; Same here. > =C2=A0 =C2=A0 =C2=A0 =C2=A0 case 0x100: > + =C2=A0 =C2=A0 =C2=A0 =C2=A0/* FreeBSD uses 0x141 for syscalls too */ > + =C2=A0 =C2=A0 =C2=A0 =C2=A0case 0x141: > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (bsd_type !=3D target_freeb= sd) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0goto badtrap; You are now also trapping on case 0x100 if bsd_type !=3D target_freebsd, which probably breaks other BSDs. > +/* 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, > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0abi_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? 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 =3D=3D target_bsdness.