From patchwork Thu Jul 5 16:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141212 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2154484ljj; Thu, 5 Jul 2018 09:41:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfO4arSOy+y7WUrDo8wYWsXfviUAXk/YiuT2k7H25ES6GiL/EZ3hI8M1lHzWf5ALlI7dykb X-Received: by 2002:a63:1644:: with SMTP id 4-v6mr229603pgw.103.1530808885602; Thu, 05 Jul 2018 09:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530808885; cv=none; d=google.com; s=arc-20160816; b=Vz1qhW5iR+vXYT0anpoIuJ6BFMjp3/eeuDsqZt9Cw9O/7xfIS8/GbBMHQpR0+Eh09L xg/6LnlgSdo0Od1xUO/bcSTFF+zKxFcFgshu6Vo/nJDsuSei+TRSKuGisEtHsRVzG0Ig eNBRorc+Hr0n272d5vF8Zfso1oPAt7+jye3895KuVx1oTU54bB511hHSwrbA6IWduwwP hZh1/oF3FavQEzlsiMHbLwSlxYzyZWBH+ZicDFJsr4gs21Z0DSkKFAEpKFizQpvLWa/j SHsaGF3QRgRumX0gPUB9pTZ/jS+zOFzVAdeNKQBORQosJSWP91vOSoDXH5oJC4cL10H1 eqfw== 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=9vcMxwGK2jwvihdB0XKV2KYAMG1YWV7VERW0UQR5ZMo=; b=IW35zGwq9qwS1JC7+qIiTztQeA37KY2aAjUAKt/ObvXWnq9Z5tI4KaZuceELMzGHgN R+R9us+D6z/Iyid3oLsxTlylP0nzu4m4zrDXdxdAFE3rU9YCCsX0B8YPBXw9PMjsvJnU oo64aWagMDqYkxYEXIoEkJfl84wBoS0Mi3camADsxINSkh8rZ3PrgeP/KDppZgPFQuJM xWigjo40XsQIyK5O0iwXpu0pnfCru9A1LSd7DLUcjFBiMGiTlUtXaMpfsuaBCkWweex9 +Cr6CWp3ChQtN2dSI3cor4B63M9tkwRxBOHlGMglSX619IITKfjaTpbM8JizXYZIt/JI MR6Q== 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 d5-v6si6107225plo.3.2018.07.05.09.41.25; Thu, 05 Jul 2018 09:41:25 -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 S1754010AbeGEQlV (ORCPT + 31 others); Thu, 5 Jul 2018 12:41:21 -0400 Received: from foss.arm.com ([217.140.101.70]:53362 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753459AbeGEQlT (ORCPT ); Thu, 5 Jul 2018 12:41:19 -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 A2F561595; Thu, 5 Jul 2018 09:41:19 -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 7BBA63F5BA; Thu, 5 Jul 2018 09:41:16 -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 02/12] atomics/x86: reduce arch_cmpxchg64*() instrumentation Date: Thu, 5 Jul 2018 17:40:43 +0100 Message-Id: <20180705164053.10073-3-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 Currently x86's arch_cmpxchg64() and arch_cmpxchg64_local() are instrumented twice, as they call into instrumented atomics rather than their arch_ equivalents. A call to cmpxchg64() results in: cmpxchg64() kasan_check_write() arch_cmpxchg64() cmpxchg() kasan_check_write() arch_cmpxchg() Let's fix this up and call the arch_ equivalents, resulting in: cmpxchg64() kasan_check_write() arch_cmpxchg64() arch_cmpxchg() Signed-off-by: Mark Rutland Acked-by: Peter Zijlstra (Intel) Cc: Boqun Feng Cc: Dmitry Vyukov Cc: H. Peter Anvin Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Will Deacon --- arch/x86/include/asm/cmpxchg_64.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.11.0 diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h index bfca3b346c74..072e5459fe2f 100644 --- a/arch/x86/include/asm/cmpxchg_64.h +++ b/arch/x86/include/asm/cmpxchg_64.h @@ -10,13 +10,13 @@ static inline void set_64bit(volatile u64 *ptr, u64 val) #define arch_cmpxchg64(ptr, o, n) \ ({ \ BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ - cmpxchg((ptr), (o), (n)); \ + arch_cmpxchg((ptr), (o), (n)); \ }) #define arch_cmpxchg64_local(ptr, o, n) \ ({ \ BUILD_BUG_ON(sizeof(*(ptr)) != 8); \ - cmpxchg_local((ptr), (o), (n)); \ + arch_cmpxchg_local((ptr), (o), (n)); \ }) #define system_has_cmpxchg_double() boot_cpu_has(X86_FEATURE_CX16)