ppc/pnv: fixing external dtb
v3 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]/
Changelog
* V2: https://lore.kernel.org/all/[email protected]/
- renamed dtb file appropriate name.
- addressed identation and spelling mistake by aditya.
- keeping reviewed by from aditya.
* 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 v3 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 v3 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Quoted 8 lines · Shivang Upadhyay
Currently externally provided dtb is overwritten in
pnv_reset. Fix this by only creating dtb if not provided from-dtb.Reviewed-by Aditya Gupta <[email protected]>Signed-off-by Shivang Upadhyay <[email protected]>--- hw/ppc/pnv.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
LGTM.
~Amit
Quoted 26 lines
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 v3 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Quoted 5 lines · Amit Machhiwal
LGTM.
Reviewed-by Amit Machhiwal <[email protected]>~Amit
Thanks
~Shivang
PATCH v3 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 whether 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/qemu-powernv11.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