Re: [PATCH v3 3/3] lib: sbi: ISA extension emulation (Zvbb).
Vivian Wang <[email protected]> Fri, 26 Jun 2026 11:17:25 +0800
| Newsgroups | org.infradead.lists.opensbi |
|---|---|
| Message-ID | <[email protected]> |
Hi Benedikt, We discovered another subtle problem while testing Zvbb emulation: On 12/27/25 20:18, Benedikt Freisen wrote: > Add trap-based emulation code for the ISA extension Zvbb based on RVV 1.0 and Zbb. > > Signed-off-by: Benedikt Freisen <[email protected]> > --- > > [...] > > diff --git a/lib/sbi/sbi_insn_emu_v.c b/lib/sbi/sbi_insn_emu_v.c > new file mode 100644 > index 00000000..483b0ee6 > --- /dev/null > +++ b/lib/sbi/sbi_insn_emu_v.c > > [...] > > + > +int sbi_insn_emu_op_v(ulong insn, struct sbi_trap_regs *regs) > +{ > > > [...] > > + > + regs->mepc += 4; > + > + return 0; > +} > + sbi_insn_emu_op_v does not set xstatus.VS to dirty, which has a chance to break context switching and cause vector register state to be broken. Something like SET_VS_DIRTY from [1] is needed before returning: #define SET_VS_DIRTY(regs) do { \ if (sbi_regs_from_virt(regs)) \ csr_set(CSR_VSSTATUS, MSTATUS_VS); \ regs->mstatus |= MSTATUS_VS; \ } while(0) It seems unlikely that upstream OpenSBI would accept these emulation patches, but I'm reporting this for the sake of anyone potentially running into this. Thanks, Vivian "dramforever" Wang [1]: https://lore.kernel.org/opensbi/[email protected]/ -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi