Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp469308imn; Fri, 29 Jul 2022 12:37:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uLtL/BQ3ZjKik7lp+rfsfgTVOfygGr51QhcjsYcBjK9N7GWt0hNd8ilkELIQJVtbSWtGig X-Received: by 2002:a17:906:6a29:b0:72e:e716:d220 with SMTP id qw41-20020a1709066a2900b0072ee716d220mr4017326ejc.82.1659123439614; Fri, 29 Jul 2022 12:37:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659123439; cv=none; d=google.com; s=arc-20160816; b=xfJKWI+SJkJ8aL+fCYCEAChFMTUAKDTz/Dupo6eM/kutOSPVh5eoizSpEptujwxeU7 rwsBwNKGVLb18vQDX3cur6R1J7j1HhmMANTe1i00rcY8Jmwo2EfbqvjG5T4XbdPYPapj ozp49bbFWpcmCRHxUBZ0G7FrlUtK6pljCx6wMgnHS/Ol20OIh1wSgWrPWs+AMx/T/Ydr I3toYNgBQfBkZGs5NbdtrNBRcHthyvWDWmnXrGk3o1kHFSNiuTXwNvM18nq0q3xfYbO7 0qFZ7tHp26Uk1oF544IvrB+S75H+JdtMtor5yRZOC9lH0IEk0KFt+Zfx0ygTuqePwbJJ L79A== 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=84B9YOyXv7c3EB71cteYmLNG2oHcoRDleMv6nuC252o=; b=WZi21Jiia8R8eMUTyEwQH+8FZXa2Nwbc/bRWzwLRrgWooCcsWNpmH48o1aq9za2p1I PQOO+krdUcLdBqqF2MDQE3EslD/Usl4+FQcghcyCBfANIF1VcfMVWCwHQWuo1AU5u9kY ngYja4MxTDsJNV2mLqVbNPOF4VNf+fMOJ78pYaIEqpFdTEYCZgU0KYR6bTlzGgJSLFUG KlcLg0w5KTR4xserOpkLK68WZsfdhZHadfiDdgZZqYzBmo7SFDNeG4D0SHehbUFlfKyE YL0S/tybJD46zbdEaGuPYE8Ldeay2Q0AnN/6O74DKhaRYX0FhveLeYngHGNur9jARzlB di4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=o3UsOEmj; 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 y25-20020a170906471900b0072f8785a8aasi3787717ejq.273.2022.07.29.12.36.54; Fri, 29 Jul 2022 12:37:19 -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=default header.b=o3UsOEmj; 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 S238699AbiG2TDq (ORCPT + 99 others); Fri, 29 Jul 2022 15:03:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238666AbiG2TDH (ORCPT ); Fri, 29 Jul 2022 15:03:07 -0400 Received: from mail.efficios.com (mail.efficios.com [167.114.26.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E84E989A48; Fri, 29 Jul 2022 12:02:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 032D6319289; Fri, 29 Jul 2022 15:02:55 -0400 (EDT) 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 C_e5cOg2bAPe; Fri, 29 Jul 2022 15:02:54 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 4A9EC318AAA; Fri, 29 Jul 2022 15:02:48 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 4A9EC318AAA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1659121368; bh=84B9YOyXv7c3EB71cteYmLNG2oHcoRDleMv6nuC252o=; h=From:To:Date:Message-Id; b=o3UsOEmjBfGQi5AiHHd+MmgnHXS8IluYh/0o7KlOtfbrUVy0zOq290Ha0tRvV/tlc /aAKOu8B2GwCfBXwh3o3hjL7/Il3ToI3tVbA8YobUZ/cvuc5qocC6s81E1bmr1mFY3 2aBDs138lLCfyusGSJNJSoVJuQiU6Ncc10mqdnNl25zy8zJt0mqvSW4IqWohHgdaF/ etE2gZ+pb/ZsGH5Q2zTOymhZljGRyKjPAXGP3Ch95JJpyIU1eKGXXJKoIcJNhvHyQg LWNVozDQSdSHeYtuVXFJh5FEbu7MMfacsZxAapsOyRVLVbfCjv2PL6yl16lSYBgOnH un9m3pAcEvDOA== 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 6du7qYx850Fh; Fri, 29 Jul 2022 15:02:48 -0400 (EDT) Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by mail.efficios.com (Postfix) with ESMTPSA id 9B087318D7A; Fri, 29 Jul 2022 15:02:44 -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 , Mathieu Desnoyers Subject: [PATCH v3 12/23] selftests/rseq: Implement rseq vm_vcpu_id field support Date: Fri, 29 Jul 2022 15:02:14 -0400 Message-Id: <20220729190225.12726-13-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220729190225.12726-1-mathieu.desnoyers@efficios.com> References: <20220729190225.12726-1-mathieu.desnoyers@efficios.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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.17.1