The cell configuration format restricts us to 64 SPIs this far. Make
sure that we properly test the range of 32 to 63 and avoid overflows due
to 32-bit word width. As Jailhouse provides no __aeabi_llsr, extract
high and low words first, then scan within 32 bits.
This addresses Coverity finding CID 21110.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
static inline bool spi_in_cell(struct cell *cell, unsigned int spi)
{
/* FIXME: Change the configuration to a bitmask range */
- u64 spi_mask;
+ u32 spi_mask;
- if (spi > 64)
+ if (spi >= 64)
return false;
+ else if (spi >= 32)
+ spi_mask = cell->arch.spis >> 32;
+ else
+ spi_mask = cell->arch.spis;
- spi_mask = cell->arch.spis;
-
- return spi_mask & (1 << spi);
+ return spi_mask & (1 << (spi & 31));
}
#endif /* __ASSEMBLY__ */