[PATCH 2/2] hw/riscv/aia: Check for invalid IMSIC configs
Joel Stanley <[email protected]>
| Newsgroups | org.nongnu.qemu-devel,org.nongnu.qemu-riscv |
|---|---|
| Message-ID | <[email protected]> |
Assert that the IMSIC layout will be valid before creating the devices. aia_guests is a command line parameter but the machines that allows it to be set (currently only virt) should be passing the correct stride for a given number of guests. The assert helps catch bugs in future changes and shouldn't be triggerable by an invalid user config. Signed-off-by: Joel Stanley <[email protected]> --- hw/riscv/aia.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/riscv/aia.c b/hw/riscv/aia.c index c33a3b32bd45..c1a5982856c5 100644 --- a/hw/riscv/aia.c +++ b/hw/riscv/aia.c @@ -43,6 +43,10 @@ DeviceState *riscv_create_aia(bool msimode, int aia_guests, /* The RISC-V Advanced Interrupt Architecture, Chapter 1.2. Limits */ g_assert(num_sources <= 1023); + /* Prevent IMSIC MMIO regions from silently overlapping */ + g_assert(s_imsic_stride >= IMSIC_HART_SIZE(imsic_num_bits(1 + aia_guests))); + g_assert(m_imsic_stride >= IMSIC_HART_SIZE(0)); + if (msimode) { if (!kvm_enabled()) { /* Per-socket M-level IMSICs */ -- 2.47.3