[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
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
- Date: Wed, 2 Sep 2026 17:21:06 +0200
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
- Cc: Romain Caritey <Romain.Caritey@xxxxxxxxxxxxx>, Baptiste Le Duc <baptiste.le-duc@xxxxxxxxxx>, Zheng Zhang <zhangzheng@xxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Connor Davis <connojdavis@xxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Wed, 02 Sep 2026 15:21:16 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
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
|