From patchwork Thu Jul 5 16:40:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141215 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2154722ljj; Thu, 5 Jul 2018 09:41:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcKep1LGcVZ+CrthWa036hkPYXVkCc381fBu9gqI07GXH/yx8GND+rWFFwqyNaOOigFyT4B X-Received: by 2002:a17:902:3124:: with SMTP id w33-v6mr6867984plb.235.1530808898948; Thu, 05 Jul 2018 09:41:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530808898; cv=none; d=google.com; s=arc-20160816; b=EEBBk7wQ3FYi4A/grSjZG2qisu7x/utztwrF/dLSgXg5ZRC/s60qw3v1LtzoiI4krO 4E/GXjA1pg7fOUxdalL8KMC/abAh8mUGIfW49xlwaDaexQsJRO7/TgEGtgLxvJhd2ZcQ CKDraWc+Pm428D1NCjYotA2X8vO88pKrT0W5uMKx0UZrdURB5UkbcbaEeM8e0fvIutVU 6mvrC9Gm0HR+dwhkrBnPj6s8ltxDJ6b4+2DUXUQoDLuNHVkp1TbOexMAMvCPhELE9tGj Ou5C7V7PscTscAQ7cLcVehBnUlir57dmF2xamzse5ZR8DvuRrC2eBRPKYyRpN/SahkLS zj2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KopUVbkshXE39p5INzQxINDfvm3DuZblKsJ5KRms+qQ=; b=vnzaErUdreu+fWN0+BqFxz5eQPK9Yh2n5jDmx5h9KwL14t/7FwUi+92WI8VHRCoyZK TL7lZ7uKt9YfqP+IL00BKO7ErUWQLkE4hPQv/9DDtJZ0f19lhsb53Oh2pRo6tX9nSvhT nBUMS5ssoLglcipkiwDLnib02YEollotx+ExgZPT5P66WG3jr1GdvZlbnfNaAoVRBEJK 9GHx8gHUkvMr9ER0aelb0vmIacmOQ/ut1uTMdWrlF54udGbJuX2TBTxBYsiYznTMGLVT 1b7JTUK3u9kGhFLazHRpENLoBwzKz1KOMG0xQOICcrzWpyEVbXf3vjLj6wTg/acyj4IX zvTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g74-v6si6584946pfg.225.2018.07.05.09.41.38; Thu, 05 Jul 2018 09:41:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754215AbeGEQlf (ORCPT + 31 others); Thu, 5 Jul 2018 12:41:35 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:53452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753459AbeGEQld (ORCPT ); Thu, 5 Jul 2018 12:41:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 610E080D; Thu, 5 Jul 2018 09:41:33 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 30F303F5BA; Thu, 5 Jul 2018 09:41:30 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, peterz@infradead.org, will.deacon@arm.com Cc: andy.shevchenko@gmail.com, arnd@arndb.de, aryabinin@virtuozzo.com, boqun.feng@gmail.com, catalin.marinas@arm.com, dvyukov@google.com, glider@google.com, hpa@zytor.com, linuxdrivers@attotech.com, mark.rutland@arm.com, mingo@kernel.org, mingo@redhat.com, parri.andrea@gmail.com, peter@hurleysoftware.com, tglx@linutronix.de Subject: [PATCHv3 05/12] atomics: instrument cmpxchg_double*() Date: Thu, 5 Jul 2018 17:40:46 +0100 Message-Id: <20180705164053.10073-6-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180705164053.10073-1-mark.rutland@arm.com> References: <20180705164053.10073-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We currently don't instrument cmpxchg_double() and cmpxchg_double_local() due to compilation issues reported in the past, which are supposedly related to GCC bug 72873 [1], reported when GCC 7 was not yet released. This bug only applies to x86-64, and does not apply to other architectures. While the test case for GCC bug 72873 triggers issues with released versions of GCC, the instrumented kernel code compiles fine for all configurations I have tried, and it is unclear how the two cases are/were related. As we can't reproduce the kernel build failures, let's instrument cmpxchg_double*() again. We can revisit the issue if build failures reappear. Signed-off-by: Mark Rutland Acked-by: Peter Zijlstra (Intel) Cc: Arnd Bergmann Cc: Boqun Feng Cc: Dmitry Vyukov Cc: Ingo Molnar Cc: Will Deacon --- include/asm-generic/atomic-instrumented.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) -- 2.11.0 diff --git a/include/asm-generic/atomic-instrumented.h b/include/asm-generic/atomic-instrumented.h index 53481b6eacdf..0d4b1d3dbc1e 100644 --- a/include/asm-generic/atomic-instrumented.h +++ b/include/asm-generic/atomic-instrumented.h @@ -450,23 +450,18 @@ static __always_inline bool atomic64_add_negative(s64 i, atomic64_t *v) arch_cmpxchg64_local(__ai_ptr, (old), (new)); \ }) -/* - * Originally we had the following code here: - * __typeof__(p1) ____p1 = (p1); - * kasan_check_write(____p1, 2 * sizeof(*____p1)); - * arch_cmpxchg_double(____p1, (p2), (o1), (o2), (n1), (n2)); - * But it leads to compilation failures (see gcc issue 72873). - * So for now it's left non-instrumented. - * There are few callers of cmpxchg_double(), so it's not critical. - */ #define cmpxchg_double(p1, p2, o1, o2, n1, n2) \ ({ \ - arch_cmpxchg_double((p1), (p2), (o1), (o2), (n1), (n2)); \ + typeof(p1) __ai_p1 = (p1); \ + kasan_check_write(__ai_p1, 2 * sizeof(*__ai_p1)); \ + arch_cmpxchg_double(__ai_p1, (p2), (o1), (o2), (n1), (n2)); \ }) -#define cmpxchg_double_local(p1, p2, o1, o2, n1, n2) \ -({ \ - arch_cmpxchg_double_local((p1), (p2), (o1), (o2), (n1), (n2)); \ +#define cmpxchg_double_local(p1, p2, o1, o2, n1, n2) \ +({ \ + typeof(p1) __ai_p1 = (p1); \ + kasan_check_write(__ai_p1, 2 * sizeof(*__ai_p1)); \ + arch_cmpxchg_double_local(__ai_p1, (p2), (o1), (o2), (n1), (n2)); \ }) #endif /* _LINUX_ATOMIC_INSTRUMENTED_H */