On Mon, 19 Feb 2024 at 01:20, Sergey Kambalin <[email protected]> wrote:
>
> Signed-off-by: Sergey Kambalin <[email protected]>
> ---
> hw/arm/bcm2838.c | 4 +
> hw/arm/bcm2838_peripherals.c | 14 +
> hw/arm/raspi4b.c | 1 -
> hw/misc/bcm2838_rng200.c | 405 +++++++++++++++++++++++++++
> hw/misc/meson.build | 1 +
> hw/misc/trace-events | 9 +
> include/hw/arm/bcm2838_peripherals.h | 2 +
> include/hw/misc/bcm2838_rng200.h | 43 +++
> 8 files changed, 478 insertions(+), 1 deletion(-)
> create mode 100644 hw/misc/bcm2838_rng200.c
> create mode 100644 include/hw/misc/bcm2838_rng200.h
Compiling with clang detects an off-by-one-error in this patch:
../../hw/misc/bcm2838_rng200.c:119:32: error: array index 9 is past
the end of the array (which contains 9 elements)
[-Werror,-Warray-bounds]
fifo_thld = FIELD_EX32(s->regs[R_RNG_FIFO_COUNT],
^ ~~~~~~~~~~~~~~~~
This is because N_BCM2838_RNG200_REGS is 9, but
R_RNG_FIFO_COUNT is 0x24 / 4 == 9.
N_BCM2838_RNG200_REGS should be 10. (The regs[] array has
an empty slot for the 0x14 offset.)
thanks
-- PMM