|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH] xen/riscv: vsbi: add SBI TIME extension
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. 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@xxxxxxxxxxxx> --- Hello, This is a prerequisite for removing the legacy v0.1 from the guest configuration. 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 decided to send the patch. Please let me know if this is not correct. [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); --- base-commit: ab77da87e9b38022341eb6a54593e681485d203a change-id: 20261117-riscv-vsbi-time-ext-20ad33685b05 Best regards, -- Hiago
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |