From owner-svn-src-all@freebsd.org Tue Jun 21 17:53:43 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 722BDAC5800; Tue, 21 Jun 2016 17:53:43 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1CE1C1BFF; Tue, 21 Jun 2016 17:53:43 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5LHrgnL082488; Tue, 21 Jun 2016 17:53:42 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5LHrg7t082487; Tue, 21 Jun 2016 17:53:42 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201606211753.u5LHrg7t082487@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Tue, 21 Jun 2016 17:53:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302064 - head/sys/arm/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2016 17:53:43 -0000 Author: ian Date: Tue Jun 21 17:53:42 2016 New Revision: 302064 URL: https://svnweb.freebsd.org/changeset/base/302064 Log: 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) Modified: head/sys/arm/include/param.h Modified: head/sys/arm/include/param.h ============================================================================== --- head/sys/arm/include/param.h Tue Jun 21 17:49:33 2016 (r302063) +++ head/sys/arm/include/param.h Tue Jun 21 17:53:42 2016 (r302064) @@ -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