[PATCH] include: sbi_platform: Increase default stack size

Aurelien Jarno aurelien at aurel32.net
Thu Jun 4 14:43:09 PDT 2026


Hi Anirudh,

On 2026-06-04 15:09, Anirudh Srinivasan wrote:
> Hi Aurelien,
> 
> On Tue, Jun 2, 2026 at 2:12 PM Aurelien Jarno <aurelien at aurel32.net> wrote:
> >
> > On 2026-05-24 13:53, Vivian Wang wrote:
> > > sbi_misaligned_v_ld_emulator() has a local buffer (namely mask) which is
> > > 8192 bytes in size, so the default stack size is not enough. Double it
> > > to 16384.
> > >
> > > This stack overflow can be observed by any S-mode software and leads to
> > > M-mode crash or unexpected behavior, as long as the S-mode software does
> > > not enable FWFT misaligned delegation [1]. This may be considered a
> > > temporary fix until further fixes are made to misaligned handling [2].
> > >
> > > Link: https://lore.kernel.org/linux-riscv/nrvt74qnojaubiwjo37ums4lnclu466hovwrhmtbag6f5uhrql@q6msoe2oto4b # [1]
> > > Link: https://lore.kernel.org/opensbi/20260210094044.72591-1-ganboing@gmail.com # [2]
> > > Signed-off-by: Vivian Wang <wangruikang at iscas.ac.cn>
> > > ---
> > >  include/sbi/sbi_platform.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Tested-by: Aurelien Jarno <aurelien at aurel32.net>
> >
> > I can confirm that this fix is required to boot a 7.1-rc6 kernel on a
> > CPU with vector instructions (in my case SpacemiT K1).
> 
> Are you sure that this is needed for the K1? It seemed like this was
> only an issue on boards with large vlen (512 like the x280)?

Yes this is an issue. The stack allocation doesn't depend on the actual 
vector size, but on VLEN_MAX which is 65536. The alternative to increase 
the stack size is to reduce this value.

> Do you
> mind sharing any kernel boot logs with/without this patch?

Yep, please find them attached. Note that I have attached the useful 
failure, sometimes the kernel boots correctly and most of the time it 
just hangs.

> I was able to boot 7.1.0-rc6-next-20260603 defconfig without issue on
> a MilkV Jupiter. Only caveat is that my board is  running an old
> vendor opensbi (version k1-bl-v2.2.4 that may be based on upstream
> v1.3) that the board shipped with, and not sure if that's
> helping/hurting in any manner.

I am using the current OpenSBI HEAD. Support for misaligned vector 
load/store was added in version 1.6 in commit c2acc5e5b0d8 ("lib: 
sbi_misaligned_ldst: Add handling of vector load/store"), so it's not 
surprising that your version does not have the issue.

Regards
Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien at aurel32.net                     http://aurel32.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opensbi-vector-failure.txt.gz
Type: application/gzip
Size: 3093 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/opensbi/attachments/20260604/f1f50f31/attachment-0002.gz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: opensbi-vector-patched.txt.gz
Type: application/gzip
Size: 15279 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/opensbi/attachments/20260604/f1f50f31/attachment-0003.gz>


More information about the opensbi mailing list