Skip to contentSkip to conversation

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

PATCH In review Oleksii Kurochko 2 participants 2 messages May 7 RISC-V

lore
Share & tools
lore
#0 lore raw

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

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")
---
 xen/arch/riscv/imsic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
xen/arch/riscv/imsic.c +3 -3
index a4460576f620..f7b70a8da09e 100644
@@ -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;
         }
 
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Oleksii Kurochko

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")