On Thu, 29 Jan 2026 at 11:21, Nicholas Piggin <[email protected]> wrote: > > On Wed, Jan 28, 2026 at 2:35 PM Nutty.Liu <[email protected]> wrote: > > > > > > On 1/14/2026 9:28 AM, Joel Stanley wrote: > > > Instead of hard coding the number of IRQ sources used by the APLIC pass > > > it in as a parameter. This allows other machines to configure this as > > > required. > > > > > > The maximum number of sources is 1023. > > > > > > Signed-off-by: Joel Stanley <[email protected]> > > > --- > > > v2: Add assert for the number of irq sources > > > --- > > > hw/riscv/aia.h | 1 + > > > include/hw/riscv/virt.h | 1 + > > > hw/riscv/aia.c | 8 ++++++-- > > > hw/riscv/virt-acpi-build.c | 25 ++++++++++++++++--------- > > > hw/riscv/virt.c | 2 ++ > > > 5 files changed, 26 insertions(+), 11 deletions(-) > > > > > > diff --git a/hw/riscv/aia.h b/hw/riscv/aia.h > > > index 50c48ea4d79c..a63a1ab293fe 100644 > > > --- a/hw/riscv/aia.h > > > +++ b/hw/riscv/aia.h > > > @@ -48,6 +48,7 @@ > > > uint32_t imsic_num_bits(uint32_t count); > > > > > > DeviceState *riscv_create_aia(bool msimode, int aia_guests, > > > + uint16_t num_sources, > > > const MemMapEntry *aplic_m, > > > const MemMapEntry *aplic_s, > > > const MemMapEntry *imsic_m, > > > diff --git a/include/hw/riscv/virt.h b/include/hw/riscv/virt.h > > > index 25ec5c665780..fa7fe8d4f648 100644 > > > --- a/include/hw/riscv/virt.h > > > +++ b/include/hw/riscv/virt.h > > > @@ -64,6 +64,7 @@ struct RISCVVirtState { > > > struct GPEXHost *gpex_host; > > > OnOffAuto iommu_sys; > > > uint16_t pci_iommu_bdf; > > > + uint16_t num_sources; > > > }; > > > > > > enum { > > > diff --git a/hw/riscv/aia.c b/hw/riscv/aia.c > > > index 0a89d7b49b7b..a9130896fba2 100644 > > > --- a/hw/riscv/aia.c > > > +++ b/hw/riscv/aia.c > > > @@ -25,6 +25,7 @@ uint32_t imsic_num_bits(uint32_t count) > > > } > > > > > > DeviceState *riscv_create_aia(bool msimode, int aia_guests, > > > + uint16_t num_sources, > > > const MemMapEntry *aplic_m, > > > const MemMapEntry *aplic_s, > > > const MemMapEntry *imsic_m, > > > @@ -37,6 +38,9 @@ DeviceState *riscv_create_aia(bool msimode, int > > > aia_guests, > > > DeviceState *aplic_s_dev = NULL; > > > DeviceState *aplic_m_dev = NULL; > > > > > > + /* The RISC-V Advanced Interrupt Architecture, Chapter 1.2. Limits */ > > > + g_assert(num_sources <= 1023); > > > + > > How about the below check ? > > > > g_assert(num_sources <= VIRT_IRQCHIP_NUM_SOURCES); > > > > And modify VIRT_IRQCHIP_NUM_SOURCES in "aia.h" as below ? > > > > #define VIRT_IRQCHIP_NUM_SOURCES 1023
I didn't bump this as it changes the ACPI blob for the virt machine. This was noticed by a test. A follow up could change the virt machine to support the max number of sources if someone was interested. > The names should probably be changed as new code is added. AFAIKS VIRT > only comes > from the riscv virt machine which was the first to use it. E.g., use > something like > > #define RISCV_APLIC_MAX_NR_SORUCES 1023 Yes, that would be more sensible if future users were added. Cheers, Joel
