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

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



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?


> +
> +    return SBI_SUCCESS;
> +}
> +
> +VSBI_EXT(time, SBI_EXT_TIME, SBI_EXT_TIME, vsbi_time_ecall_handler);
With Nits fixed, it lgtm.
Thanks for your contribution!

Reviewed-by: Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>

-- 
Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>



 


Rackspace

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