[PATCH] Simplify in*() and out*() functions of AMD64 and i386
Christoph Mallon
christoph.mallon at gmx.de
Thu Apr 9 23:13:37 PDT 2009
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.
More information about the freebsd-amd64
mailing list