From patchwork Mon Jun 5 07:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 103124 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2501025vqr; Mon, 5 Jun 2023 00:11:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ48UUnCnepGsgfigmYN/u/Xw18ClbjcNNuviDX0rKX7s+dAYFeAcRXEPihf7kE9mUqtIi09 X-Received: by 2002:aca:1805:0:b0:396:11b3:5851 with SMTP id h5-20020aca1805000000b0039611b35851mr6233012oih.54.1685949112354; Mon, 05 Jun 2023 00:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685949112; cv=none; d=google.com; s=arc-20160816; b=EKvm2A1yNSkjEfa3s6RiDHjY7Chf/lmMOjGF35KhaqczqCppwkxNRrO49NceI6pvWL bl9E8YJfHDO8z2YpBjR0FakTecl4iUs60MAuuayeewbhmAZhi/etYC4ECduuH0Qiws7W f0YessGzl+5Ik0GqAhSXhFhc+QJ75GQjH4txZF4dT1iGNvYPofcHsKlY1OTsYF92ZeSa Ml2nnOfdgDiixO4KcVxwQybAFwoTtRmKIMPy9BMPZKOpfCsLhfOExctfBbzvGI+SjH7t xSfcZf73FspQlBPwlUgKrjJiiL4Z1vGpj1b+tTYVJBBtcCBFsAFkIRvKfSZFd/ZaXwlL fcKA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c26-20020a056a00009a00b0065c7d752e15si678332pfj.50.2023.06.05.00.11.40; Mon, 05 Jun 2023 00:11:52 -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 S230444AbjFEHCz (ORCPT + 99 others); Mon, 5 Jun 2023 03:02:55 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767845776379177375?= X-GMAIL-MSGID: =?utf-8?q?1767845776379177375?= 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)