[PATCH] lib: sbi: Fix shift bug in sbi_system_reset

Anup Patel apatel at ventanamicro.com
Tue Dec 26 07:51:49 PST 2023


On Mon, Dec 25, 2023 at 3:19 PM Andreas Schwab <schwab at linux-m68k.org> wrote:
>
> On Dez 25 2023, Anup Patel wrote:
>
> > If "cur_hartid < hbase + BITS_PER_LONG" then
> > "1UL << (cur_hartid - hbase) == 0x0"
>
> If cur_hartid - hbase < BITS_PER_LONG, then 1UL << (cur_hartid - hbase)
> will not be 0.  If cur_hartid - hbase >= BITS_PER_LONG, then 1UL <<
> (cur_hartid - hbase) will overflow and be undefined.

I meant "cur_hartid >= hbase + BITS_PER_LONG" which is
the overflow case.

Since the overflow behavior is undefined, we have the
explicit check added by this patch.

Regards,
Anup

>
> --
> Andreas Schwab, schwab at linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list