ppc/pnv: fixing external dtb
cover ppc/pnv: fixing external dtb
Currently powerpc pnv machines doesnt respect -dtb argument passed from outside. During cpu start content of machine->fdt is overwritten by pnv_dt_create.
This was previously found and fixed, during the discussion for dumpdtb issue [1]. But reintroduced in MPIPL support [2]. Saddly it skipped in the review phase [3].
Adding a functional test for checking the external dtb case in powernv11.
[1] https://lore.kernel.org/all/20260323231612.GA2637687@ax162/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
[3] https://lore.kernel.org/qemu-devel/[email protected]/
Shivang Upadhyay (2):
ppc/pnv: avoid regenerating DTB if external DTB is present ppc/pnv: add test to verify external DTB is honored
hw/ppc/pnv.c | 10 ++++++++-- tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-)
Signature · 1 line
2.54.0
PATCH 1/2 ppc/pnv: avoid regenerating DTB if external DTB is present
--- hw/ppc/pnv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
hw/ppc/pnv.c +8 -2
@@ -803,8 +803,14 @@ static void pnv_reset(MachineState *machine, ResetType type) mpipl_write_succeeded =do_mpipl_write (pnv); } -/* Regenerate device tree */ - fdt =pnv_dt_create (machine); +if (machine->dtb) { +int file_size;/* discard */ + fdt =load_device_tree (machine->dtb, &file_size); + }else { +/* Regenerate device tree */ + fdt =pnv_dt_create (machine); + } +_FDT ((fdt_pack (fdt)));/*
Signature · 1 line
2.54.0
Re: [PATCH 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Quoted 13 lines · Shivang Upadhyay
Signed-off-by Shivang Upadhyay <[email protected]>--- hw/ppc/pnv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)hw/ppc/pnv.c +0
-0@@ -803,8 +803,14 @@ static void pnv_reset(MachineState *machine, ResetType type) mpipl_write_succeeded =do_mpipl_write (pnv); }
hw/ppc/pnv.c static void pnv_reset(MachineState *machine, ResetType type) · line 813
Quoted 10 lines
hw/ppc/pnv.c +8
-2-/* Regenerate device tree */ - fdt =pnv_dt_create (machine); +if (machine->dtb) { +int file_size;/* discard */ + fdt =load_device_tree (machine->dtb, &file_size); + }else { +/* Regenerate device tree */ + fdt =pnv_dt_create (machine); + } +
load_device_tree is being done in pnv_init also, how about this ?
/* only create new dt if -dtb wasn't explicity passed */
if (!machine->dtb) {
pnv_dt_create
fdt_pack
}also, keep this before the mpipl block, ie. after qemu_devices_reset ?
Thanks,
- Aditya G
Re: [PATCH 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Quoted 28 lines · Aditya Gupta
Quoted 16 lines · Shivang Upadhyay
Signed-off-by Shivang Upadhyay <[email protected]>---
hw/ppc/pnv.c | 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)hw/ppc/pnv.c +0
-0@@ -803,8 +803,14 @@ static void pnv_reset(MachineState *machine, ResetType type) mpipl_write_succeeded = do_mpipl_write(pnv); }
- /* Regenerate device tree */
- fdt =pnv_dt_create(machine);Quoted 8 lines
+ if (
machine->dtb) {
+ intfile_size; /* discard */
+ fdt =load_device_tree(machine->dtb, &file_size); + } else {
+ /* Regenerate device tree */
+ fdt =pnv_dt_create(machine);
+ }
+
load_device_treeis being done inpnv_initalso, how about this ?
Quoted 8 lines
/* only create new dt if -dtb wasn't explicity passed */ if (!machine->dtb) { pnv_dt_create fdt_pack }also, keep this before the mpipl block, ie. after
qemu_devices_reset?
Yea, That makes sense.
ill fix this in v2.
Quoted 3 lines
Thanks,
- Aditya G
~Shivang.
PATCH 2/2 ppc/pnv: add test to verify external DTB is honored
In reply to Shivang Upadhyay--- tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tests/functional/ppc64/test_powernv.py +19 -0
@@ -27,6 +27,11 @@ class PowernvMachine(LinuxKernelTest): 'buildroot/qemu_ppc64le_powernv8-2025.02/rootfs.ext2'), 'aee2192b692077c4bde31cb56ce474424b358f17cec323d5c94af3970c9aada2') + # testdtb for power11, which contains string "hello world" in command line + ASSET_SAMPLE_DTB = Asset( + ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dtb'), + '2dd3330561768fc5c8e4b93aa29bc44c64278d186f1e0f8c584cdf15c3f8cf43') + def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): self.require_accelerator("tcg") kernel_path = self.ASSET_KERNEL.fetch()
@@ -104,6 +109,20 @@ def do_test_ppc64_powernv(self, proc): # Device detection output driven by udev probing is sometimes cut off # from console output, suspect S14silence-console init script. + def test_ppc64_powernv_external_dtb(self): + self.set_machine('powernv11') + self.require_accelerator("tcg") + + kernel_path = self.ASSET_KERNEL.fetch() + sample_dtb_path = self.ASSET_SAMPLE_DTB.fetch() + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-dtb', sample_dtb_path) + self.vm.launch() + + # check if custom dtb is reflected or not + wait_for_console_pattern(self, "Kernel command line: hello world", self.panic_message) + def test_powernv8(self): self.set_machine('powernv8') self.do_test_ppc64_powernv('P8')
Signature · 1 line
2.54.0
Re: [PATCH 2/2] ppc/pnv: add test to verify external DTB is honored
Quoted 4 lines · Shivang Upadhyay
Signed-off-by Shivang Upadhyay <[email protected]>--- tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
The test addition looks fine, but the commit message body is missing. According to the official QEMU submission guidelines at:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#write-a-meaningful-commit-message
"Commit messages should be meaningful and should stand on their own as a historical record of why the changes you applied were necessary or useful."
You may want to add a commit message body in the next version.
Thanks,
Amit
Quoted 42 lines
tests/functional/ppc64/test_powernv.py +19
-0@@ -27,6 +27,11 @@ class PowernvMachine(LinuxKernelTest): 'buildroot/qemu_ppc64le_powernv8-2025.02/rootfs.ext2'), 'aee2192b692077c4bde31cb56ce474424b358f17cec323d5c94af3970c9aada2') + # testdtb for power11, which contains string "hello world" in command line + ASSET_SAMPLE_DTB = Asset( + ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dtb'), + '2dd3330561768fc5c8e4b93aa29bc44c64278d186f1e0f8c584cdf15c3f8cf43') + def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): self.require_accelerator("tcg") kernel_path = self.ASSET_KERNEL.fetch()@@ -104,6 +109,20 @@ def do_test_ppc64_powernv(self, proc): # Device detection output driven by udev probing is sometimes cut off # from console output, suspect S14silence-console init script. + def test_ppc64_powernv_external_dtb(self): + self.set_machine('powernv11') + self.require_accelerator("tcg") + + kernel_path = self.ASSET_KERNEL.fetch() + sample_dtb_path = self.ASSET_SAMPLE_DTB.fetch() + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-dtb', sample_dtb_path) + self.vm.launch() + + # check if custom dtb is reflected or not + wait_for_console_pattern(self, "Kernel command line: hello world", self.panic_message) + def test_powernv8(self): self.set_machine('powernv8') self.do_test_ppc64_powernv('P8')Signature · 1 line
2.54.0
Re: [PATCH 2/2] ppc/pnv: add test to verify external DTB is honored
Quoted 6 lines · Amit Machhiwal
The test addition looks fine, but the commit message body is missing. According to the official QEMU submission guidelines at:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#write-a-meaningful-commit-message
Quoted 7 lines
"Commit messages should be meaningful and should stand on their own as
a historical record of why the changes you applied were necessary or
useful."You may want to add a commit message body in the next version.
Sure Amit, Ill add the body.
~Shivang.
Re: [PATCH 2/2] ppc/pnv: add test to verify external DTB is honored
In reply to Shivang UpadhyayQuoted 1 line · Shivang Upadhyay
Signed-off-by Shivang Upadhyay <[email protected]>
description, as pointed by amit
Quoted 10 lines
<...snip...>
tests/functional/ppc64/test_powernv.py +5
-0+ # testdtb for power11, which contains string "hello world" in command line + ASSET_SAMPLE_DTB = Asset( + ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dtb'), + '2dd3330561768fc5c8e4b93aa29bc44c64278d186f1e0f8c584cdf15c3f8cf43') + def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): self.require_accelerator("tcg") kernel_path = self.ASSET_KERNEL.fetch()
tests/functional/ppc64/test_powernv.py def do_test_ppc64_powernv(self, proc): · line 117
Quoted 9 lines
tests/functional/ppc64/test_powernv.py +6
-0@@ -104,6 +109,20 @@ def do_test_ppc64_powernv(self, proc): # Device detection output driven by udev probing is sometimes cut off # from console output, suspect S14silence-console init script. + def test_ppc64_powernv_external_dtb(self): + self.set_machine('powernv11') + self.require_accelerator("tcg") + + kernel_path = self.ASSET_KERNEL.fetch() + sample_dtb_path = self.ASSET_SAMPLE_DTB.fetch()
update the dtb also when you post v2, this dtb is of power10, works, but better to have power11's dtb here
Thanks,
- Aditya G
Re: [PATCH 2/2] ppc/pnv: add test to verify external DTB is honored
Quoted 6 lines · Aditya Gupta
Quoted 2 lines
+
kernel_path=self.ASSET_KERNEL.fetch()+sample_dtb_path=self.ASSET_SAMPLE_DTB.fetch()update the dtb also when you post v2, this dtb is of power10, works, but
better to have power11's dtb here
Sure, ill change that. Is it possible we can put it somewhere else other than personal github?
~Shivang.
v2 cover ppc/pnv: fixing external dtb
In reply to Shivang UpadhyayCurrently powerpc pnv machines doesnt respect -dtb argument passed from outside. During cpu start content of machine->fdt is overwritten by pnv_dt_create.
This was previously found and fixed, during the discussion for dumpdtb issue [1]. But reintroduced in MPIPL support [2]. Saddly it skipped in the review phase [3].
Adding a functional test for checking the external dtb case in powernv11.
[1] https://lore.kernel.org/all/20260323231612.GA2637687@ax162/
[2] https://lore.kernel.org/qemu-devel/[email protected]/
[3] https://lore.kernel.org/qemu-devel/[email protected]/
Changelog
* V1: https://lore.kernel.org/all/[email protected]/
- change dtb from power10 to power11
- refactored pnv_reset code to not load_device_tree on each iteration.
- added commit message body.
Shivang Upadhyay (2):
ppc/pnv: avoid regenerating DTB if external DTB is present ppc/pnv: add test to verify external DTB is honored
hw/ppc/pnv.c | 10 +++++++--- tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-)
Signature · 1 line
2.54.0
PATCH v2 1/2 ppc/pnv: avoid regenerating DTB if external DTB is present
Currently externally provided dtb is overwritten in pnv_reset. Fix this by only creating dtb if not provided from -dtb.
--- hw/ppc/pnv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +7 -3
@@ -803,9 +803,13 @@ static void pnv_reset(MachineState *machine, ResetType type) mpipl_write_succeeded =do_mpipl_write (pnv); } -/* Regenerate device tree */ - fdt =pnv_dt_create (machine); -_FDT ((fdt_pack (fdt))); +/* Only create new dt if not provided in -dtb */ +if (!machine->dtb) { + fdt =pnv_dt_create (machine); +_FDT ((fdt_pack (fdt))); + }else { + fdt = machine->fdt; + }/* * If it's a MPIPL boot, add the "mpipl-boot" property, and reset the
Signature · 1 line
2.54.0
Re: [PATCH v2 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Quoted 16 lines · Shivang Upadhyay
Currently externally provided dtb is overwritten in
pnv_reset. Fix this by only creating dtb if not provided from-dtb.Signed-off-by Shivang Upadhyay <[email protected]>--- hw/ppc/pnv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)hw/ppc/pnv.c +0
-0@@ -803,9 +803,13 @@ static void pnv_reset(MachineState *machine, ResetType type) mpipl_write_succeeded =do_mpipl_write (pnv); }
hw/ppc/pnv.c static void pnv_reset(MachineState *machine, ResetType type) · line 812
Quoted 10 lines
hw/ppc/pnv.c +7
-3-/* Regenerate device tree */ - fdt =pnv_dt_create (machine); -_FDT ((fdt_pack (fdt))); +/* Only create new dt if not provided in -dtb */ +if (!machine->dtb) { + fdt =pnv_dt_create (machine); +_FDT ((fdt_pack (fdt))); + }else { + fdt = machine->fdt; + }
nit: indent is wrong
with indentation fixed, feel free to add:
- Aditya G
PATCH v2 2/2 ppc/pnv: add test to verify external DTB is honored
In reply to Shivang UpadhyayTest boots a powernv11 machine, using a custom dtb. Custom dtb has the following bootargs.
chosen {
bootargs = "hello world";
};Test Checks wheather above bootargs make it to kernel's command line.
--- tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
tests/functional/ppc64/test_powernv.py +19 -0
@@ -27,6 +27,11 @@ class PowernvMachine(LinuxKernelTest): 'buildroot/qemu_ppc64le_powernv8-2025.02/rootfs.ext2'), 'aee2192b692077c4bde31cb56ce474424b358f17cec323d5c94af3970c9aada2') + # testdtb for power11, which contains string "hello world" in command line + ASSET_SAMPLE_DTB = Asset( + ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dtb'), + 'ea1271516264eea1eb58a067a99d0c2ca9528be8dc7d4e46bb2d5ae0d42fc568') + def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): self.require_accelerator("tcg") kernel_path = self.ASSET_KERNEL.fetch()
@@ -104,6 +109,20 @@ def do_test_ppc64_powernv(self, proc): # Device detection output driven by udev probing is sometimes cut off # from console output, suspect S14silence-console init script. + def test_ppc64_powernv_external_dtb(self): + self.set_machine('powernv11') + self.require_accelerator("tcg") + + kernel_path = self.ASSET_KERNEL.fetch() + sample_dtb_path = self.ASSET_SAMPLE_DTB.fetch() + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-dtb', sample_dtb_path) + self.vm.launch() + + # check if custom dtb is reflected or not + wait_for_console_pattern(self, "Kernel command line: hello world", self.panic_message) + def test_powernv8(self): self.set_machine('powernv8') self.do_test_ppc64_powernv('P8')
Signature · 1 line
2.54.0
Re: [PATCH v2 2/2] ppc/pnv: add test to verify external DTB is honored
Quoted 8 lines · Shivang Upadhyay
Test boots a powernv11 machine, using a custom dtb. Custom dtb has the following bootargs.
chosen { bootargs = "hello world"; };Test Checks wheather above bootargs make it to kernel's command line.
nit: s/wheather/whether
tests/functional/ppc64/test_powernv.py class PowernvMachine(LinuxKernelTest): · line 33
Quoted 4 lines
tests/functional/ppc64/test_powernv.py +4
-0+ # testdtb for power11, which contains string "hello world" in command line + ASSET_SAMPLE_DTB = Asset( + ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dtb'), + 'ea1271516264eea1eb58a067a99d0c2ca9528be8dc7d4e46bb2d5ae0d42fc568')
nit: since you are anyways sending a v3, can you rename output.dtb to something like qemu-powernv10.dtb, etc so in future you don't modify this generic path unknowingly ?
Quoted 12 lines
tests/functional/ppc64/test_powernv.py +5
-0+ def do_test_linux_boot(self, command_line = KERNEL_COMMON_COMMAND_LINE): self.require_accelerator("tcg") kernel_path = self.ASSET_KERNEL.fetch()@@ -104,6 +109,20 @@ def do_test_ppc64_powernv(self, proc): # Device detection output driven by udev probing is sometimes cut off # from console output, suspect S14silence-console init script. + def test_ppc64_powernv_external_dtb(self): + self.set_machine('powernv11') + self.require_accelerator("tcg") +
tests/functional/ppc64/test_powernv.py def do_test_ppc64_powernv(self, proc): · line 125
Quoted 10 lines
tests/functional/ppc64/test_powernv.py +10
-0+ kernel_path = self.ASSET_KERNEL.fetch() + sample_dtb_path = self.ASSET_SAMPLE_DTB.fetch() + self.vm.set_console() + self.vm.add_args('-kernel', kernel_path, + '-dtb', sample_dtb_path) + self.vm.launch() + + # check if custom dtb is reflected or not + wait_for_console_pattern(self, "Kernel command line: hello world", self.panic_message) +
Thanks,
- Aditya G
Re: [PATCH v2 2/2] ppc/pnv: add test to verify external DTB is honored
Quoted 9 lines · Aditya Gupta
Quoted 8 lines
+ # testdtb for power11, which contains string "hello world" in command line
+ASSET_SAMPLE_DTB= Asset(
+ ('https://github.com/roz3x/qemu/raw/refs/heads/sample-dtb/output.dt b'),
+ 'ea1271516264eea1eb58a067a99d0c2ca9528be8dc7d4e46bb2d5ae0d42fc568')
Quoted 3 lines
nit: since you are anyways sending a v3, can you rename output.dtb to something like qemu-powernv10.dtb, etc so in future you don't modify this generic path unknowingly ?
Yeah, Sounds like a good idea.
Ill send the next revision.
~Shivang.