[PATCH] xen/riscv: fix MMIO alignment check in imsic_init()

Oleksii Kurochko posted 1 patch 3 weeks, 2 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260507093155.105950-1-oleksii.kurochko@gmail.com
xen/arch/riscv/imsic.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[PATCH] xen/riscv: fix MMIO alignment check in imsic_init()
Posted by Oleksii Kurochko 3 weeks, 2 days ago
The MMIO alignment check in imsic_init() incorrectly uses cpu as
the index into mmios[]. The loop index should be used instead.
Otherwise, the alignment check may be performed on the wrong MMIO
address.

Fix the index used in the alignment check and corresponding printk.

Fixes: c9bd8b322ecbb ("xen/riscv: imsic_init() implementation")
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/arch/riscv/imsic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/riscv/imsic.c b/xen/arch/riscv/imsic.c
index a4460576f620..f7b70a8da09e 100644
--- a/xen/arch/riscv/imsic.c
+++ b/xen/arch/riscv/imsic.c
@@ -451,11 +451,11 @@ int __init imsic_init(const struct dt_device_node *node)
             continue;
         }
 
-        if ( !IS_ALIGNED(mmios[cpu].base_addr + reloff,
-                         IMSIC_MMIO_PAGE_SZ) )
+        if ( !IS_ALIGNED(mmios[index].base_addr + reloff, IMSIC_MMIO_PAGE_SZ) )
         {
             printk(XENLOG_WARNING "%s: MMIO address %#lx is not aligned on a page\n",
-                   node->name, msi[cpu].base_addr + reloff);
+                   node->name, mmios[index].base_addr + reloff);
+
             continue;
         }
 
-- 
2.54.0
Re: [PATCH] xen/riscv: fix MMIO alignment check in imsic_init()
Posted by Jan Beulich 3 weeks, 2 days ago
On 07.05.2026 11:31, Oleksii Kurochko wrote:
> The MMIO alignment check in imsic_init() incorrectly uses cpu as
> the index into mmios[]. The loop index should be used instead.
> Otherwise, the alignment check may be performed on the wrong MMIO
> address.
> 
> Fix the index used in the alignment check and corresponding printk.
> 
> Fixes: c9bd8b322ecbb ("xen/riscv: imsic_init() implementation")
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>