[PATCH] Work with hartid equal to or greater than SBI_HARTMASK_MAX_BITS.
Chao-ying Fu
icebergfu at gmail.com
Thu Jan 9 17:36:10 PST 2025
On Thu, Jan 9, 2025 at 4:57 PM Jessica Clarke <jrtc27 at jrtc27.com> wrote:
>
> On 9 Jan 2025, at 23:08, Chao-ying Fu <icebergfu at gmail.com> wrote:
> >
> > Some platforms use hartid that is equal to greater than SBI_HARTMASK_MAX_BITS,
> > so we should remove the check.
>
> The checks aren’t there for fun, they’re required. From sbi_hartmask.h:
>
> > /**
> > * Maximum number of bits in a hartmask
> > *
> > * The hartmask is indexed using physical HART id so this define
> > * also represents the maximum number of HART ids generic OpenSBI
> > * can handle.
> > */
This comment may not be accurate, as OpenSBI changed to use hart index
to access the array last year.
>
> OpenSBI does not support hart IDs outside this range today, so there is
> real work to do if that’s needed, not just deleting checks. Otherwise
> you’re going to end up with out-of-bounds memory accesses.
>
> I’m concerned that none of the patches you’ve sent just now seem to
> have been thought through properly. Whilst I’m sure you have the best
> intentions, I also note that this kind of patch is precisely the kind
> of patch one might make were one to want to insert vulnerabilities into
> core system components.
>
> Jess
We did run OpenSBI 1.6 and Linux 6.12 with hart ids (some of them >=
SBI_HARTMASK_MAX_BITS) with this patch on FPGA boards, RTL
simulations, and QEMU.
Thanks!
Regards,
Chao-ying
More information about the opensbi
mailing list