[PATCH v2 04/11] RISC-V: KVM: Modify SBI extension handler to return SBI error code
Andrew Jones
ajones at ventanamicro.com
Thu Jan 12 23:42:04 PST 2023
On Thu, Jan 12, 2023 at 10:47:13AM -0800, Atish Kumar Patra wrote:
> On Thu, Jan 12, 2023 at 3:04 AM Andrew Jones <ajones at ventanamicro.com> wrote:
> >
> > On Thu, Dec 15, 2022 at 09:00:39AM -0800, Atish Patra wrote:
...
> > > + * and forwards the error to the userspace.
> > > + */
> > > + if (ret < 0) {
> > > + next_sepc = false;
> > > + goto ecall_done;
> > > + }
> >
> > Shouldn't this ret < 0 check go above the "Handle special error cases..."
> > block?
> >
>
> Why ? I thought if an extension handler has both utrap updated and
> returns an error,
> user space redirection should take precedence. Let me know if it is wrong.
My thinking was that utrap cannot be trusted if the handler returned an
error. The handler may not even have had a chance to set it before hitting
the error condition. IOW, we should check 'ret' right after the handler
call. If it's < 0, then from the caller's perspective the handler didn't
execute due to a KVM failure and it should be reported to userspace.
Thanks,
drew
More information about the linux-riscv
mailing list