[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] xen/riscv: fix out-of-range indexing of the IMSIC per-CPU MSI array





On 9/2/26 4:49 PM, Jan Beulich wrote:
On 02.09.2026 16:16, Oleksii Kurochko wrote:
--- a/xen/arch/riscv/imsic.c
+++ b/xen/arch/riscv/imsic.c
@@ -326,6 +326,8 @@ int __init imsic_init(const struct dt_device_node *node)
      unsigned int nr_parent_irqs, index, nr_handlers = 0;
      paddr_t base_addr;
      unsigned int nr_mmios;
+    /* imsic_cfg.msi[] is indexed by Xen CPU id, so size it accordingly. */
+    unsigned int nr_msi = nr_cpu_ids;

Since there's no calculation involved anymore, is there a reason this
new variable is still needed? With it dropped, ...

I just thought that nr_msi will be more clear nr_cpu_ids but ...


@@ -405,7 +407,18 @@ int __init imsic_init(const struct dt_device_node *node)
              continue;
          }
+ /*
+         * hartid_to_cpuid() returns NR_CPUS for a hart Xen doesn't know, so
+         * the range has to be checked before msi[] is indexed at all.
+         */
          cpu = hartid_to_cpuid(hartid);
+        if ( cpu >= nr_msi )

... this comparison also will end up looking less odd.

... I was wrong. Will use nr_cpu_ids instead.

Thanks.

~ Oleksii



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.