From owner-freebsd-amd64@FreeBSD.ORG Fri Apr 10 06:13:36 2009 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D8F46106566B for ; Fri, 10 Apr 2009 06:13:36 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by mx1.freebsd.org (Postfix) with SMTP id 466C88FC15 for ; Fri, 10 Apr 2009 06:13:36 +0000 (UTC) (envelope-from christoph.mallon@gmx.de) Received: (qmail invoked by alias); 10 Apr 2009 06:13:34 -0000 Received: from p54A3ED4A.dip.t-dialin.net (EHLO tron.homeunix.org) [84.163.237.74] by mail.gmx.net (mp063) with SMTP; 10 Apr 2009 08:13:34 +0200 X-Authenticated: #1673122 X-Provags-ID: V01U2FsdGVkX18NGQQxRVMNrcP3UqW4WEZtCjugRHJfkzBVJwJaoi 6r0tiW6YerY4ad Message-ID: <49DEE38D.6050604@gmx.de> Date: Fri, 10 Apr 2009 08:13:33 +0200 From: Christoph Mallon User-Agent: Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Kostik Belousov References: <49DD01CA.3040900@gmx.de> <20090408205831.GK3014@deviant.kiev.zoral.com.ua> In-Reply-To: <20090408205831.GK3014@deviant.kiev.zoral.com.ua> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-FuHaFi: 0.54 X-Mailman-Approved-At: Fri, 10 Apr 2009 11:39:39 +0000 Cc: Ed Schouten , freebsd-i386@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: [PATCH] Simplify in*() and out*() functions of AMD64 and i386 X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Apr 2009 06:13:37 -0000 Kostik Belousov schrieb: > On Wed, Apr 08, 2009 at 09:58:02PM +0200, Christoph Mallon wrote: >> Hi amd64@ and i386@, >> >> attached is a patch which simplifies the in*() and out*() functions for >> I/O port access of AMD64 and i386. It removes an unnecessary distinction >> of cases for inb() and outb(), which was used to generate better code >> for ports < 256. This is unnecessary, because GCC supports an asm input >> constraint to handle this ("N"). The stale comment, which states there >> is no constraint for this, is removed, too. Also the {in,out}{w,l}() get >> treated with this constraint. They had no special case before, so now > >> better code is generated for them. Further, the unnecessary "cld" is >> removed from {in,out}s{b,w,l}(), because it is guaranteed by the ABI >> that the direction flag is cleared. All in all the code for in/out gets >> a bit simpler. > The DF flag is guaranteed to be cleared for usermode only. Currently, > kernel does not clear the flag on entry. > > We did fixed signal handlers to always have DF cleared, but the kernel > was explicitely left out because used version of gcc does the right > thing with DF when needed. This will break with GCC >= 4.3. Also other compilers (e.g. LLVM and ICC) do not generate cld before they insert string instructions. I would not trust GCC < 4.3 to place cld everywhere, either. As a *temporary* workaround the cld in the {in,out}s*() functions could be left in, but this issue *must* be resolved correctly soon. Especially because LLVM is not generating the (according to the ABI spec) redundant clds and newer GCCs will not either. So no matter what the prospective compiler of FreeBSD will be, this issue must be tackled.