From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 21 12:22:07 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 08C681065675 for ; Thu, 21 Jun 2012 12:22:07 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id D3F3D8FC1E for ; Thu, 21 Jun 2012 12:22:06 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 41511B94F; Thu, 21 Jun 2012 08:22:06 -0400 (EDT) From: John Baldwin To: freebsd-hackers@freebsd.org Date: Thu, 21 Jun 2012 08:11:20 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p13; KDE/4.5.5; amd64; ; ) References: <201206182256.30535.dcherednik@roshianokatachi.com> In-Reply-To: <201206182256.30535.dcherednik@roshianokatachi.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201206210811.20427.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 21 Jun 2012 08:22:06 -0400 (EDT) Cc: 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: Thu, 21 Jun 2012 12:22:07 -0000 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 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 am 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 != frame.tf_edx) > td->td_pcb->pcb_flags |= 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 just c- > function. No clue on this one, looks like it is not needed. -- John Baldwin