Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5247630rwd; Mon, 5 Jun 2023 00:10:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6L10/T0M8LUWozVnP0/u3rTM1wxIMR+a1lh/OPy091MgN+RXQpvI33TYc6wFocJ9s6/zTA X-Received: by 2002:a05:6808:618b:b0:39a:a8c5:b3f0 with SMTP id dn11-20020a056808618b00b0039aa8c5b3f0mr4559845oib.46.1685949058880; Mon, 05 Jun 2023 00:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685949058; cv=none; d=google.com; s=arc-20160816; b=uIWDQTMmu6Nh43f8XGR5WRsYxhpxG9kZpnr7nYgHsaQaHwKwGflSUkiktT/Lo27+xv D9TojVNLlh+gt84gea4u6ypB7fzSqo1DsL5z+IKDN3WsF7RR90fzlt6EskcCdF5JtxK8 Ss+WRjKHqvwNNUsUZWf9qrQRORTuHdfpRSaceMDGCt2GZ77TM6zddmevW11i9rjLAT+v 0uZ1JY25tKNjAEaQOUg0Cj4zrNwvOt7cZixKuFs89Ql/FzGzBF+Exekl7zumW7Wt7ha+ i7pnTzf21vxVXSPL72YPa5MYMEtHFVpuONA7dw95Ib2j1xoMBIenA1djrGNhe1VZKqxI VRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=TstChfnbt9Hjx4FbiD3OGjFmsk+j1dPQxheN3Y2sz6I=; b=tzb1v8lLKNUGFpJ3RS59EGsAHyp6MzgpRL71+7CvSxz8qgvRN9D9ZMxH3F8TLsQWFl IiGOYAr4Jywsk+JKgnPjkXN9lk4LPpDXDc7Y12SjuUOMr9IxVIaEftYj4lOA6zR75BOV 6vOGKkPkRJto/8H2ZMUSBww3rFC61y0mNyKjaLYQ0GWhK7NPGJQHawPTsMCU45jfgyuc JPxTyk0jMzRua2s/fVUB3H/sQY87X4VZQBhfwgvTftph4FNcwhFz6LF7P7X8oQn31SXg /8Fpce/OyuKdnDKbtP8FhZji2MhzmFS2Qxab4ptnTGlLVDl9dAy4SMUzW8nFG/VEpF36 dpLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a198-20020a621acf000000b0064f46404b78si4891550pfa.130.2023.06.05.00.10.46; Mon, 05 Jun 2023 00:10:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230433AbjFEHCy (ORCPT + 99 others); Mon, 5 Jun 2023 03:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbjFEHCa (ORCPT ); Mon, 5 Jun 2023 03:02:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2D1A10CB; Mon, 5 Jun 2023 00:02:03 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FFC9152B; Mon, 5 Jun 2023 00:02:49 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DF8DC3F793; Mon, 5 Jun 2023 00:02:01 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: akiyks@gmail.com, boqun.feng@gmail.com, corbet@lwn.net, keescook@chromium.org, linux@armlinux.org.uk, linux-doc@vger.kernel.org, mark.rutland@arm.com, mchehab@kernel.org, paulmck@kernel.org, peterz@infradead.org, rdunlap@infradead.org, sstabellini@kernel.org, will@kernel.org Subject: [PATCH v2 12/27] locking/atomic: x86: add preprocessor symbols Date: Mon, 5 Jun 2023 08:01:09 +0100 Message-Id: <20230605070124.3741859-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230605070124.3741859-1-mark.rutland@arm.com> References: <20230605070124.3741859-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some atomics can be implemented in several different ways, e.g. FULL/ACQUIRE/RELEASE ordered atomics can be implemented in terms of RELAXED atomics, and ACQUIRE/RELEASE/RELAXED can be implemented in terms of FULL ordered atomics. Other atomics are optional, and don't exist in some configurations (e.g. not all architectures implement the 128-bit cmpxchg ops). Subsequent patches will require that architectures define a preprocessor symbol for any atomic (or ordering variant) which is optional. This will make the fallback ifdeffery more robust, and simplify future changes. Add the required definitions to arch/x86. Signed-off-by: Mark Rutland Reviewed-by: Kees Cook Cc: Boqun Feng Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Will Deacon --- arch/x86/include/asm/cmpxchg_64.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/include/asm/cmpxchg_64.h b/arch/x86/include/asm/cmpxchg_64.h index 3e6e3eef701b3..44b08b53ab32f 100644 --- a/arch/x86/include/asm/cmpxchg_64.h +++ b/arch/x86/include/asm/cmpxchg_64.h @@ -45,11 +45,13 @@ static __always_inline u128 arch_cmpxchg128(volatile u128 *ptr, u128 old, u128 n { return __arch_cmpxchg128(ptr, old, new, LOCK_PREFIX); } +#define arch_cmpxchg128 arch_cmpxchg128 static __always_inline u128 arch_cmpxchg128_local(volatile u128 *ptr, u128 old, u128 new) { return __arch_cmpxchg128(ptr, old, new,); } +#define arch_cmpxchg128_local arch_cmpxchg128_local #define __arch_try_cmpxchg128(_ptr, _oldp, _new, _lock) \ ({ \ @@ -75,11 +77,13 @@ static __always_inline bool arch_try_cmpxchg128(volatile u128 *ptr, u128 *oldp, { return __arch_try_cmpxchg128(ptr, oldp, new, LOCK_PREFIX); } +#define arch_try_cmpxchg128 arch_try_cmpxchg128 static __always_inline bool arch_try_cmpxchg128_local(volatile u128 *ptr, u128 *oldp, u128 new) { return __arch_try_cmpxchg128(ptr, oldp, new,); } +#define arch_try_cmpxchg128_local arch_try_cmpxchg128_local #define system_has_cmpxchg128() boot_cpu_has(X86_FEATURE_CX16) -- 2.30.2