From: Oleksii Kurochko <oleksii.kurochko@gmail.com>
To: Hiago De Franco <hfranco@baylibre.com>, xen-devel@lists.xenproject.org
Cc: "Alistair Francis" <alistair.francis@wdc.com>,
"Baptiste Le Duc" <baptiste.le-duc@vates.tech>,
"Connor Davis" <connojdavis@gmail.com>,
"Ronaldo Nunez" <rnunez@baylibre.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Anthony PERARD" <anthony.perard@vates.tech>,
"Michal Orzel" <michal.orzel@amd.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Julien Grall" <julien@xen.org>,
"Roger Pau Monné" <roger@xenproject.org>,
"Stefano Stabellini" <sstabellini@kernel.org>
Subject: Re: [PATCH] xen/riscv: vsbi: add SBI TIME extension
Date: Thu, 19 Nov 2026 14:52:46 +0100 [thread overview]
Message-ID: <7deceb1b-bf57-4e0b-9181-da1d638fda70@gmail.com> (raw)
In-Reply-To: <20261119-riscv-vsbi-time-ext-v1-1-1d5813a883e6@baylibre.com>
On 11/19/26 12:59 PM, Hiago De Franco wrote:
> Xen reports SBI v0.2 but does not implement the TIME extension, so the
> guest probe fails and Linux falls back to the legacy SBI v0.1 SET_TIMER
> call.
Nit: the probe itself doesn't fail, it reports the extension as
unavailable. Maybe something like:
"Xen reports SBI v0.2 but does not implement the TIME extension, so
SBI_EXT_BASE_PROBE_EXT reports TIME as unavailable and Linux falls
back to the legacy SBI v0.1 SET_TIMER call."
>
> The fallback is deprecated and only available when the guest is built
> with CONFIG_RISCV_SBI_V01, so a guest built without it never arms the
> timer.
>
> Implement the TIME extension and handle SET_TIMER() by programming the
> vCPU virtual timer through vtimer_set_timer(). With the extension
> registered, SBI_EXT_BASE_PROBE_EXT reports TIME as available and Linux
> selects the v0.2 path.
>
> Assisted-by: DeepSeek:v4.1-flash
> Signed-off-by: Hiago De Franco <hfranco@baylibre.com>
> ---
> Hello,
>
> This is a prerequisite for removing the legacy v0.1 from the guest
> configuration.
I don't think removing legacy v0.1 is the best idea, as there could
still be guests that only support v0.1 or, for some reason, prefer to
use it. Therefore, both functionalities should remain available and be
configurable in one way or another.
>
> Tested by booting dom0less Linux guest, which prints "SBI TIME
> extension detected". To test this, I used the fork from Oleksii [1]
> (branch riscv-next-upstreaming) to boot linux guest with dom0less.
>
> Since this is an isolated patch and applies to the xen master branch, I
Please note, though, that development happens on the staging branch;
master lags behind it, so patches should be based on staging. This one
applies to staging as is.
> decided to send the patch. Please let me know if this is not correct.
Generally speaking, I can't say whether this is right or wrong. IMO, we
should have a policy that we all agree on. If I'm not mistaken, Bruno
invited you to our weekly Xen RISC-V meetings, and we have one today. It
would be great if you could join us so we could discuss these things.
At this point, the patch does look independent and ready to go. However,
another option would be to take the patch to the riscv-next-upstreaming
branch, apply it there, and verify that it works. That said, this might
not be the best general approach.
The patch is currently targeting upstream/staging, which cannot boot any
guests. Strictly speaking, it is therefore difficult to verify how the
patch works without fetching [1], switching to the mentioned branch, and
applying the patch there. In this sense, the fact that staging cannot
currently boot a guest creates a kind of "logical dependency".
So, technically, we could proceed with this patch as it is. However, if
you could join today's meeting, it would be good to discuss how we
should handle similar situations with future patches and agree on a
general upstreaming policy.
>
> [1] https://gitlab.com/xen-project/people/olkur/xen
> ---
> xen/arch/riscv/vsbi/Makefile | 1 +
> xen/arch/riscv/vsbi/time-extension.c | 25 +++++++++++++++++++++++++
> 2 files changed, 26 insertions(+)
>
> diff --git a/xen/arch/riscv/vsbi/Makefile b/xen/arch/riscv/vsbi/Makefile
> index 8ce470f787c5b04f985dfb76d076025b49ddef19..31ff8e86d1a20500b9321c826c1e48c0f84cde84 100644
> --- a/xen/arch/riscv/vsbi/Makefile
> +++ b/xen/arch/riscv/vsbi/Makefile
> @@ -1,3 +1,4 @@
> obj-y += base-extension.o
> obj-y += core.o
> obj-y += legacy-extension.o
> +obj-y += time-extension.o
> diff --git a/xen/arch/riscv/vsbi/time-extension.c b/xen/arch/riscv/vsbi/time-extension.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..6bf23f5708d45d2f671bb15f423f209fb250525a
> --- /dev/null
> +++ b/xen/arch/riscv/vsbi/time-extension.c
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#include <xen/lib.h>
> +#include <xen/sched.h>
> +
> +#include <asm/current.h>
> +#include <asm/processor.h>
> +#include <asm/sbi.h>
> +#include <asm/vsbi.h>
> +#include <asm/vtimer.h>
> +
> +static int vsbi_time_ecall_handler(unsigned long eid, unsigned long fid,
> + struct cpu_user_regs *regs)
> +{
> + ASSERT(eid == SBI_EXT_TIME);
> +
> + if ( fid != SBI_EXT_TIME_SET_TIMER )
> + return SBI_ERR_NOT_SUPPORTED;
> +
> + vtimer_set_timer(¤t->arch.vtimer, regs->a0);
> +
> + return SBI_SUCCESS;
> +}
> +
> +VSBI_EXT(time, SBI_EXT_TIME, SBI_EXT_TIME, vsbi_time_ecall_handler);
Nit: VSBI_EXT() already expands to a definition ending in "};", so the
trailing ';' produces an empty declaration at file scope.
base-extension.c doesn't have it; I'd drop it here too.
With Nits fixed:
Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Thanks.
~ Oleksii
next prev parent reply other threads:[~2026-11-19 13:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 11:59 [PATCH] xen/riscv: vsbi: add SBI TIME extension Hiago De Franco
2026-11-19 13:52 ` Oleksii Kurochko [this message]
[not found] ` <bkmmgcqrbq47i7gxn3nt64xrypt2l2hrhlbip7rv7cfo7p6dqs@lssohgkujou5>
2026-11-20 8:42 ` Oleksii Kurochko
2026-11-19 16:32 ` Baptiste Le Duc
2026-11-19 21:38 ` Hiago De Franco
2026-11-20 8:31 ` Oleksii Kurochko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7deceb1b-bf57-4e0b-9181-da1d638fda70@gmail.com \
--to=oleksii.kurochko@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=andrew.cooper3@citrix.com \
--cc=anthony.perard@vates.tech \
--cc=baptiste.le-duc@vates.tech \
--cc=connojdavis@gmail.com \
--cc=hfranco@baylibre.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=rnunez@baylibre.com \
--cc=roger@xenproject.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.