From owner-freebsd-hackers@FreeBSD.ORG Mon Jun 18 19:01:46 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 EC699106566B for ; Mon, 18 Jun 2012 19:01:46 +0000 (UTC) (envelope-from dcherednik@roshianokatachi.com) Received: from smtp.nanocore.sportcomitet.org (mail.sportcomitet.org [78.47.203.36]) by mx1.freebsd.org (Postfix) with ESMTP id 991DF8FC0C for ; Mon, 18 Jun 2012 19:01:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp.nanocore.sportcomitet.org (Postfix) with SMTP id D48AAC06C9 for ; Mon, 18 Jun 2012 22:56:33 +0400 (MSK) Received: from nxs1.localnet (ppp91-76-112-188.pppoe.mtu-net.ru [91.76.112.188]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: dcherednik@roshianokatachi.com) by smtp.nanocore.sportcomitet.org (Postfix) with ESMTPSA id 66972C0530 for ; Mon, 18 Jun 2012 22:56:33 +0400 (MSK) To: freebsd-hackers@freebsd.org From: Daniil Cherednik Date: Mon, 18 Jun 2012 22:56:30 +0400 MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201206182256.30535.dcherednik@roshianokatachi.com> X-DSPAM-Result: Innocent X-DSPAM-Processed: Mon Jun 18 22:56:33 2012 X-DSPAM-Confidence: 1.0000 X-DSPAM-Improbability: 1 in 98689409 chance of being spam X-DSPAM-Probability: 0.0023 X-DSPAM-Signature: 24,4fdf79e1298013881511382 X-DSPAM-Factors: 27, beginner+#+kernel, 0.40000, Received*Postfix+with, 0.40000, pushl+#+#+3, 0.40000, Received*with+#+id, 0.40000, works+#+I, 0.40000, just+c, 0.40000, of+fast, 0.40000, to+#+the, 0.40000, beginner+in, 0.40000, Received*Authenticated+sender, 0.40000, was+changed, 0.40000, to+#+#+in, 0.40000, To*freebsd-hackers+freebsd.org, 0.40000, Received*using+TLSv1, 0.40000, see+#+#+was, 0.40000, continue+the, 0.40000, frame+#+edx, 0.40000, Date*18+#+2012, 0.40000, store+#+to, 0.40000, Unfortunately+#+am, 0.40000, some+#+1, 0.40000, What+is, 0.40000, In+#+store, 0.40000, Date*Mon+#+#+#+22, 0.40000, have+#+#+1, 0.40000, esi+#+calling, 0.40000, 3+#+#+#+movl, 0.40000 Subject: 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: Mon, 18 Jun 2012 19:01:47 -0000 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 */ 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. -- Daniil Cherednik