From patchwork Thu Nov 3 20:03:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 15170 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp743084wru; Thu, 3 Nov 2022 13:07:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ETSynEGmyyz6RKzr9NpxhDGUCQg8uPyRpMTlUNN8sjIUQGj20Gj1KvIw8d7640fNQX9eG X-Received: by 2002:a63:82c7:0:b0:470:22e0:7031 with SMTP id w190-20020a6382c7000000b0047022e07031mr3305346pgd.63.1667506076894; Thu, 03 Nov 2022 13:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667506076; cv=none; d=google.com; s=arc-20160816; b=uD+pFN3iq3FmxUv/3maxgEYAqaYxePR8/AwW506zPz6dxunrifX8IP5nVUrC62A5pk DcqJSGtErYRo+VW4uAQ+0nS2/gIIlJeD6jv857IDaS6DrvUmSxowBFCYutroaKdPKYIp emB0sU4+VabZO4ezJ4JgBfWbG8VPBPFiCgAoh2URRDerJBhGuCy0UYwZRqrSn88+Vr/i Jvj7A2/PS+mqJdPTLyiEFFivue4NW7FcLeF6A/NK++mf9Ys1zvYChqSTVsgr255xMyji q1coU5AjT1IN+E5h/snPblUYUxKwu4b9gZg8RpAVDwsVWYWl4NIsXDTpTuYK/KdcbR05 iwoQ== 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=D9iO9wvW2XmcwqEzVJrYWhfbYXaWJ9jBXEE8trb0fds6chm+6rkIRGhYbxtse7KZXq mDba3Z8b6Tp8jCu4cJPn0v1jWaGnZtIgHDbWuw5iNVlT3TIol4vkqpUxdsqDo4kOVvVd eFUD8K1Qtd5jxzmNn+t/10XfDzVpBOGNR2W0YwbhRWC9KpsQewm+iXS6Nytu3WbiR1V+ swTyUxL0GIO72YqnxUr5pNtHUeesP9nhTwUlMA8lFmvSry7VIwMbwnbeTR3MSdg5XYQd GkFDEXrlxpVJDT6muySHLopgyR86sLZ3ZOBly0APBz+B+MwyXtIOxqAGwjKR8Ixcf17F +bvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=t5i7poKY; 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 l12-20020a170903120c00b001870506835bsi2144934plh.601.2022.11.03.13.07.44; Thu, 03 Nov 2022 13:07:56 -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=t5i7poKY; 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 S231555AbiKCUFb (ORCPT + 99 others); Thu, 3 Nov 2022 16:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230497AbiKCUFA (ORCPT ); Thu, 3 Nov 2022 16:05:00 -0400 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA32320362; Thu, 3 Nov 2022 13:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1667505899; bh=fkx/2owExzHUCN4g/xHByxaw+klP4dt2rTfC0R62Avo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5i7poKYqZ5elj2LTCnnwveYuSn5ZrTHELnjzsWSLvubAUlozPEaDblMqxefhKnQe E5CrovNy6klwz3GyHg08/BrHeYUItialMcBXtoU1ns9D9pRUxfcndQSmbfWHdgTbby /6npPr4NqWI8TNkYV2vQTE28WIt88YrXsnaW3Dm12W02OB7EGHGDh0rN8K69i4BDfP cSpehhdTiaotQuBIaYAGvTfy36STLJKgQfyDrwRhpwRK2wD4AsybWxibZ3Se9FiexO iHqm5Oi4xP5a9ASKp9ZDikxC5fqMNQNObVULOhEo76OyVLOpXUZmCSbiiKk7bxEKz4 arj96J19m1/eA== Received: from localhost.localdomain (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4N3F966x8fzg2l; Thu, 3 Nov 2022 16:04:58 -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 , Chris Kennelly , Mathieu Desnoyers Subject: [PATCH v5 11/24] selftests/rseq: Implement rseq vm_vcpu_id field support Date: Thu, 3 Nov 2022 16:03:46 -0400 Message-Id: <20221103200359.328736-12-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> References: <20221103200359.328736-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748506852145231262?= X-GMAIL-MSGID: =?utf-8?q?1748506852145231262?= 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);