From nobody Sat Nov 23 23:50:37 2024 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730679969; cv=none; d=zohomail.com; s=zohoarc; b=XWupyH7wndaoJF7y+eyWkBM/QY3gDn5w3NVAMZxeVu0W3sSynyoNhfEJjlZw/vu1YmVhBU1Gdyou5OPYrJf6MZijPyiTwL+3Z3kFv4HDbp3WSrwjARi+lMoLd0A/L/40R0wJitt21CLeKVMfYG5MxVJB474cT2sqPDqlUoSPjHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730679969; 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=qjrKzQxSpQ20SJEUNd7c887GiOBsc4dW1KUxIdtg7vI=; b=BWCNhOoriqIdolGr6qY/wBsFIzkYLcAeMHDsQZFA5l0PbfxkmNd6A3d6xTuYgyM2jln6nH4XGcvQCvEcwYT2YfWZ6dxxfYA7T083DYY0xTwhpZAqKThz99FWC50g2nE2nbCo+qDJL7Rqs1RtWykhwxWa87nd+CXBdyRSIqgMzIQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730679969611533.0100102543016; Sun, 3 Nov 2024 16:26:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t7krK-0006Oi-UQ; Sun, 03 Nov 2024 19:22:18 -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 1t7kr3-0005N9-Fy; Sun, 03 Nov 2024 19:22:04 -0500 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t7kr1-0002jw-9T; Sun, 03 Nov 2024 19:22:01 -0500 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-720cb6ac25aso2512910b3a.3; Sun, 03 Nov 2024 16:21:57 -0800 (PST) Received: from wheely.local0.net (124-171-217-17.tpgi.com.au. [124.171.217.17]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7ee45a0081esm5900648a12.59.2024.11.03.16.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 16:21:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730679717; x=1731284517; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qjrKzQxSpQ20SJEUNd7c887GiOBsc4dW1KUxIdtg7vI=; b=SnGs5zbu6ZacGjy+8Hu9FtjH2H1L3jJZG4VOqdQswsesS0F8JDl9HYBvS3jNJyBRwJ 1nPMArdFAQrEHvS+NGl0GVTCnJVk2B0dBXPwlsaoGNfMezO2wXdam9LxE+VTRC0FwcBO WtaOa4/IDiQRGrUDfVIH+azJGl9csSG73GvmTeGeitxIpyHkBrA4rGFcqgvGW5D8TK+/ NSRmMFqew9YvNPhfTH6gHGzid+sVRQdOYPFIcn2Nr8HYoP+HfCumdFDGrH0YO1mKacfF L2TtXgCm+4T/8U9HWhIFkYwJQshCKxD11Sp/RNnMIhV3PgX845Ldg0p9yW2An/1tQs+c EDKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730679717; x=1731284517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qjrKzQxSpQ20SJEUNd7c887GiOBsc4dW1KUxIdtg7vI=; b=REK/LWt8UXJhb+g9R2M9ZvQD7EHT0iR1AqRMh84bt9wsEKvYI7NRn24MbldetO0zZx 59nQTfsQYi92gfao3+3Hyn5Ipzt9fsXV2L6h2iji3zl+BFLJewcTOV23nQhRVAE4MJ++ OhmI/wIqXrJtFK/RS2h8l/oagghY9UYmvTnMGebnFe9Dud6DweOE4S01L4WagXXGrBMA vhcNAaGQoB5yFefIca9kGcDdz4lsSj5XdcJXTNvCXpuKo2KoWqNN8rSLYZuFRkpRfs+C XQpAGWMMSu1O8abRcxPHDEVCShKTBHG05gbRp17lj4eco0OiHkHHolNvX3mcU+k8ANR2 FMYg== X-Forwarded-Encrypted: i=1; AJvYcCU5SHiT38/9PC5MHaRdO3Yrokg7MwEx1oW7to453Egyspj/wemlthQNh4Nv838f2ODIWdJJ/qQ25w==@nongnu.org X-Gm-Message-State: AOJu0YxtLTVr5N7famX+bU+IMS2bjsx6j6GDbNttI0TrdBIPObNI64O4 cBE2e7D5MuaoLzbUYxdG2kwsmUXu6wA1/pYtsZTN55BTQzMcQoLvs9hS1g== X-Google-Smtp-Source: AGHT+IG/KHQNSr8NID9bxbR/QYbTbrey8O/A5mNKLYKasroBxemDPgnWuT5T16b054v9I7yCmg9cOA== X-Received: by 2002:a05:6a21:1690:b0:1d9:3456:b794 with SMTP id adf61e73a8af0-1d9a84bcdd6mr45310503637.38.1730679716499; Sun, 03 Nov 2024 16:21:56 -0800 (PST) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org, Aditya Gupta Subject: [PULL 46/67] hw/ppc: Implement -dtb support for PowerNV Date: Mon, 4 Nov 2024 10:18:35 +1000 Message-ID: <20241104001900.682660-47-npiggin@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104001900.682660-1-npiggin@gmail.com> References: <20241104001900.682660-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::436; envelope-from=npiggin@gmail.com; helo=mail-pf1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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 @gmail.com) X-ZM-MESSAGEID: 1730679970110116600 Content-Type: text/plain; charset="utf-8" From: Aditya Gupta 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. 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 Reviewed-by: Nicholas Piggin Signed-off-by: Aditya Gupta Signed-off-by: Nicholas Piggin --- hw/ppc/pnv.c | 51 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 795acc289f..f0f0d7567d 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -736,21 +736,27 @@ static void pnv_reset(MachineState *machine, ResetTyp= e type) } } =20 - fdt =3D pnv_dt_create(machine); - - /* Pack resulting tree */ - _FDT((fdt_pack(fdt))); + if (machine->fdt) { + fdt =3D machine->fdt; + } else { + fdt =3D pnv_dt_create(machine); + /* Pack resulting tree */ + _FDT((fdt_pack(fdt))); + } =20 qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt)); =20 - /* - * Set machine->fdt for 'dumpdtb' QMP/HMP command. Free - * the existing machine->fdt to avoid leaking it during - * a reset. - */ - g_free(machine->fdt); - machine->fdt =3D fdt; + /* Update machine->fdt with latest fdt */ + if (machine->fdt !=3D fdt) { + /* + * Set machine->fdt for 'dumpdtb' QMP/HMP command. Free + * the existing machine->fdt to avoid leaking it during + * a reset. + */ + g_free(machine->fdt); + machine->fdt =3D fdt; + } } =20 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp) @@ -952,6 +958,14 @@ static void pnv_init(MachineState *machine) g_free(sz); exit(EXIT_FAILURE); } + + /* checks for invalid option combinations */ + if (machine->dtb && (strlen(machine->kernel_cmdline) !=3D 0)) { + error_report("-append and -dtb cannot be used together, as passed" + " command line is ignored in case of custom dtb"); + exit(EXIT_FAILURE); + } + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 /* @@ -1003,6 +1017,21 @@ static void pnv_init(MachineState *machine) } } =20 + /* load dtb if passed */ + if (machine->dtb) { + int fdt_size; + + warn_report("with manually passed dtb, some options like '-append'" + " will get ignored and the dtb passed will be used as-is"); + + /* read the file 'machine->dtb', and load it into 'fdt' buffer */ + machine->fdt =3D load_device_tree(machine->dtb, &fdt_size); + if (!machine->fdt) { + error_report("Could not load dtb '%s'", machine->dtb); + exit(1); + } + } + /* MSIs are supported on this platform */ msi_nonbroken =3D true; =20 --=20 2.45.2