From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 23 16:58:30 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 54E2D1065674; Sat, 23 Jun 2012 16:58:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id E30A68FC0A; Sat, 23 Jun 2012 16:58:29 +0000 (UTC) Received: from skuns.kiev.zoral.com.ua (localhost [127.0.0.1]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id q5NGwNm1022895; Sat, 23 Jun 2012 19:58:23 +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.5/8.14.5) with ESMTP id q5NGwNsj064794; Sat, 23 Jun 2012 19:58:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.5/8.14.5/Submit) id q5NGwNaT064793; Sat, 23 Jun 2012 19:58:23 +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: Sat, 23 Jun 2012 19:58:23 +0300 From: Konstantin Belousov To: davidxu@freebsd.org Message-ID: <20120623165823.GX2337@deviant.kiev.zoral.com.ua> References: <201206182256.30535.dcherednik@roshianokatachi.com> <201206210811.20427.jhb@freebsd.org> <4FE55F91.5070303@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qBOV/12gVmFoc0GF" Content-Disposition: inline In-Reply-To: <4FE55F91.5070303@gmail.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 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 Cc: freebsd-hackers@freebsd.org, Daniil Cherednik Subject: Re: Fast syscalls via sysenter X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Jun 2012 16:58:30 -0000 --qBOV/12gVmFoc0GF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jun 23, 2012 at 02:17:53PM +0800, David Xu wrote: > On 2012/06/21 20:11, John Baldwin wrote: > >On Monday, June 18, 2012 2:56:30 pm Daniil Cherednik wrote: > >>Hi! > >> > >>I am trying to continue the work started by DavidXu on implemention of= =20 > >>fast > >>syscalls via sysenter/sysexit. > >>http://people.freebsd.org/~davidxu/sysenter/kernel/ > >>I have ported it on FreeBSD9. It looks like it works. Unfortunately I a= m a > >>beginner in kernel so I have some questions: > >> > >>1. see http://people.freebsd.org/~davidxu/sysenter/kernel/kernel.patch > >>/* > >>* If %edx was changed, we can not use sysexit, because it > >>* needs %edx to restore userland %eip. > >>*/ > >>if (orig_edx !=3D frame.tf_edx) > >> td->td_pcb->pcb_flags |=3D PCB_FULLCTX; > >> > >>What is the reason why we have to do this additional check? In > >>http://people.freebsd.org/~davidxu/sysenter/kernel/sysenter.s > >>we store %edx to the stack in > >>pushl %edx /* ring 3 next %eip */ > >>and we restore the register in > >>popl %edx /* ring 3 %eip */ > >Some system calls return two return values (pipe(2)) or return a 64-bit > >off_t (lseek(2)). Those system calls change %edx's value and need that > >changed value to make it out to userland. > > > >>2. see http://people.freebsd.org/~davidxu/sysenter/kernel/sysenter.s > >>movl PCPU(CURPCB),%esi > >>call syscall > >> > >>Why do we movl PCPU(CURPCB),%esi before calling syscall? syscall is ju= st=20 > >>c- > >>function. > >No clue on this one, looks like it is not needed. > > > [kib@ is cc'ed] > I implemented the sysenter syscall long time ago, it indeed can reduce > system call overhead on i386. I think it might be the time to implement > linux like vdso syscall now based on the work kib@ recently has done, > though I don''t know how to hook it into kib's code. > I quick googled it, and found they put some data into aux vector: > http://www.trilithium.com/johan/2005/08/linux-gate/ > http://www.takatan.net/lxr/source/arch/um/os-Linux/elf_aux.c?a=3Dx86_64#L= 40 Yes, intent is to eventually switch to VDSO from current situation were libc is aware of shared page content. This was extensively discussed in flame that resulted in me writing the current gettimeofday(2) patch. It was arch@ several weeks ago, AFAIR. Committed gettimeofday() code structure allows for VDSO interposing without breaking normal symbol visibility rules. I do not see a sense in implementing syscall or sysenter support for i386 kernel. On the other hand, using syscall for 32bit binaries on amd64 looks reasonable. --qBOV/12gVmFoc0GF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (FreeBSD) iEYEARECAAYFAk/l9a4ACgkQC3+MBN1Mb4hCfACgqHGnquHF6p96npl7HJyERWfN rpkAoJRdG8/IWtROWbSVhAaSBqiqCJt5 =6qU8 -----END PGP SIGNATURE----- --qBOV/12gVmFoc0GF--