@samitouri / QOSamiQemu / commits / 4cb8c9d6a3

pnv/mpipl: Set thread entry size to be allocated by firmware

Set the "Thread Register State Entry Size" that is required by firmware (OPAL), to know size of memory to allocate to capture CPU state, in the event of a crash 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-7-adityag@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>

Aditya Gupta committed Apr 24, 2026 at 14:08 UTC 4cb8c9d6a3998fb51659ce8de623c152eaf9e53c
1 file changed +25
hw/ppc/pnv.c
+25
@@ -748,10 +748,35 @@ static void pnv_powerdown_notify(Notifier *n, void *opaque)
748
749 static void pnv_reset(MachineState *machine, ResetType type)
750 {
751 + PnvMachineState *pnv = PNV_MACHINE(machine);
752 void *fdt;
753
754 qemu_devices_reset(type);
755
756 + if (!pnv->mpipl_state.is_next_boot_mpipl) {
757 + /*
758 + * Set the "Thread Register State Entry Size", so that firmware can
759 + * allocate enough memory to capture CPU state in the event of a
760 + * crash
761 + */
762 +
763 + MpiplProcDumpArea proc_area;
764 +
765 + proc_area.version = PROC_DUMP_AREA_VERSION_P9;
766 + proc_area.thread_size = cpu_to_be32(sizeof(MpiplPreservedCPUState));
767 +
768 + /* These are to be allocated & assigned by the firmware */
769 + proc_area.alloc_addr = 0;
770 + proc_area.alloc_size = 0;
771 +
772 + /* These get assigned after crash, when QEMU preserves the registers */
773 + proc_area.dest_addr = 0;
774 + proc_area.act_size = 0;
775 +
776 + cpu_physical_memory_write(PROC_DUMP_AREA_OFF, &proc_area,
777 + sizeof(proc_area));
778 + }
779 +
780 fdt = machine->fdt;
781 cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));
782 }