From owner-freebsd-emulation@FreeBSD.ORG Sun Sep 7 21:53:11 2008 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 A3E9B106564A; Sun, 7 Sep 2008 21:53:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id 4B2698FC23; Sun, 7 Sep 2008 21:53:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1KcSBw-000Cld-Nn; Mon, 08 Sep 2008 00:53:09 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m87Lr0jk016165 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 8 Sep 2008 00:53:01 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m87Lr0kG041672; Mon, 8 Sep 2008 00:53:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id m87Lr0x0041671; Mon, 8 Sep 2008 00:53:00 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 8 Sep 2008 00:53:00 +0300 From: Kostik Belousov To: Juergen Lock Message-ID: <20080907215300.GH2038@deviant.kiev.zoral.com.ua> References: <20080830113448.GA2152@dchagin.dialup.corbina.ru> <20080906104659.GA2113@dchagin.dialup.corbina.ru> <200809062215.m86MF6NS040797@saturn.kn-bremen.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KmlZJfNsL65MWMNI" Content-Disposition: inline In-Reply-To: <200809062215.m86MF6NS040797@saturn.kn-bremen.de> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.93.3, clamav-milter version 0.93.3 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1KcSBw-000Cld-Nn d7b7b5504c113b763aff89a06fa7053e X-Terabit: YES Cc: freebsd-emulation@freebsd.org, peter@freebsd.org Subject: Re: Linux applications core if running (k)qemu 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: Sun, 07 Sep 2008 21:53:11 -0000 --KmlZJfNsL65MWMNI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Sep 07, 2008 at 12:15:06AM +0200, Juergen Lock wrote: > In article <20080906152929.GB2038@deviant.kiev.zoral.com.ua> you write: > >-=3D-=3D-=3D-=3D-=3D- > > > >On Sat, Sep 06, 2008 at 02:46:59PM +0400, Chagin Dmitry wrote: > >> On Tue, Sep 02, 2008 at 03:56:33PM -0500, Sean C. Farley wrote: > >> > On Sat, 30 Aug 2008, Chagin Dmitry wrote: > >> >=20 > >> > >On Fri, Aug 29, 2008 at 05:29:09PM -0500, Sean C. Farley wrote: > >> > >>I am having trouble with kqemu.ko and linux.ko. If I run qemu with > >> > >>the following command, Linux applications (chroot, acroread, ls) w= ill > >> > >>start core dumping: > >> > >> qemu-system-x86_64 -m 512 \ > >> > >> -drive file=3D/usr/QEMU/WinXP/c.img,if=3Dide,media=3Ddisk -boo= t c \ > >> > >> -std-vga -parallel none -serial none -monitor stdio \ > >> > >> -net nic,model=3De1000 -net tap,ifname=3Dtap0,script=3Dno -loc= altime > >> > >> > >> > >>Loading kqemu.ko does not cause the problem, but the cores start a > >> > >>little after WinXP starts running. Unloading kqemu.ko does not he= lp; > >> > >>the cores still happen but more randomly. I even tried unloading = all > >> > >>linux modules and reloading them without luck. It takes a reboot. > >> > >> > >> > >>Packages: > >> > >>qemu-devel-0.9.1s.20080620_1 > >> > >>kqemu-kmod-devel-1.4.0.p1 > >> > >>linux_base-f8-8_4 > >> > >> > >> > >>sysctl: > >> > >>compat.linux.osrelease: 2.6.16 > >> > >> > >> > >>dmesg: > >> > >>kqemu version 0x00010400 > >> > >>kqemu: KQEMU installed, max_locked_mem=3D1792492kB. > >> > >> > >> > >>System is 7-STABLE as of r181963 with or without the patch to fix = RT > >> > >>signals from Chagin. > >> > > > >> > >Interestingly... Sean, can you provide ktrace/kdump log of coring > >> > >apps? thnx! > >> >=20 > >> > Here they are (good and bad): > >> > http://www.farley.org/freebsd/tmp/linuxulator_vs_kqemu/ > >> >=20 > >> > The good trace is after the bad trace. I just kept running ktrace > >> > /compat/linux/bin/date over and over until I got a good trace. Befo= re > >> > loading kqemu and running qemu, there were no core dumps. Also, I > >> > compared two bad traces and they were basically the same except for = PID > >> > and a couple of addresses (still very close in value). > >> >=20 > >>=20 > >> Most likely it is a tls problem again, some days ago kib@ has made MFC > >> r182684, probably it will help.. > > > >I doubt it. This seems to be an ingenious kqemu bug. As far as I remembe= r, > >it tries to use GDT/LDT. This probably has unwanted interaction with > >PCB_GS32BIT. >=20 > Wow. That corner of the code had escaped me so far, and yes this (in > amd64/linux32) looks like it won't like kqemu's seperating of the gdts > on SMP indeed. (it stores a pointer to &gdt[GUGS32_SEL] in pcb_gs32p and > lets linux processes manipulate the segment pointed to by it, and when > kqemu is (or was) running this won't be used by all cpus, see older threa= ds > like > http://lists.freebsd.org/pipermail/freebsd-emulation/2008-May/004902.html > for the reasons.) >=20 > What I wonder tho is, won't this also cause problems without kqemu when > there are linux processes running on multiple cpus that manipulate this > segment because the gdt is then shared between the cpus? (like, linux > process on cpu 0 changes the segment, then linux process on cpu 1 comes > along and changes it again and then the linux process on cpu 0 will pick > it up from cpu 1?) At least I must have somehow assumed the shared gdt > wouldn't be changed later because of reasons like this... Very nice catch! Me and Peter Wemm discussed the right approach, that consists of actually providing per-cpu GDT. Patch is at http://people.freebsd.org/~kib/misc/amd64_gdt.1.patch Please, test and give a feedback. Even reports about thinks working the same as before the patch are important. >=20 > Anyway, fixing this will require changes to the kernel, I don't see how > kqemu could fix it by itself alone. :( See above. If you need some further kernel changes for kqemu, this is the best time to discuss them. --KmlZJfNsL65MWMNI Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkjETTsACgkQC3+MBN1Mb4hWnQCdF1bzuSkQZzoTc5vSGywkEY+M F/IAoPQLavVdxMDEnc7G01UQCq9ecpik =UdU6 -----END PGP SIGNATURE----- --KmlZJfNsL65MWMNI--