From nobody Fri Apr 4 21:13:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1739776899; cv=none; d=zohomail.com; s=zohoarc; b=bMPbWb0jnyLzZeGEwx2qREGhVkUd5kWd+KvdYGs6VDR/U9RozcABAiRTZbSzJb1NBOylV5g3Bu6vxrmnhKetBEOxCJc3KjOkSntnR6MviDJTNGMJM//1B8aCnn4dZntwiVmNg/7fXDg2XYk07DJFT64VvIvwB/x7xEodUEW7wFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739776899; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CIEQUAzOgWg0GTUB9vpmPnI0WjpRuU17T/q/hej9LkI=; b=ezRwuQE1t3ztaw83abkQeGCyBDdkQmkh4pnIcNXZpEZaV2edqSYT2s0n9ILC+mxBmhBwE32WESs2oh5abtIRuuwIlR/I9P4ELqNp7jpcrY+cis8pPI1JbKo0A/d/qw8j6tbsZkwtAvlalI2/Vm0iiYHvWqJfHVY9D7mQiiQuVxE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17397768992671017.1851194276825; Sun, 16 Feb 2025 23:21:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tjvQc-0001Wu-Us; Mon, 17 Feb 2025 02:20:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjvQZ-0001S2-BI; Mon, 17 Feb 2025 02:20:29 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tjvQW-00033v-3K; Mon, 17 Feb 2025 02:20:26 -0500 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 51GLj4Sb022143; Mon, 17 Feb 2025 07:20:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44ujutjnb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Feb 2025 07:20:22 +0000 (GMT) Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 51H7KMhl024604; Mon, 17 Feb 2025 07:20:22 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44ujutjnb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Feb 2025 07:20:21 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 51H355df008164; Mon, 17 Feb 2025 07:20:21 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 44u58td574-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 17 Feb 2025 07:20:21 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 51H7KHcN57606460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 17 Feb 2025 07:20:17 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A34562004E; Mon, 17 Feb 2025 07:20:17 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A263220049; Mon, 17 Feb 2025 07:20:07 +0000 (GMT) Received: from li-3c92a0cc-27cf-11b2-a85c-b804d9ca68fa.in.ibm.com (unknown [9.109.199.160]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 17 Feb 2025 07:20:07 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=CIEQUAzOgWg0GTUB9 vpmPnI0WjpRuU17T/q/hej9LkI=; b=pc/fxe7nWaagLYX31AFd9IJ0ooDk7yaYC tn0Nlx6xa4bL9N/utle65NZRY0R/j7cPyDauViKS1pLe5FyDE6JT2aypfjai98jU 1NGQRzpXs9PEXryXylWPDM8yE04pCoOxheGRtZa/qy4GilMho+an3CY6DQdu8r5U 9Asqw6a8aH2oAZJwsia2hGtFP/aoqF+dgYQj0fhS+wZYz5jIBGoM6dY3euV8zGu7 I6CVUvBnuHMzGKQoJVc+7KlCScpEUZoYJYOFGgwQhKW7wfuhTPBb+RpAz3cSYRqp Ebsvqy2OLK5JreQ4NTIP7QV1wY/3AQ/hhvWl8LgpedK43Ppqqhv4g== From: Aditya Gupta To: Cc: , Nicholas Piggin , =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Barrat?= , Sourabh Jain , Mahesh J Salgaonkar , Hari Bathini Subject: [PATCH 7/7] hw/ppc: Implement MPIPL in PowerNV Date: Mon, 17 Feb 2025 12:49:34 +0530 Message-ID: <20250217071934.86131-8-adityag@linux.ibm.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250217071934.86131-1-adityag@linux.ibm.com> References: <20250217071934.86131-1-adityag@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: bpG-yvLp2cKJEtVydhqe2hyaLyecSQJq X-Proofpoint-GUID: -PLp7_MnXs8UZ8sqtCdsEwFk3c8geFhm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-17_03,2025-02-13_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2501170000 definitions=main-2502170060 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=adityag@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1739776901317019100 Content-Type: text/plain; charset="utf-8" Linux expect a "ibm,opal/dump" node to know whether MPIPL (aka fadump) is supported on the hardware. Export the "ibm,opal/dump" node in QEMU's device tree for Linux to know that PowerNV supports MPIPL. With the commit, kernel boots thinking fadump is supported, and reserves memory regions for fadump if "fadump=3Don" is passed in kernel cmdline: Linux/PowerPC load: init=3D/bin/sh debug fadump=3Don Finalizing device tree... flat tree at 0x20ebaca0 [ 1.005765851,5] DUMP: Payload sent metadata tag : 0x800002a8 [ 1.005980914,5] DUMP: Boot mem size : 0x40000000 [ 0.000000] opal fadump: Kernel metadata addr: 800002a8 [ 0.000000] fadump: Reserved 1024MB of memory at 0x00000040000000 (S= ystem RAM: 20480MB) [ 0.000000] fadump: Initialized 0x40000000 bytes cma area at 1024MB = from 0x400102a8 bytes of memory reserved for firmware-assisted dump Also, OPAL and Linux expect the "mpipl-boot" device tree node on a MPIPL boot. Hence add "mpipl-boot" property in device tree on an MPIPL boot. Hence after crash, Linux knows when it's a MPIPL/fadump boot: [ 0.000000] opal fadump: Firmware-assisted dump is active. [ 0.000000] fadump: Firmware-assisted dump is active. [ 0.000000] fadump: Reserving 23552MB of memory at 0x00000040000000 = for preserving crash data Do note that fadump boot in PowerNV seems to require more memory, trying with 1GB causes this error by kernel: [ 0.000000] fadump: Failed to find memory chunk for reservation! And even with anything from 2GB - 19GB, the kernel fails to boot due to some memory issues. Trying with >20GB memory is recommended for now Signed-off-by: Aditya Gupta --- hw/ppc/pnv.c | 49 ++++++++++++++++++++++++++++++++++++++++ hw/ppc/pnv_sbe.c | 18 +++++++++++---- include/hw/ppc/pnv_sbe.h | 4 ++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 11fd477b71be..39ed3f873e9a 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -51,6 +51,7 @@ #include "hw/ppc/pnv_chip.h" #include "hw/ppc/pnv_xscom.h" #include "hw/ppc/pnv_pnor.h" +#include "hw/ppc/pnv_sbe.h" =20 #include "hw/isa/isa.h" #include "hw/char/serial-isa.h" @@ -697,6 +698,26 @@ static void *pnv_dt_create(MachineState *machine) pmc->dt_power_mgt(pnv, fdt); } =20 + /* Add "dump" node so kernel knows MPIPL (aka fadump) is supported */ + off =3D fdt_add_subnode(fdt, 0, "ibm,opal"); + if (off =3D=3D -FDT_ERR_EXISTS) { + off =3D fdt_path_offset(fdt, "/ibm,opal"); + } + + _FDT(off); + off =3D fdt_add_subnode(fdt, off, "dump"); + _FDT(off); + _FDT((fdt_setprop_string(fdt, off, "compatible", "ibm,opal-dump"))); + + /* Add kernel and initrd as fw-load-area */ + uint64_t fw_load_area[4] =3D { + cpu_to_be64(KERNEL_LOAD_ADDR), cpu_to_be64(KERNEL_MAX_SIZE), + cpu_to_be64(INITRD_LOAD_ADDR), cpu_to_be64(INITRD_MAX_SIZE) + }; + + _FDT((fdt_setprop(fdt, off, "fw-load-area", + fw_load_area, sizeof(fw_load_area)))); + return fdt; } =20 @@ -714,6 +735,7 @@ static void pnv_reset(MachineState *machine, ResetType = type) PnvMachineState *pnv =3D PNV_MACHINE(machine); IPMIBmc *bmc; void *fdt; + int node_offset; =20 qemu_devices_reset(type); =20 @@ -744,6 +766,33 @@ static void pnv_reset(MachineState *machine, ResetType= type) _FDT((fdt_pack(fdt))); } =20 + /* + * If it's a MPIPL boot, add the "mpipl-boot" property, and reset the + * boolean for MPIPL boot for next boot + */ + if (pnv_sbe_is_mpipl_boot()) { + void *fdt_copy =3D g_malloc0(FDT_MAX_SIZE); + + /* Create a writable copy of the fdt */ + _FDT((fdt_open_into(fdt, fdt_copy, FDT_MAX_SIZE))); + + node_offset =3D fdt_path_offset(fdt_copy, "/ibm,opal/dump"); + _FDT((fdt_appendprop_u64(fdt_copy, node_offset, "mpipl-boot", 1))); + + /* Update the fdt, and free the original fdt */ + if (fdt !=3D machine->fdt) { + /* + * Only free the fdt if it's not machine->fdt, to prevent + * double free, since we already free machine->fdt later + */ + g_free(fdt); + } + fdt =3D fdt_copy; + + /* This boot is an MPIPL, reset the boolean for next boot */ + pnv_sbe_reset_is_next_boot_mpipl(); + } + qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt)); =20 diff --git a/hw/ppc/pnv_sbe.c b/hw/ppc/pnv_sbe.c index 3b50667226b5..671dc81c9501 100644 --- a/hw/ppc/pnv_sbe.c +++ b/hw/ppc/pnv_sbe.c @@ -216,6 +216,18 @@ struct proc_dump_area { __be32 act_size; /* Actual data size */ } __packed; =20 +static bool is_next_boot_mpipl; + +bool pnv_sbe_is_mpipl_boot(void) +{ + return is_next_boot_mpipl; +} + +void pnv_sbe_reset_is_next_boot_mpipl(void) +{ + is_next_boot_mpipl =3D false; +} + static void pnv_sbe_set_host_doorbell(PnvSBE *sbe, uint64_t val) { val &=3D SBE_HOST_RESPONSE_MASK; /* Is this right? What does HW do? */ @@ -334,10 +346,8 @@ static void pnv_sbe_power9_xscom_ctrl_write(void *opaq= ue, hwaddr addr, /* Save processor state */ pnv_mpipl_save_proc_regs(); =20 - /* - * TODO: Pass `mpipl` node in device tree to signify next - * boot is an MPIPL boot - */ + /* Mark next boot as Memory-preserving boot */ + is_next_boot_mpipl =3D true; =20 /* Then do a guest reset */ /* diff --git a/include/hw/ppc/pnv_sbe.h b/include/hw/ppc/pnv_sbe.h index f6cbcf990ed9..94bbdc7b6414 100644 --- a/include/hw/ppc/pnv_sbe.h +++ b/include/hw/ppc/pnv_sbe.h @@ -56,4 +56,8 @@ struct PnvSBEClass { /* Helper to access stashed SKIBOOT_BASE */ bool pnv_sbe_mpipl_skiboot_base(void); =20 +/* Helpers to know if next boot is MPIPL boot */ +bool pnv_sbe_is_mpipl_boot(void); +void pnv_sbe_reset_is_next_boot_mpipl(void); + #endif /* PPC_PNV_SBE_H */ --=20 2.48.1