[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 15/15] hw/intc: sifive_plic: Fix the pending register range c
From: |
Bin Meng |
Subject: |
Re: [PATCH 15/15] hw/intc: sifive_plic: Fix the pending register range check |
Date: |
Mon, 5 Dec 2022 16:21:46 +0800 |
On Fri, Dec 2, 2022 at 8:28 AM Wilfred Mallawa <wilfred.mallawa@wdc.com> wrote:
>
> On Thu, 2022-12-01 at 22:08 +0800, Bin Meng wrote:
> > The pending register upper limit is currently set to
> > plic->num_sources >> 3, which is wrong, e.g.: considering
> > plic->num_sources is 7, the upper limit becomes 0 which fails
> > the range check if reading the pending register at pending_base.
> >
> > Fixes: 1e24429e40df ("SiFive RISC-V PLIC Block")
> > Signed-off-by: Bin Meng <bmeng@tinylab.org>
> >
> > ---
> >
> > hw/intc/sifive_plic.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c
> > index 7a6a358c57..a3fc8222c7 100644
> > --- a/hw/intc/sifive_plic.c
> > +++ b/hw/intc/sifive_plic.c
> > @@ -143,7 +143,8 @@ static uint64_t sifive_plic_read(void *opaque,
> > hwaddr addr, unsigned size)
> > uint32_t irq = (addr - plic->priority_base) >> 2;
> >
> > return plic->source_priority[irq];
> > - } else if (addr_between(addr, plic->pending_base, plic-
> > >num_sources >> 3)) {
> > + } else if (addr_between(addr, plic->pending_base,
> > + (plic->num_sources + 31) >> 3)) {
> why does adding specifically 31 work here?
>
Each pending register is 32-bit for 32 interrupt sources. Adding 31 is
to round up to next pending register offset.
Regards,
Bin
- [PATCH 12/15] hw/riscv: virt: Fix the value of "riscv, ndev" in the dtb, (continued)
- [PATCH 12/15] hw/riscv: virt: Fix the value of "riscv, ndev" in the dtb, Bin Meng, 2022/12/01
- [PATCH 13/15] hw/intc: sifive_plic: Change "priority-base" to start from interrupt source 0, Bin Meng, 2022/12/01
- [PATCH 14/15] hw/riscv: opentitan: Drop "hartid-base" and "priority-base" initialization, Bin Meng, 2022/12/01
- [PATCH 15/15] hw/intc: sifive_plic: Fix the pending register range check, Bin Meng, 2022/12/01
- Re: [PATCH 15/15] hw/intc: sifive_plic: Fix the pending register range check, Alistair Francis, 2022/12/07
- Re: [PATCH 01/15] hw/riscv: Select MSI_NONBROKEN in SIFIVE_PLIC, Alistair Francis, 2022/12/04