Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1875647pxb; Wed, 2 Feb 2022 14:44:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwighvz538wfSSTJWLV/IwQzsxXNPZrwL7gK3t2v+hiG8sqtU2ujCmqS5sogu4naq6q64c4 X-Received: by 2002:a05:6402:42d4:: with SMTP id i20mr32756554edc.306.1643841847014; Wed, 02 Feb 2022 14:44:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643841847; cv=none; d=google.com; s=arc-20160816; b=rBwhLxna8/TXC6RWr1lFc2hPvbWLCH0MzhJHEHpO4XkmnbXf9ca/ot1bilZH4U9gUU 8iqC1kfNrlfa7ueU6wzwdSnIEuYqEPKNUHplihDVyNHvNMG3wKkRcMeaMpJ7T5XUY953 CM0edcTed1NkxRUKBYAJSfSj0f2/rHYbAeTE1B6QpXvVtsII1HI4HIL7o45132BwEFZ7 8eF/FWTTaQqs5rdaVXmrJnBkdWcgoo4a/YSoaf3Kt2FTVRERGqV5B0T24FM/dvankBpl tXxmyvZSS1qat7A7vkpGQGsR3Itq2ZgYaqKrkqg6LWj3Ljo4eX/nzrUQZPCUJt7/GZfW JqoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature:dkim-filter; bh=UerzEHT0HokfvobQ6Sx0XXHkVzDdD+XuQ7F7dL2bDt4=; b=n2nySVsAK4Xst+pIzSZVD6KVtliW+6IqAA66gCP/DlqoMlR55pG1DUsafGE6TyWDFk 3DmBnEXl6kSnEQzaLJEWH54M/a8qe8h8m7jYhZfeUrNs5yafujzHbWthYYWRRAQqSmJi QHvQYE7D84b7A5UC2ZctXtj9MA71RLWlMnAk3xlawZRJ9lnUpKCL1G2dbjtld4RD4r1X sWZjym++7gmO6hHpWi8us2ONQQczKafHQVU/PBlBq4QMCdrF7vxmut0KD0BpEBSSH1aY gHTkBW1PKkVGUYk4Y5ph/KgHuaLPPYMN0GcsPzBbGZ3udYZy1UpTnxPnGnBnNNRooLsL a+Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=lcUnLu59; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3si11530886edr.547.2022.02.02.14.43.43; Wed, 02 Feb 2022 14:44:07 -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=default header.b=lcUnLu59; 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 S242307AbiBAT03 (ORCPT + 99 others); Tue, 1 Feb 2022 14:26:29 -0500 Received: from mail.efficios.com ([167.114.26.124]:53348 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242362AbiBAT0Z (ORCPT ); Tue, 1 Feb 2022 14:26:25 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 7D74D33FC17; Tue, 1 Feb 2022 14:26:24 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 0PdxbvaKTw7s; Tue, 1 Feb 2022 14:26:24 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 278AA33FC16; Tue, 1 Feb 2022 14:26:24 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 278AA33FC16 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1643743584; bh=UerzEHT0HokfvobQ6Sx0XXHkVzDdD+XuQ7F7dL2bDt4=; h=From:To:Date:Message-Id; b=lcUnLu59tpKPeUMApFtzsnz3PFre7XjC114lnEuPMWK6kHaeDbOZM6S3ocftaotzq jtXt1tCTX/Qn+Zzc5ryNzcLmTuHsvnlWLEaWu+zNUziqKO1tih+ZUcVGTAGcJH/Rlf c2uZpsulMq2KIuGWGpDTTFJCNJ1+ndXsRa8X50X/qWnL8aeIU/n+nrYICKvY04/GSI VdEycjx375ExAHsCs4nNM6rVDNdmItd28C6RTJdM6vbUSlQt0lHbzUgq6WW6Q1dBfz GggTDMozEDTlHruLOWXBhMr7SFrGGmqwfwW8BDgFBn5Bv2h8XzM9oWoI4QsPPRjAYd 6qrrvQrcb0GMg== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id juUsdtvvD7aA; Tue, 1 Feb 2022 14:26:24 -0500 (EST) Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by mail.efficios.com (Postfix) with ESMTPSA id 17F7233F8FB; Tue, 1 Feb 2022 14:26:23 -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 , Mathieu Desnoyers Subject: [RFC PATCH 3/3] selftests/rseq: Implement rseq tg_vcpu_id field support Date: Tue, 1 Feb 2022 14:25:40 -0500 Message-Id: <20220201192540.10439-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220201192540.10439-1-mathieu.desnoyers@efficios.com> References: <20220201192540.10439-1-mathieu.desnoyers@efficios.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Mathieu Desnoyers --- tools/testing/selftests/rseq/rseq-abi.h | 15 +++++++++++++++ tools/testing/selftests/rseq/rseq.c | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/rseq/rseq-abi.h b/tools/testing/selftests/rseq/rseq-abi.h index 850827e8d089..929183c2b3c0 100644 --- a/tools/testing/selftests/rseq/rseq-abi.h +++ b/tools/testing/selftests/rseq/rseq-abi.h @@ -169,6 +169,21 @@ struct rseq_abi { * rseq_len. Use the offset immediately after the node_id field as * rseq_len. */ + + /* + * Restartable sequences tg_vcpu_id 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 virtual CPU ID + * (allocated uniquely within thread group). + */ + __u32 tg_vcpu_id; + + /* + * This is a valid end of rseq ABI for the purpose of rseq registration + * rseq_len. Use the offset immediately after the tg_vcpu_id field as + * rseq_len. + */ } __attribute__((aligned(4 * sizeof(__u64)))); #endif /* _RSEQ_ABI_H */ diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4b0e68051db8..c8d30e770d59 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -88,7 +88,7 @@ int rseq_register_current_thread(void) /* Treat libc's ownership as a successful registration. */ return 0; } - rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, node_id), 0, RSEQ_SIG); + rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, tg_vcpu_id), 0, RSEQ_SIG); if (rc) return -1; assert(rseq_current_cpu_raw() >= 0); @@ -103,7 +103,7 @@ int rseq_unregister_current_thread(void) /* Treat libc's ownership as a successful unregistration. */ return 0; } - rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, node_id), RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); + rc = sys_rseq(&__rseq_abi, rseq_offsetofend(struct rseq_abi, tg_vcpu_id), RSEQ_ABI_FLAG_UNREGISTER, RSEQ_SIG); if (rc) return -1; return 0; @@ -126,7 +126,7 @@ void rseq_init(void) return; rseq_ownership = 1; rseq_offset = (void *)&__rseq_abi - rseq_thread_pointer(); - rseq_size = rseq_offsetofend(struct rseq_abi, node_id); + rseq_size = rseq_offsetofend(struct rseq_abi, tg_vcpu_id); rseq_flags = 0; } -- 2.17.1