Commit 9d6ac47d31 for qemu.org
commit 9d6ac47d3182f2bdadea4bed596c82759a167e67
Author: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Date: Fri Aug 28 17:39:10 2026 -0300
hw/riscv/virt.c: fix aclint soc/mtimer nodename
Running 'dtc' to generate a readable fdt for the virt machine produce
warnings:
$ dtc -I dtb -O dts virt.dtb > virt.dts
<stdout>: Warning (simple_bus_reg): /soc/mtimer@2000000: simple-bus unit address format error, expected "2007ff8"
<stdout>: Warning (simple_bus_reg): /soc/mtimer@2008000: simple-bus unit address format error, expected "200fff8"
This happens because the 'reg' field does not match the address in the
nodename. The right fix, pointed out by Chao in [1], is to make the
nodename match the reg value:
"In the current QEMU implement, `addr` is the MTIMECMP base address,
while the MTIME register is located at addr + RISCV_ACLINT_DEFAULT_MTIME."
In other words, the 'reg' value is correct but the nodename isn't.
We'll make the fix now, allowing the next patch to move the fixed version
of aclint FDT to fdt-common.
[1] https://lore.kernel.org/qemu-devel/apHH1upnh8udUUT-@ChaodeMacBook-Pro.local/
Cc: qemu-stable@nongnu.org
Suggested-by: Chao Liu <chao.liu@processmission.com>
Fixes: 954886ea6d ("hw/riscv: virt: Add optional ACLINT support to virt machine")
Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Chao Liu <chao.liu@processmission.com>
Message-ID: <20260828203918.350131-9-daniel.barboza@oss.qualcomm.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index 63a32de3b4..840dd0e075 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -233,7 +233,8 @@ static void create_fdt_socket_aclint(RISCVVirtState *s,
(s->memmap[VIRT_CLINT].size * socket);
size = s->memmap[VIRT_CLINT].size - RISCV_ACLINT_SWI_SIZE;
}
- name = g_strdup_printf("/soc/mtimer@%lx", addr);
+ name = g_strdup_printf("/soc/mtimer@%"HWADDR_PRIx,
+ addr + RISCV_ACLINT_DEFAULT_MTIME);
qemu_fdt_add_subnode(ms->fdt, name);
qemu_fdt_setprop_string(ms->fdt, name, "compatible",
"riscv,aclint-mtimer");