riscv: Fix serial0 alias path
We have all MMIO devices under "/smb" DT node so the serial0 alias
path should have "/smb" prefix.
Fixes: 7c9aac003925 ("riscv: Generate FDT at runtime for Guest/VM")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20220815101325.477694-6-apatel@ventanamicro.com
Signed-off-by: Will Deacon <will@kernel.org>
diff --git a/riscv/fdt.c b/riscv/fdt.c
index aeba042..e3d7717 100644
--- a/riscv/fdt.c
+++ b/riscv/fdt.c
@@ -122,6 +122,7 @@
cpu_to_fdt64(kvm->arch.memory_guest_start),
cpu_to_fdt64(kvm->ram_size),
};
+ char *str;
void *fdt = staging_fdt;
void *fdt_dest = guest_flat_to_host(kvm,
kvm->arch.dtb_guest_start);
@@ -205,12 +206,15 @@
_FDT(fdt_end_node(fdt));
if (fdt_stdout_path) {
- _FDT(fdt_begin_node(fdt, "aliases"));
- _FDT(fdt_property_string(fdt, "serial0", fdt_stdout_path));
- _FDT(fdt_end_node(fdt));
-
+ str = malloc(strlen(fdt_stdout_path) + strlen("/smb") + 1);
+ sprintf(str, "/smb%s", fdt_stdout_path);
free(fdt_stdout_path);
fdt_stdout_path = NULL;
+
+ _FDT(fdt_begin_node(fdt, "aliases"));
+ _FDT(fdt_property_string(fdt, "serial0", str));
+ _FDT(fdt_end_node(fdt));
+ free(str);
}
/* Finalise. */