From nobody Mon Jan 26 09:20:17 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; 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=1769100504; cv=none; d=zohomail.com; s=zohoarc; b=GSkxUZT7fxp1F+ua5A9zn/tjx08ZFPtn4okGB2TMND3ktKiWqKi6gXLhFpXAFE2SCJwv188ispg7rdTSytNqWxFJbt3qmpbd45Rd2PO78gx8/+WhmQSkQEbxzTUhOrY8iuYURkmZBg/S8XpwCJLo6nxgmPxPkTYudct4XqBywGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769100504; 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=bossoBnEH4JNpm3EBQfuiRI4dS6yLi1VOSzTCCzzE2k=; b=n/IWR7gLaWC9sLb150Irc/uFQeR92ioco5iKSpZA6eXurrfmWco9kXoJYtKCD+SocuD+f7i6mXFdORiPS9fn/HhPCOoza1bQiuoXXvqQPdyJCLwZ+R83Oj38ARMMt7ok6Fi6kz09XTPYMrB0TqZ9+1tyXoAVnCha6NaCzMUqDwg= 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 1769100504042142.73631797256542; Thu, 22 Jan 2026 08:48:24 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1211360.1522990 (Exim 4.92) (envelope-from ) id 1vixqh-0001u9-A0; Thu, 22 Jan 2026 16:47:59 +0000 Received: by outflank-mailman (output) from mailman id 1211360.1522990; Thu, 22 Jan 2026 16:47:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vixqg-0001t0-R9; Thu, 22 Jan 2026 16:47:58 +0000 Received: by outflank-mailman (input) for mailman id 1211360; Thu, 22 Jan 2026 16:47:57 +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 1vixqf-0007Ij-3e for xen-devel@lists.xenproject.org; Thu, 22 Jan 2026 16:47:57 +0000 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [2a00:1450:4864:20::62d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 17c12453-f7b2-11f0-9ccf-f158ae23cfc8; Thu, 22 Jan 2026 17:47:52 +0100 (CET) Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-b7cf4a975d2so162748366b.2 for ; Thu, 22 Jan 2026 08:47:52 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b879513e951sm1686014966b.7.2026.01.22.08.47.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 08:47:51 -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: 17c12453-f7b2-11f0-9ccf-f158ae23cfc8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769100472; x=1769705272; 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=bossoBnEH4JNpm3EBQfuiRI4dS6yLi1VOSzTCCzzE2k=; b=ajLOboWcatoihKUlCyAOFvjWaybErVFl6cMz/RNu6GmVGCuXlmZ0cK9RQCPgEWGNmc HYBLyP+t9mODCJ0HnzZIkS6R3UkJvuTqCHyrLSJCXdvzcLb+1X5fXLXNnps/AxgEbr0b 81y+lNVE/FnF+YQzlO5YWXpHmY9p+71yTQkMRTx3oq9QTzhbdm/ThUJEV8kQ2/De8eke GEUx5SpguF0lWb54lsi+XxRa1vrztdOCUOvKbtI5qQ0nEMnn9pOJgUpcT5oDiK0N0ks0 PgH3+rcCxBYa4PyMKI1DhWglPNmqIVq5VnHRQtaGnPt+AaULMxRUH0C0puGV7PfBV88V AQTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769100472; x=1769705272; 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=bossoBnEH4JNpm3EBQfuiRI4dS6yLi1VOSzTCCzzE2k=; b=XU3UDJiA/higxnfdlrGQsQOX4bBcgVh9q6NfF7W9J/Kfo8dZC0xhcffiUB/jGT+CP2 SZuINAxx+2k2FIWMnnZiwoRa/bismN+EzBNOufRLWTCE1arIEA/vyIciZEvtvQ3Rp7EB PJxesCQx/Rfsve5dfcy4MZUtnlo84dEyzQC266ODd3aVPQw99gFiGNCE1UT2O7NJqACy Li3Wc3qz2qdT8QXWyWSpCI2VVeZVeB71iZJ+W6YuncDmswLBd0/j9cYThPuxQP66I/+X 9y4QIPEf/2kQ3SACFCX3L1cLadGiG/483a3m+PMWDmdw5FbMCPy/Pe8j+E5pMmGT4wx3 sb0g== X-Gm-Message-State: AOJu0YwE3338lL1xbgE2FeiW+C42UQwUNK4seGiX9cPowfA0oo/OS8fv iQQJLGV79hXt2q+HzV3+usKBbN+Qba94wCsuEsjhFnThXzAMmW7dEtxaBFl6fA== X-Gm-Gg: AZuq6aJ/t3xAAFRzUOVvfzTRSBixsKeVxahr/AwYCvtO28ccYYrfYkmqB19M1rUnFYS dPFarajGt4EHZeOvlkCr1X3LVSpbpDvairl9AY6QIEuK1weNZqhCrz+OH6IsZX+Gl+Jpt74BdkD ybXvdbmbWEmDCt3VePGoYGzVRFurRM7dv6MF6VY+XFrsF93ynOOZ0um0SSFvFSJrILZUlT+4oD2 5H/O3sCL3lMZIVQVAHTZrMFl/Bi5WHVayVENmcZfBCUqvQxfFJM/9Czy4HJGOe13Qc2RyPDW3fY 6ctr/3AflOvrBr0p5f1jfoTskdBRtb1iouhQUOIs6r42eWCcKevMFxow7oxhkBSJFFhqYvJt0lb 7SFlxBS83OPi/+YOxmkMAS7dwprciKszrOg7ozdx8CB9y05vPPljjXVTx+rWlCo+6fPxuPNfXk2 nuEvVZ3FoQT9pW8vCnZ213h3PKyCgKstXigHgeRiNnh/iBEV/fTjzK4A== X-Received: by 2002:a17:906:f5a5:b0:b80:149b:badd with SMTP id a640c23a62f3a-b8800342b42mr751480066b.37.1769100471595; Thu, 22 Jan 2026 08:47:51 -0800 (PST) From: Oleksii Kurochko To: xen-devel@lists.xenproject.org Cc: 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 , Romain Caritey Subject: [PATCH v2 10/16] xen/riscv: add vtimer context switch helpers Date: Thu, 22 Jan 2026 17:47:25 +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: 1769100504432158500 Content-Type: text/plain; charset="utf-8" Introduce vtimer_ctx_switch_from() and vtimer_ctx_switch_to() to handle virtual timer state across vCPU context switches. At present, vtimer_ctx_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_ctx_switch_t= o() migrates the timer to the target pCPU when a vCPU is scheduled in. Signed-off-by: Oleksii Kurochko --- 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..52b7fb7b1cbb 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_ctx_switch_from(struct vcpu *p); +void vtimer_ctx_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 b6599fa383b8..6dfd6d836260 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 @@ -71,3 +72,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_ctx_switch_from(struct vcpu *p) +{ + ASSERT(!is_idle_vcpu(p)); + + /* Nothing to do at the moment as SSTC isn't supported now. */ +} + +void vtimer_ctx_switch_to(struct vcpu *n) +{ + ASSERT(!is_idle_vcpu(n)); + + migrate_timer(&n->arch.vtimer.timer, n->processor); +} --=20 2.52.0