lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201101182056.35673.arnd@arndb.de>
Date:	Tue, 18 Jan 2011 20:56:35 +0100
From:	Arnd Bergmann <arnd@...db.de>
To:	"Lars-Peter Clausen" <lars@...afoo.de>
Cc:	linux-arch@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] asm-generic/io.h: Fix io{read,write}{16,32}be for big endian systems

On Tuesday 18 January 2011 20:01:12 Lars-Peter Clausen wrote:
> Well, i've though about that as well, but in the current asm-generic/io.h readl is
> unconditionally defined as cpu_to_le32(__raw_readl(addr)) and ioread32 is defined as
> readl.
> 
> So unless an arch io.h undefines those macros and redefines them (which none of the
> current archs does, as far as i can see), we are o
> 
> If an arch chooses to redefine ioread or readl, it should probably also redefine
> ioread{16,32}be.

Right, but the header file also serves as a template for new architectures
that cannot directly use it. I would prefer not to give a possibly bad example
here, especially when it's in a rarely used function.

> > The right solution is probably to use swab16/swab32 for the
> > big-endian functions. This also corrects the iowrite functions
> > which really should be using cpu_to_be32 instead of be32_to_cpu
> > (although they are always defined to be the same afaict.
> 
> This would first cause a conversion to little-endian, which is a swap() in the
> generic case and then you would call swap() again on the result. Which is basically a
> noop, but I'm not sure if compilers will detect this.

The overhead of the swab() is certainly dwarfed by the long time spent in
readl().

I would prefer to swap twice in this case and let the compiler work it out
if possible. The next best alternative would probably be to define both
ioread and ioread_be using __raw_readl in combination with a le32_to_cpu
or be32_to_cpu.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ