summaryrefslogtreecommitdiffstats
path: root/sys/arm/include
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2016-06-21 17:53:42 +0000
committerian <ian@FreeBSD.org>2016-06-21 17:53:42 +0000
commit6a5a941a5ece1b83fe5a3f6c0ab79086b3af9857 (patch)
tree1929b792d2d11887df10016e1bf2bcab9f4739d2 /sys/arm/include
parent907f8ff806f5029a8d6bf65516539742dff59ddb (diff)
downloadFreeBSD-src-6a5a941a5ece1b83fe5a3f6c0ab79086b3af9857.zip
FreeBSD-src-6a5a941a5ece1b83fe5a3f6c0ab79086b3af9857.tar.gz
Revert the recent armv6 changes to ALIGNED_POINTER(), restoring the
fully-pessimized implementation that requires a type to be aligned to its natural size. On armv6+ the compiler might generate load-/store-multiple instructions which require 4-byte alignment even though the source code is only accessing individual uint32_t values in a way that doesn't require any particular alignment at all. The compiler apparently feels free to combine multiple accesses into a single instruction that requires a more-strict alignment, and no set of compiler flags seems to disable this behavior (at least in clang 3.8). This fixes alignment faults on arm systems using wifi adapters. The wifi code uses ALIGNED_POINTER(p, uint32_t) to decide whether it needs to copy-align tcp headers. Because clang is combining several uint32_t accesses into a single ldm instruction, we need to say that accessing a uint32_t requires 4-byte alignment. Approved by: re(gjb)
Diffstat (limited to 'sys/arm/include')
-rw-r--r--sys/arm/include/param.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/arm/include/param.h b/sys/arm/include/param.h
index 0ad5493..a5fd520 100644
--- a/sys/arm/include/param.h
+++ b/sys/arm/include/param.h
@@ -91,15 +91,15 @@
* This does not reflect the optimal alignment, just the possibility
* (within reasonable limits).
*
- * armv4 and v5 require alignment to the type's size. armv6 and later require
- * that an 8-byte type be aligned to at least a 4-byte boundary; access to
- * smaller types can be unaligned.
+ * armv4 and v5 require alignment to the type's size. armv6 requires 8-byte
+ * alignment for the ldrd/strd instructions, but otherwise follows armv7 rules.
+ * armv7 requires that an 8-byte type be aligned to at least a 4-byte boundary;
+ * access to smaller types can be unaligned, except that the compiler may
+ * optimize access to adjacent uint32_t values into a single load/store-multiple
+ * instruction which requires 4-byte alignment, so we must provide the most-
+ * pessimistic answer possible even on armv7.
*/
-#if __ARM_ARCH >= 6
-#define ALIGNED_POINTER(p, t) (((sizeof(t) != 8) || ((unsigned)(p) & 3) == 0))
-#else
#define ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof(t)-1)) == 0)
-#endif
/*
* CACHE_LINE_SIZE is the compile-time maximum cache line size for an
OpenPOWER on IntegriCloud