From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 28 14:32:47 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3712216A41F for ; Sun, 28 Aug 2005 14:32:47 +0000 (GMT) (envelope-from arundel@h3c.de) Received: from enterprise4.noxa.de (enterprise.noxa.de [212.60.197.71]) by mx1.FreeBSD.org (Postfix) with ESMTP id 670D943D46 for ; Sun, 28 Aug 2005 14:32:45 +0000 (GMT) (envelope-from arundel@h3c.de) Received: (qmail 24409 invoked from network); 28 Aug 2005 16:32:43 +0200 Received: from p508fe2dc.dip.t-dialin.net (HELO localhost.skatecity) (80.143.226.220) by enterprise.noxa.de with AES256-SHA encrypted SMTP; 28 Aug 2005 16:32:43 +0200 Received: from localhost.skatecity (nobody@localhost.skatecity [127.0.0.1]) by localhost.skatecity (8.13.4/8.13.4) with ESMTP id j7SEWedB064812 for ; Sun, 28 Aug 2005 16:32:40 +0200 (CEST) (envelope-from arundel@localhost.skatecity) Received: (from arundel@localhost) by localhost.skatecity (8.13.4/8.13.4/Submit) id j7SEWdSl064811 for freebsd-hackers@freebsd.org; Sun, 28 Aug 2005 16:32:39 +0200 (CEST) (envelope-from arundel) From: alexander Date: Sun, 28 Aug 2005 16:32:39 +0200 To: freebsd-hackers@freebsd.org Message-ID: <20050828143239.GA64597@skatecity> Mail-Followup-To: freebsd-hackers@freebsd.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: Syscall/Sysret state on i386 arch 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: Sun, 28 Aug 2005 14:32:47 -0000 The AMD64 arch is using the syscall/sysret opcodes instead of int80h to perform a syscall (/usr/src/lib/libc/amd64/SYS.h). I just checked the output my of dmesg and it says: CPU: AMD Duron(tm) Processor (1311.69-MHz 686-class CPU) Origin = "AuthenticAMD" Id = 0x671 Stepping = 1 Features=0x383f9ff AMD Features=0xc0400800 I got a hold of the AMD document number 21086.pdf. It describes both opcodes pretty well, but doesn't tell which CPUs support the new opcodes. But since the first revision of that document is dated Sept 1997 quite a lot of i386 CPU's should support the opcodes. The NASM manual only states [P6,AMD] as the required CPU to perform those opcodes. I found some patches for Linux that replace the int80h syscall calling convention with syscall/sysret on i386 and the results look pretty convincing: > (INT $0x80 based getpid(), got pid 497) latency:282 cycles > (SYSENTER based getpid(), got pid 497) latency:138 cycles > > on a 266 MHz PII this is 0.51 usecs for a getpid(). (was 1.06 usecs) Quoted from: http://www.ussg.iu.edu/hypermail/linux/kernel/9806.1/0878.html Does anybody know more about this? Is it even possible to replace the current syscall implementation that easily or would that require elaborate changes to all the syscalls (libc), etc. And which CPU's support these new opcodes? Doesn anybody know if the Linux patches actually got comitted to the official kernel? Cheers.