hw/riscv: spike: Add '/chosen/stdout-path' in device tree unconditionally
Subsystems (2)
PATCH 1/2 hw/riscv: spike: Add '/chosen/stdout-path' in device tree unconditionally
From: Bin Meng <[email protected]>
At present the adding '/chosen/stdout-path' property in device tree is determined by whether a kernel command line is provided, which is wrong. It should be added unconditionally.
---
hw/riscv/spike.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
hw/riscv/spike.c +3 -2
@@ -174,10 +174,11 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,riscv_socket_fdt_write_distance_matrix (mc, fdt); +qemu_fdt_add_subnode (fdt,"/chosen" ); +qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); +if (cmdline) { -qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); -qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); } }
Signature · 1 line
2.25.1
PATCH 2/2 hw/riscv: Don't add empty bootargs to device tree
From: Bin Meng <[email protected]>
Commit 7c28f4da20e5 ("RISC-V: Don't add NULL bootargs to device-tree") tried to avoid adding *NULL* bootargs to device tree, but unfortunately the changes were entirely useless, due to MachineState::kernel_cmdline can't be NULL at all as the default value is given as an empty string. (see hw/core/machine.c::machine_initfn()).
Note the wording of *NULL* bootargs is wrong. It can't be NULL otherwise a segfault had already been observed by dereferencing the NULL pointer. It should be worded as *empty" bootargs.
---
hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/riscv/spike.c | 2 +- hw/riscv/virt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
hw/riscv/microchip_pfsoc.c +1 -1
@@ -571,7 +571,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) "linux,initrd-end", end); } -if (machine->kernel_cmdline) { +if (machine->kernel_cmdline && *machine->kernel_cmdline) {qemu_fdt_setprop_string (machine->fdt,"/chosen" ,"bootargs" , machine->kernel_cmdline); }
hw/riscv/sifive_u.c +1 -1
@@ -511,7 +511,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,g_free (nodename); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }
hw/riscv/spike.c +1 -1
@@ -177,7 +177,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }
hw/riscv/virt.c +1 -1
@@ -998,7 +998,7 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,create_fdt_flash (s, memmap); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (mc->fdt,"/chosen" ,"bootargs" , cmdline); } }
Signature · 1 line
2.25.1
Re: [PATCH 2/2] hw/riscv: Don't add empty bootargs to device tree
+ Philippe's another email address as the redhat one is unreachable
Quoted 67 lines · Bin Meng
From: Bin Meng <[email protected]>
Commit
7c28f4da20e5("RISC-V: Don't add NULL bootargs to device-tree") tried to avoid adding *NULL* bootargs to device tree, but unfortunately the changes were entirely useless, due toMachineState::kernel_cmdlinecan't be NULL at all as the default value is given as an empty string. (see hw/core/machine.c::machine_initfn()).Note the wording of *NULL* bootargs is wrong. It can't be NULL otherwise a segfault had already been observed by dereferencing the NULL pointer. It should be worded as *empty" bootargs.
Fixes 7c28f4da20e5 ("RISC-V: Don't add NULL bootargs to device-tree")Signed-off-by Bin Meng <[email protected]>---
hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/riscv/spike.c | 2 +- hw/riscv/virt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)hw/riscv/microchip_pfsoc.c +1
-1@@ -571,7 +571,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) "linux,initrd-end", end); } -if (machine->kernel_cmdline) { +if (machine->kernel_cmdline && *machine->kernel_cmdline) {qemu_fdt_setprop_string (machine->fdt,"/chosen" ,"bootargs" , machine->kernel_cmdline); }hw/riscv/sifive_u.c +1
-1@@ -511,7 +511,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,g_free (nodename); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/spike.c +1
-1@@ -177,7 +177,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/virt.c +0
-0
hw/riscv/virt.c static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,
Quoted 9 lines
hw/riscv/virt.c +1
-2@@ -998,7 +998,7 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,create_fdt_flash (s, memmap); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (mc->fdt,"/chosen" ,"bootargs" , cmdline); } } --
Regards,
Bin
Re: [PATCH 2/2] hw/riscv: Don't add empty bootargs to device tree
In reply to Bin MengQuoted 9 lines · Bin Meng
From: Bin Meng <[email protected]>
Commit
7c28f4da20e5("RISC-V: Don't add NULL bootargs to device-tree") tried to avoid adding *NULL* bootargs to device tree, but unfortunately the changes were entirely useless, due toMachineState::kernel_cmdlinecan't be NULL at all as the default value is given as an empty string. (see hw/core/machine.c::machine_initfn()).
Quoted 6 lines
Note the wording of *NULL* bootargs is wrong. It can't be NULL otherwise a segfault had already been observed by dereferencing the NULL pointer. It should be worded as *empty" bootargs.
Fixes 7c28f4da20e5 ("RISC-V: Don't add NULL bootargs to device-tree")Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 64 lines
---
hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/riscv/spike.c | 2 +- hw/riscv/virt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)hw/riscv/microchip_pfsoc.c +1
-1@@ -571,7 +571,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) "linux,initrd-end", end); } -if (machine->kernel_cmdline) { +if (machine->kernel_cmdline && *machine->kernel_cmdline) {qemu_fdt_setprop_string (machine->fdt,"/chosen" ,"bootargs" , machine->kernel_cmdline); }hw/riscv/sifive_u.c +1
-1@@ -511,7 +511,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,g_free (nodename); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/spike.c +1
-1@@ -177,7 +177,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/virt.c +1
-2@@ -998,7 +998,7 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,create_fdt_flash (s, memmap); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (mc->fdt,"/chosen" ,"bootargs" , cmdline); } } --2.25.1
Alistair Francis
AppliedRe: [PATCH 2/2] hw/riscv: Don't add empty bootargs to device tree
In reply to Bin MengQuoted 9 lines · Bin Meng
From: Bin Meng <[email protected]>
Commit
7c28f4da20e5("RISC-V: Don't add NULL bootargs to device-tree") tried to avoid adding *NULL* bootargs to device tree, but unfortunately the changes were entirely useless, due toMachineState::kernel_cmdlinecan't be NULL at all as the default value is given as an empty string. (see hw/core/machine.c::machine_initfn()).
Quoted 6 lines
Note the wording of *NULL* bootargs is wrong. It can't be NULL otherwise a segfault had already been observed by dereferencing the NULL pointer. It should be worded as *empty" bootargs.
Fixes 7c28f4da20e5 ("RISC-V: Don't add NULL bootargs to device-tree")Signed-off-by Bin Meng <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 64 lines
---
hw/riscv/microchip_pfsoc.c | 2 +- hw/riscv/sifive_u.c | 2 +- hw/riscv/spike.c | 2 +- hw/riscv/virt.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)hw/riscv/microchip_pfsoc.c +1
-1@@ -571,7 +571,7 @@ static void microchip_icicle_kit_machine_init(MachineState *machine) "linux,initrd-end", end); } -if (machine->kernel_cmdline) { +if (machine->kernel_cmdline && *machine->kernel_cmdline) {qemu_fdt_setprop_string (machine->fdt,"/chosen" ,"bootargs" , machine->kernel_cmdline); }hw/riscv/sifive_u.c +1
-1@@ -511,7 +511,7 @@ static void create_fdt(SiFiveUState *s, const MemMapEntry *memmap,g_free (nodename); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/spike.c +1
-1@@ -177,7 +177,7 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); } }hw/riscv/virt.c +1
-2@@ -998,7 +998,7 @@ static void create_fdt(RISCVVirtState *s, const MemMapEntry *memmap,create_fdt_flash (s, memmap); update_bootargs: -if (cmdline) { +if (cmdline && *cmdline) {qemu_fdt_setprop_string (mc->fdt,"/chosen" ,"bootargs" , cmdline); } } --2.25.1
Quoted 9 lines · Bin Meng
From: Bin Meng <[email protected]>
At present the adding '/chosen/stdout-path' property in device tree is determined by whether a kernel command line is provided, which is wrong. It should be added unconditionally.
Fixes 8d8897accb1c ("hw/riscv: spike: Allow using binary firmware as bios")Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 27 lines
---
hw/riscv/spike.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)hw/riscv/spike.c +3
-3@@ -174,10 +174,11 @@ static void create_fdt(SpikeState *s, const MemMapEntry *memmap,riscv_socket_fdt_write_distance_matrix (mc, fdt); +qemu_fdt_add_subnode (fdt,"/chosen" ); +qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); +if (cmdline) { -qemu_fdt_add_subnode (fdt,"/chosen" );qemu_fdt_setprop_string (fdt,"/chosen" ,"bootargs" , cmdline); -qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" ,"/htif" ); } } --2.25.1