From owner-freebsd-emulation@FreeBSD.ORG Mon Apr 14 12:31:45 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 4E4101065677 for ; Mon, 14 Apr 2008 12:31:45 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com (relay02.kiev.sovam.com [62.64.120.197]) by mx1.freebsd.org (Postfix) with ESMTP id CF9858FC17 for ; Mon, 14 Apr 2008 12:31:44 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from [212.82.216.226] (helo=skuns.kiev.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1JlNqY-0003Wu-QG for freebsd-emulation@freebsd.org; Mon, 14 Apr 2008 15:31:43 +0300 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by skuns.kiev.zoral.com.ua (8.14.2/8.14.2) with ESMTP id m3ECVkM8086678 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Apr 2008 15:31:46 +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 m3ECVcwI049261; Mon, 14 Apr 2008 15:31:38 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.2/8.14.2/Submit) id m3ECVbSX049256; Mon, 14 Apr 2008 15:31:37 +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, 14 Apr 2008 15:31:37 +0300 From: Kostik Belousov To: Chagin Dmitry Message-ID: <20080414123137.GH18958@deviant.kiev.zoral.com.ua> References: <20080412181712.Y38920@ora.chd.net> <20080412145401.GA4139@freebsd.org> <20080413214624.S7426@ora.chd.net> <20080413183248.GA68642@freebsd.org> <20080413183659.GA18958@deviant.kiev.zoral.com.ua> <20080413231135.K1079@ora.chd.net> <20080413192614.GC18958@deviant.kiev.zoral.com.ua> <20080413234359.H1165@ora.chd.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LiQwW4YX+w4axhAx" Content-Disposition: inline In-Reply-To: <20080413234359.H1165@ora.chd.net> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.91.2, clamav-milter version 0.91.2 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.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on skuns.kiev.zoral.com.ua X-Scanner-Signature: 417be1d66bc02b3cfc7f91380aac6f56 X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 2625 [Apr 14 2008] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {received from trusted relay: not dialup} X-SpamTest-Method: none X-SpamTest-Method: Local Lists X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release Cc: freebsd-emulation@freebsd.org Subject: Re: Call for review && test: linux_kdump-1.6 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, 14 Apr 2008 12:31:45 -0000 --LiQwW4YX+w4axhAx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 14, 2008 at 12:42:29AM +0400, Chagin Dmitry wrote: > On Sun, 13 Apr 2008, Kostik Belousov wrote: >=20 > >On Sun, Apr 13, 2008 at 11:11:55PM +0400, Chagin Dmitry wrote: > >>On Sun, 13 Apr 2008, Kostik Belousov wrote: > >> > >>>On Sun, Apr 13, 2008 at 08:32:48PM +0200, Roman Divacky wrote: > >>>>On Sun, Apr 13, 2008 at 09:58:08PM +0400, Chagin Dmitry wrote: > >>>>>On Sat, 12 Apr 2008, Roman Divacky wrote: > >>>>> > >>>>>>>And question: whether i can add to linuxolator some ktr_struct > >>>>>>> functionality? > >>>>>> > >>>>>>sure... please provide a patch and I'll take care about it. > >>>>> > >>>>>ok, thnx :) > >>>>>what about EJUSTRETURN? > >>>>>i attached simple patch for demo only (not tested). > >>>> > >>>>uh... can you provide diff -u ? I dont understand the diff at all ;) > >>> > >>>Also, please note that the ML software strips your attachments. Either > >>>inline the patch, or use the plain-text content-type for it. > >>> > >> > >>ups... ah google )) > >>i have understood, sorry and thnx. > >>Speech about that in linux_kdump it is impossible to distinguish > >>EJUSTRETURN from a real error. look: > >> > >>--- sys/i386/i386/trap.c.orig 2008-04-13 21:39:18.000000000 +0400 > >>+++ sys/i386/i386/trap.c 2008-04-13 22:35:25.000000000 +0400 > >>@@ -1091,8 +1091,12 @@ > >> td->td_proc->p_pid, td->td_name, code); > >> > >> #ifdef KTRACE > >>- if (KTRPOINT(td, KTR_SYSRET)) > >>- ktrsysret(code, error, td->td_retval[0]); > >>+ if (KTRPOINT(td, KTR_SYSRET)) { > >>+ if (error =3D=3D EJUSTRETURN) > >>+ ktrsysret(code, 0, td->td_retval[0]); > >>+ else > >>+ ktrsysret(code, error, td->td_retval[0]); > >>+ } > >> #endif > >> > >> /* > >>@@ -1104,4 +1108,3 @@ > >> > >> PTRACESTOP_SC(p, td, S_PT_SCX); > >> } > >>- > > > >I do not quite understand the intent of this change. > > > >EJUSTRETURN is used for two different purposes in the kernel. > >1. The sigreturn family of the syscalls use it after the interrupted > >frame is restored to avoid the normal syscall return sequence to modify > >the machine state. > >2. It is used by the kernel to notify the in-kernel caller code about > >some special condition, that nonetheless shall not be returned to the > >userspace. > > > >Only the first case is applicable to the kdump, and IMHO you actually > >destroy some information, since error =3D=3D EJUSTRETURN is reported as = 0. > > > >Could you, please, provide some more arguments in the support of your > >proposed change ? > > >=20 > Thanks for you informative reply Kostya. > The problem arises only in linux_kdump. Because linux error > codes negative and EJUSTRETURN coincides with ENOENT. > Before a call ktr_sysret we decode return codes of emulators syscalls. Ah, I see. Then, we shall never dump the ERESTART and EJUSTRETURN for the emulated ABIs. At least, this is true for Linux, I am not so sure about iBCS2 and SVR4. Could you test the patch below, instead ? diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index b6a454d..9ccbd4b 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -912,8 +912,23 @@ syscall(struct trapframe *frame) td->td_proc->p_pid, td->td_name, code); =20 #ifdef KTRACE - if (KTRPOINT(td, KTR_SYSRET)) - ktrsysret(code, error, td->td_retval[0]); + if (KTRPOINT(td, KTR_SYSRET)) { + int error1; + + /* + * The ABIs that use the negative error codes, like + * Linux, would confuse the in-kernel errno values + * with proper userspace errno. Clean these values to + * avoid a confusion in the kdump. + */ + if (p->p_sysent->sv_errsize && + (error =3D=3D EJUSTRETURN || error =3D=3D ERESTART)) + error1 =3D 0; + else + error1 =3D error; + + ktrsysret(code, error1, td->td_retval[0]); + } #endif =20 /* diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index e7de579..55642d1 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -1091,8 +1091,22 @@ syscall(struct trapframe *frame) td->td_proc->p_pid, td->td_name, code); =20 #ifdef KTRACE - if (KTRPOINT(td, KTR_SYSRET)) - ktrsysret(code, error, td->td_retval[0]); + if (KTRPOINT(td, KTR_SYSRET)) { + int error1; + + /* + * The ABIs that use the negative error codes, like + * Linux, would confuse the in-kernel errno values + * with proper userspace errno. Clean these values to + * avoid a confusion in the kdump. + */ + if (p->p_sysent->sv_errsize && + (error =3D=3D EJUSTRETURN || error =3D=3D ERESTART)) + error1 =3D 0; + else + error1 =3D error; + ktrsysret(code, error1, td->td_retval[0]); + } #endif =20 /* --LiQwW4YX+w4axhAx Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkgDTqkACgkQC3+MBN1Mb4jprgCgp4mCU+ZN5pVIE5ou5CJumCKl egEAoI+ZkemjvkyonzDvdduetOq6+y6f =fb2Y -----END PGP SIGNATURE----- --LiQwW4YX+w4axhAx--