Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp619712rwb; Thu, 22 Sep 2022 04:28:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM53qkIPryOL4PWFfFwyyO2+uAFGX+ko97DvsLzu//jrRG4Ua7WHlMhRSc8DCfwh7MgEJmWu X-Received: by 2002:a05:6402:124c:b0:454:61b8:dea0 with SMTP id l12-20020a056402124c00b0045461b8dea0mr2814718edw.200.1663846081544; Thu, 22 Sep 2022 04:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663846081; cv=none; d=google.com; s=arc-20160816; b=0K2U2Z/wTjsbCPMh4SpI4o3BKgWEbQuWNPcv7XpTcg/5JfXsYRnCepb9ZU+pGIdacW IT8WRe/gNy0cetDVVrKnFTFc+hHOsGbbwvlrggymwl1xEDOsd9wkp1VEgZ9y+6K1EnRX lJ3pOhPWN+JodW9Pj5W4T1e1dlKGY5EJPk/xkZTKvnP+ZqcgTs9XbYA3UOshlaVUJvcU 2WoaDkunpJ0lowJm9VapERzUM6Ur76gUPNZo2usU5DvrsV3K39pJDslPL6em6Ht59bD0 RJFGdQvWSNWkjTNGPP9G/GMVkESUud6f9gptQC7vLtaTt0z5PPSDraws1HxMBoY61d8/ +sXA== 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=ydX5abDtVcdG40sp4OcpZsdWY4VrieobyAhF6HkHwd0=; b=gDmPLfiul3bpL5twixGGbm6eVq4TUVVrXCsjwgODcdQtbTJmqmdLojGW3lIDFzzTzq iXc/uNCwV/WdQC8/nE5G6f8OwQepag6JzlbzdfaJL9uTWbK3kJpiViyv1VysISJb3BPG 9fJVM4FhcQ4xssom+96Uur8p13AYaSS3LVwzCSGgDLjhGhUe7RsxhpNB2Sx0kB88mMZ/ eZwxXxSpWvaLtQUEw2u5iLU1hYAaan8kveHyJXkTUtLkre+ffd82RJa0adYZJDZd+YC5 xqZN2QTM5GIV6t/GeJ5RpvZNjEbiUF/q9a/slcMAp48n0aHcxSGJij9Tws4Ok/sR0syt Uhog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=OrpStuUx; 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 f7-20020a50a6c7000000b00451a3b1670bsi4895530edc.539.2022.09.22.04.27.32; Thu, 22 Sep 2022 04:28:01 -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; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=OrpStuUx; 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 S229723AbiIVLKr (ORCPT + 99 others); Thu, 22 Sep 2022 07:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbiIVLKY (ORCPT ); Thu, 22 Sep 2022 07:10:24 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C10EC86896; Thu, 22 Sep 2022 04:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1663844386; bh=fkx/2owExzHUCN4g/xHByxaw+klP4dt2rTfC0R62Avo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrpStuUxUEEsuKoYv95U4+foz6w5Q+fzHAI7tCbmJCB9lmF/98JXWAvP6JQu4RN43 gFvggQalBe1FXqGP/hTKE9/7iWG4RpY42SUaOsqFoR1gHqHIlnJv6W3rODvpkdz3Lb WnepOpoqwSUK3WcK0gfnGM2XBqUKKNF7nVBGu95elmlk7WRCnl3b1UpRhC6XAPeILW tnSxrwtFDBReYc797vI5DLZ0DCRsG1NhI/7bLrt9CyudrnXWWNLzGRr7c//igooiG9 un71yWeanrVp5bKUNK0tWTSmu9hVXsq8d6e8GVl+qqB4MVmIAS/EqAJ6PHSSUPwHGl RU6DFcQO4Calg== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4MYC3Q1JkvzNbw; Thu, 22 Sep 2022 06:59:46 -0400 (EDT) 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 , Mathieu Desnoyers Subject: [PATCH v4 12/25] selftests/rseq: Implement rseq vm_vcpu_id field support Date: Thu, 22 Sep 2022 06:59:27 -0400 Message-Id: <20220922105941.237830-13-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220922105941.237830-1-mathieu.desnoyers@efficios.com> References: <20220922105941.237830-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 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..1ee4740ebe94 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 vm_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 a memory space). + */ + __u32 vm_vcpu_id; + /* * 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..003e0e3750ce 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_vm_vcpu_id_available(void) +{ + return (int) rseq_feature_size >= rseq_offsetofend(struct rseq_abi, vm_vcpu_id); +} + +static inline uint32_t rseq_current_vm_vcpu_id(void) +{ + return RSEQ_ACCESS_ONCE(rseq_get_abi()->vm_vcpu_id); +} + static inline void rseq_clear_rseq_cs(void) { RSEQ_WRITE_ONCE(rseq_get_abi()->rseq_cs.arch.ptr, 0); -- 2.25.1