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: <1402441994-16780-11-git-send-email-hpa@zytor.com>
Date:	Tue, 10 Jun 2014 16:13:14 -0700
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Sam Ravnborg <sam@...nborg.org>, linux-kernel@...r.kernel.org,
	linux-kbuild@...r.kernel.org, linux-arch@...r.kernel.org
Cc:	Andy Lutomirski <luto@...capital.net>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...nel.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	"H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH RFC 10/10] tools: Use reasonable defaults for the default access

By default, as long as we are using gcc, use struct access for the
native byte order and byte swap it for the reverse byte order.  This
works well on most gcc targets.  If we are not compiling with gcc,
then we cannot assume that struct access is safe, and so fall back to
the most generic portable form ([bl]e_byteshift.h).

However, there are some architectures on which this generates poor
code even with gcc, and so some architectures may want to implement
specific overrides in this header file.

Signed-off-by: H. Peter Anvin <hpa@...or.com>
---
 tools/include/tools/unaligned.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/include/tools/unaligned.h b/tools/include/tools/unaligned.h
index a3d43989bd25..1ef19a1ca9b4 100644
--- a/tools/include/tools/unaligned.h
+++ b/tools/include/tools/unaligned.h
@@ -30,7 +30,21 @@ struct _packed_u64_struct {
 
 #endif /* __GNUC__ */
 
-#include <tools/unaligned/le_byteshift.h>
-#include <tools/unaligned/be_byteshift.h>
+#if defined(__GNUC__) && (__BYTE_ORDER == __LITTLE_ENDIAN)
+
+# include <tools/unaligned/le_struct.h>
+# include <tools/unaligned/be_swap.h>
+
+#elif defined(__GNUC__) && (__BYTE_ORDER == __BIG_ENDIAN)
+
+# include <tools/unaligned/be_struct.h>
+# include <tools/unaligned/le_swap.h>
+
+#else /* No idea what we actually are dealing with */
+
+# include <tools/unaligned/be_byteshift.h>
+# include <tools/unaligned/le_byteshift.h>
+
+#endif
 
 #endif /* TOOLS_UNALIGNED_H */
-- 
1.9.3

--
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