From patchwork Tue Nov 22 20:39:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 24568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2429198wrr; Tue, 22 Nov 2022 12:42:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf4m6cmy4w1fFo6YTA3EEJMMyoCb0t1uq6wz++ztlfNuPFthebNhjXMW7yRgvtHK8yhgzX9X X-Received: by 2002:a17:90a:7004:b0:218:ab86:3acb with SMTP id f4-20020a17090a700400b00218ab863acbmr13205828pjk.195.1669149746331; Tue, 22 Nov 2022 12:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669149746; cv=none; d=google.com; s=arc-20160816; b=Q9WFQ8bZZkUISb9NvWRlFMTdxv4j6ye/ZnrfhjrvgfLjlx8WzqJ8NTRPvglCj/HLwg 3lORC6cW/5u6JCgaNfWtF4h8K9fP9aWvB6AOlJo2B2PEAYo0qA5uIhlpHigjY2TkDj7B iB33SaH5ulHgpVRDj2iwSRGK4AwnafRlVlGvPm9BPTXNqjwEEpEpg783yeugY072SM6A N0KXkKlsg2jafsOWVMOYQFC7LRJf0CN7RK4ue/s5u3uBoHCHuTd7z7uzmC8yWIFSE02S 8RMfK2WIZg1eYt2GYZVYEBx9LnIecBQOhV5D1+yafXV3lK9pZcL4Dkl8f+hotahaI/NX Aovg== 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 :dkim-signature; bh=+F5OeHQSL4gPQaE3qzc4beCn08ggaYqUg6FkJS+UQAo=; b=YNBt6/+K4aAfGQf1wwH3cXlq4cbQg1vckMELbBTkJIDhs6H1moMbef8DJhGoCiqd2u RiBvDrZ2paBqXmN5wHot3/pgrgZECrd8cpGj31gtk9QoUicKAvdc/D5O2nJ/znSdED4F S33SLAMJ6wOl3R3Dib7SGJ1XLn5b3Rbe6Z2p/X/OSurHrWznl8J+4gQwMnEPb3W3PuY5 8GDHdyU16GjNw2R/fd9YClIgMCfvTOcqRmGAWLF1Igm0SwM6sR4dkAIWBkty7eqgE2rk ICWYz8VNkWGAS77tlyIO+emyNGR3M/8mvugzX4uOOUkvbeKwW85JaQ/zZMxpv9zniaKY MTOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=QB29dn3Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b20-20020a056a000a9400b0053e0d9dfee5si16225114pfl.217.2022.11.22.12.42.12; Tue, 22 Nov 2022 12:42:26 -0800 (PST) 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; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=QB29dn3Y; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234948AbiKVUkg (ORCPT + 99 others); Tue, 22 Nov 2022 15:40:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234894AbiKVUjw (ORCPT ); Tue, 22 Nov 2022 15:39:52 -0500 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD189697E8; Tue, 22 Nov 2022 12:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1669149588; bh=Ittf5/h2eFHZsvkRxlERVQgY2E4qLD49CL1ob0scu/M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QB29dn3YuH5o+c6C31/1e3b2Qv5Zd357TgCdWqBctDiK0bT0DofRffW1hU0ho+/lF tQy6uhTXy/dfVXEJx7SSmFzzi9NW2K2jG+6BhpO1MCWqHsJz0d+ht5b3eMsVALHY1u AcVelrcrHog+ucXcj0FucEJKVcDQvS+zhZ7zj1iKI6QuDuZfBw+rTl9QN1iytiGcp9 G3amSCVSd/OaWU7PpiZJ074mPAyqEysg532AQr79Vn1/TLEDYKjx2Z3yqLqDWwqL5F XCdS05wtOBDZ6ymztvEVTET/ASRO3PH6ZygVxtc81w9++NE7d1KqbK6taxApFw/mb0 D7XyqlGgBwsZw== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4NGx2X1RYPzXLR; Tue, 22 Nov 2022 15:39:48 -0500 (EST) From: Mathieu Desnoyers To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Thomas Gleixner , "Paul E . McKenney" , Boqun Feng , "H . Peter Anvin" , Paul Turner , linux-api@vger.kernel.org, Christian Brauner , Florian Weimer , David.Laight@ACULAB.COM, carlos@redhat.com, Peter Oskolkov , Alexander Mikhalitsyn , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH 10/30] selftests/rseq: Implement rseq mm_cid field support Date: Tue, 22 Nov 2022 15:39:12 -0500 Message-Id: <20221122203932.231377-11-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> References: <20221122203932.231377-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RDNS_NONE,SPF_HELO_NONE, SPF_PASS autolearn=no 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?1750230364313063439?= X-GMAIL-MSGID: =?utf-8?q?1750230364313063439?= Add support for the mm_cid field (per-memory-map concurrency ID) of struct rseq to rseq selftests. Signed-off-by: Mathieu Desnoyers --- tools/testing/selftests/rseq/rseq-abi.h | 9 +++++++++ tools/testing/selftests/rseq/rseq.h | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/tools/testing/selftests/rseq/rseq-abi.h b/tools/testing/selftests/rseq/rseq-abi.h index a1faa9162d52..fb4ec8a75dd4 100644 --- a/tools/testing/selftests/rseq/rseq-abi.h +++ b/tools/testing/selftests/rseq/rseq-abi.h @@ -155,6 +155,15 @@ struct rseq_abi { */ __u32 node_id; + /* + * Restartable sequences mm_cid field. Updated by the kernel. Read by + * user-space with single-copy atomicity semantics. This field should + * only be read by the thread which registered this data structure. + * Aligned on 32-bit. Contains the current thread's concurrency ID + * (allocated uniquely within a memory map). + */ + __u32 mm_cid; + /* * Flexible array member at end of structure, after last feature field. */ diff --git a/tools/testing/selftests/rseq/rseq.h b/tools/testing/selftests/rseq/rseq.h index fd17d0e54a1b..10ebf13644fa 100644 --- a/tools/testing/selftests/rseq/rseq.h +++ b/tools/testing/selftests/rseq/rseq.h @@ -191,6 +191,16 @@ static inline uint32_t rseq_current_node_id(void) return RSEQ_ACCESS_ONCE(rseq_get_abi()->node_id); } +static inline bool rseq_mm_cid_available(void) +{ + return (int) rseq_feature_size >= rseq_offsetofend(struct rseq_abi, mm_cid); +} + +static inline uint32_t rseq_current_mm_cid(void) +{ + return RSEQ_ACCESS_ONCE(rseq_get_abi()->mm_cid); +} + static inline void rseq_clear_rseq_cs(void) { RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs.arch.ptr, 0);