[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/riscv: vsbi: add SBI TIME extension





On 11/19/26 5:32 PM, Baptiste Le Duc wrote:
The commit's name is kind of weird with this two `:` next to each other.
Here is suggestion based on previous patches (xen/riscv: implement SBI legacy 
SET_TIMER support for guests (647542cdf1)...)
     ```
     xen/riscv: implement SBI TIME extension for guests
     ```

[ ... 8 lines skipped ... ]
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
Uncommon to see DeepSeek model used :)
[ ... 46 lines skipped ... ]
+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(&current->arch.vtimer, regs->a0);

Nit: this assumes VSXLEN == 64, i.e. that stime_value fits in a0. The
SBI spec (binary-encoding.adoc) says:

     Parameters that are 2×XLEN bits wide are passed in a pair of
     argument registers, with the low-order XLEN bits in the
     lower-numbered register and the high-order XLEN bits in the
     higher-numbered register.

and sbi_set_timer() takes a uint64_t stime_value, so an RV32 guest
passes it in a0 (low) and a1 (high).

That's fine today, as both Xen and its guests are RV64 only, and the
legacy SET_TIMER path makes the same assumption. But nothing in the
tree enforces it for guests, so it might be worth stating it somewhere.

Oleksii, any opinion on that point?

I thought about that too, but decided not to mention it since, as you
noted, only RV64 guests are possible at the moment. Another reason is
that it isn't specific to this handler: every vSBI handler takes guest
arguments as full-width registers, so other SBI extensions have the
same issue. To me, this should be addressed together with RV32 guest
support.

If we want the assumption stated explicitly until then, I think it
should be done once, in a separate patch, e.g. with a comment in
asm/vsbi.h or an ASSERT(is_64bit_domain(current->domain)) in
vsbi_handle_ecall(), rather than per extension.

~ Oleksii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.