From nobody Mon Apr 13 03:28:25 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=1772814858; cv=none; d=zohomail.com; s=zohoarc; b=Wzeh0ySUEU+lfDCRxlAfDOY+Afkfq6Jrpa9t68FykqNwka56rjfKvctIH/hcRO34/BqqBN1R5AM212jjkyOlRX858W/7OBdo+3TeGRrN7enl5XB+eXG5WKQ4BCt4qXPjF/D/0+esCsXOMEJAxHEYeFTrfnUibq1UzNa9ppH6P4o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772814858; 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=wshUHaSMY4kHHsx5qEs6V10my02G5AGEo5sXu7Wg0WM=; b=fizWFmewhoenugxul6kWxmKshZswzSHaV4Gen2DwKcfqNbU+NN6pjr/FvwO8ER9bfAUFFgogw0mUIt2Rwg5tJLAbpzWwgwceQ2Z31YOC9/DXMDW2DK7kn7EhRpSj3GSx/F1KnBGSBlmIslVC6H5fw0f0JirgVf170gY0YI8R5sA= 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 177281485865913.313938463825593; Fri, 6 Mar 2026 08:34:18 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.1247978.1546366 (Exim 4.92) (envelope-from ) id 1vyY7a-0004Ll-N6; Fri, 06 Mar 2026 16:33:50 +0000 Received: by outflank-mailman (output) from mailman id 1247978.1546366; Fri, 06 Mar 2026 16:33:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vyY7a-0004Jq-H5; Fri, 06 Mar 2026 16:33:50 +0000 Received: by outflank-mailman (input) for mailman id 1247978; Fri, 06 Mar 2026 16:33:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vyY7Y-00030j-Vv for xen-devel@lists.xenproject.org; Fri, 06 Mar 2026 16:33:48 +0000 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [2a00:1450:4864:20::32a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 40449f26-197a-11f1-b164-2bf370ae4941; Fri, 06 Mar 2026 17:33:48 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-480706554beso102815215e9.1 for ; Fri, 06 Mar 2026 08:33:48 -0800 (PST) Received: from fedora (user-109-243-67-101.play-internet.pl. [109.243.67.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae57c05sm4406550f8f.39.2026.03.06.08.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 08:33:46 -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: 40449f26-197a-11f1-b164-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772814827; x=1773419627; 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=wshUHaSMY4kHHsx5qEs6V10my02G5AGEo5sXu7Wg0WM=; b=mt3C7V7JKPnDGNQsg1+AoxzHJc/wwFFmfD4nJmLj/VOVxUV2p67UieTLCXfEvbBFft MNoIl5xfno7X74Bf9k5E+ICjIVn/1T5Hgntg4lT8IdlB7gt1HqW0zm5cs4OMwbiAUPpZ oOvqqTffeBeraYrqg+PKHVe/70+g3hIcPGrL26LxdH92Ucw2J9TzPJYRlaH+SftNjBOD BV+x3jpspQ9ClJslLti0l9inZLjf5fk7eaWOqAg3RQJRz3chNbIa7WcrGVDRJqW/B1Wd kknaeHoi6Fn3xTJ9M37kvOH/GWCZwqNdo5QW2USpZVSz5q6fu4hcuCXN9gUR0VGnUUtZ aipQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772814827; x=1773419627; 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=wshUHaSMY4kHHsx5qEs6V10my02G5AGEo5sXu7Wg0WM=; b=tAhX6FIGYWo/GG8u/R3tfrS2A6tFlyZZu/h+Q0iZ9CVO916et3wsk31EM3sDa/nC8H sEcNPEq5tnrl46p+ONTzPxxJ+dHnbCMH3kHyjhIqojWhbFZ0Wd+bdR0PqS1c8D8J4Mdi 11h83Di8dqnQjB3W6TAFK/wbBy8qwH1rp4klSA1vWlK8T/NNr9NzOVUoJHJ8qPbqMfTg zPtbaAkbIGc6cWWmkdYTKkn8Hj9umE7bVnWrbLhrKWPP5qribxE2Z6Jv1X7BIgf9JXCB V5mC0gFhP+6ri4htiBM6xciTV6xETFKR2eQTTlrtmnq12W0x9nOMfHfx5y9C1vmTsL/v d0Ow== X-Gm-Message-State: AOJu0YyGkp8+sX/B+qKp2A0Esh9s3zQgJfIj3TlSJAKM9kXLGa+9j/TW jSNo3ydku7xo5o5+Q3sW3WMwZU31CPvIHnn+BwQEiY3nbRGGok2T/viAcJprAA== X-Gm-Gg: ATEYQzwr8GQzgIIkW8qb86HKUPrnntNpOCEco5xF9Y45YHguOi8tpK8ln7yKIaLHE6h i/YJJOXZlZ1KJqN3bbu6kE1V4rPLI8tSbvFMvhU6ShZs9ikzuYFIS5sVh/XPDkyxAmOk20h/KZU fG0ImcNMx7BSLB6Ze7JE4vk6nbtyJIaeWh0CPsEXq2qb9pDsyLsvCvwdH+tqjmN23pPFfX/30aO 9nzYSgyPEJIpI6hraBZACXmFxhXYBaKK+UcUBmQabSW4oG0AcGghmb4dLS80h8UhxC3vqphruOz rLSNAR9SFIvyA+Gu6qalrVNFcPCUb11yoL7OzrANg4WfXUavl/Q6UxQ79hl+SMUWrv62c2tzdbU CD/Xsbnj+25jH1dUIJ2KEkmDSkC1sjeNjY+gzHg9J+Kef8rJ7Nw8TI3yTTvgOX5DxSGcjnkVHD5 HhXHsXCLtOrQi5bHYMgpnRu7vNKdiMM4amO44bP160l4jnB0nmX5ImYlLAa+8StCq5++aO+CrcZ Pvq X-Received: by 2002:a05:600c:620c:b0:47d:3ffa:5f03 with SMTP id 5b1f17b1804b1-4852695b633mr46566025e9.21.1772814827041; Fri, 06 Mar 2026 08:33:47 -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 v7 07/14] xen/riscv: add vtimer context switch helpers Date: Fri, 6 Mar 2026 17:33:24 +0100 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1772814858970158500 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-v7: - 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 111863610a92..b4d48d1a1732 100644 --- a/xen/arch/riscv/include/asm/vtimer.h +++ b/xen/arch/riscv/include/asm/vtimer.h @@ -14,4 +14,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.53.0