[PATCH 0/2] ppc/pnv: fixing external dtb

Shivang Upadhyay posted 2 patches 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260623063156.1110370-1-shivangu@linux.ibm.com
Maintainers: Nicholas Piggin <npiggin@gmail.com>, Aditya Gupta <adityag@linux.ibm.com>, Glenn Miles <milesg@linux.ibm.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>
There is a newer version of this series
hw/ppc/pnv.c                           | 10 ++++++++--
tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++
2 files changed, 27 insertions(+), 2 deletions(-)
[PATCH 0/2] ppc/pnv: fixing external dtb
Posted by Shivang Upadhyay 1 month ago
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/20260310124619.3909045-8-adityag@linux.ibm.com/
[3] https://lore.kernel.org/qemu-devel/abAmBV7g_bGNw0Ax@shivang.upadyay/

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(-)

-- 
2.54.0
[PATCH v2 0/2] ppc/pnv: fixing external dtb
Posted by Shivang Upadhyay 1 month ago
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/20260310124619.3909045-8-adityag@linux.ibm.com/
[3] https://lore.kernel.org/qemu-devel/abAmBV7g_bGNw0Ax@shivang.upadyay/

Changelog
* V1: https://lore.kernel.org/all/20260623063156.1110370-1-shivangu@linux.ibm.com/
  - 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(-)

-- 
2.54.0
[PATCH v2 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Posted by Shivang Upadhyay 1 month ago
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 <shivangu@linux.ibm.com>
---
 hw/ppc/pnv.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 62812f22f8..e44fb7e2dc 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -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
-- 
2.54.0
Re: [PATCH v2 1/2] ppc/pnv: avoid regenerating DTB if external DTB is present
Posted by Aditya Gupta 3 weeks, 6 days ago
On 26/06/26 04:52PM, Shivang Upadhyay wrote:
> 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 <shivangu@linux.ibm.com>
> ---
>  hw/ppc/pnv.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> index 62812f22f8..e44fb7e2dc 100644
> --- a/hw/ppc/pnv.c
> +++ b/hw/ppc/pnv.c
> @@ -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;
> +	}

nit: indent is wrong

with indentation fixed, feel free to add:
Reviewed-by: Aditya Gupta <adityag@linux.ibm.com>

- Aditya G
[PATCH v2 2/2] ppc/pnv: add test to verify external DTB is honored
Posted by Shivang Upadhyay 1 month ago
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.

Signed-off-by: Shivang Upadhyay <shivangu@linux.ibm.com>
---
 tests/functional/ppc64/test_powernv.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tests/functional/ppc64/test_powernv.py b/tests/functional/ppc64/test_powernv.py
index 0ea6c93e42..cb8f6545a0 100755
--- a/tests/functional/ppc64/test_powernv.py
+++ b/tests/functional/ppc64/test_powernv.py
@@ -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')
-- 
2.54.0
Re: [PATCH v2 2/2] ppc/pnv: add test to verify external DTB is honored
Posted by Aditya Gupta 3 weeks, 5 days ago
On 26/06/26 04:52PM, Shivang Upadhyay wrote:
> 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

> +    # 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 ?

> +
>      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)
> +

Reviewed-by: Aditya Gupta <adityag@linux.ibm.com>

Thanks,
- Aditya G
Re: [PATCH v2 2/2] ppc/pnv: add test to verify external DTB is honored
Posted by Shivang Upadhyay 3 weeks, 5 days ago
On Mon, 2026-06-29 at 17:23 +0530, Aditya Gupta wrote:
> > +    # 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')
> 
> 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.