From nobody Mon Apr 13 05:27:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1771000192; cv=none; d=zohomail.com; s=zohoarc; b=TmHKZA9LIqwHfUQlSQSHI80TYSCNMpwb0Lhr7/XgxjCyEPd/eOq72Cxf3x6d4Z/OElLaWU5u4tyshmYHMcdU/25XdLHrZRZ88CwL4aqGP8E+oZntB3BNs0hAVkNRvQdiTXEhLpqCe5IXBpTpnMNqlZn/alloZ1QppYT3XZ+6SJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771000192; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5hWO4jWrfrLp9yyPELp3VQAn+IIJ4GM5hz6O0oK25QU=; b=TkAnPF7gG/gAbYZpPwb6uqiiBqLM3FL5K9muiOjQG2jUpaO25IcbvPfT5LbwB/WScRH7hKk/Kozqi9gbQYsxPav5wBjH5vp1zvpK2sdcv5R01cVezSbHESnGjZzSIVhaHDRzw1SMNlrULQwHkrmQV84Bx/leK6zDV9DlccMoyFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1771000192658410.41883466755985; Fri, 13 Feb 2026 08:29:52 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1231321.1536582 (Exim 4.92) (envelope-from ) id 1vqw2o-00085w-Ib; Fri, 13 Feb 2026 16:29:26 +0000 Received: by outflank-mailman (output) from mailman id 1231321.1536582; Fri, 13 Feb 2026 16:29:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqw2o-00085d-Dl; Fri, 13 Feb 2026 16:29:26 +0000 Received: by outflank-mailman (input) for mailman id 1231321; Fri, 13 Feb 2026 16:29:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vqw2m-0005Wn-5q for xen-devel@lists.xenproject.org; Fri, 13 Feb 2026 16:29:24 +0000 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [2a00:1450:4864:20::32e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2732d33a-08f9-11f1-9ccf-f158ae23cfc8; Fri, 13 Feb 2026 17:29:22 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-48375f1defeso5716165e9.0 for ; Fri, 13 Feb 2026 08:29:22 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4834d5ebd1bsm303288185e9.6.2026.02.13.08.29.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Feb 2026 08:29:21 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2732d33a-08f9-11f1-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771000161; x=1771604961; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5hWO4jWrfrLp9yyPELp3VQAn+IIJ4GM5hz6O0oK25QU=; b=CCIadwNVQE/aeo301zLTi9O2azuT9S4rQGI3SHrWi8m+kDwUCPazBIQhNlXEMxdDaQ RfXXMe/BSyiRAhdXThU0XWsnulvi+yQIEVhyDqNfT4qlJwAeFc0LDPnR8LsClAukGfi5 ka0kVDK0hmKiJVpkB6oc4K3yraQdwW1an5MdyFxiuPAo1IcLJgjmGfsp4p2tlrejTZtk QfmEilm9FYL0JlueRBNJZS0B+QCj3VdMtsgRXarCpSKjg8IN5RoC00IJswQofgoSEQVD 7OVKIreoSYZ4aLUofrQhIVws+JdYYNh87YKYpZ8xD8TOQzygvfCuwYNOlLq2PbWIr2ov wpSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771000161; x=1771604961; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5hWO4jWrfrLp9yyPELp3VQAn+IIJ4GM5hz6O0oK25QU=; b=jj2DDOxv2IIwjKPnjBKOyujGdQak2jOmU513aIjMMIx5j5uNdKNPTp9xtaZ78HgMVu VaYwbZ/In/nY4vXHvYDCGY5d8Y8+Il4NEwlUdroWe29VAi3BJPvTQ4sEK6tVMGcZp6t/ TiJpJAhOcDtgoHMVWzsVv/2wifXcPHJVkxrV5mmv48KdS3s/FcrT0zDXbFJh9xigDpyS F7+uTZ6dwDDnRUNZfbGRhxlmW48uGtY1DJIu6b/ydaqEzaG/IWDXfn5nXXFNbFqAt6kJ 0fmK7F95hUxMJygt79lSw16wSsG6MGXGSleoa6lMPVQutcHi6S322VXF8q3Zn0TX/85Q NdqQ== X-Gm-Message-State: AOJu0Yw6o3aVVKT8eF7VyM6vFBIchn5dgU8dcmJ6oeHa5KowngsM2n3s w4gl60ZVlo3OUiQIyk6CgtasU72qTYYBXeOoMkS34RkRv/ef3ftBTQjlOJOHMM38 X-Gm-Gg: AZuq6aJL1ZN6zEeASpi67PvEPIgKoc/J/IxkH8xApJR1GE0Qrk+jnpcJBfB1UQcwQ/H HBXzl/q7WVDOgQURO0sOAWkDmFhJ6nGiUcQR+QoHvrbR/llz4G1qAaUrYmijnOKNB7jX2SEDufV XOOUnPLzZPeeobRDvuDo8yyFQXnoIi6HBXCL2lQu2BjOQPjvVbJp/mQy2ojnTvLzff8UcxClIqP 6xG2lFwJyEvdMxu18JCYFpPVOfAaS8tjN//OXMrmTIcZJJAUmDY3wTFkjynS6kjOtMqDQssX7E5 pFM62mJ5uSjtpWm6QNxJY3x9oYzB0NwkAiH9J1y/nnUhbVeZX0HEcu5hhmvuSK5SNcbzG4TXVld /y0Zk7Yqem0Y2+R3mMYhDsxYy1GeXDdWCbhUpm5xfyHPtn5ImURcWl8hDpI9RMrnl8ImqNdSLSs Fty4yKbNt2nS4rukbvXurHdo16gC0L9mXQd5wIVtJKotZf7uUZwy1iyEBLHOPYxXXEfJWw1/wpq +fu X-Received: by 2002:a05:600c:c8d:b0:480:699c:abe9 with SMTP id 5b1f17b1804b1-48373a7b3f1mr37905615e9.37.1771000161294; Fri, 13 Feb 2026 08:29:21 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: Romain Caritey , Oleksii Kurochko , Alistair Francis , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini Subject: [PATCH v4 10/16] xen/riscv: add vtimer context switch helpers Date: Fri, 13 Feb 2026 17:28:56 +0100 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1771000194372158500 Content-Type: text/plain; charset="utf-8" Introduce vtimer_ctxt_switch_from() and vtimer_ctxt_switch_to() to handle virtual timer state across vCPU context switches. At present, vtimer_ctxt_switch_from() is a no-op because the RISC-V SSTC extension, which provides a virtualization-aware timer, is not yet supported. Xen therefore relies the virtual (SBI-based) timer. The virtual timer uses Xen's internal timer infrastructure and must be associated with the pCPU on which the vCPU is currently running so that timer events can be delivered efficiently. As a result, vtimer_ctxt_switch_= to() migrates the timer to the target pCPU when a vCPU is scheduled in. Signed-off-by: Oleksii Kurochko Acked-by: Jan Beulich --- Changes in v4: - Nothing changed. Only rebase. --- Changes in v3: - s/vtimer_ctx_switch_to/vtimer_ctxt_switch_to - s/vtimer_ctx_switch_from/vtimer_ctxt_switch_from - Add Acked-by: Jan Beulich . --- Changes in v2: - Align the parameters names for vtimer_ctx_switch_from() and vtimer_ctx_= switch_to() in declarations to match the ones in the defintions to make Misra happy. - s/vtimer_save/vtimer_ctx_switch_from. - s/vtimer_restore/vtimer_ctx_switch_to. - Update the commit message. --- xen/arch/riscv/include/asm/vtimer.h | 3 +++ xen/arch/riscv/vtimer.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/xen/arch/riscv/include/asm/vtimer.h b/xen/arch/riscv/include/a= sm/vtimer.h index 0d1555511755..c70b0226515e 100644 --- a/xen/arch/riscv/include/asm/vtimer.h +++ b/xen/arch/riscv/include/asm/vtimer.h @@ -17,4 +17,7 @@ void vcpu_timer_destroy(struct vcpu *v); =20 void vtimer_set_timer(struct vtimer *t, uint64_t ticks); =20 +void vtimer_ctxt_switch_from(struct vcpu *p); +void vtimer_ctxt_switch_to(struct vcpu *n); + #endif /* ASM__RISCV__VTIMER_H */ diff --git a/xen/arch/riscv/vtimer.c b/xen/arch/riscv/vtimer.c index 32d142bcdfcd..afd8a53a7387 100644 --- a/xen/arch/riscv/vtimer.c +++ b/xen/arch/riscv/vtimer.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ =20 +#include #include #include =20 @@ -69,3 +70,17 @@ void vtimer_set_timer(struct vtimer *t, const uint64_t t= icks) migrate_timer(&t->timer, smp_processor_id()); set_timer(&t->timer, expires); } + +void vtimer_ctxt_switch_from(struct vcpu *p) +{ + ASSERT(!is_idle_vcpu(p)); + + /* Nothing to do at the moment as SSTC isn't supported now. */ +} + +void vtimer_ctxt_switch_to(struct vcpu *n) +{ + ASSERT(!is_idle_vcpu(n)); + + migrate_timer(&n->arch.vtimer.timer, n->processor); +} --=20 2.52.0