Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0E64CF6C15 for ; Thu, 8 Jan 2026 10:29:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.1197544.1515044 (Exim 4.92) (envelope-from ) id 1vdnG6-0006k3-P8; Thu, 08 Jan 2026 10:28:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 1197544.1515044; Thu, 08 Jan 2026 10:28: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 1vdnG6-0006jw-MP; Thu, 08 Jan 2026 10:28:50 +0000 Received: by outflank-mailman (input) for mailman id 1197544; Thu, 08 Jan 2026 10:28: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 1vdnG5-0006ja-L4 for xen-devel@lists.xenproject.org; Thu, 08 Jan 2026 10:28:49 +0000 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [2a00:1450:4864:20::42a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id d1b55c1b-ec7c-11f0-b15e-2bf370ae4941; Thu, 08 Jan 2026 11:28:48 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-42fb5810d39so1654947f8f.2 for ; Thu, 08 Jan 2026 02:28:48 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0daa84sm15450699f8f.2.2026.01.08.02.28.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Jan 2026 02:28:47 -0800 (PST) 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: d1b55c1b-ec7c-11f0-b15e-2bf370ae4941 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1767868128; x=1768472928; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=zNup6adGZkuCQuKzXd+xhAU69SGktIrsd4oRrCyU8M8=; b=Zv9OglEcC47QR8ZiixddAmg/TUMg6EcAKM3xpmlWcbErqb/1/WQGDQEy4TOVb+S5P1 Mx+t8H0PzGGeRx/5RiVYp7CnPyw60FwJUuwaBvV7ik6NyvE2xE5pfUfMt+MNUa9ZCTzI QCtud1MT90KjtKhQp6ng3SHtOXsUNdRRpIaMODFCmBZNJ5Pek2BRmNaL1nlHQ0YALh65 tIdYYIi4JJJxNACPYM80PbZFdSzaI+FqUHmaOzHZJIbtedLxnCxVyh1t3a76t7W6L1qK KZqO9j/XPJZaPvtQLQOBtZ33FqOHhx+zCwGapoQLaJHRpX51I+c2hUQD60YQpUiCWBkg YSGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767868128; x=1768472928; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=zNup6adGZkuCQuKzXd+xhAU69SGktIrsd4oRrCyU8M8=; b=i5nDARy5MDdU9NfXkDQmVS0sv2Jy5j+c6FsVCYdU5f1SlJ138FUx2UAbJM6kmueMS7 xW5J8FS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AGHT+IH241JPlrZpjbda0iiIDWOKjPYiM3PYgLFjJAemZquoBsXJDu5G/ikuzNdZyJGl488iPkF3mw== X-Received: by 2002:a05:6000:40df:b0:430:f742:fbc7 with SMTP id ffacd0b85a97d-432c36328c5mr7024918f8f.14.1767868128142; Thu, 08 Jan 2026 02:28:48 -0800 (PST) Message-ID: Date: Thu, 8 Jan 2026 11:28:46 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 08/15] xen/riscv: introduce vtimer_set_timer() and vtimer_expired() To: Oleksii Kurochko Cc: Alistair Francis , Bob Eshleman , Connor Davis , Andrew Cooper , Anthony PERARD , Michal Orzel , Julien Grall , =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= , Stefano Stabellini , xen-devel@lists.xenproject.org References: <8cd3efa488b3da2a6751c92d20bbfeb87b3ba39a.1766595589.git.oleksii.kurochko@gmail.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQy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> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 24.12.2025 18:03, Oleksii Kurochko wrote: > --- a/xen/arch/riscv/include/asm/vtimer.h > +++ b/xen/arch/riscv/include/asm/vtimer.h > @@ -22,4 +22,6 @@ void vcpu_timer_destroy(struct vcpu *v); > > int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config); > > +void vtimer_set_timer(struct vtimer *t, const uint64_t ticks); > + > #endif /* ASM__RISCV__VTIMER_H */ > diff --git a/xen/arch/riscv/vtimer.c b/xen/arch/riscv/vtimer.c > index 5ba533690bc2..99a0c5986f1d 100644 > --- a/xen/arch/riscv/vtimer.c > +++ b/xen/arch/riscv/vtimer.c > @@ -1,6 +1,8 @@ > /* SPDX-License-Identifier: GPL-2.0-only */ > > +#include Is this really needed, when ... > #include ... this is already there? > +#include Don't you mean xen/timer.h here? > @@ -15,7 +17,9 @@ int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config) > > static void vtimer_expired(void *data) > { > - panic("%s: TBD\n", __func__); > + struct vtimer *t = data; Pointer-to-const please. > @@ -37,3 +41,27 @@ void vcpu_timer_destroy(struct vcpu *v) > > kill_timer(&v->arch.vtimer.timer); > } > + > +void vtimer_set_timer(struct vtimer *t, const uint64_t ticks) > +{ > + s_time_t expires = ticks_to_ns(ticks - boot_clock_cycles); boot_clock_cycles is known to just Xen. If the guest provided input is an absolute value, how would that work across migration? Doesn't there need to be a guest-specific bias instead? > + vcpu_unset_interrupt(t->v, IRQ_VS_TIMER); > + > + /* > + * According to the RISC-V sbi spec: > + * If the supervisor wishes to clear the timer interrupt without > + * scheduling the next timer event, it can either request a timer > + * interrupt infinitely far into the future (i.e., (uint64_t)-1), > + * or it can instead mask the timer interrupt by clearing sie.STIE CSR > + * bit. > + */ And SBI is the only way to set the expiry value? No CSR access? (Question also concerns the unconditional vcpu_unset_interrupt() above.) > + if ( ticks == ((uint64_t)~0ULL) ) Nit: With the cast you won't need the ULL suffix. > + { > + stop_timer(&t->timer); > + > + return; > + } > + > + set_timer(&t->timer, expires); See the handling of VCPUOP_set_singleshot_timer for what you may want to do if the expiry asked for is (perhaps just very slightly) into the past. There you'll also find a use of migrate_timer(), which you will want to at least consider using here as well. Jan