From patchwork Mon Jul 9 12:47:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 941257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ebFhqW0f"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="XYEbT49L"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41PQ9b1cx3z9rvt for ; Mon, 9 Jul 2018 22:48:19 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=2q15OCcDhNo+TqWFS2AS4+J1rhz72m+4sH6JlKH3KJQ=; b=ebF hqW0fMApYpnqAjdvO1dC7cU9XOQ7oZ7xVfXOWPxGrfAz6ypPsbY/4BJmvlNqnpBAlbyrJCFoZUTj4 H3m16XvSUZt/LeOPxmOPX8W81PflOwhxa/TvqQeqamdY0jQHfUbAWab6c9aRf56SP/MZ05RfCHiO7 yuvGWklkTrjLz+XG2NATnqNjWB4TPfIl87PRvLRBL6TYSfYhMDiV38ztlOXlveEdVYUAWJMrJVP1w Iuqq0nzRyoz2MAQ7ASkc862roeYIZPQ4nX8Uc2MNNxwwiWmKn2pOaxG4OqKRR6MrKNtwOCSdInl0C +0hJ1mIdNSRkgtA36JlMdCR9jxhhGXw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcVaS-0000bp-I7; Mon, 09 Jul 2018 12:48:16 +0000 Received: from smtprelay4.synopsys.com ([198.182.47.9] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcVaN-0000PO-76 for linux-snps-arc@lists.infradead.org; Mon, 09 Jul 2018 12:48:14 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 8948C24E248F; Mon, 9 Jul 2018 05:47:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1531140479; bh=ziHDFDYHe0Z2FwUlEMEpP1JMKGmT2D926phKTo+loW4=; h=From:To:Cc:Subject:Date:From; b=XYEbT49LdavnOCkLitIUjMVlSdlG03ZUOUgxdQSjuBA4gNTzkUWKWWzi3wdl2QaSA H0eXHX97QWRe5pqb+Di2V78mADtlvO3W9h4ZtRdrCHxlBIDy7YHvooA5iOKkcVvg+7 Jnro+Zhh6cGz3gj2nWzPJ5JzVfgm7Sk+SyWy/FzvE9nRMamZMhNlTyL4Hu4XNEshzU cRPizXtQ95WGvPv7e626WQcGWnjZsCmW2K8dP9X3C2/lQnDXIO4xbhBhDjZx2Fe//h c191gBSnB9w2ZTMLP7ZDgtWYDBBCLTvOY5sXV38cBaIeE8CoHAXM4d6RKgqy6RVETZ Lly0FySu/g8pA== Received: from abrodkin-7480l.internal.synopsys.com (unknown [10.121.8.87]) by mailhost.synopsys.com (Postfix) with ESMTP id 5B22F5F2C; Mon, 9 Jul 2018 05:47:51 -0700 (PDT) From: Alexey Brodkin To: linux-kernel@vger.kernel.org Subject: [PATCH] atomic{64}_t: Explicitly specify data storage length and alignment Date: Mon, 9 Jul 2018 15:47:41 +0300 Message-Id: <20180709124741.21037-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180709_054811_299605_0E495CD6 X-CRM114-Status: GOOD ( 10.47 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.47.9 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Geert Uytterhoeven , "Paul E. McKenney" , David Laight , Arnd Bergmann , Peter Zijlstra , Lai Jiangshan , Boqun Feng , Alexey Brodkin , Will Deacon , Russell King , Steven Rostedt , Josh Triplett , Ingo Molnar , Mathieu Desnoyers , Greg Kroah-Hartman , Darren Hart , Thomas Gleixner , linux-snps-arc@lists.infradead.org, Shuah Khan MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Atomic instructions require data they operate on to be aligned according to data size. I.e. 32-bit atomic values must be 32-bit aligned while 64-bit values must be 64-bit aligned. Otherwise even if CPU may handle not-aligend normal data access, still atomic instructions fail and typically raise an exception leaving us dead in the water. This came-up during lengthly discussion here: http://lists.infradead.org/pipermail/linux-snps-arc/2018-July/004022.html Signed-off-by: Alexey Brodkin Cc: Will Deacon Cc: Peter Zijlstra Cc: Boqun Feng Cc: Russell King Cc: Arnd Bergmann Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Darren Hart Cc: Shuah Khan Cc: "Paul E. McKenney" Cc: Josh Triplett Cc: Steven Rostedt Cc: Mathieu Desnoyers Cc: Lai Jiangshan Cc: David Laight Cc: Geert Uytterhoeven Cc: Greg Kroah-Hartman Reviewed-by: Geert Uytterhoeven --- arch/arm/include/asm/atomic.h | 2 +- include/asm-generic/atomic64.h | 2 +- include/linux/types.h | 4 ++-- tools/include/linux/types.h | 2 +- tools/testing/selftests/futex/include/atomic.h | 2 +- .../rcutorture/formal/srcu-cbmc/include/linux/types.h | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h index 66d0e215a773..2ed6d7cf1407 100644 --- a/arch/arm/include/asm/atomic.h +++ b/arch/arm/include/asm/atomic.h @@ -267,7 +267,7 @@ ATOMIC_OPS(xor, ^=, eor) #ifndef CONFIG_GENERIC_ATOMIC64 typedef struct { - long long counter; + u64 __aligned(8) counter; } atomic64_t; #define ATOMIC64_INIT(i) { (i) } diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h index 8d28eb010d0d..b94b749b5952 100644 --- a/include/asm-generic/atomic64.h +++ b/include/asm-generic/atomic64.h @@ -13,7 +13,7 @@ #define _ASM_GENERIC_ATOMIC64_H typedef struct { - long long counter; + u64 __aligned(8) counter; } atomic64_t; #define ATOMIC64_INIT(i) { (i) } diff --git a/include/linux/types.h b/include/linux/types.h index 9834e90aa010..e2f631782621 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -174,12 +174,12 @@ typedef phys_addr_t resource_size_t; typedef unsigned long irq_hw_number_t; typedef struct { - int counter; + u32 __aligned(4) counter; } atomic_t; #ifdef CONFIG_64BIT typedef struct { - long counter; + u64 __aligned(8) counter; } atomic64_t; #endif diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h index 154eb4e3ca7c..c913e26ea4eb 100644 --- a/tools/include/linux/types.h +++ b/tools/include/linux/types.h @@ -59,7 +59,7 @@ typedef __u64 __bitwise __le64; typedef __u64 __bitwise __be64; typedef struct { - int counter; + u32 __aligned(4) counter; } atomic_t; #ifndef __aligned_u64 diff --git a/tools/testing/selftests/futex/include/atomic.h b/tools/testing/selftests/futex/include/atomic.h index f861da3e31ab..34e14295e492 100644 --- a/tools/testing/selftests/futex/include/atomic.h +++ b/tools/testing/selftests/futex/include/atomic.h @@ -23,7 +23,7 @@ #define _ATOMIC_H typedef struct { - volatile int val; + volatile u32 __aligned(4) val; } atomic_t; #define ATOMIC_INITIALIZER { 0 } diff --git a/tools/testing/selftests/rcutorture/formal/srcu-cbmc/include/linux/types.h b/tools/testing/selftests/rcutorture/formal/srcu-cbmc/include/linux/types.h index 891ad13e95b2..32ce965187b3 100644 --- a/tools/testing/selftests/rcutorture/formal/srcu-cbmc/include/linux/types.h +++ b/tools/testing/selftests/rcutorture/formal/srcu-cbmc/include/linux/types.h @@ -100,12 +100,12 @@ typedef phys_addr_t resource_size_t; typedef unsigned long irq_hw_number_t; typedef struct { - int counter; + u32 __aligned(4) counter; } atomic_t; #ifdef CONFIG_64BIT typedef struct { - long counter; + u64 __aligned(8) counter; } atomic64_t; #endif