From patchwork Thu Feb 6 15:12:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862519 Delivered-To: patch@linaro.org Received: by 2002:adf:ea4b:0:b0:386:330a:81a2 with SMTP id j11csp173885wrn; Thu, 6 Feb 2025 07:13:21 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVJetVTn7LJLmhooo9EKXB9k5SsBgAcrlHjDUgd+wG/YeNfJaTyeO/XOv7dUzz7rgUARLKjeA==@linaro.org X-Google-Smtp-Source: AGHT+IFW/qQJLyZgWjWtDNlMHEiNTudkM3kTvbEGWA0HrUpeeu8Rp4AF/EZB0WyUo5ACiXGfEmMo X-Received: by 2002:a05:6122:2905:b0:515:1fde:1cb1 with SMTP id 71dfb90a1353d-51f1c272236mr2355041e0c.3.1738854800833; Thu, 06 Feb 2025 07:13:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854800; cv=none; d=google.com; s=arc-20240605; b=Gh8HQOE24WNGgSBHP1B51BDlDhnt/fdCtO+1PT9JirX3h4dfQ/Vp5hYSCqifyAALQ8 sLt1oXlETpLH6NOkqxO/5ZQjABbDdZSKehnggS1iX3F3oUSiKN+4bp0mdX6aFROcpWDD kna27nIoKdTNaDeKSDXEG6kRwaLq7V/UEIElyb1EpTIl/+sSyL5XTZDqrIsSA2ywXCJ7 hleAO6c/6BValcsyBQbXUkpfiCPFwRNbtLQm/JVR2bPZkptyB/E0mwWT0SG5YSoXuASw Irgp1An6F5rgvdx6Cj/RpyX3Wurpw6X0UaqMCQRWgG3KIkTRA1LCmcVVoOWwIlcHyQZv 7X/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OBNYNjCfYi4QoRh0F+kJieima3x5PkzU8IjA7dU/mlo=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=GwXMkH07PimVhO8dmGdZ3IzWgLFE3vgWdDtMKuk0iSs6EUTXtFASU+TaeMyKF0xFYQ Dqdh85wn4HAs29N9rCv9CeY5QyRYW9BJImMyA9pjeVQd9zMapyTGyqH2sIjUZblHcMWi 89PLVpacGUh8pGaqR/Gwlrm56zFn4jxfDn3gF9Nr4Zpo3br/hhDMVXFX/uS9q2bB56O1 /yOpwcCRtL1DMhFNkWniEzI/wnaWYbRJC30c0mlV+oI53MFVPMNbucVYDX2DsQUW2x1Y FJI1XFuQ03OC4GeC7zB9YWYVcdK5Rx2KgfJyKBeSsyQ89eHvkP3JM0qSY2ANvByXyWyo uM1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GytINZ5A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-51f2292edacsi220144e0c.122.2025.02.06.07.13.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:13:20 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GytINZ5A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YG-0000Wn-Id; Thu, 06 Feb 2025 10:12:24 -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 1tg3YE-0000Vk-64 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:23 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YB-00013e-KL for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:21 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-436a03197b2so7093045e9.2 for ; Thu, 06 Feb 2025 07:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854738; x=1739459538; 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=OBNYNjCfYi4QoRh0F+kJieima3x5PkzU8IjA7dU/mlo=; b=GytINZ5AHEP0t42WDUKymQ538wjb8A3XJZ2YYKgwXJ+ne5Mf9/QGr5zS/Gj5o4ORTm dRDeyGxlOIy72q7hKg+Jj83+pvrIO+oKocx6qlVjoxu7YViu27KQQJcfDi+bM6Zh4YR+ vsLrWb1SoiEsSTyKJ9yvFP4YJEZhvPGVDu1RDO0niNQe74w6TRulWYY1rWgqO5PlNDVK mbQg3yMq2YiBAWr6bT5F3waykfW4bbxmZCG6tIglJG8q1zozjCgigD7iq7xf3X0F2zWR lGzi+Dm6RNiGjFYhYqFNxiIn1WMBY9/4LMWUZsxS4t5LOKDr6bJApLSqRdnrobw88zd2 W3YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854738; x=1739459538; 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=OBNYNjCfYi4QoRh0F+kJieima3x5PkzU8IjA7dU/mlo=; b=DKqLso4gi3JfGehQChp+E2B7Yn1Ag7vW5VvNeu1Xckl64kJ8kJFDwcokIJu2LJ59ep xevUY+C8+Orvl9OOfd5Yzml/JX8OYH+QFtlNkhO4U01fStv8VncHyq1HZDMqCZR4rYWS LA1DL8eYTovN4ebfKvlfS/vIz70rLDhj7xe9+fmeOGF83t5lCfiK1rqq47gtITmlqehz mXAhSeIpeHxgNb3rdh8oFtptTjySkwGFh8WIQVSLKTmBfTuHjt0ULH93j2/hmwZVQGpO WMCh56E1GvoIM0RtDMTRahumZ9gdTvb92wzKCbvBfu8H4wfeXzV/UIm9sVkp1SAJ3YPe lHrA== X-Gm-Message-State: AOJu0YzgN+JKIlfixu/TzOBt/hWzWRTGAOynVbVCG7ypDJv5T33Cki+b OxA99sKEwVqyu0IM3Z2GN6E+U8HuK5bsX/41xQ2aHtqX+ceLIcnQtxg2teY8ppN6BswBHmCXkGN D X-Gm-Gg: ASbGncvW3nS3ItIM3TMPYX0qQimR7VYwd2lNpJDg4WVHLV315wXm9Br4ZCMkwFZ+Wb8 G8dD/DVgPzBI/ntjRVbVVR5TGVJNikaZE4QKiiClIBb8f5KDJegplm3GIzULOfDyM3a8ZqpYVvW 03Od2vWlq9gEzWwdbJcOFCo62PZOIEcpzYgqqHfjhcm0qVzuuACiU3Ty5lxBzoMct7Kf6b7EldZ iEmcm4BAV8sKXjGDLVtvo45AwJs4EKmLKwnTVAWG8hSyJ7iEvhloX95ninOFX0cLaH7ylIpszNl z/41Xy73I+d9S+I8O21mLQ== X-Received: by 2002:a05:600c:1d1e:b0:436:faeb:2a1b with SMTP id 5b1f17b1804b1-4390d43e579mr58801755e9.13.1738854737474; Thu, 06 Feb 2025 07:12:17 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:16 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 1/6] monitor/hmp-cmds.c: Clean up hmp_dumpdtb printf Date: Thu, 6 Feb 2025 15:12:09 +0000 Message-Id: <20250206151214.2947842-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org In hmp_dumpdtb(), we print a message when the command succeeds. This message is missing the trailing \n, so the HMP command prompt is printed immediately after it. We also weren't capitalizing 'DTB', or quoting the filename in the message. Fix these nits. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- monitor/hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 0aa22e1ae27..ff87fd89e4d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -431,6 +431,6 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict) return; } - monitor_printf(mon, "dtb dumped to %s", filename); + monitor_printf(mon, "DTB dumped to '%s'\n", filename); } #endif From patchwork Thu Feb 6 15:12:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862518 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp164737wrv; Thu, 6 Feb 2025 07:13:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCU0kvjAv6+WinNYuNyMhLfeVkQ5UzF17e5uUhbUvBrBSJQc+GEfapw37fs66hmU4qGxuYEQag==@linaro.org X-Google-Smtp-Source: AGHT+IGvKtuxz2/I7gvsZuEoGwbZDPxZUbYKrfhE+KkK88L825OY7vBQanAQcO62iQxTfvRrCO7W X-Received: by 2002:a05:620a:400f:b0:7b6:e9db:3b19 with SMTP id af79cd13be357-7c03a047b6cmr1075176085a.47.1738854799643; Thu, 06 Feb 2025 07:13:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854799; cv=none; d=google.com; s=arc-20240605; b=f7izJ2Npu2J9vxRh8C8pd+j+aexm6nly959fZM+sP0Kw15LNvO2B8tdUl5eT1cLWcu V2tvASR/I1ax43gEkHFrgF7gUwxIdKEVQg/1Kw5UpS6OpcExEQGUKyMHfI/pHj+X31ak PkZ0iEBGIqIL7xZ4sZICjWAYWEwwXcX5f+wST9GCGJFQDH9kqt9t//9UObDfYrOFglDq VZ/NyL4zBNhYLe1hIHVMu2ETtdGL8IzEs7OsM/Pg1NpQ6x/sgjWhCQMJ+3rcKsIwVJV0 tHy9eqybANbyByZxgvTW/KUb2XHKN3xHa+RXBjic+K38KdB4p0x9Jc5rzz2wnKQiYulX j08Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Dyc4k4zZ3UDjTeOj4G3vch41PnGrPu5ooBf/NMqW0u8=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=RZB0ANVZ71ea3/h9ZgsJg+Q+cPlEPhxnpb4qLYZmDP/jJyPVMssCnVxd9L4IYGB1Pj LR+8+AE84ML09lIH50U+Gg5WbpaReOnB+wBOBXl0S1TMP/2wbScdrhxJIS/B9raES4ze rsggPQh9PFjWhiE+q+YQzRT/6lN0t+bTwAmqCvRdBtEJ81s3GCOEZSM/LfH8LGN3hQAb 9jNYjPEWyL/UAFdU/Ue9E0zBFxWeu2V2EQM49/7jqeo1XTXez1sNBem/TmS4yXfoCBiw VJsyFZYOJK+TB+dntHSzNFTxRNqMp0cdzde9IBSopCLzvqCn9mDXk36LvUbx+kz7HrO7 pEtw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xih5rxwU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-866f963edfasi214893241.68.2025.02.06.07.13.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:13:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Xih5rxwU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YI-0000Y3-83; Thu, 06 Feb 2025 10:12:26 -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 1tg3YE-0000Vt-9X for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:23 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YC-00013m-9d for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:21 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-437a92d7b96so10230475e9.2 for ; Thu, 06 Feb 2025 07:12:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854738; x=1739459538; 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=Dyc4k4zZ3UDjTeOj4G3vch41PnGrPu5ooBf/NMqW0u8=; b=Xih5rxwUrZhpx/r741Y/GOmx4ptWOkxgwnUEs2rv1t3fA/68/yf0Kk/HbekxH4YrgZ llMrZoqT0FhotzENKVhEHa2tcvCvbHTVVwp6uGc0Kh4Cleu36XIR1JPXbG3FJwyvB+he rsJdLGLNYJo89x8F2MOMyp3tcTB5gjYjuXx2ZprTlGZ4BPfx+zG3XdnPYFB8GTP//raW U4BhQ8EONFyRgbSOEMiEhimk7MUG7YN3MB7Le0q7fX/F5W8Xe1cXG9M2t1yRU7v5jhaX 7/ZgMwVc/lo13ONFQlEefDKMXzeto06OR+0/rF6YBv4kmWuNydsafckuO+JorfKWK7ia cibA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854738; x=1739459538; 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=Dyc4k4zZ3UDjTeOj4G3vch41PnGrPu5ooBf/NMqW0u8=; b=sdIAOjPRmTb+SRPJUD5YX5LlPlNt/PPTr15ehy2c1XzNpIe9GbAFIGoKbsga59b+BU SvdMzLKgwYcOUoDvumgO5W5UMhgg+b2jXsYZjBLvhlogbhSIvjzRqhopnjafVCms8CPP hQdcCajXOh1stBuTF+kzmnTW7W0h+1l4fbKO2cCElou3S0taokaEV5CELBbzKR3zwDAw tfFCquoiuRByP09tgAipEV0QpOQOiqHKoR3rs7NQA8DYikROeClxRAXUWWZ/3c93sBtz vNbokwIrr+8YKyOT0Wsx9BRIprXzVOu09ARK/f3hGUsD74kZj284YlDIfCnJ7OqPYtxw vISQ== X-Gm-Message-State: AOJu0Yy9JXHCf0JTZ9mIg02KXZHX/Gz/PDQOmxFtns5CGdvNe48eqPWh 8Ioj0qtkEQnpBCEv2esmBbjd+N7YotZ4nXCJbMPLgfS7oVVzCkgpvnEM4NWoVIXDVPQ3GiNm+pv Y X-Gm-Gg: ASbGncujuhGnz3zT26VYCbAdn6A8IA2eswE22oxUxYMHy4x4hsVJ0U8wObwRvamXy+9 rRJv7J+d62AsKuuQgyRFPb8V/mgSdcmSkWvBPblhK7EbLYofVPSsT9NJPyTE36JMDv71u02Y4kG ULXVuJTqPnwGVKMiI3YgBesPSDUqr3wrkSO3BX0gIBe5WZeXlV1PTMp1u+7WwAjww4RSdTIB7f8 AXV8AZL9jTUYuxFw/tTnHzXNCV2I9AoJmje8rx2xiMTIsXgb2dRI/nXrstovCdn2ExLTa6CPyYJ 3ZJvLWe2u91Hl2bePUCNVw== X-Received: by 2002:a05:600c:3b0f:b0:434:e9ee:c2d with SMTP id 5b1f17b1804b1-4390d56c256mr48427715e9.26.1738854738483; Thu, 06 Feb 2025 07:12:18 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:17 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 2/6] hw/openrisc: Support monitor dumpdtb command Date: Thu, 6 Feb 2025 15:12:10 +0000 Message-Id: <20250206151214.2947842-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The openrisc machines don't set MachineState::fdt to point to their DTB blob. This means that although the command line '-machine dumpdtb=file.dtb' option works, the equivalent QMP and HMP monitor commands do not, but instead produce the error "This machine doesn't have a FDT". Set MachineState::fdt in openrisc_load_fdt(), when we write it to guest memory. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/hw/openrisc/boot.h | 3 ++- hw/openrisc/boot.c | 7 +++++-- hw/openrisc/openrisc_sim.c | 2 +- hw/openrisc/virt.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/hw/openrisc/boot.h b/include/hw/openrisc/boot.h index 25a313d63a1..9b4d88072c4 100644 --- a/include/hw/openrisc/boot.h +++ b/include/hw/openrisc/boot.h @@ -20,6 +20,7 @@ #define OPENRISC_BOOT_H #include "exec/cpu-defs.h" +#include "hw/boards.h" hwaddr openrisc_load_kernel(ram_addr_t ram_size, const char *kernel_filename, @@ -28,7 +29,7 @@ hwaddr openrisc_load_kernel(ram_addr_t ram_size, hwaddr openrisc_load_initrd(void *fdt, const char *filename, hwaddr load_start, uint64_t mem_size); -uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start, +uint32_t openrisc_load_fdt(MachineState *ms, void *fdt, hwaddr load_start, uint64_t mem_size); #endif /* OPENRISC_BOOT_H */ diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c index 0f08df812dc..72e2756af05 100644 --- a/hw/openrisc/boot.c +++ b/hw/openrisc/boot.c @@ -90,8 +90,8 @@ hwaddr openrisc_load_initrd(void *fdt, const char *filename, return start + size; } -uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start, - uint64_t mem_size) +uint32_t openrisc_load_fdt(MachineState *ms, void *fdt, + hwaddr load_start, uint64_t mem_size) { uint32_t fdt_addr; int ret; @@ -111,6 +111,9 @@ uint32_t openrisc_load_fdt(void *fdt, hwaddr load_start, /* copy in the device tree */ qemu_fdt_dumpdtb(fdt, fdtsize); + /* Save FDT for dumpdtb monitor command */ + ms->fdt = fdt; + rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr, &address_space_memory); qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index e0da4067ba3..d9e0744922a 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -354,7 +354,7 @@ static void openrisc_sim_init(MachineState *machine) machine->initrd_filename, load_addr, machine->ram_size); } - boot_info.fdt_addr = openrisc_load_fdt(state->fdt, load_addr, + boot_info.fdt_addr = openrisc_load_fdt(machine, state->fdt, load_addr, machine->ram_size); } } diff --git a/hw/openrisc/virt.c b/hw/openrisc/virt.c index 7b60bf85094..9afe407b00a 100644 --- a/hw/openrisc/virt.c +++ b/hw/openrisc/virt.c @@ -540,7 +540,7 @@ static void openrisc_virt_init(MachineState *machine) machine->initrd_filename, load_addr, machine->ram_size); } - boot_info.fdt_addr = openrisc_load_fdt(state->fdt, load_addr, + boot_info.fdt_addr = openrisc_load_fdt(machine, state->fdt, load_addr, machine->ram_size); } } From patchwork Thu Feb 6 15:12:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862520 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp164838wrv; Thu, 6 Feb 2025 07:13:41 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW6fr34S5ximMEUaNokXhspwuoLBY5QkgJY3qKmxem2GWS6QmmUN3MeKpYkTTXLWR4VTKz+NQ==@linaro.org X-Google-Smtp-Source: AGHT+IG08JpePXntzlwDDdd+eR3GrwxRBzTU7EBlWFX5ejq3Ob+f6Ie7iVCxatKNwpbEC/We1G9t X-Received: by 2002:a05:6122:e68:b0:515:d230:f2c6 with SMTP id 71dfb90a1353d-51f1c2f4633mr1651259e0c.7.1738854821268; Thu, 06 Feb 2025 07:13:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854821; cv=none; d=google.com; s=arc-20240605; b=ctsvsDCSqYCdN2zURGbhqdoWDRLqckNOelMQc0kY8xlYPSVfU4lBWuZwii4mcjqjkh A22M/A+i6/oO5VWXpypBvI9xOq1iVTcNkPyVzCqWvbRV3fX2rVw5puQ9OpxFmUQtr58A CNFzpYWWD8g3rLgclLOZDSAStQQNhAE8IODWAz6FTcwvXKPPzHbbjqUqMj1BgWln7xHU jYeGVF5g3vQXHqJMpCCIM9GGbnubKAbx6pwB/amQ6iQRi+4l+ZOxB87xSuhwyqyr0HAr xDARcVoim2/pY6967auYHLzEJjeD03Dau3xqcG2ANmG/cKFenbFjFfhByWmoGOJr+hVk K/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hLhEoOyFDF+F7bcPTogQbyGAms0Psz74NYqAb/clUUs=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=hjux2cd93kR6ZvqV+vS8j1bwVZtPx53spnoN/HKmmP25ES3lb/DZVVAywjIO5JLDUn PQ5RRBhPtofVVKChWFdO7a+el33o7KpIYs7sOWdg920zcNU2dg+QUnXcwfAiFpl9fyJ3 AyB+xrYC+Co7lx/P76mFDt0Ah9Hws4GMlUA5ATPL010wBIle5mGTUFbYwc+M13J8iC5u qesoxBVvtHVS8k3BSC+j9Kc2E0hrCa8TMryJsqCHYzTxXkzDq03qslWMdQtIdsCsM6Hi Osehur/wNsM4pNrrEuNU6qbPd+xxgaUDA3SGi2WQPRDki4Q6od2fVfn0cTpIS+nqb3+r y2AA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qgm+1LDf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4ba778b1aabsi242819137.405.2025.02.06.07.13.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:13:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qgm+1LDf; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YH-0000Xr-J6; Thu, 06 Feb 2025 10:12:25 -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 1tg3YF-0000W7-Dm for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:23 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YD-000141-Uf for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:23 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4364a37a1d7so10210475e9.3 for ; Thu, 06 Feb 2025 07:12:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854739; x=1739459539; 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=hLhEoOyFDF+F7bcPTogQbyGAms0Psz74NYqAb/clUUs=; b=qgm+1LDfG3UStZruvs5BDwWEQ1DejSAfwY1E5NAnp7zPgh8HRMtSNKQeWJhCzU4TQb 7PlNJcIPJkNelz1JF8t+3qgPdTLyBpXglaqAKsuwqdvYfhKv69jP8r4zU524PuKPo+ru Cm7SA3S7WVRppYSC/MFH1LOoM0iRu/2hAdIlSlTayipHXNirX2zd60YLNm+YRbOE34Fd JBFlE1RnXA8jrl/wnTyGKt1bANhSkk8h0HeF9UdzOAcFwV/7MuxkEKNSnp0mpITfeV4R fXyAyY3i4BcccTOkqBQtO0qT5AY0f4bPzspoaEwVvIWpSYP/VhcbttUbVKROAsLweI0e mmXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854739; x=1739459539; 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=hLhEoOyFDF+F7bcPTogQbyGAms0Psz74NYqAb/clUUs=; b=svIKMYZiuAXXbQoF1Z3nwj3vzE7/k+e3Ko85FWe06i+GX81ntFkRomhRARhjX4NW3e AUzN5HOjTW0rs53hufJ/+XZ7mjk/BZkyHBF2ygrF8Ao1jzapRkxoKTkReDirrkV7k6Ga nizcLrz/xqlXs9U3SDrW8gy4ZIynLwOqZEZmC+QErRPlxx4aAhQfxqSTd1Jy2Ha2kgHk weu4x0r7P10WlnVeIqFE+oVjrH938IZlu3OghcrrIDGMAjnNjgBvP9qmlZDIppYXWnRM LOnffUp1q7yAc7WuLJRROTHaWyE3toa0/YGUKdpmtr8LxeVTTFQrwZ5TilbCUB4hTtA0 etuA== X-Gm-Message-State: AOJu0Yw2X0aFcUdGjUWlmXKjUCEyN0z9QDp9p/nP369s4HCTQhnGKQCn LTzoeJWOoWDz5oGv9imLWlM+ftymUvhPzifrcldFqQNRXCd44yQTC/EPXpDjNPZNBPD2OcISEeN C X-Gm-Gg: ASbGncuASd3RJJ3VV2d9rs1JTVYva1M/wdSBBo7YhN8B+E1btYYaJT8+H1O8f8BcmaJ OkVbH8twDswA46qP/2aE8WC3B+nbIPNXJOLxMZyVUmQkwBT/Gj0Nual+FMJJqfY0R2D6YjF9LK5 eXWjTOg7O80bSoPY40KqWnO1hQDLzrPeed+f6aCsv4tl2p7TmSUYlgVGbPP/N47oj0M4ZPb20KO VMmuXbfw637chC5ZU1fdJegStuWHLLt4bWOe5oc/rwOZxpmS4QFu538/HUeeFtIwmQY60CrEP9X 1AZE0ruAORJBQOk4djD2Ag== X-Received: by 2002:a05:600c:4f8b:b0:436:469f:2210 with SMTP id 5b1f17b1804b1-4390d42d7efmr49857045e9.1.1738854739471; Thu, 06 Feb 2025 07:12:19 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:18 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 3/6] hw/mips/boston: Check for error return from boston_fdt_filter() Date: Thu, 6 Feb 2025 15:12:11 +0000 Message-Id: <20250206151214.2947842-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The function boston_fdt_filter() can return NULL on errors (in which case it will print an error message). When we call this from the non-FIT-image codepath, we aren't checking the return value, so we will plough on with a NULL pointer, and segfault in fdt_totalsize(). Check for errors here. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- hw/mips/boston.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 364c328032a..f0e9a2461a0 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -810,6 +810,10 @@ static void boston_mach_init(MachineState *machine) dtb_load_data = boston_fdt_filter(s, dtb_file_data, NULL, &dtb_vaddr); + if (!dtb_load_data) { + /* boston_fdt_filter() already printed the error for us */ + exit(1); + } /* Calculate real fdt size after filter */ dt_size = fdt_totalsize(dtb_load_data); From patchwork Thu Feb 6 15:12:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862517 Delivered-To: patch@linaro.org Received: by 2002:adf:ea4b:0:b0:386:330a:81a2 with SMTP id j11csp173770wrn; Thu, 6 Feb 2025 07:13:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5wMum/cnNJDD4rDptOeD97ciH9y6DoOv2kFiIlSBb+0t6oNzU+NXuu231ax5PxnfJtu1J6w==@linaro.org X-Google-Smtp-Source: AGHT+IHOwo+Cb80nBk/WOzwqVLbWcH5qeztMiIc7cfulLL1n7qT3MUSOh2D2jR3WD0icbj3RYWsI X-Received: by 2002:ac5:c809:0:b0:51f:216f:5bc1 with SMTP id 71dfb90a1353d-51f216f6081mr1192501e0c.11.1738854789526; Thu, 06 Feb 2025 07:13:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854789; cv=none; d=google.com; s=arc-20240605; b=hzCa+4T1ihEPUaHW1OsyTvEnBbdrVknBZbQh+svVQcz43K97oyR3UtxrARNRUy52C+ qH96FgsCY5Axvt7eOw0GCtYAWrG9YnsjH2IzCZJ4n0zbc4ogM4r1+l+DUsLsNxj8KZ50 EjsFsiHxCLavkeR6JQ0D1r+TOLe6NLKgHs75ybOGDWhnCCBrgp7oNg5VlDgGuWJaDp4p x6uf3sLB+Zp8PJp1+TTC3h9CqYZF5f6HPHu6ZVQVYGRCkIX4UaDQQADJZ5+MLs/G8O17 6r/0jeeTyviUWxYJDTM3UBeHk5P6QzOE5gJSha9q8xwXZPIm0Jx5zP6uYJRGTrRzsiEQ 4wvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g8TxGdxGszXK4FnFTNRsRq5az6WiULq+qEDjSEW/1ZY=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=g8kvMl5uzVSpk1gYQFJ+6/iB9FVZ7olv2qXJ15GX91CxZZsRhabFORKDOZ7sdvC1SJ gNYeY/UUqzbCaV92K9QPJ0mFCTfvXuhwjhMHkLCPLcUQDu38mnaiAcmZ2mw+nvpIgq6s QWMheTVtiegOSNaiZ7fKK8xyhNTiBAwb5BM7W7H0DlkkPRNAMcTbwUI4RpDStKhyHi1M m87S7fPfQrNcKnHF+lwld0+N6bDOa4M1o8Rt+HiIyeek5QRd1BvVbfizEUalXcslmBRH SUTkdMCELqB/Gpqbqfko/m4XW1aNDisBDTKmLM5kA1GnHDTq2mQNi2RMZcM0Ej2cKnsX 4+oA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=setECVru; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-51f2298e811si217715e0c.246.2025.02.06.07.13.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:13:09 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=setECVru; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YJ-0000YQ-4N; Thu, 06 Feb 2025 10:12:27 -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 1tg3YG-0000Wl-98 for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:24 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YE-00014M-9L for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:24 -0500 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4361c705434so7412275e9.3 for ; Thu, 06 Feb 2025 07:12:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854741; x=1739459541; 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=g8TxGdxGszXK4FnFTNRsRq5az6WiULq+qEDjSEW/1ZY=; b=setECVruKR1HOl+JXJpuGKXNfIiZxafK+Nrhv1U2M8pfUAsLEOJXTf2s+Ut4y8ygkD cc2jxYQKW83QWs/jMHCctzJ4x2AtRlgcHBTd9B3PFQG1tUjRBPHsLvkjTPgGex48/Lp2 4SvtL04HaBhLQwpcPHQA0ISbFpJr5A42vA0iYLTPvlWF9PcD4ZlI8Z347Cv4wQI4vKWk 6r4Dcm6uv1jffJTrvIr916HfjQ/DKxiNFfoPehNykzZmm7hCDE280Vs6DeHfAtyDMSXa xa01syM8K0MaGXNopBIPnSO7yLqG0AxGwWn84pQSOMUoL41qd2DjFPkqSvQZviPt7JC+ hCHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854741; x=1739459541; 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=g8TxGdxGszXK4FnFTNRsRq5az6WiULq+qEDjSEW/1ZY=; b=H5PK7sGxFwO3KvTkgvuAzqp3wVwOPv5x728lNCEOHj1wOZd1vajQH+j/MJ/9USbhwQ UipA8BBVoW5QeBcsAvdUdIWYJxBc5AFjouFegwKRybaWWBorLdvYZlAl+FujB600dMvA P50F5S+fRAqKt00v3GvTkyTh15UM7o468ygg9fZcjJqPR4jWqnKRe5jzpF/Qjamo9niZ bSmagBs88imGfbKvGlZlJNF/lzucWDQuhNj5pUZh2okosdM/07jRd/4JFAfGJnbpliCH 2caCwsI5WE2ZB046eqn849L4QijUWdoqcmaLfE5DpwC3aphHKevbENepBmzV/DfJPw1c dOQA== X-Gm-Message-State: AOJu0YyfPSIC7lf2PG+RN5+ABoRbIEcVwFYczY1bgRyh8jAWkGzBlun0 ac8ALsy5f8DWFgh5BxipE7y+mT02mLRywrA8gg9WMOIjHT/jyLyMnPUnNqCl85CZDG6Zfdbtamc K X-Gm-Gg: ASbGncu/y/wP+zTo9DDBcGW6aK7v+YV1jdkNbINClUsYHznTPLwGjTPVaKBNYvLvyAu yt2xhXMZPWWL0ULm/Sa5iaJSXU1QF9AdeWH/NougB2WUnaLM8ALxOyamwQlpfxIX+Zm0C3pZReO hoTWGwX/a840mvOZOlQKyqkP6kElBEx8mcOKgchvQRcUzAt96o5lVZZM0SFu5fSQ82XjhikFgtH DXAUpabzNB/2WhLYIj/g+na8o8nOgXA+88c1RU2NU6d0QISFNJY5eg1QbVqzvF90+2YI9D56I/l jxuri8NkT6sUyY7QVs77qg== X-Received: by 2002:a05:600c:3c8e:b0:436:f3f6:9582 with SMTP id 5b1f17b1804b1-4390d433bbamr54549495e9.8.1738854740547; Thu, 06 Feb 2025 07:12:20 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:19 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 4/6] hw/mips/boston: Support dumpdtb monitor commands Date: Thu, 6 Feb 2025 15:12:12 +0000 Message-Id: <20250206151214.2947842-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The boston machine doesn't set MachineState::fdt to the DTB blob that it has loaded or created, which means that the QMP/HMP dumpdtb monitor commands don't work. Setting MachineState::fdt is easy in the non-FIT codepath: we can simply do so immediately before loading the DTB into guest memory. The FIT codepath is a bit more awkward as currently the FIT loader throws away the memory that the FDT was in after it loads it into guest memory. So we add a void *pfdt argument to load_fit() for it to store the FDT pointer into. There is some readjustment required of the pointer handling in loader-fit.c, so that it applies 'const' only where it should (e.g. the data pointer we get back from fdt_getprop() is const, because it's into the middle of the input FDT data, but the pointer that fit_load_image_alloc() should not be const, because it's freshly allocated memory that the caller can change if it likes). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- include/hw/loader-fit.h | 21 ++++++++++++++++++--- hw/core/loader-fit.c | 38 +++++++++++++++++++++----------------- hw/mips/boston.c | 11 +++++++---- 3 files changed, 46 insertions(+), 24 deletions(-) diff --git a/include/hw/loader-fit.h b/include/hw/loader-fit.h index 0832e379dc9..9a43490ed63 100644 --- a/include/hw/loader-fit.h +++ b/include/hw/loader-fit.h @@ -30,12 +30,27 @@ struct fit_loader_match { struct fit_loader { const struct fit_loader_match *matches; hwaddr (*addr_to_phys)(void *opaque, uint64_t addr); - const void *(*fdt_filter)(void *opaque, const void *fdt, - const void *match_data, hwaddr *load_addr); + void *(*fdt_filter)(void *opaque, const void *fdt, + const void *match_data, hwaddr *load_addr); const void *(*kernel_filter)(void *opaque, const void *kernel, hwaddr *load_addr, hwaddr *entry_addr); }; -int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque); +/** + * load_fit: load a FIT format image + * @ldr: structure defining board specific properties and hooks + * @filename: image to load + * @pfdt: pointer to update with address of FDT blob + * @opaque: opaque value passed back to the hook functions in @ldr + * Returns: 0 on success, or a negative errno on failure + * + * @pfdt is used to tell the caller about the FDT blob. On return, it + * has been set to point to the FDT blob, and it is now the caller's + * responsibility to free that memory with g_free(). Usually the caller + * will want to pass in &machine->fdt here, to record the FDT blob for + * the dumpdtb option and QMP/HMP commands. + */ +int load_fit(const struct fit_loader *ldr, const char *filename, void **pfdt, + void *opaque); #endif /* HW_LOADER_FIT_H */ diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index 9bdd4fa17c6..6eb66406b07 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -32,8 +32,8 @@ #define FIT_LOADER_MAX_PATH (128) -static const void *fit_load_image_alloc(const void *itb, const char *name, - int *poff, size_t *psz, Error **errp) +static void *fit_load_image_alloc(const void *itb, const char *name, + int *poff, size_t *psz, Error **errp) { const void *data; const char *comp; @@ -80,11 +80,11 @@ static const void *fit_load_image_alloc(const void *itb, const char *name, return NULL; } - data = g_realloc(uncomp_data, uncomp_len); + uncomp_data = g_realloc(uncomp_data, uncomp_len); if (psz) { *psz = uncomp_len; } - return data; + return uncomp_data; } error_setg(errp, "unknown compression '%s'", comp); @@ -177,13 +177,12 @@ out: static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, const void *match_data, - hwaddr kernel_end, Error **errp) + hwaddr kernel_end, void **pfdt, Error **errp) { ERRP_GUARD(); Error *err = NULL; const char *name; - const void *data; - const void *load_data; + void *data; hwaddr load_addr; int img_off; size_t sz; @@ -194,7 +193,7 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, return 0; } - load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, errp); + data = fit_load_image_alloc(itb, name, &img_off, &sz, errp); if (!data) { error_prepend(errp, "unable to load FDT image from FIT: "); return -EINVAL; @@ -211,19 +210,23 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, } if (ldr->fdt_filter) { - load_data = ldr->fdt_filter(opaque, data, match_data, &load_addr); + void *filtered_data; + + filtered_data = ldr->fdt_filter(opaque, data, match_data, &load_addr); + if (filtered_data != data) { + g_free(data); + data = filtered_data; + } } load_addr = ldr->addr_to_phys(opaque, load_addr); - sz = fdt_totalsize(load_data); - rom_add_blob_fixed(name, load_data, sz, load_addr); + sz = fdt_totalsize(data); + rom_add_blob_fixed(name, data, sz, load_addr); - ret = 0; + *pfdt = data; + return 0; out: g_free((void *) data); - if (data != load_data) { - g_free((void *) load_data); - } return ret; } @@ -259,7 +262,8 @@ out: return ret; } -int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque) +int load_fit(const struct fit_loader *ldr, const char *filename, + void **pfdt, void *opaque) { Error *err = NULL; const struct fit_loader_match *match; @@ -323,7 +327,7 @@ int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque) goto out; } - ret = fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end, + ret = fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end, pfdt, &err); if (ret) { error_report_err(err); diff --git a/hw/mips/boston.c b/hw/mips/boston.c index f0e9a2461a0..99e65f9fafb 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -358,8 +358,8 @@ static void gen_firmware(void *p, hwaddr kernel_entry, hwaddr fdt_addr) kernel_entry); } -static const void *boston_fdt_filter(void *opaque, const void *fdt_orig, - const void *match_data, hwaddr *load_addr) +static void *boston_fdt_filter(void *opaque, const void *fdt_orig, + const void *match_data, hwaddr *load_addr) { BostonState *s = BOSTON(opaque); MachineState *machine = s->mach; @@ -797,7 +797,7 @@ static void boston_mach_init(MachineState *machine) if (kernel_size > 0) { int dt_size; g_autofree const void *dtb_file_data = NULL; - g_autofree const void *dtb_load_data = NULL; + void *dtb_load_data = NULL; hwaddr dtb_paddr = QEMU_ALIGN_UP(kernel_high, 64 * KiB); hwaddr dtb_vaddr = cpu_mips_phys_to_kseg0(NULL, dtb_paddr); @@ -815,6 +815,8 @@ static void boston_mach_init(MachineState *machine) exit(1); } + machine->fdt = dtb_load_data; + /* Calculate real fdt size after filter */ dt_size = fdt_totalsize(dtb_load_data); rom_add_blob_fixed("dtb", dtb_load_data, dt_size, dtb_paddr); @@ -822,7 +824,8 @@ static void boston_mach_init(MachineState *machine) rom_ptr(dtb_paddr, dt_size)); } else { /* Try to load file as FIT */ - fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, s); + fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, + &machine->fdt, s); if (fit_err) { error_report("unable to load kernel image"); exit(1); From patchwork Thu Feb 6 15:12:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862515 Delivered-To: patch@linaro.org Received: by 2002:a5d:51d2:0:b0:385:e875:8a9e with SMTP id n18csp164598wrv; Thu, 6 Feb 2025 07:12:52 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUtGnGDSbynm8DiyorcF/x9ZjvAxkgxnXTPcx7WYDpwinTPsBGfCqF+mrSaUgIREMPdHLPq+g==@linaro.org X-Google-Smtp-Source: AGHT+IEnGywsoiLJLFsXoj/8cVpJLHSfeL40jjZ5vMNDtVJD94yoJRdS5680yIWhlDcEVn0p6vyb X-Received: by 2002:a05:6102:1609:b0:4b6:697c:6b89 with SMTP id ada2fe7eead31-4ba46dab167mr4121158137.5.1738854771911; Thu, 06 Feb 2025 07:12:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854771; cv=none; d=google.com; s=arc-20240605; b=kGhWHbxQX87XBi6HSMtIosN8befco27zOuJIbRdmCb4p1cFY26NxOFYEM9OD5t7ePr GpX8E48sBRzPhxUwN9hxAwSdvjDzXPU7yFDQCXZk0wGR5MwpGee+bizUd4Dd2jIjHqe2 Hz0BWL7q/zDAI4M8wKu58Vl89jOzFIaNRvZN8LKkSkNQhXY9yjJB1voXv38N13+asfuQ vIqhfbCzwSBxMUCP3xQyB9tA56aJ+MH6wx5pfVtHRPiqWE3x5+DGlmnDpG7Gte9jYk35 RTjvLaxhLVu02Aqj6mgj3/RL7q2i6uCEgWCTklM+EG8Uu6aD02nPYWSxUTstZyApPXtj u8tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pQfyZEYqPRxTPSL57zZ1u3qRYEtEoZ2VMJhJtdhLxfE=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=Nm/j7CgoM6cb8RLph6YdCI7QPgajbvXY2RwoRElz88nAwtKg6fRxlcDgHqGERJS9Te mstzoQKAIlgho0xqCW5RBjxnf7v7d3vSj2YGp56Hl24KwOnuELnRQxsrMjD306m6WtiX 0n8H5n5aAuOmJSZYJnllcg9wSUSFsRXlrdw1dfqdUxpFVVPHPzhVFkIuYx+Zf+ckHoHV NEEV6qFegAhxRv9Zqt+izbukrb3LhZFdyL0fyAgx8p4yG+Vh79TqH+xvhSo8Gl2QQ9RH MT8ygWArYT/1nm5FBL283Q7msoxqv3hFQY9PvEs2kR+zmA/RFd4B9pHXf9BQ5k/IbZ4/ zTOw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yxYulhoC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4ba778e93fesi265645137.531.2025.02.06.07.12.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:12:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yxYulhoC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YM-0000Yz-PL; Thu, 06 Feb 2025 10:12: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 1tg3YK-0000Yh-MQ for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:28 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YI-00015X-KD for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:28 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-436a39e4891so7125475e9.1 for ; Thu, 06 Feb 2025 07:12:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854745; x=1739459545; 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=pQfyZEYqPRxTPSL57zZ1u3qRYEtEoZ2VMJhJtdhLxfE=; b=yxYulhoCPh/TKyLbVEqsoKAglGNM/GwMryUu8AbMs78Jvw2hvjTFHMjFlJD3lqTrJC v7HD3SR3tkrpPSf1dy5al7Ny+kDGx0pZzAd1gM1JAaFEXk5ZGI7loLcQ+3AZPxTLX4/a B0ypyMKPEuqp6PCxU4YXa6h8yFaNtQpOjsc5GVRWt8F3jq8Sm7zL1DmUvBum+Nqu5zDh SOmsPdxjfLJExON8L0SWwrxCrx+/2sN9igSNLiK7ntnTpnaY5tV0T4YaiFUVIEWKPoW9 qCMn2zmB12rWoTkqY1x0QerKbmulLQWaPlgy+5tAvRaZxfaE4lIyn9pZZiDlFmIeYhXC oGMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854745; x=1739459545; 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=pQfyZEYqPRxTPSL57zZ1u3qRYEtEoZ2VMJhJtdhLxfE=; b=Qyh/faNAScndwLngjHEiRsH5BCsFEWsAUMpg202cONFe7T3aRuz6LITiOX9eUVbokc O9GUEpdGml8O7gGAa6lOP0I25L+yb9SWDiEvbVS/HK9YKiEzex5k5AfeSJSPcUDYoQWd J++dV1vlNW8a190f/ETtyATXoyS9DloRuUr6F65ITUzoCon7F/98/dlZvDhrFq9uIalk kUsFeZ8PY2HvFnZ289YmGeErL4ocTtFGf9GzbbvzrviOZlMNt053vKlM0GnchgcqZjJF kkNAH21UYSFoOukypSSbXXMK08vYJDQLnSVVsYtmLoBaBukAfIqvNASmOhqtdxgdkKd2 UOWg== X-Gm-Message-State: AOJu0YxgXHrAuxNtu0fFhpe0hNk3UugRd6qgmG+r3XPG1ddpKgExS25S qob537f61NU5/gEYXzHWFbJUd8sSHYyf3ktZ2o9Dfc5vqhU13uPK/axTuzZX/fBbJIZrQhreH4Q j X-Gm-Gg: ASbGncsquq/vsxaGB9g5kDEZHMRE7KT5JMa8EDJAsdngmH7g5u0EuKMs76RjK2uGpxx 53IstMsn4fjNlCtPgchmzy2mG0WmHUPXxtTCFR1B34oJ6yPZbzShEjoZXT1LRK1tOkc+n9HQV0z iL4Ku0QwlX0yboOQ2bxmqaWzgHuMy3i0lT7AOJV33xupkGOo0iSEo13yotoCpmf4pDdlMaNUEtR feGIA/+7g8a3tc/WI/lSi+9nkf2s7vEPuUsUWDf6d8/l99SF/wUfmrjVnzmkT4J6uV2RVWPB7N+ 4PN0x2Cfs9TTaywncqR3fQ== X-Received: by 2002:a05:600c:4452:b0:434:f82b:c5e6 with SMTP id 5b1f17b1804b1-4390d42cd07mr50351675e9.1.1738854741576; Thu, 06 Feb 2025 07:12:21 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 5/6] hw: Centralize handling of -machine dumpdtb option Date: Thu, 6 Feb 2025 15:12:13 +0000 Message-Id: <20250206151214.2947842-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently we handle the 'dumpdtb' machine sub-option ad-hoc in every board model that has an FDT. It's up to the board code to make sure it calls qemu_fdt_dumpdtb() in the right place. This means we're inconsistent and often just ignore the user's command line argument: * if the board doesn't have an FDT at all * if the board supports FDT, but there happens not to be one present (usually because of a missing -fdt option) This isn't very helpful because it gives the user no clue why their option was ignored. However, in order to support the QMP/HMP dumpdtb commands we require now that every FDT machine stores a pointer to the FDT in MachineState::fdt. This means we can handle -machine dumpdtb centrally by calling the qmp_dumpdtb() function, unifying its handling with the QMP/HMP commands. All the board code calls to qemu_fdt_dumpdtb() can then be removed. For this commit we retain the existing behaviour that if there is no FDT we silently ignore the -machine dumpdtb option. Reviewed-by: Richard Henderson --- include/system/device_tree.h | 2 -- hw/arm/boot.c | 2 -- hw/core/machine.c | 25 +++++++++++++++++++++++++ hw/loongarch/virt.c | 1 - hw/mips/boston.c | 1 - hw/openrisc/boot.c | 1 - hw/ppc/e500.c | 1 - hw/ppc/pegasos2.c | 1 - hw/ppc/pnv.c | 1 - hw/ppc/spapr.c | 1 - hw/riscv/boot.c | 2 -- system/device_tree.c | 15 --------------- 12 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/system/device_tree.h b/include/system/device_tree.h index eb601522f88..49d8482ed4e 100644 --- a/include/system/device_tree.h +++ b/include/system/device_tree.h @@ -133,8 +133,6 @@ int qemu_fdt_add_path(void *fdt, const char *path); sizeof(qdt_tmp)); \ } while (0) -void qemu_fdt_dumpdtb(void *fdt, int size); - /** * qemu_fdt_setprop_sized_cells_from_array: * @fdt: device tree blob diff --git a/hw/arm/boot.c b/hw/arm/boot.c index cbc24356fc1..533424cf2e1 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -661,8 +661,6 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, binfo->modify_dtb(binfo, fdt); } - qemu_fdt_dumpdtb(fdt, size); - /* Put the DTB into the memory map as a ROM image: this will ensure * the DTB is copied again upon reset, even if addr points into RAM. */ diff --git a/hw/core/machine.c b/hw/core/machine.c index 254cc20c4cb..1b740071ac7 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -19,6 +19,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "qapi/qapi-visit-machine.h" +#include "qapi/qapi-commands-machine.h" #include "qemu/madvise.h" #include "qom/object_interfaces.h" #include "system/cpus.h" @@ -1695,6 +1696,24 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify) notifier_remove(notify); } +static void handle_machine_dumpdtb(MachineState *ms) +{ + if (!ms->dumpdtb) { + return; + } + if (!ms->fdt) { + /* Silently ignore dumpdtb option if there is nothing to dump */ + return; + } +#ifdef CONFIG_FDT + qmp_dumpdtb(ms->dumpdtb, &error_fatal); + exit(0); +#else + error_report("This machine doesn't have an FDT"); + exit(1); +#endif +} + void qdev_machine_creation_done(void) { cpu_synchronize_all_post_init(); @@ -1711,6 +1730,12 @@ void qdev_machine_creation_done(void) phase_advance(PHASE_MACHINE_READY); qdev_assert_realized_properly(); + /* + * If the user used -machine dumpdtb=file.dtb to request that we + * dump the DTB to a file, do it now, and exit. + */ + handle_machine_dumpdtb(current_machine); + /* TODO: once all bus devices are qdevified, this should be done * when bus is created by qdev.c */ /* diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 63fa0f4e32a..8ef965dea0e 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -674,7 +674,6 @@ static void virt_fdt_setup(LoongArchVirtMachineState *lvms) * Put the FDT into the memory map as a ROM image: this will ensure * the FDT is copied again upon reset, even if addr points into RAM. */ - qemu_fdt_dumpdtb(machine->fdt, lvms->fdt_size); rom_add_blob_fixed_as("fdt", machine->fdt, lvms->fdt_size, FDT_BASE, &address_space_memory); qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 99e65f9fafb..73cbc11b33d 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -395,7 +395,6 @@ static void *boston_fdt_filter(void *opaque, const void *fdt_orig, 1, ram_high_sz); fdt = g_realloc(fdt, fdt_totalsize(fdt)); - qemu_fdt_dumpdtb(fdt, fdt_sz); s->fdt_base = *load_addr; diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c index 72e2756af05..0a5881be314 100644 --- a/hw/openrisc/boot.c +++ b/hw/openrisc/boot.c @@ -109,7 +109,6 @@ uint32_t openrisc_load_fdt(MachineState *ms, void *fdt, /* Should only fail if we've built a corrupted tree */ g_assert(ret == 0); /* copy in the device tree */ - qemu_fdt_dumpdtb(fdt, fdtsize); /* Save FDT for dumpdtb monitor command */ ms->fdt = fdt; diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 26933e0457e..fe8b9f79621 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -658,7 +658,6 @@ static int ppce500_load_device_tree(PPCE500MachineState *pms, done: if (!dry_run) { - qemu_fdt_dumpdtb(fdt, fdt_size); cpu_physical_memory_write(addr, fdt, fdt_size); /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 0364243f4fe..eebb359abb0 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -417,7 +417,6 @@ static void pegasos2_machine_reset(MachineState *machine, ResetType type) d[1] = cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_addr)); qemu_fdt_setprop(fdt, "/chosen", "qemu,boot-kernel", d, sizeof(d)); - qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); g_free(pm->fdt_blob); pm->fdt_blob = fdt; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 11fd477b71b..87607508c76 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -744,7 +744,6 @@ static void pnv_reset(MachineState *machine, ResetType type) _FDT((fdt_pack(fdt))); } - qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt)); /* Update machine->fdt with latest fdt */ diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f3a4b4235d4..c15340a58d8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1760,7 +1760,6 @@ static void spapr_machine_reset(MachineState *machine, ResetType type) 0, fdt_addr, 0); cpu_physical_memory_write(fdt_addr, fdt, fdt_totalsize(fdt)); } - qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); g_free(spapr->fdt_blob); spapr->fdt_size = fdt_totalsize(fdt); diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index c309441b7d8..765b9e2b1ab 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -374,8 +374,6 @@ void riscv_load_fdt(hwaddr fdt_addr, void *fdt) uint32_t fdtsize = fdt_totalsize(fdt); /* copy in the device tree */ - qemu_fdt_dumpdtb(fdt, fdtsize); - rom_add_blob_fixed_as("fdt", fdt, fdtsize, fdt_addr, &address_space_memory); qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds, diff --git a/system/device_tree.c b/system/device_tree.c index 11f3178095c..56d4ac5650a 100644 --- a/system/device_tree.c +++ b/system/device_tree.c @@ -594,21 +594,6 @@ int qemu_fdt_add_path(void *fdt, const char *path) return retval; } -void qemu_fdt_dumpdtb(void *fdt, int size) -{ - const char *dumpdtb = current_machine->dumpdtb; - - if (dumpdtb) { - /* Dump the dtb to a file and quit */ - if (g_file_set_contents(dumpdtb, fdt, size, NULL)) { - info_report("dtb dumped to %s. Exiting.", dumpdtb); - exit(0); - } - error_report("%s: Failed dumping dtb to %s", __func__, dumpdtb); - exit(1); - } -} - int qemu_fdt_setprop_sized_cells_from_array(void *fdt, const char *node_path, const char *property, From patchwork Thu Feb 6 15:12:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 862516 Delivered-To: patch@linaro.org Received: by 2002:adf:ea4b:0:b0:386:330a:81a2 with SMTP id j11csp173727wrn; Thu, 6 Feb 2025 07:13:06 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVcahEU/E/XqNHw30UoyjXZmTpOsQ3NCPHKLrM0eQ0aQFWuGJsrPMz9fdfsrP013fU6bz4Eew==@linaro.org X-Google-Smtp-Source: AGHT+IFbcGwMbkhPQw1YFegTOHlOrxym6+80rs1ms8uv6jsQwOrYyqgIDe6a3DQNWgpcvMPj4Bdy X-Received: by 2002:a05:6122:c92:b0:518:79f2:9345 with SMTP id 71dfb90a1353d-51f0c392972mr4722903e0c.4.1738854786271; Thu, 06 Feb 2025 07:13:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738854786; cv=none; d=google.com; s=arc-20240605; b=JUpZULy4XBZoHgRUkqvqxaV3ur6wiH1v9T72Tt0jbFBv0bQINkBOUGZLdfMnYFeb50 YuMB8uf/5TGd/NClueUm6UcGp4XvE8WyQMHT9dEXKCW3/8xyoYkNfiN4Csuh8GXV1SJm /Rc1RJFriTxHTEZhlEpSzNtUUothw/T8pXkMujISQ4Dk2AmabO+zysGvrd/5BtdhZlIM /1On9vBqXVG3LcZtFEjuCjRLf6G7kmUbuA8bijlg1FoMlNJhmwMqhxUl3O5Jufl1zCBU XEoAo8KckE9tvz+PhbiV0WXvBtfmIJxgSpLEgPoOCA4KefSXzPM95uSCNPPRMUgjCiDl fqSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; fh=/TilQLwyttiBBYoxQPhW9QA6ISv7dt8NoLGF4ij1vv8=; b=e5tikBVEEixPCjFpXfGLyElTSTjMmrmGEiBEZBjfY9AWCapSW4CmZiH4EWaCYyLw53 1AhTI7cFAnO27Nfmzxq1X2foR7hHrxmaqMqeR7AxiiIj6Tx/XGxDRps7ygflaqaPJBTm LNrZyOgx1zIRBx3gmIvj90znxMf1XDskWbkgAQnVWU1f4leF8+V7mVF4Orrlzp3sRSSS 19MBCRaOawpr15wUMnqyaxvrQkSTkyYJQV+cHkyAtVt5ViJ9VCg/87YzH1/l3bztA8Vq Q2ln6zXZxnIiOlaFd/pA5wD49Bt8NUV62NbsfGVPSSV0XkIffhxWl9eEoSR3N/u2fhTR g2KQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w39CDkRr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-51f2292fe59si222178e0c.136.2025.02.06.07.13.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Feb 2025 07:13:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w39CDkRr; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tg3YP-0000Zk-F3; Thu, 06 Feb 2025 10:12:33 -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 1tg3YM-0000Yq-5Y for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:30 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tg3YK-00015t-4k for qemu-devel@nongnu.org; Thu, 06 Feb 2025 10:12:29 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso7082895e9.3 for ; Thu, 06 Feb 2025 07:12:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1738854746; x=1739459546; 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=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; b=w39CDkRrNfp3UBBvB43S4xJ/J2OShWEnci5cs9MrpYyD482ikugbqxAKI2Sss/5nhk uNfhsYcaBsWcasxnsslb/e0jGFd1QTj+YvMcj7xtMDNzXV6cAtj2PfycJ+SfA0sW+i9m Wbs7BOHop5N4MnC1sij6FZO9d67ofluGVQwGISAMvnZb1DVa4DuyyWLLMWSEnhmy88Dt mzQFqCTGZ8isZvW2YutiSOUcTM6OX7Uy/yKKf3OMZMjq8I1JLm7keVrb4qlwkUioLn55 xYCwZwc3Re4Lk/LSO48tKpagnMgmEVrGjgtWCQtZF8YGEIR2ZHrvYLEuth7x7/bW5byh LNKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854746; x=1739459546; 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=xHepygSTQPvUisviVKnRnZ056x3g9J+9ojwVkl7r+jE=; b=fHTnFjWMaS3C7igVhsSdPUhbDVTqllOais911fBWG8ruaG6wCs8pV5fL9iR1G5fO8t G4JbiSh6/kU9zwQc6YuYk8pzd1syMaxhBhdMxDhg9mxE3FQ9a6n9ljm+NTJl6WnXZTCS /8Twk9ofsnspMA4eQ+rhp6eiARqpWarqv8Q6ceU+DgD+fTbX7/WGHGscpS007v7+4R6C wx+oQg4jPil30+52NKDKtWTKr3CV3chhRlAWUbBMpr4N7gEA7X2U3kVAfwlQGRv3cPZ5 HaWeeMCHMTteBOG2yXyHWEZufCynspzU3DszsuW3HwPr8RX1tQYFzvyhcLtn2x7w7ZfJ TQyw== X-Gm-Message-State: AOJu0YwfoUmHgQXu5KcugCRUdCHHQBfUXEV/4aSl/t9YmfbG40nwcsVe kVDTCvCqGvmodazm1XzCwRKbfmd0n3bpAaYe2qj1Jwem/d/E1ysFgDcJADtyfkd+Kd5n+V9J0os L X-Gm-Gg: ASbGncu2xKqPdmsJmSES+M4Qo5o7e005M4fCgx7p9+do4zi7px0WNmMRZrjMnSPhIZ8 6K3BXVMJiJHl4PWepo4iiGhfj3fopi1nU5jXtCZ6ElSW9//CcN6YI46S5DMfeW/ieXfXkwYn1MQ R75UgZXOTrfsioyj8GJB/a5JObQI8qfqxa+kkUgFdQuO+krK5AVQtNlHww9klcEy1o2Q/QfEPJ/ 8Uci9yM76Va8Vazi1qUMtL/QcUzZmqcrb3QRgE30qjKonMgT5hqNHCmW/5MXQyQDEzoD64OehJZ p0dmULdB+thZOHNlkuD9WA== X-Received: by 2002:a05:600c:46d0:b0:434:e9ee:c1e with SMTP id 5b1f17b1804b1-4390d57762amr65606665e9.31.1738854746320; Thu, 06 Feb 2025 07:12:26 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4391d5283b2sm23591535e9.0.2025.02.06.07.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:12:25 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Paul Burton , Aleksandar Rikalo , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-D?= =?utf-8?q?aud=C3=A9?= , Yanan Wang , Zhao Liu , Jia Liu Subject: [PATCH 6/6] hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error Date: Thu, 6 Feb 2025 15:12:14 +0000 Message-Id: <20250206151214.2947842-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250206151214.2947842-1-peter.maydell@linaro.org> References: <20250206151214.2947842-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Currently if the user requests via -machine dumpdtb=file.dtb that we dump the DTB, but the machine doesn't have a DTB, we silently ignore the option. This is confusing to users, and is a legacy of the old board-specific implementation of the option, where if the execution codepath didn't go via a call to qemu_fdt_dumpdtb() we would never handle the option. Now we handle the option in one place in machine.c, we can provide the user with a useful message if they asked us to dump a DTB when none exists. qmp_dumpdtb() already produces this error; remove the logic in handle_machine_dumpdtb() that was there specifically to avoid hitting it. While we're here, beef up the error message a bit with a hint, and make it consistent about "an FDT" rather than "a FDT". (In the qmp_dumpdtb() case this needs an ERRP_GUARD to make error_append_hint() work when the caller passes error_fatal.) Note that the three places where we might report "doesn't have an FDT" are hit in different situations: (1) in handle_machine_dumpdtb(), if CONFIG_FDT is not set: this is because the QEMU binary was built without libfdt at all. The build system will not let you build with a machine type that needs an FDT but no libfdt, so here we know both that the machine doesn't use FDT and that QEMU doesn't have the support: (2) in the device_tree-stub.c qmp_dumpdtb(): this is used when we had libfdt at build time but the target architecture didn't enable any machines which did "select DEVICE_TREE", so here we know that the machine doesn't use FDT. (3) in qmp_dumpdtb(), if current_machine->fdt is NULL all we know is that this machine never set it. That might be because it doesn't use FDT, or it might be because the user didn't pass an FDT on the command line and the machine doesn't autogenerate an FDT. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2733 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- hw/core/machine.c | 6 ++---- system/device_tree-stub.c | 5 ++++- system/device_tree.c | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1b740071ac7..f0e45fbad9d 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -1701,15 +1701,13 @@ static void handle_machine_dumpdtb(MachineState *ms) if (!ms->dumpdtb) { return; } - if (!ms->fdt) { - /* Silently ignore dumpdtb option if there is nothing to dump */ - return; - } #ifdef CONFIG_FDT qmp_dumpdtb(ms->dumpdtb, &error_fatal); exit(0); #else error_report("This machine doesn't have an FDT"); + error_printf("(this machine type definitely doesn't use FDT, and " + "this QEMU doesn't have FDT support compiled in)\n"); exit(1); #endif } diff --git a/system/device_tree-stub.c b/system/device_tree-stub.c index bddda6fa37a..428330b0fec 100644 --- a/system/device_tree-stub.c +++ b/system/device_tree-stub.c @@ -5,6 +5,9 @@ #ifdef CONFIG_FDT void qmp_dumpdtb(const char *filename, Error **errp) { - error_setg(errp, "This machine doesn't have a FDT"); + ERRP_GUARD(); + + error_setg(errp, "This machine doesn't have an FDT"); + error_append_hint(errp, "(this machine type definitely doesn't use FDT)\n"); } #endif diff --git a/system/device_tree.c b/system/device_tree.c index 56d4ac5650a..0d554240f93 100644 --- a/system/device_tree.c +++ b/system/device_tree.c @@ -635,11 +635,16 @@ out: void qmp_dumpdtb(const char *filename, Error **errp) { + ERRP_GUARD(); + g_autoptr(GError) err = NULL; uint32_t size; if (!current_machine->fdt) { - error_setg(errp, "This machine doesn't have a FDT"); + error_setg(errp, "This machine doesn't have an FDT"); + error_append_hint(errp, + "(Perhaps it doesn't support FDT at all, or perhaps " + "you need to provide an FDT with the -fdt option?)\n"); return; }