@samitouri / QOSamiQemu / commits / 327e82dbd3

pnv/mpipl: Enable MPIPL support

With all MPIPL support in place, export a "dump" node in device tree, signifying that PowerNV QEMU platform supports MPIPL Also, export fw-load-area dt node, which has details about where the kernel & initrd were loaded, so that kernel can verify whether the kernel/initrd images were loaded within the boot memory region. QEMU just exports these details in fw-load-area, the check for boot memory region is done in kernel. Since now device tree can change at pnv_reset, hence regenerate device tree during pnv_reset Reviewed-by: Hari Bathini <hbathini@linux.ibm.com> Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> Tested-by: Shivang Upadhyay <shivangu@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260424083837.214947-9-adityag@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Aditya Gupta committed Apr 24, 2026 at 14:08 UTC 327e82dbd3fc4e45642a055f65cf0a6553b20cf4
1 file changed +45 -1
hw/ppc/pnv.c
+45 -1
@@ -54,6 +54,7 @@
54 #include "hw/ppc/pnv_chip.h"
55 #include "hw/ppc/pnv_xscom.h"
56 #include "hw/ppc/pnv_pnor.h"
57 +#include "hw/ppc/pnv_mpipl.h"
58
59 #include "hw/isa/isa.h"
60 #include "hw/char/serial-isa.h"
@@ -672,6 +673,39 @@ static void pnv_dt_power_mgt(PnvMachineState *pnv, void *fdt)
673 _FDT(fdt_setprop_cell(fdt, off, "ibm,enabled-stop-levels", 0xc0000000));
674 }
675
676 +static void pnv_dt_mpipl_dump(PnvMachineState *pnv, void *fdt)
677 +{
678 + int off;
679 +
680 + /*
681 + * Add "dump" node so kernel knows MPIPL (aka fadump) is supported
682 + *
683 + * Note: This is only needed to be done since we are passing device tree to
684 + * opal
685 + *
686 + * In case HDAT is supported in future, then opal can add these nodes by
687 + * itself based on system attribute having MPIPL_SUPPORTED bit set
688 + */
689 + off = fdt_add_subnode(fdt, 0, "ibm,opal");
690 + if (off == -FDT_ERR_EXISTS) {
691 + off = fdt_path_offset(fdt, "/ibm,opal");
692 + }
693 +
694 + _FDT(off);
695 + off = fdt_add_subnode(fdt, off, "dump");
696 + _FDT(off);
697 + _FDT((fdt_setprop_string(fdt, off, "compatible", "ibm,opal-dump")));
698 +
699 + /* Add kernel and initrd as fw-load-area */
700 + uint64_t fw_load_area[4] = {
701 + cpu_to_be64(KERNEL_LOAD_ADDR), cpu_to_be64(KERNEL_MAX_SIZE),
702 + cpu_to_be64(INITRD_LOAD_ADDR), cpu_to_be64(INITRD_MAX_SIZE)
703 + };
704 +
705 + _FDT((fdt_setprop(fdt, off, "fw-load-area",
706 + fw_load_area, sizeof(fw_load_area))));
707 +}
708 +
709 static void *pnv_dt_create(MachineState *machine)
710 {
711 PnvMachineClass *pmc = PNV_MACHINE_GET_CLASS(machine);
@@ -734,6 +768,9 @@ static void *pnv_dt_create(MachineState *machine)
768 pmc->dt_power_mgt(pnv, fdt);
769 }
770
771 + /* Advertise support for MPIPL */
772 + pnv_dt_mpipl_dump(pnv, fdt);
773 +
774 return fdt;
775 }
776
@@ -765,6 +802,10 @@ static void pnv_reset(MachineState *machine, ResetType type)
802 mpipl_write_succeeded = do_mpipl_write(pnv);
803 }
804
805 + /* Regenerate device tree */
806 + fdt = pnv_dt_create(machine);
807 + _FDT((fdt_pack(fdt)));
808 +
809 /*
810 * If it's a MPIPL boot, add the "mpipl-boot" property, and reset the
811 * boolean for MPIPL boot for next boot
@@ -814,8 +855,11 @@ static void pnv_reset(MachineState *machine, ResetType type)
855 sizeof(proc_area));
856 }
857
817 - fdt = machine->fdt;
858 cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
859 +
860 + /* Free previous device tree set by pnv_init/reset/machine_init_done */
861 + g_free(machine->fdt);
862 + machine->fdt = fdt;
863 }
864
865 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp)