Re: [PATCH] RISC-V: KVM: Reject overlapping AIA IMSIC address fields
Anup Patel <[email protected]>
| Newsgroups | org.infradead.lists.linux-riscv,org.infradead.lists.kvm-riscv,org.kernel.vger.kvm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAAhSdy2j+0sV0_XD=ieDgSDPTK8eAxJBy6EFjR+yFxT0XH-5cQ@mail.gmail.com> |
On Sat, Jul 18, 2026 at 10:05 AM Pengpeng Hou <[email protected]> wrote: > > KVM lets userspace configure the IMSIC guest, HART, group-width, and > group-shift fields independently. The individual bounds allow a layout > such as guest_bits=7, hart_bits=6, group_bits=1, and group_shift=24. > > That layout places the group index bit at bit 24 while the lower > guest+HART field also extends through bit 24. The IMSIC address helpers > later consume these values as one address layout: aia_imsic_ppn() masks > the lower guest+HART field and the group field, while > aia_imsic_hart_index() combines the group and HART index. Allowing an > overlapping configuration therefore gives one address bit two different > meanings. > > Reject group-index layouts that start before the end of the guest+HART > field before initializing the in-kernel irqchip. > > Fixes: 89d01306e34d ("RISC-V: KVM: Implement device interface for AIA irqchip") > Signed-off-by: Pengpeng Hou <[email protected]> LGTM. Reviewed-by: Anup Patel <[email protected]> Queued this patch for Linux-7.3 Thanks, Anup > --- > arch/riscv/kvm/aia_device.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/riscv/kvm/aia_device.c b/arch/riscv/kvm/aia_device.c > index be83c2d5fc308..0793d4d4cf5e3 100644 > --- a/arch/riscv/kvm/aia_device.c > +++ b/arch/riscv/kvm/aia_device.c > @@ -248,6 +248,12 @@ static int aia_init(struct kvm *kvm) > if (aia->nr_sources && aia->aplic_addr == KVM_RISCV_AIA_UNDEF_ADDR) > return -EINVAL; > > + /* Group index bits must not overlap guest and HART index bits. */ > + if (aia->nr_group_bits && > + aia->nr_group_shift < IMSIC_MMIO_PAGE_SHIFT + > + aia->nr_guest_bits + aia->nr_hart_bits) > + return -EINVAL; > + > /* Initialize APLIC */ > ret = kvm_riscv_aia_aplic_init(kvm); > if (ret) > -- > 2.43.0 > _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv