From patchwork Thu Aug 24 05:42:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hoeun Ryu X-Patchwork-Id: 9919083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 003E360353 for ; Thu, 24 Aug 2017 05:48:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4A3828B5C for ; Thu, 24 Aug 2017 05:48:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7B8928B65; Thu, 24 Aug 2017 05:48:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9DED28B5C for ; Thu, 24 Aug 2017 05:48:29 +0000 (UTC) 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:References: In-Reply-To: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:List-Owner; bh=C4kidpJBREPckTu3QKm9w9OTqvnuhHzpO1QdrHA9ZlI=; b=uRal8g/10AZR9f69FMNrQgjfCs 3YzOTkhY66ednGJJKrY33rFrhbUHpqzwfjED1EefWULNZS4axDcDD7fVK31u9jOTtKDhe3xrITP22 RLnYip05+HLzhnLb67SW3jGqCJ21gffgTexJ5mt7AhpEogqK4HWEMz3TVyu/6r4gFfohuI6cQvAh8 gYGWZwrc4BGrtf59ALqXkCjgmguarFVNMOjkkuCdyCKgxxf52vILaSC1F8VI2TdZHQujjrm6vMTGi ZmWQQmLnhx/BdabW0BS7VjxFwIYE5VgG8q9hVj6Q0zXBR6OtQyt3jJABNJr2UNjH3HBCG1u2wCCHU uK+lWawA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dkl0D-0008EH-3H; Thu, 24 Aug 2017 05:48:25 +0000 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkkzl-0007p3-I9 for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2017 05:48:02 +0000 Received: by mail-pg0-x244.google.com with SMTP id p14so2422730pgd.1 for ; Wed, 23 Aug 2017 22:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NvZCsaRJuC60ZnPHBQ7yi/AWx/aJ3qxD4pky4Y1Shns=; b=WKpUND+fL/+un0blKSOhq9h8X9cDCAuXhs70gWpZzRCSg3tsSlNm9ykLiWFi5z0Dxr A6VbHSVqtNqHlVHmLxv7vwd1/73fQep3blO81baGYQ+EmIoA9OoX87+baS0PnxTGFIBL nwwiITmDxSeBQja3/mXrcp0MtLVIuevaXx0QiQ54xPsOPC9gjqZeED+qEWzeVXJwl7Re Xa5CmUwNYjmGCAbueOmlgUlprPfezo2YGQAw4V3Cr48LEF1kEeymUnBa16MOvfdu7cMa EH2kwHJHPWTJI0erLtiURMEg8cNj6MC6u6oqJroV30m5odL/WpNRSj9yC2SklPoTXlMO l8PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NvZCsaRJuC60ZnPHBQ7yi/AWx/aJ3qxD4pky4Y1Shns=; b=BQRZJ30nhbDY2XM0rkNaJ1LDKSLXMi0YHMNGIEwg2F37nlOTnU12x3/5gYJpnl0pyQ vvRns34mBjJqYhcJBDOj7a+Pfz+wnwtXU+Kc3wuRutHH8aG8rR73TDVCcN+5P1XXBQVQ +q+bLr7TS2p0WGlqNesKcLSQPabupA7mmpR28rWrXqeFQKycdEH/XRLrL7WLF2fYejd7 TkAxsPkzl6d1mCYnRF2u1gS0GG4Zf8GwqllrKJ20EwwJUBhpeAHk8ObPxhGsqCEAUt5D /cmVCjfB4ylJexNxVSN4Tge3g0eCUOfjtmVPzgBwWWY+llePxAqJZhO/uIushZchUDka /nag== X-Gm-Message-State: AHYfb5gjKQWB7Y0Ll8GFEfh+YyqoUAhMI1DARuvVSCdOU+ljDPm8oCM8 MRPLE0TlNbQdNA== X-Received: by 10.98.43.78 with SMTP id r75mr5202137pfr.269.1503553657596; Wed, 23 Aug 2017 22:47:37 -0700 (PDT) Received: from hryu-OptiPlex-9020.corp.ad.wrs.com ([61.107.31.52]) by smtp.gmail.com with ESMTPSA id 63sm5728500pgg.44.2017.08.23.22.47.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 22:47:37 -0700 (PDT) From: Hoeun Ryu To: Kees Cook , Andrew Morton , Nicholas Piggin , Ingo Molnar , Michal Marek , Laura Abbott , Al Viro , Andy Lutomirski , mic@digikod.net, Russell King , Vladimir Murzin , Heiko Carstens , Jonathan Austin , Masahiro Yamada , Mark Rutland , Peter Zijlstra Subject: [RFC 1/3] arch: add 64BIT_ATOMIC_ACCESS to support 64bit atomic access on 32bit machines Date: Thu, 24 Aug 2017 14:42:55 +0900 Message-Id: <1503553377-3646-2-git-send-email-hoeun.ryu@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503553377-3646-1-git-send-email-hoeun.ryu@gmail.com> References: <1503553377-3646-1-git-send-email-hoeun.ryu@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170823_224757_920255_F89C5BDB X-CRM114-Status: GOOD ( 10.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, hoeun.ryu@gmail.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On some 32-bit architectures, 64bit accesses are atomic when certain conditions are satisfied. For example, on LPAE (Large Physical Address Extension) enabled ARM architecture, 'ldrd/strd' (load/store doublewords) instructions are 64bit atomic as long as the address is 64-bit aligned. This feature is to guarantee atomic accesses on newly introduced 64bit wide descriptors in the translation tables, and 's/u64' variables can be accessed atomically when they are aligned(8) on LPAE enabled ARM architecture machines. Introducing 64BIT_ATOMIC_ACCESS and 64BIT_ATOMIC_ALIGNED_ACCESS, which can be true for the 32bit architectures as well as 64bit architectures, we can optimize some kernel codes using seqlock (timekeeping) or mimics of it (like in sched/cfq) simply to read or write 64bit variables. The existing codes depend on CONFIG_64BIT to determine whether the 64bit variables can be directly accessed or need additional synchronization primitives like seqlock. CONFIG_64BIT_ATOMIC_ACCESS can be used instead of CONFIG_64BIT in the cases. 64BIT_ATOMIC_ALIGNED_ACCESS can be used in the variable declaration to indicate the alignment requirement to the compiler (__attribute__((aligned(8)))) in the way of #ifdef. Signed-off-by: Hoeun Ryu --- arch/Kconfig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 21d0089..1def331 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -115,6 +115,26 @@ config UPROBES managed by the kernel and kept transparent to the probed application. ) +config 64BIT_ATOMIC_ACCESS + def_bool 64BIT + help + On some 32bit architectures as well as 64bit architectures, + 64bit accesses are atomic when certain conditions are satisfied. + + This symbol should be selected by an architecture if 64 bit + accesses can be atomic. + +config 64BIT_ATOMIC_ALIGNED_ACCESS + def_bool n + depends on 64BIT_ATOMIC_ACCESS + help + On 64BIT_ATOMIC_ACCESS enabled system, the address should be + aligned by 8 to guarantee the accesses are atomic. + + This symbol should be selected by an architecture if 64 bit + accesses are required to be 64 bit aligned to guarantee that + the 64bit accesses are atomic. + config HAVE_64BIT_ALIGNED_ACCESS def_bool 64BIT && !HAVE_EFFICIENT_UNALIGNED_ACCESS help