Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 18EE5C3DA7F for ; Wed, 31 Jul 2024 14:44:48 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZAYt-0005VE-EL; Wed, 31 Jul 2024 10:44:19 -0400 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 1sZAYr-0005Pe-QB; Wed, 31 Jul 2024 10:44:17 -0400 Received: from mail.ozlabs.org ([2404:9400:2221:ea00::3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZAYp-0004WI-Ii; Wed, 31 Jul 2024 10:44:17 -0400 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4WYvxH7099z4wym; Thu, 1 Aug 2024 00:44:03 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mail.ozlabs.org (Postfix) with ESMTPSA id 4WYvxF3FJxz4wcl; Thu, 1 Aug 2024 00:44:01 +1000 (AEST) Message-ID: <5dfc59ec-fa30-47c5-a4e0-edea921098d3@kaod.org> Date: Wed, 31 Jul 2024 16:43:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] hw/ppc: Implement -dtb support for PowerNV To: Aditya Gupta , Mahesh J Salgaonkar , Madhavan Srinivasan , Nicholas Piggin , Harsh Prateek Bora , =?UTF-8?B?RnLDqWTDqXJpYyBCYXJyYXQ=?= Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org References: <20240731132235.887918-1-adityag@linux.ibm.com> Content-Language: en-US, fr From: =?UTF-8?Q?C=C3=A9dric_Le_Goater?= In-Reply-To: <20240731132235.887918-1-adityag@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=2404:9400:2221:ea00::3; envelope-from=SRS0=ZOnj=O7=kaod.org=clg@ozlabs.org; helo=mail.ozlabs.org X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Hello Aditya, On 7/31/24 15:22, Aditya Gupta wrote: > Currently any device tree passed with -dtb option in QEMU, was ignored > by the PowerNV code. > > Read and pass the passed -dtb to the kernel, thus enabling easier > debugging with custom DTBs. I thought we had enough controls with the QEMU command line options to generate a custom DTB. We should improve that first. Unless you want to mimic a bogus DTB as generated by hostboot and check skiboot behavior. Can you explain more the use case please ? Is it for skiboot testing ? Thanks, C. > The existing behaviour when -dtb is 'not' passed, is preserved as-is. > > But when a '-dtb' is passed, it completely overrides any dtb nodes or > changes QEMU might have done, such as '-append' arguments to the kernel > (which are mentioned in /chosen/bootargs in the dtb), hence add warning > when -dtb is being used > > Signed-off-by: Aditya Gupta > > --- > This is an RFC patch, and hence might not be the final implementation, > though this current one is a solution which works > > --- > hw/ppc/pnv.c | 29 ++++++++++++++++++++++++++--- > 1 file changed, 26 insertions(+), 3 deletions(-) > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > index 3526852685b4..12cc909b9e26 100644 > --- a/hw/ppc/pnv.c > +++ b/hw/ppc/pnv.c > @@ -714,6 +714,8 @@ static void pnv_reset(MachineState *machine, ShutdownCause reason) > PnvMachineState *pnv = PNV_MACHINE(machine); > IPMIBmc *bmc; > void *fdt; > + FILE *fdt_file; > + uint32_t fdt_size; > > qemu_devices_reset(reason); > > @@ -736,10 +738,31 @@ static void pnv_reset(MachineState *machine, ShutdownCause reason) > } > } > > - fdt = pnv_dt_create(machine); > + if (machine->dtb) { > + warn_report("with manually passed dtb, some options like '-append'" > + " might ignored and the dtb passed will be used as-is"); > > - /* Pack resulting tree */ > - _FDT((fdt_pack(fdt))); > + fdt = g_malloc0(FDT_MAX_SIZE); > + > + /* read the file 'machine->dtb', and load it into 'fdt' buffer */ > + fdt_file = fopen(machine->dtb, "r"); > + if (fdt_file != NULL) { > + fdt_size = fread(fdt, sizeof(char), FDT_MAX_SIZE, fdt_file); > + if (ferror(fdt_file) != 0) { > + error_report("Could not load dtb '%s'", > + machine->dtb); > + exit(1); > + } > + > + /* mark end of the fdt buffer with '\0' */ > + ((char *)fdt)[fdt_size] = '\0'; > + } > + } else { > + fdt = pnv_dt_create(machine); > + > + /* Pack resulting tree */ > + _FDT((fdt_pack(fdt))); > + } > > qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); > cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt));