From nobody Fri Nov 14 16:47:11 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=1761044170; cv=none; d=zohomail.com; s=zohoarc; b=hsud8b/PMbiMUN1DS6buBepFltdcMw7fLvtSaEyybbbIy+y3MVB/nM+2nbg0sYX5o9COmqWht8hLk4ahJdXs3LDXV0+MD2ogDGrxOaJzNNTMKdYMivZDmeA4dDqCHnxCX4vcf7wlzHnL2SIyle3qLTVBD6KlYvn4Om/+5idtiMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044170; h=Content-Type: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=6MG5H2rdn6AOGLT3/QofZzQfvud8goyYPy2TUqKhe3w=; b=TBphHaZz4Bni8xvi5qCQJYAsvY9ztuPmoKchdJ3ca1YeLgW/UTpbQAZfjfyWjs1g6b0t3d2u7B0AMY8DOqjOmSEf+HzB0BEcnTPwa9IH358troOjwDsKHnbIRLp5dxuRq9Rbh3/zJXsj5B+HNKjGYrD5yYfyCICUL4Cb7WmOSIk= 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 1761044170883268.5779218092159; Tue, 21 Oct 2025 03:56:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA1Z-00055n-TG; Tue, 21 Oct 2025 06:55:29 -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 1vBA1V-00054V-R5; Tue, 21 Oct 2025 06:55:26 -0400 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 1vBA1R-0001MY-6a; Tue, 21 Oct 2025 06:55:22 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L2078T030499; Tue, 21 Oct 2025 10:55:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v31c59kb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:18 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LArX4v031827; Tue, 21 Oct 2025 10:55:17 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 49v31c59k7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:17 +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 59L6ekJ2014663; Tue, 21 Oct 2025 10:55:16 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 49vn7s2h5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:16 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAtDKW30736768 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:55:13 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27AC12004E; Tue, 21 Oct 2025 10:55:13 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55BA020043; Tue, 21 Oct 2025 10:55:10 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:55:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=6MG5H2 rdn6AOGLT3/QofZzQfvud8goyYPy2TUqKhe3w=; b=QwFJHd+cOqsh88YjsvsI0V rX8hWXDHwG+JT3ig0JNfZYi1KKzaPZ4Xa6VkOPBlKRf3bMwSH9t8gBMJsmvOdExy t2ciFyIWLbaPFK5gGNTnlRGt2ZFJkoaa8Ogqz1F39AJWxefMMu3Dme9dEBtE4uLW wORDbOJ+f99PtgqAU6/1JWTMHRgjgev/Jzdx+21BS7N2fvX8A0aYiyZ28hY8bFz5 x4CXeG2K0XZVyTwi2ExUav8NdS/8kPot9l5VcHaN4tpZd5F469/+a1jEbBQpczII fy9r2ect9lPzcoyYMABLOXMX4OFiUEs3PDM18Rb48EQI0QPv6TajyRlWWD5nj/lw == From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com Cc: Vishal Chourasia Subject: [Patch v5 1/6] hw/core/loader: Use qemu_open() instead of open() in get_image_size() Date: Tue, 21 Oct 2025 16:24:39 +0530 Message-ID: <20251021105442.1474602-4-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ws_mtltuIg8_z0BfS0xN7zI8_Kaa9Y8m X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfX6KhF3FeqMlhJ 4UVciBRhH5xSYTqVEPcGK26LIr5gagaEB9xOaV6ler+MoWJ18jrDwYjIoo+5bTwGYPW/O3k1Wat 5oo74L6SxRHWw+c4rFFSNAF19H/Nw463HNz/BEWR3W0cZy+ayByuHPj+1yZT03/47s8/KwFAtij l2R6rCxzGSLyVhH53ij1uyzx6zYh3int4dzyitCLsAZL2P+VAv/CMPVarkEdxLobfiH4/6R83zo pH3fYTOIjohr2YrOll5DYt6GrLtule9qL1Z8o2KtEyWzBvyZTroBEquVt+zV5bQYvaB8/NFjDzF bs0s1bLtfB+Js3qo6ZQ4MBGwUapOvhQdyDhcm0RhEMQ35GZC0CwL1p/VdyPYSzwiWicPDx8Ilh3 9sDf2tk1WHS/n67+UqlmgOsjR5Z7GA== X-Proofpoint-GUID: PmzyhdRGtfIhZAW40-e1t7jln4SfLJWc X-Authority-Analysis: v=2.4 cv=SKNPlevH c=1 sm=1 tr=0 ts=68f76696 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=20KFwNOVAAAA:8 a=VnNF1IyMAAAA:8 a=-CUL7ttSjCJlytmGOe4A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 suspectscore=0 clxscore=1015 priorityscore=1501 spamscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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=vishalc@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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1761044176192158500 Replace open() with qemu_open() which provides better error handling via the Error object, automatically sets O_CLOEXEC, and supports FD passing with /dev/fdset. Currently pass errp argument as NULL. Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Vishal Chourasia --- hw/core/loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index 477661a025..c9782d67e8 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -74,7 +74,7 @@ int64_t get_image_size(const char *filename) { int fd; int64_t size; - fd =3D open(filename, O_RDONLY | O_BINARY); + fd =3D qemu_open(filename, O_RDONLY | O_BINARY, NULL); if (fd < 0) return -1; size =3D lseek(fd, 0, SEEK_END); --=20 2.51.0 From nobody Fri Nov 14 16:47:11 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=1761044193; cv=none; d=zohomail.com; s=zohoarc; b=D1smmQsKMl5z/c8X4S369imU7d//wk+15muvncF+rlk6Xc854n2R3cLcnulf0Dqwueu52/xAtwQ9CYRvGLDX/u0hqL+VZkjEmkxl6UqMEE/cMJ15mmF7gUvdThwGo449ZVbCxLXZtEO7rpt72rAk/xldyH/Gn9MtY7Buq9uwKC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044193; 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=56895CtE7o6QivnopznQLPfsmRlLAhmc9yD/QZAXrII=; b=Us5W+PENxDrmhV9EZlATZUePbcl+FH938372bEgJv/Z3KYwinxhWa+zukyx6l1PWz0CyAKxF0kOfbErN1lsdJFj21p7r5KtHb7uXwyd4tcQO8oyhfks4t3P/clBKAScNsibgNz+UcBfPTEO48VpRAPVH1u5YWbO0f4ZxEJq61Xs= 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 1761044193465225.3285304084161; Tue, 21 Oct 2025 03:56:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA2T-0005nI-Sw; Tue, 21 Oct 2025 06:56:28 -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 1vBA2H-0005gp-NW; Tue, 21 Oct 2025 06:56:13 -0400 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 1vBA2B-0001YC-OJ; Tue, 21 Oct 2025 06:56:13 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L7lKZq025774; Tue, 21 Oct 2025 10:55:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v32hd644-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:50 +0000 (GMT) Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LAnuCJ015758; Tue, 21 Oct 2025 10:55:50 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v32hd640-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:49 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59L94I4B011075; Tue, 21 Oct 2025 10:55:48 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 49vqx121v6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:55:48 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAtiCu14221714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:55:44 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79CC02004B; Tue, 21 Oct 2025 10:55:44 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCB5F20043; Tue, 21 Oct 2025 10:55:37 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:55:37 +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=56895CtE7o6Qivnop znQLPfsmRlLAhmc9yD/QZAXrII=; b=PDAjPD2m0iPlddgl3RfIBwdcUMNPS49/F BS465HAtDCtYMJomQBPSJQyPL8s4NfWSp0Zs3xZ6JRhcZpwE+LAN/I4xOP/+Q77y 44K25Q13sXU2QwBgNrowu/iO04/oSivFtRiDg0ef3cGyP3llgcSM8ZYW6f74dWAY roNVHuBvRBLKq3DeI45hMPed/GQ1cCQWrJZV1FhuVwRoKxoVKrdJXZa2Z7ySl2v9 WAx3Z1K+lSTgCl3EtiDMU6+i2XP+QzXQ6TKNit/LSUPqrIEhXZLSdwx6MCT0susk AqFYqwQzO0KkLBxuZnZTPU8LQ4JXkmDI9SvSwcyz2pGjwCoDafwtQ== From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com, richard.henderson@linaro.org, alistair@alistair23.me, alex.bennee@linaro.org, deller@gmx.de, pbonzini@redhat.com, eduardo@habkost.net, minyard@acm.org, gaosong@loongson.cn, maobibo@loongson.cn, laurent@vivier.eu, edgar.iglesias@gmail.com, hpoussin@reactos.org, david@redhat.com, chigot@adacore.com, konrad.frederic@yahoo.fr, atar4qemu@gmail.com, jcmvbkbc@gmail.com Cc: Vishal Chourasia Subject: [Patch v5 2/6] hw/core/loader: capture Error from load_image_targphys Date: Tue, 21 Oct 2025 16:24:41 +0530 Message-ID: <20251021105442.1474602-6-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfX42BjKFtiMmYD KDjOZG1GIoUlmK6eAtWMJFSbtOLc9V0FzvfATx/M2ICuKX1N4IMqI3Xgx486J8O0SNuvatiSKLd 2nHgaOtx7TZaeQl5J+nCEijljrKfNcEJn92hsE3c28NHfha2waNZ3/4PZ3Ty70gy+YFcJnq777h epgkOVSK7YhTdLb/D6CkLibASIUkdJ8RXNSdlbcQl1yl5Ml6lQQe9wl5G/Qe0w2sA6xExCxv1B9 Iv2T2a69wMK1cWorQ3BAY2zIlt5jmomqk2pZgoN4+2lzlfit/k6x4cDeenu6vAy/aAoS1DQQyA3 A80dt+WuIWTEMrfMLcW8E9pepvRDEcty/4oMokKPzM8FpBBNLHjEJYEfA2zzn+A2piFApJCpXy6 YIfGx6R6EpQZH7DvnY6Unpd4W3sJrA== X-Authority-Analysis: v=2.4 cv=OrVCCi/t c=1 sm=1 tr=0 ts=68f766b6 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=KKAkSRfTAAAA:8 a=VnNF1IyMAAAA:8 a=euy7I40VSQCDqpXkRMUA:9 a=cvBusfyB2V15izCimMoJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: iyfvKd6OpemwFsYEGTCOatjmOycvdZvb X-Proofpoint-ORIG-GUID: vFd1ZtI-8eopvAX0GR3sDi9reKmUwFs9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 priorityscore=1501 spamscore=0 phishscore=0 clxscore=1015 bulkscore=0 malwarescore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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=vishalc@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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1761044196882154100 Content-Type: text/plain; charset="utf-8" Add Error **errp parameter to load_image_targphys(), load_image_targphys_as(), and get_image_size() to enable better error reporting when image loading fails. Pass NULL for errp in all existing call sites to maintain current behavior. No functional change intended in this patch. Suggested-by: Peter Maydell Signed-off-by: Vishal Chourasia --- hw/alpha/dp264.c | 4 ++-- hw/arm/armv7m.c | 2 +- hw/arm/boot.c | 5 +++-- hw/arm/digic_boards.c | 2 +- hw/arm/highbank.c | 3 ++- hw/arm/raspi.c | 2 +- hw/arm/vexpress.c | 2 +- hw/core/generic-loader.c | 3 ++- hw/core/guest-loader.c | 2 +- hw/core/loader.c | 31 +++++++++++++++++++++++-------- hw/hppa/machine.c | 5 +++-- hw/i386/multiboot.c | 2 +- hw/i386/x86-common.c | 4 ++-- hw/ipmi/ipmi_bmc_sim.c | 2 +- hw/loongarch/boot.c | 5 ++--- hw/m68k/an5206.c | 2 +- hw/m68k/mcf5208.c | 4 ++-- hw/m68k/next-cube.c | 2 +- hw/m68k/q800.c | 7 ++++--- hw/m68k/virt.c | 4 ++-- hw/microblaze/boot.c | 5 +++-- hw/mips/boston.c | 2 +- hw/mips/fuloong2e.c | 9 +++++---- hw/mips/jazz.c | 2 +- hw/mips/loongson3_virt.c | 10 ++++++---- hw/mips/malta.c | 9 +++++---- hw/nubus/nubus-device.c | 2 +- hw/openrisc/boot.c | 5 +++-- hw/pci/pci.c | 2 +- hw/ppc/amigaone.c | 4 ++-- hw/ppc/e500.c | 5 +++-- hw/ppc/mac_newworld.c | 9 ++++++--- hw/ppc/mac_oldworld.c | 9 ++++++--- hw/ppc/pegasos2.c | 5 +++-- hw/ppc/pnv.c | 9 ++++++--- hw/ppc/ppc440_bamboo.c | 3 ++- hw/ppc/prep.c | 8 +++++--- hw/ppc/sam460ex.c | 3 ++- hw/ppc/spapr.c | 8 ++++---- hw/ppc/virtex_ml507.c | 5 +++-- hw/riscv/boot.c | 7 ++++--- hw/rx/rx-gdbsim.c | 2 +- hw/s390x/ipl.c | 8 +++++--- hw/sh4/r2d.c | 8 +++++--- hw/smbios/smbios.c | 2 +- hw/sparc/leon3.c | 4 ++-- hw/sparc/sun4m.c | 8 +++++--- hw/sparc64/sun4u.c | 7 ++++--- hw/xtensa/xtfpga.c | 3 ++- include/hw/loader.h | 8 +++++--- system/device_tree.c | 2 +- 51 files changed, 159 insertions(+), 107 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 19562b5967..b6155646ef 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -182,7 +182,7 @@ static void clipper_init(MachineState *machine) long initrd_base; int64_t initrd_size; =20 - initrd_size =3D get_image_size(initrd_filename); + initrd_size =3D get_image_size(initrd_filename, NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -192,7 +192,7 @@ static void clipper_init(MachineState *machine) /* Put the initrd image as high in memory as possible. */ initrd_base =3D (ram_size - initrd_size) & TARGET_PAGE_MASK; load_image_targphys(initrd_filename, initrd_base, - ram_size - initrd_base); + ram_size - initrd_base, NULL); =20 address_space_stq(&address_space_memory, param_offset + 0x100, initrd_base + 0xfffffc0000000000ULL, diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index cea3eb49ee..c4a9c3ac52 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -611,7 +611,7 @@ void armv7m_load_kernel(ARMCPU *cpu, const char *kernel= _filename, NULL, ELFDATA2LSB, EM_ARM, 1, 0, as); if (image_size < 0) { image_size =3D load_image_targphys_as(kernel_filename, mem_bas= e, - mem_size, as); + mem_size, as, NULL); } if (image_size < 0) { error_report("Could not load kernel '%s'", kernel_filename); diff --git a/hw/arm/boot.c b/hw/arm/boot.c index e77d8679d8..b91660208f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -964,7 +964,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, /* 32-bit ARM */ entry =3D info->loader_start + KERNEL_LOAD_ADDR; kernel_size =3D load_image_targphys_as(info->kernel_filename, entr= y, - ram_end - KERNEL_LOAD_ADDR, a= s); + ram_end - KERNEL_LOAD_ADDR, a= s, + NULL); is_linux =3D 1; if (kernel_size >=3D 0) { image_low_addr =3D entry; @@ -1025,7 +1026,7 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu, info->initrd_start, ram_end - info->initrd_start, - as); + as, NULL); } if (initrd_size < 0) { error_report("could not load initrd '%s'", diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c index 466b8b84c0..de56991bac 100644 --- a/hw/arm/digic_boards.c +++ b/hw/arm/digic_boards.c @@ -97,7 +97,7 @@ static void digic_load_rom(DigicState *s, hwaddr addr, exit(1); } =20 - rom_size =3D load_image_targphys(fn, addr, max_size); + rom_size =3D load_image_targphys(fn, addr, max_size, NULL); if (rom_size < 0 || rom_size > max_size) { error_report("Couldn't load rom image '%s'.", filename); exit(1); diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c index 165c0b741a..ff987467a9 100644 --- a/hw/arm/highbank.c +++ b/hw/arm/highbank.c @@ -235,7 +235,8 @@ static void calxeda_init(MachineState *machine, enum cx= machines machine_id) if (machine->firmware !=3D NULL) { sysboot_filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, machine->= firmware); if (sysboot_filename !=3D NULL) { - if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000) = < 0) { + if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000, + NULL) < 0) { error_report("Unable to load %s", machine->firmware); exit(1); } diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c index 9d9af63d65..fbf3e09c03 100644 --- a/hw/arm/raspi.c +++ b/hw/arm/raspi.c @@ -230,7 +230,7 @@ static void setup_boot(MachineState *machine, ARMCPU *c= pu, ? FIRMWARE_ADDR_2 : FIRMWARE_ADDR_3; /* load the firmware image (typically kernel.img) */ r =3D load_image_targphys(machine->firmware, firmware_addr, - ram_size - firmware_addr); + ram_size - firmware_addr, NULL); if (r < 0) { error_report("Failed to load firmware from %s", machine->firmw= are); exit(1); diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 35f8d05ea1..60cd375fe7 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -578,7 +578,7 @@ static void vexpress_common_init(MachineState *machine) exit(1); } image_size =3D load_image_targphys(fn, map[VE_NORFLASH0], - VEXPRESS_FLASH_SIZE); + VEXPRESS_FLASH_SIZE, NULL); g_free(fn); if (image_size < 0) { error_report("Could not load ROM image '%s'", machine->firmwar= e); diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index e72bbde2a2..6689847c33 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -148,7 +148,8 @@ static void generic_loader_realize(DeviceState *dev, Er= ror **errp) =20 if (size < 0 || s->force_raw) { /* Default to the maximum size being the machine's ram size */ - size =3D load_image_targphys_as(s->file, s->addr, current_mach= ine->ram_size, as); + size =3D load_image_targphys_as(s->file, s->addr, + current_machine->ram_size, as, NULL); } else { s->addr =3D entry; } diff --git a/hw/core/guest-loader.c b/hw/core/guest-loader.c index 3db89d7a2e..59f325ad9c 100644 --- a/hw/core/guest-loader.c +++ b/hw/core/guest-loader.c @@ -101,7 +101,7 @@ static void guest_loader_realize(DeviceState *dev, Erro= r **errp) =20 /* Default to the maximum size being the machine's ram size */ size =3D load_image_targphys_as(file, s->addr, current_machine->ram_si= ze, - NULL); + NULL, NULL); if (size < 0) { error_setg(errp, "Cannot load specified image %s", file); return; diff --git a/hw/core/loader.c b/hw/core/loader.c index c9782d67e8..de35e40719 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -48,6 +48,7 @@ #include "qapi/error.h" #include "qapi/qapi-commands-machine.h" #include "qapi/type-helpers.h" +#include "qemu/units.h" #include "trace.h" #include "hw/hw.h" #include "disas/disas.h" @@ -70,14 +71,18 @@ static int roms_loaded; =20 /* return the size or -1 if error */ -int64_t get_image_size(const char *filename) +int64_t get_image_size(const char *filename, Error **errp) { int fd; int64_t size; - fd =3D qemu_open(filename, O_RDONLY | O_BINARY, NULL); + fd =3D qemu_open(filename, O_RDONLY | O_BINARY, errp); if (fd < 0) return -1; size =3D lseek(fd, 0, SEEK_END); + if (size < 0) { + error_setg_errno(errp, errno, "lseek failure: %s", filename); + return -1; + } close(fd); return size; } @@ -118,23 +123,33 @@ ssize_t read_targphys(const char *name, } =20 ssize_t load_image_targphys(const char *filename, - hwaddr addr, uint64_t max_sz) + hwaddr addr, uint64_t max_sz, Error **errp) { - return load_image_targphys_as(filename, addr, max_sz, NULL); + return load_image_targphys_as(filename, addr, max_sz, NULL, errp); } =20 /* return the size or -1 if error */ ssize_t load_image_targphys_as(const char *filename, - hwaddr addr, uint64_t max_sz, AddressSpace = *as) + hwaddr addr, uint64_t max_sz, AddressSpace = *as, + Error **errp) { + ERRP_GUARD(); ssize_t size; =20 - size =3D get_image_size(filename); - if (size < 0 || size > max_sz) { + size =3D get_image_size(filename, errp); + if (*errp) { + return -1; + } + + if (size > max_sz) { + error_setg(errp, "%s exceeds maximum image size (%" PRIu64 " MiB)", + filename, max_sz / MiB); return -1; } + if (size > 0) { if (rom_add_file_fixed_as(filename, addr, -1, as) < 0) { + error_setg(errp, "failed to add file as ROM"); return -1; } } @@ -150,7 +165,7 @@ ssize_t load_image_mr(const char *filename, MemoryRegio= n *mr) return -1; } =20 - size =3D get_image_size(filename); + size =3D get_image_size(filename, NULL); =20 if (size < 0 || size > memory_region_size(mr)) { return -1; diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index cddca69b93..ba894f8b1e 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -495,7 +495,7 @@ static void machine_HP_common_init_tail(MachineState *m= achine, PCIBus *pci_bus, ram_addr_t initrd_base; int64_t initrd_size; =20 - initrd_size =3D get_image_size(initrd_filename); + initrd_size =3D get_image_size(initrd_filename, NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -516,7 +516,8 @@ static void machine_HP_common_init_tail(MachineState *m= achine, PCIBus *pci_bus, exit(1); } =20 - load_image_targphys(initrd_filename, initrd_base, initrd_size); + load_image_targphys(initrd_filename, initrd_base, initrd_size, + NULL); cpu[0]->env.initrd_base =3D initrd_base; cpu[0]->env.initrd_end =3D initrd_base + initrd_size; } diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 6e6b96bc34..78690781b7 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -337,7 +337,7 @@ int load_multiboot(X86MachineState *x86ms, *next_space =3D '\0'; } mb_debug("multiboot loading module: %s", one_file); - mb_mod_length =3D get_image_size(one_file); + mb_mod_length =3D get_image_size(one_file, NULL); if (mb_mod_length < 0) { error_report("Failed to open file '%s'", one_file); exit(1); diff --git a/hw/i386/x86-common.c b/hw/i386/x86-common.c index 7512be64d6..6e78f3d07d 100644 --- a/hw/i386/x86-common.c +++ b/hw/i386/x86-common.c @@ -924,7 +924,7 @@ void x86_load_linux(X86MachineState *x86ms, exit(1); } =20 - dtb_size =3D get_image_size(dtb_filename); + dtb_size =3D get_image_size(dtb_filename, NULL); if (dtb_size <=3D 0) { fprintf(stderr, "qemu: error reading dtb %s: %s\n", dtb_filename, strerror(errno)); @@ -1025,7 +1025,7 @@ void x86_bios_rom_init(X86MachineState *x86ms, const = char *default_firmware, bios_name =3D MACHINE(x86ms)->firmware ?: default_firmware; filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size =3D get_image_size(filename); + bios_size =3D get_image_size(filename, NULL); } else { bios_size =3D -1; } diff --git a/hw/ipmi/ipmi_bmc_sim.c b/hw/ipmi/ipmi_bmc_sim.c index 04e1dcd0e7..4604d632b1 100644 --- a/hw/ipmi/ipmi_bmc_sim.c +++ b/hw/ipmi/ipmi_bmc_sim.c @@ -2211,7 +2211,7 @@ static void ipmi_fru_init(IPMIFru *fru) goto out; } =20 - fsize =3D get_image_size(fru->filename); + fsize =3D get_image_size(fru->filename, NULL); if (fsize > 0) { size =3D QEMU_ALIGN_UP(fsize, fru->areasize); fru->data =3D g_malloc0(size); diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index 3dd48cb8aa..8857a04998 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -328,14 +328,13 @@ static int64_t load_kernel_info(struct loongarch_boot= _info *info) } =20 if (info->initrd_filename) { - ssize_t initrd_size =3D get_image_size(info->initrd_filename); - + ssize_t initrd_size =3D get_image_size(info->initrd_filename, NULL= ); if (initrd_size > 0) { initrd_offset =3D ROUND_UP(kernel_high + 4 * kernel_size, 64 *= KiB); initrd_offset =3D alloc_initrd_memory(info, initrd_offset, initrd_size); initrd_size =3D load_image_targphys(info->initrd_filename, - initrd_offset, initrd_size); + initrd_offset, initrd_size, = NULL); } =20 if (initrd_size =3D=3D -1) { diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c index d97399b882..ff21d7779e 100644 --- a/hw/m68k/an5206.c +++ b/hw/m68k/an5206.c @@ -82,7 +82,7 @@ static void an5206_init(MachineState *machine) } if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, KERNEL_LOAD_A= DDR, - ram_size - KERNEL_LOAD_ADDR); + ram_size - KERNEL_LOAD_ADDR, NUL= L); entry =3D KERNEL_LOAD_ADDR; } if (kernel_size < 0) { diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 75cc076f78..4a585b231d 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -351,7 +351,7 @@ static void mcf5208evb_init(MachineState *machine) error_report("Could not find ROM image '%s'", machine->firmwar= e); exit(1); } - if (load_image_targphys(fn, 0x0, ROM_SIZE) < 8) { + if (load_image_targphys(fn, 0x0, ROM_SIZE, NULL) < 8) { error_report("Could not load ROM image '%s'", machine->firmwar= e); exit(1); } @@ -380,7 +380,7 @@ static void mcf5208evb_init(MachineState *machine) } if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, 0x40000000, - ram_size); + ram_size, NULL); entry =3D 0x40000000; } if (kernel_size < 0) { diff --git a/hw/m68k/next-cube.c b/hw/m68k/next-cube.c index 957644b2d1..cfb2b319e5 100644 --- a/hw/m68k/next-cube.c +++ b/hw/m68k/next-cube.c @@ -1325,7 +1325,7 @@ static void next_cube_init(MachineState *machine) memory_region_init_alias(&m->rom2, NULL, "next.rom2", &m->rom, 0x0, 0x20000); memory_region_add_subregion(sysmem, 0x0, &m->rom2); - if (load_image_targphys(bios_name, 0x01000000, 0x20000) < 8) { + if (load_image_targphys(bios_name, 0x01000000, 0x20000, NULL) < 8) { if (!qtest_enabled()) { error_report("Failed to load firmware '%s'.", bios_name); } diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c index 793b23f815..b8676feb41 100644 --- a/hw/m68k/q800.c +++ b/hw/m68k/q800.c @@ -629,7 +629,7 @@ static void q800_machine_init(MachineState *machine) =20 /* load initrd */ if (initrd_filename) { - initrd_size =3D get_image_size(initrd_filename); + initrd_size =3D get_image_size(initrd_filename, NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -638,7 +638,7 @@ static void q800_machine_init(MachineState *machine) =20 initrd_base =3D (ram_size - initrd_size) & TARGET_PAGE_MASK; load_image_targphys(initrd_filename, initrd_base, - ram_size - initrd_base); + ram_size - initrd_base, NULL); BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base, initrd_size); } else { @@ -668,7 +668,8 @@ static void q800_machine_init(MachineState *machine) =20 /* Load MacROM binary */ if (filename) { - bios_size =3D load_image_targphys(filename, MACROM_ADDR, MACRO= M_SIZE); + bios_size =3D load_image_targphys(filename, MACROM_ADDR, MACRO= M_SIZE, + NULL); g_free(filename); } else { bios_size =3D -1; diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index 98cfe43c73..3f65d91556 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -283,7 +283,7 @@ static void virt_init(MachineState *machine) =20 /* load initrd */ if (initrd_filename) { - initrd_size =3D get_image_size(initrd_filename); + initrd_size =3D get_image_size(initrd_filename, NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -292,7 +292,7 @@ static void virt_init(MachineState *machine) =20 initrd_base =3D (ram_size - initrd_size) & TARGET_PAGE_MASK; load_image_targphys(initrd_filename, initrd_base, - ram_size - initrd_base); + ram_size - initrd_base, NULL); BOOTINFO2(param_ptr, BI_RAMDISK, initrd_base, initrd_size); } else { diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 4a9c9df318..ec38107f50 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -170,7 +170,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is= _little_endian, /* Not an ELF image nor an u-boot image, try a RAW image. */ if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, ddr_base, - ramsize); + ramsize, NULL); boot_info.bootstrap_pc =3D ddr_base; high =3D (ddr_base + kernel_size + 3) & ~3; } @@ -189,7 +189,8 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, bool is= _little_endian, if (initrd_size < 0) { initrd_size =3D load_image_targphys(initrd_filename, boot_info.initrd_start, - ramsize - initrd_offset); + ramsize - initrd_offset, + NULL); } if (initrd_size < 0) { error_report("could not load initrd '%s'", diff --git a/hw/mips/boston.c b/hw/mips/boston.c index 149a263bd5..0a3a827b5f 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -778,7 +778,7 @@ static void boston_mach_init(MachineState *machine) =20 if (machine->firmware) { fw_size =3D load_image_targphys(machine->firmware, - 0x1fc00000, 4 * MiB); + 0x1fc00000, 4 * MiB, NULL); if (fw_size =3D=3D -1) { error_report("unable to load firmware image '%s'", machine->firmware); diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 2a8507b8b0..5fe40eee65 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -118,7 +118,7 @@ static uint64_t load_kernel(MIPSCPU *cpu) initrd_size =3D 0; initrd_offset =3D 0; if (loaderparams.initrd_filename) { - initrd_size =3D get_image_size(loaderparams.initrd_filename); + initrd_size =3D get_image_size(loaderparams.initrd_filename, NULL); if (initrd_size > 0) { initrd_offset =3D ROUND_UP(kernel_high, INITRD_PAGE_SIZE); if (initrd_offset + initrd_size > loaderparams.ram_size) { @@ -127,8 +127,9 @@ static uint64_t load_kernel(MIPSCPU *cpu) exit(1); } initrd_size =3D load_image_targphys(loaderparams.initrd_filena= me, - initrd_offset, - loaderparams.ram_size - init= rd_offset); + initrd_offset, + loaderparams.ram_size - initrd_of= fset, + NULL); } if (initrd_size =3D=3D (target_ulong) -1) { error_report("could not load initial ram disk '%s'", @@ -264,7 +265,7 @@ static void mips_fuloong2e_init(MachineState *machine) machine->firmware ?: FULOONG_BIOSNAME); if (filename) { bios_size =3D load_image_targphys(filename, 0x1fc00000LL, - BIOS_SIZE); + BIOS_SIZE, NULL); g_free(filename); } else { bios_size =3D -1; diff --git a/hw/mips/jazz.c b/hw/mips/jazz.c index 7fb0b97a38..1d6bdc0091 100644 --- a/hw/mips/jazz.c +++ b/hw/mips/jazz.c @@ -245,7 +245,7 @@ static void mips_jazz_init(MachineState *machine, machine->firmware ?: bios_name); if (filename) { bios_size =3D load_image_targphys(filename, 0xfff00000LL, - MAGNUM_BIOS_SIZE); + MAGNUM_BIOS_SIZE, NULL); g_free(filename); } else { bios_size =3D -1; diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c index 672083dec9..77dc895648 100644 --- a/hw/mips/loongson3_virt.c +++ b/hw/mips/loongson3_virt.c @@ -371,7 +371,7 @@ static uint64_t load_kernel(CPUMIPSState *env) initrd_size =3D 0; initrd_offset =3D 0; if (loaderparams.initrd_filename) { - initrd_size =3D get_image_size(loaderparams.initrd_filename); + initrd_size =3D get_image_size(loaderparams.initrd_filename, NULL); if (initrd_size > 0) { initrd_offset =3D MAX(loader_memmap[LOADER_INITRD].base, ROUND_UP(kernel_high, INITRD_PAGE_SIZE)); @@ -383,8 +383,9 @@ static uint64_t load_kernel(CPUMIPSState *env) } =20 initrd_size =3D load_image_targphys(loaderparams.initrd_filena= me, - initrd_offset, - loaderparams.ram_size - init= rd_offset); + initrd_offset, + loaderparams.ram_size - initrd_off= set, + NULL); } =20 if (initrd_size =3D=3D (target_ulong) -1) { @@ -650,7 +651,8 @@ static void mips_loongson3_virt_init(MachineState *mach= ine) if (filename) { bios_size =3D load_image_targphys(filename, virt_memmap[VIRT_BIOS_ROM].bas= e, - virt_memmap[VIRT_BIOS_ROM].siz= e); + virt_memmap[VIRT_BIOS_ROM].siz= e, + NULL); g_free(filename); } else { bios_size =3D -1; diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 02da629b5a..806e8d5078 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -892,7 +892,7 @@ static uint64_t load_kernel(void) initrd_size =3D 0; initrd_offset =3D 0; if (loaderparams.initrd_filename) { - initrd_size =3D get_image_size(loaderparams.initrd_filename); + initrd_size =3D get_image_size(loaderparams.initrd_filename, NULL); if (initrd_size > 0) { /* * The kernel allocates the bootmap memory in the low memory a= fter @@ -908,8 +908,9 @@ static uint64_t load_kernel(void) exit(1); } initrd_size =3D load_image_targphys(loaderparams.initrd_filena= me, - initrd_offset, - loaderparams.ram_size - init= rd_offset); + initrd_offset, + loaderparams.ram_size - initrd_off= set, + NULL); } if (initrd_size =3D=3D (target_ulong) -1) { error_report("could not load initial ram disk '%s'", @@ -1176,7 +1177,7 @@ void mips_malta_init(MachineState *machine) machine->firmware ?: bios_name); if (filename) { bios_size =3D load_image_targphys(filename, FLASH_ADDRESS, - BIOS_SIZE); + BIOS_SIZE, NULL); g_free(filename); } else { bios_size =3D -1; diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c index 7797e61c7f..0d4d6c0d87 100644 --- a/hw/nubus/nubus-device.c +++ b/hw/nubus/nubus-device.c @@ -68,7 +68,7 @@ static void nubus_device_realize(DeviceState *dev, Error = **errp) path =3D g_strdup(nd->romfile); } =20 - size =3D get_image_size(path); + size =3D get_image_size(path, NULL); if (size < 0) { error_setg(errp, "failed to find romfile \"%s\"", nd->romfile); g_free(path); diff --git a/hw/openrisc/boot.c b/hw/openrisc/boot.c index c81efe8138..db6fea071e 100644 --- a/hw/openrisc/boot.c +++ b/hw/openrisc/boot.c @@ -44,7 +44,8 @@ hwaddr openrisc_load_kernel(ram_addr_t ram_size, if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, - ram_size - KERNEL_LOAD_ADDR); + ram_size - KERNEL_LOAD_ADDR, + NULL); high_addr =3D KERNEL_LOAD_ADDR + kernel_size; } =20 @@ -74,7 +75,7 @@ hwaddr openrisc_load_initrd(void *fdt, const char *filena= me, =20 size =3D load_ramdisk(filename, start, mem_size - start); if (size < 0) { - size =3D load_image_targphys(filename, start, mem_size - start); + size =3D load_image_targphys(filename, start, mem_size - start, NU= LL); if (size < 0) { error_report("could not load ramdisk '%s'", filename); exit(1); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index acc03fd470..738b0c41ae 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2557,7 +2557,7 @@ static void pci_add_option_rom(PCIDevice *pdev, bool = is_default_rom, path =3D g_strdup(pdev->romfile); } =20 - size =3D get_image_size(path); + size =3D get_image_size(path, NULL); if (size < 0) { error_setg(errp, "failed to find romfile \"%s\"", pdev->romfil= e); return; diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c index 12279f42bc..5c5acc9872 100644 --- a/hw/ppc/amigaone.c +++ b/hw/ppc/amigaone.c @@ -324,7 +324,7 @@ static void amigaone_init(MachineState *machine) error_report("Could not find firmware '%s'", machine->firmware= ); exit(1); } - sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE); + sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE, NULL); if (sz <=3D 0 || sz > PROM_SIZE) { error_report("Could not load firmware '%s'", filename); exit(1); @@ -413,7 +413,7 @@ static void amigaone_init(MachineState *machine) loadaddr =3D ROUND_UP(loadaddr + 4 * MiB, 4 * KiB); loadaddr =3D MAX(loadaddr, INITRD_MIN_ADDR); sz =3D load_image_targphys(machine->initrd_filename, loadaddr, - bi->bd_info - loadaddr); + bi->bd_info - loadaddr, NULL); if (sz <=3D 0) { error_report("Could not load initrd '%s'", machine->initrd_filename); diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 723c97fad2..30937a4a92 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -1227,7 +1227,7 @@ void ppce500_init(MachineState *machine) kernel_base =3D cur_base; kernel_size =3D load_image_targphys(machine->kernel_filename, cur_base, - machine->ram_size - cur_base); + machine->ram_size - cur_base, NU= LL); if (kernel_size < 0) { error_report("could not load kernel '%s'", machine->kernel_filename); @@ -1241,7 +1241,8 @@ void ppce500_init(MachineState *machine) if (machine->initrd_filename) { initrd_base =3D (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; initrd_size =3D load_image_targphys(machine->initrd_filename, init= rd_base, - machine->ram_size - initrd_base); + machine->ram_size - initrd_base, + NULL); =20 if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 0b6e096116..004efc6b97 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -188,7 +188,8 @@ static void ppc_core99_init(MachineState *machine) =20 if (bios_size <=3D 0) { /* or load binary ROM image */ - bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE); + bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE, + NULL); } g_free(filename); } @@ -210,7 +211,8 @@ static void ppc_core99_init(MachineState *machine) if (kernel_size < 0) { kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, - machine->ram_size - kernel_b= ase); + machine->ram_size - kernel_b= ase, + NULL); } if (kernel_size < 0) { error_report("could not load kernel '%s'", @@ -222,7 +224,8 @@ static void ppc_core99_init(MachineState *machine) initrd_base =3D TARGET_PAGE_ALIGN(kernel_base + kernel_size + = KERNEL_GAP); initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, - machine->ram_size - initrd_b= ase); + machine->ram_size - initrd_b= ase, + NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", machine->initrd_filename); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 40ae936ad8..c7e44d49b0 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -143,7 +143,8 @@ static void ppc_heathrow_init(MachineState *machine) =20 if (bios_size <=3D 0) { /* or if could not load ELF try loading a binary ROM image */ - bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE); + bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE, + NULL); bios_addr =3D PROM_BASE; } g_free(filename); @@ -166,7 +167,8 @@ static void ppc_heathrow_init(MachineState *machine) if (kernel_size < 0) { kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, - machine->ram_size - kernel_b= ase); + machine->ram_size - kernel_b= ase, + NULL); } if (kernel_size < 0) { error_report("could not load kernel '%s'", @@ -179,7 +181,8 @@ static void ppc_heathrow_init(MachineState *machine) KERNEL_GAP); initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, - machine->ram_size - initrd_b= ase); + machine->ram_size - initrd_b= ase, + NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", machine->initrd_filename); diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index e15cf96427..1f754df0e2 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -163,7 +163,8 @@ static void pegasos2_init(MachineState *machine) sz =3D load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (sz <=3D 0) { - sz =3D load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM= _SIZE); + sz =3D load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM= _SIZE, + NULL); } if (sz <=3D 0 || sz > PROM_SIZE) { error_report("Could not load firmware '%s'", filename); @@ -259,7 +260,7 @@ static void pegasos2_init(MachineState *machine) pm->initrd_addr =3D ROUND_UP(pm->initrd_addr, 4); pm->initrd_addr =3D MAX(pm->initrd_addr, INITRD_MIN_ADDR); sz =3D load_image_targphys(machine->initrd_filename, pm->initrd_ad= dr, - machine->ram_size - pm->initrd_addr); + machine->ram_size - pm->initrd_addr, NULL= ); if (sz <=3D 0) { error_report("Could not load initrd '%s'", machine->initrd_filename); diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f0469cdb8b..1c0dadda87 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1068,7 +1068,8 @@ static void pnv_init(MachineState *machine) exit(1); } =20 - fw_size =3D load_image_targphys(fw_filename, pnv->fw_load_addr, FW_MAX= _SIZE); + fw_size =3D load_image_targphys(fw_filename, pnv->fw_load_addr, FW_MAX= _SIZE, + NULL); if (fw_size < 0) { error_report("Could not load OPAL firmware '%s'", fw_filename); exit(1); @@ -1080,7 +1081,8 @@ static void pnv_init(MachineState *machine) long kernel_size; =20 kernel_size =3D load_image_targphys(machine->kernel_filename, - KERNEL_LOAD_ADDR, KERNEL_MAX_SIZ= E); + KERNEL_LOAD_ADDR, KERNEL_MAX_SIZ= E, + NULL); if (kernel_size < 0) { error_report("Could not load kernel '%s'", machine->kernel_filename); @@ -1092,7 +1094,8 @@ static void pnv_init(MachineState *machine) if (machine->initrd_filename) { pnv->initrd_base =3D INITRD_LOAD_ADDR; pnv->initrd_size =3D load_image_targphys(machine->initrd_filename, - pnv->initrd_base, INITRD_MAX_SIZE); + pnv->initrd_base, + INITRD_MAX_SIZE, NULL); if (pnv->initrd_size < 0) { error_report("Could not load initial ram disk '%s'", machine->initrd_filename); diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 6fff0d8afb..7c66912c10 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -242,7 +242,8 @@ static void bamboo_init(MachineState *machine) /* Load initrd. */ if (initrd_filename) { initrd_size =3D load_image_targphys(initrd_filename, RAMDISK_ADDR, - machine->ram_size - RAMDISK_ADDR= ); + machine->ram_size - RAMDISK_ADDR, + NULL); =20 if (initrd_size < 0) { error_report("could not load ram disk '%s' at %x", diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index 982e40e53e..edd3da7102 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -280,7 +280,7 @@ static void ibm_40p_init(MachineState *machine) bios_size =3D load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, N= ULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (bios_size < 0) { - bios_size =3D load_image_targphys(filename, BIOS_ADDR, BIOS_SIZE); + bios_size =3D load_image_targphys(filename, BIOS_ADDR, BIOS_SIZE, = NULL); } if (bios_size < 0 || bios_size > BIOS_SIZE) { error_report("Could not load bios image '%s'", filename); @@ -380,7 +380,8 @@ static void ibm_40p_init(MachineState *machine) kernel_base =3D KERNEL_LOAD_ADDR; kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, - machine->ram_size - kernel_base); + machine->ram_size - kernel_base, + NULL); if (kernel_size < 0) { error_report("could not load kernel '%s'", machine->kernel_filename); @@ -393,7 +394,8 @@ static void ibm_40p_init(MachineState *machine) initrd_base =3D INITRD_LOAD_ADDR; initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, - machine->ram_size - initrd_b= ase); + machine->ram_size - initrd_b= ase, + NULL); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", machine->initrd_filename); diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index ee31bd8f34..68d3eacbff 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -494,7 +494,8 @@ static void sam460ex_init(MachineState *machine) if (machine->initrd_filename) { initrd_size =3D load_image_targphys(machine->initrd_filename, RAMDISK_ADDR, - machine->ram_size - RAMDISK_ADDR= ); + machine->ram_size - RAMDISK_ADDR, + NULL); if (initrd_size < 0) { error_report("could not load ram disk '%s' at %x", machine->initrd_filename, RAMDISK_ADDR); diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 97ab6bebd2..d69117d3b4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2824,7 +2824,7 @@ static void spapr_machine_init(MachineState *machine) error_report("Could not find LPAR firmware '%s'", bios_name); exit(1); } - fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE); + fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE, NULL); if (fw_size <=3D 0) { error_report("Could not load LPAR firmware '%s'", filename); exit(1); @@ -3087,9 +3087,9 @@ static void spapr_machine_init(MachineState *machine) spapr->initrd_base =3D (spapr->kernel_addr + spapr->kernel_size + 0x1ffff) & ~0xffff; spapr->initrd_size =3D load_image_targphys(initrd_filename, - spapr->initrd_base, - load_limit - - spapr->initrd_base); + spapr->initrd_base, + load_limit - spapr->initrd= _base, + NULL); if (spapr->initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index c9969ae48a..00d9ab7509 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -253,7 +253,7 @@ static void virtex_init(MachineState *machine) /* If we failed loading ELF's try a raw image. */ kernel_size =3D load_image_targphys(kernel_filename, boot_offset, - machine->ram_size); + machine->ram_size, NULL); boot_info.bootstrap_pc =3D boot_offset; high =3D boot_info.bootstrap_pc + kernel_size + 8192; } @@ -264,7 +264,8 @@ static void virtex_init(MachineState *machine) if (machine->initrd_filename) { initrd_base =3D high =3D ROUND_UP(high, 4); initrd_size =3D load_image_targphys(machine->initrd_filename, - high, machine->ram_size - hi= gh); + high, machine->ram_size - hi= gh, + NULL); =20 if (initrd_size < 0) { error_report("couldn't load ram disk '%s'", diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c index 828a867be3..f38078c8c2 100644 --- a/hw/riscv/boot.c +++ b/hw/riscv/boot.c @@ -172,7 +172,8 @@ target_ulong riscv_load_firmware(const char *firmware_f= ilename, =20 firmware_size =3D load_image_targphys_as(firmware_filename, *firmware_load_addr, - current_machine->ram_size, NULL= ); + current_machine->ram_size, NULL, + NULL); =20 if (firmware_size > 0) { return *firmware_load_addr + firmware_size; @@ -207,7 +208,7 @@ static void riscv_load_initrd(MachineState *machine, RI= SCVBootInfo *info) =20 size =3D load_ramdisk(filename, start, mem_size - start); if (size =3D=3D -1) { - size =3D load_image_targphys(filename, start, mem_size - start); + size =3D load_image_targphys(filename, start, mem_size - start, NU= LL); if (size =3D=3D -1) { error_report("could not load ramdisk '%s'", filename); exit(1); @@ -262,7 +263,7 @@ void riscv_load_kernel(MachineState *machine, } =20 kernel_size =3D load_image_targphys_as(kernel_filename, kernel_start_a= ddr, - current_machine->ram_size, NULL); + current_machine->ram_size, NULL, = NULL); if (kernel_size > 0) { info->kernel_size =3D kernel_size; info->image_low_addr =3D kernel_start_addr; diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c index 5b9004e9e1..ed91c63178 100644 --- a/hw/rx/rx-gdbsim.c +++ b/hw/rx/rx-gdbsim.c @@ -63,7 +63,7 @@ static void rx_load_image(RXCPU *cpu, const char *filenam= e, long kernel_size; int i; =20 - kernel_size =3D load_image_targphys(filename, start, size); + kernel_size =3D load_image_targphys(filename, start, size, NULL); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", filename); exit(1); diff --git a/hw/s390x/ipl.c b/hw/s390x/ipl.c index 2f082396c7..3843d2a850 100644 --- a/hw/s390x/ipl.c +++ b/hw/s390x/ipl.c @@ -169,7 +169,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **= errp) } else { /* Try to load non-ELF file */ bios_size =3D load_image_targphys(bios_filename, ZIPL_IMAGE_ST= ART, - 4096); + 4096, NULL); ipl->bios_start_addr =3D ZIPL_IMAGE_START; } g_free(bios_filename); @@ -188,7 +188,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **= errp) &pentry, NULL, NULL, NULL, ELFDATA2MSB, EM_S390, 0, 0); if (kernel_size < 0) { - kernel_size =3D load_image_targphys(ipl->kernel, 0, ms->ram_si= ze); + kernel_size =3D load_image_targphys(ipl->kernel, 0, ms->ram_si= ze, + NULL); if (kernel_size < 0) { error_setg(errp, "could not load kernel '%s'", ipl->kernel= ); return; @@ -247,7 +248,8 @@ static void s390_ipl_realize(DeviceState *dev, Error **= errp) initrd_offset +=3D 0x100000; } initrd_size =3D load_image_targphys(ipl->initrd, initrd_offset, - ms->ram_size - initrd_offset= ); + ms->ram_size - initrd_offset, + NULL); if (initrd_size =3D=3D -1) { error_setg(errp, "could not load initrd '%s'", ipl->initrd= ); return; diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c index d68c94e82e..010be6d539 100644 --- a/hw/sh4/r2d.c +++ b/hw/sh4/r2d.c @@ -329,8 +329,9 @@ static void r2d_init(MachineState *machine) int kernel_size; =20 kernel_size =3D load_image_targphys(kernel_filename, - SDRAM_BASE + LINUX_LOAD_OFFSET, - INITRD_LOAD_OFFSET - LINUX_LOAD_= OFFSET); + SDRAM_BASE + LINUX_LOAD_OFFSET, + INITRD_LOAD_OFFSET - LINUX_LOAD_OF= FSET, + NULL); if (kernel_size < 0) { error_report("qemu: could not load kernel '%s'", kernel_filena= me); exit(1); @@ -350,7 +351,8 @@ static void r2d_init(MachineState *machine) =20 initrd_size =3D load_image_targphys(initrd_filename, SDRAM_BASE + INITRD_LOAD_OFFSET, - SDRAM_SIZE - INITRD_LOAD_OFFSET); + SDRAM_SIZE - INITRD_LOAD_OFFSET, + NULL); =20 if (initrd_size < 0) { error_report("qemu: could not load initrd '%s'", initrd_filena= me); diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 13e21a9c43..7558b2ad83 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -1340,7 +1340,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) return; } =20 - size =3D get_image_size(val); + size =3D get_image_size(val, NULL); if (size =3D=3D -1 || size < sizeof(struct smbios_structure_header= )) { error_setg(errp, "Cannot read SMBIOS file %s", val); return; diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c index 09d2cec488..631c6113b5 100644 --- a/hw/sparc/leon3.c +++ b/hw/sparc/leon3.c @@ -349,7 +349,7 @@ static void leon3_generic_hw_init(MachineState *machine) filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); =20 if (filename) { - bios_size =3D get_image_size(filename); + bios_size =3D get_image_size(filename, NULL); } else { bios_size =3D -1; } @@ -360,7 +360,7 @@ static void leon3_generic_hw_init(MachineState *machine) } =20 if (bios_size > 0) { - ret =3D load_image_targphys(filename, LEON3_PROM_OFFSET, bios_size= ); + ret =3D load_image_targphys(filename, LEON3_PROM_OFFSET, bios_size= , NULL); if (ret < 0 || ret > prom_size) { error_report("could not load prom '%s'", filename); exit(1); diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c index 8ac7e625ef..53d7ae08ae 100644 --- a/hw/sparc/sun4m.c +++ b/hw/sparc/sun4m.c @@ -245,7 +245,8 @@ static unsigned long sun4m_load_kernel(const char *kern= el_filename, if (kernel_size < 0) kernel_size =3D load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, - RAM_size - KERNEL_LOAD_ADDR); + RAM_size - KERNEL_LOAD_ADDR, + NULL); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); @@ -256,7 +257,8 @@ static unsigned long sun4m_load_kernel(const char *kern= el_filename, if (initrd_filename) { *initrd_size =3D load_image_targphys(initrd_filename, INITRD_LOAD_ADDR, - RAM_size - INITRD_LOAD_ADDR= ); + RAM_size - INITRD_LOAD_ADDR, + NULL); if ((int)*initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -700,7 +702,7 @@ static void prom_init(hwaddr addr, const char *bios_nam= e) translate_prom_address, &addr, NULL, NULL, NULL, NULL, ELFDATA2MSB, EM_SPARC, 0, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { - ret =3D load_image_targphys(filename, addr, PROM_SIZE_MAX); + ret =3D load_image_targphys(filename, addr, PROM_SIZE_MAX, NUL= L); } g_free(filename); } else { diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index e9f9b0a4cb..82c3e7c855 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -182,7 +182,8 @@ static uint64_t sun4u_load_kernel(const char *kernel_fi= lename, if (kernel_size < 0) { kernel_size =3D load_image_targphys(kernel_filename, KERNEL_LOAD_ADDR, - RAM_size - KERNEL_LOAD_ADDR); + RAM_size - KERNEL_LOAD_ADDR, + NULL); } if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); @@ -195,7 +196,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_fi= lename, =20 *initrd_size =3D load_image_targphys(initrd_filename, *initrd_addr, - RAM_size - *initrd_addr); + RAM_size - *initrd_addr, NU= LL); if ((int)*initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); @@ -437,7 +438,7 @@ static void prom_init(hwaddr addr, const char *bios_nam= e) ret =3D load_elf(filename, NULL, translate_prom_address, &addr, NULL, NULL, NULL, NULL, ELFDATA2MSB, EM_SPARCV9, 0,= 0); if (ret < 0 || ret > PROM_SIZE_MAX) { - ret =3D load_image_targphys(filename, addr, PROM_SIZE_MAX); + ret =3D load_image_targphys(filename, addr, PROM_SIZE_MAX, NUL= L); } g_free(filename); } else { diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 55de1a7a07..db3b015549 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -381,7 +381,8 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, M= achineState *machine) if (initrd_size < 0) { initrd_size =3D load_image_targphys(initrd_filename, cur_lowmem, - lowmem_end - cur_lowmem); + lowmem_end - cur_lowmem, + NULL); } if (initrd_size < 0) { error_report("could not load initrd '%s'", initrd_filename= ); diff --git a/include/hw/loader.h b/include/hw/loader.h index c96b5e141c..d035e72748 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -1,6 +1,7 @@ #ifndef LOADER_H #define LOADER_H #include "hw/nvram/fw_cfg.h" +#include "qemu/typedefs.h" =20 /* loader.c */ /** @@ -10,7 +11,7 @@ * Returns the size of the image file on success, -1 otherwise. * On error, errno is also set as appropriate. */ -int64_t get_image_size(const char *filename); +int64_t get_image_size(const char *filename, Error **errp); /** * load_image_size: load an image file into specified buffer * @filename: Path to the image file @@ -41,7 +42,8 @@ ssize_t load_image_size(const char *filename, void *addr,= size_t size); * Returns the size of the loaded image on success, -1 otherwise. */ ssize_t load_image_targphys_as(const char *filename, - hwaddr addr, uint64_t max_sz, AddressSpace = *as); + hwaddr addr, uint64_t max_sz, AddressSpace = *as, + Error **errp); =20 /**load_targphys_hex_as: * @filename: Path to the .hex file @@ -61,7 +63,7 @@ ssize_t load_targphys_hex_as(const char *filename, hwaddr= *entry, * an AddressSpace. */ ssize_t load_image_targphys(const char *filename, hwaddr, - uint64_t max_sz); + uint64_t max_sz, Error **errp); =20 /** * load_image_mr: load an image into a memory region diff --git a/system/device_tree.c b/system/device_tree.c index aa3fe9516f..7850b90fa7 100644 --- a/system/device_tree.c +++ b/system/device_tree.c @@ -83,7 +83,7 @@ void *load_device_tree(const char *filename_path, int *si= zep) void *fdt =3D NULL; =20 *sizep =3D 0; - dt_size =3D get_image_size(filename_path); + dt_size =3D get_image_size(filename_path, NULL); if (dt_size < 0) { error_report("Unable to get size of device tree file '%s'", filename_path); --=20 2.51.0 From nobody Fri Nov 14 16:47:11 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=1761044232; cv=none; d=zohomail.com; s=zohoarc; b=ZSNPu+rR5VAsU9HAzazUkMTIw5a1t8ohiY9u4Q58VF6HFMJ63ZVRGSg4MpunS3kbNGgl2Uw1CBY8hmxl0c3aeNlvozMC7dQ9BLZ9k5EFUfWxv5haimtKObagx9Pf6B/B5yPnKr7sKYPecnAwRftWcO6jhupx39y8Y/lJHzx8r00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044232; 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=FO1mcICwLiIn/LNi1WBqGKKba0QseRn08I3lIz2M2SE=; b=Rz3nZY+MuPRzvJh+hkpvlYfs49CjX4moP0RD2r1PYBZUCzThj//EFxPxhLbDGPIgfawjKos1phpXyksu3lx1zjtCap6aN4bMogwSFaP7kkyQRhs0DMKz0hgRQ8PzcRWVib65GzAMyND489t6/E/LjmpyaeoN+sWiYrSu4jKXG5k= 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 17610442329721020.8735166730082; Tue, 21 Oct 2025 03:57:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA2k-00063j-6R; Tue, 21 Oct 2025 06:56:42 -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 1vBA2H-0005go-MX; Tue, 21 Oct 2025 06:56:13 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBA2F-0001YR-6W; Tue, 21 Oct 2025 06:56:13 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L8m0F2005743; Tue, 21 Oct 2025 10:56:05 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v31rxj8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:04 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LAhe94023457; Tue, 21 Oct 2025 10:56:04 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v31rxj89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:04 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59L81fsG032099; Tue, 21 Oct 2025 10:56:03 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 49vp7mt9mk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:03 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAtxj650725298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:55:59 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 21D5F20043; Tue, 21 Oct 2025 10:55:59 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41D012004B; Tue, 21 Oct 2025 10:55:56 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:55:56 +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=FO1mcICwLiIn/LNi1 WBqGKKba0QseRn08I3lIz2M2SE=; b=a0vQtHMpgB6WT9xXu+n1M/Tb0rWTtJAum oSEYW1PtSG6wYyyNePYO/5ZwNQ99aGDQe/mhkQ6S389JFbsudRYp5C4HRHlWZSOB lyZ8gJCON0/7eUVbRcU03G6QaJmNbr4KmBxLCJZ1/XWxhbQ8xUONDSusFapSfv1d NkJSpqxOErCXiTORhMIsaUtFiYstTqT1HI59QGlw/CTmS07SobBhkBnN4pt57fRe IhYtVm17qAxD7yEObBiSpJciwDdn/iP4orDLXdhbnQO9ARPn3W2lySGEWwBks0gI vpuVqMAC5HWj2K+5217+bEaXI+w5oIGIKEz6zc4Qpfv15ZQPCg43A== From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com Cc: Vishal Chourasia Subject: [Patch v5 3/6] hw/core/loader: add check for zero size in load_image_targphys_as Date: Tue, 21 Oct 2025 16:24:42 +0530 Message-ID: <20251021105442.1474602-7-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lGM34rt_6froou_mL19YpQ2b960sgBF0 X-Proofpoint-GUID: m_Ojn-USPqA8QCOwLFSJuWF2NoS1RZAB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfX/4bzQJJh43wY SlStUyVficisa7ABQtzc+BjRZ5eZHMDrETczdsP8tAhHW1rEuOTBoCidkDAo26iP+YyP4S227DY hh+I+zH7fDYTnN1RHtk9fpbSGU2vC08PcYn+sa2SSa+g+EMdlx3cGhPhxqecDDm6tiLdy29H8ff gsSoYBVlwVqXvGn6oEHNcqGL9X7XoQQs5rQx3M8ya5Ct1ziFh+jAF63CRV3bc69ihvJbcGuBH84 wH6zaMy7NAXhjpByLwfFOrrytOtS8jQdGab33gH2IM+hXV6CJeNS3ZEO0WoLpBBlDw61TnXuWbK pJcTC4izVhqihoSrkmSHMXrMaXheVGZjhkEju9rDNGVvBxjp1dpqM3JCl6UdDxjlqe8ebmEWc7q Rwtkq4nX58AuVKCaUEGIY2fXzPwGVQ== X-Authority-Analysis: v=2.4 cv=IJYPywvG c=1 sm=1 tr=0 ts=68f766c4 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=EMG23Z06JWfOmfJaRK0A:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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.156.1; envelope-from=vishalc@linux.ibm.com; helo=mx0a-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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1761044236840154100 Content-Type: text/plain; charset="utf-8" Currently load_image_targphys_as() returns -1 on file open failure or when max size is exceeded. Add an explicit check for zero-sized files to catch this error early, since some callers check for size <=3D 0. Signed-off-by: Vishal Chourasia --- hw/core/loader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/core/loader.c b/hw/core/loader.c index de35e40719..e1a30da2ac 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -141,6 +141,11 @@ ssize_t load_image_targphys_as(const char *filename, return -1; } =20 + if (size =3D=3D 0) { + error_setg(errp, "empty file"); + return -1; + } + if (size > max_sz) { error_setg(errp, "%s exceeds maximum image size (%" PRIu64 " MiB)", filename, max_sz / MiB); --=20 2.51.0 From nobody Fri Nov 14 16:47:11 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=1761044248; cv=none; d=zohomail.com; s=zohoarc; b=nm8gGSnrIZYJlxesATdBfwOViRhBUT2M/TtbZTjGZs+FKguySX/y7e4lu7HENpnQmyKQn3XnhDK0qjaNA0bc0lKYCNT+ukhLnbbFTgYdZf9/HWDn9EdoMVmo3uh1ahpm5n9APH5nMm6/xsdvMLADhW8JRG6hEvmVyJlkGDWM+5w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044248; 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=VsPixCQuXr0a3YA1KwWnXXRiIgqzlv8MPMc2bZkj0yA=; b=LxxTUwraART/4ux/zqRQZ6ea/GYJCkUF8LxLy3oDxX9OGheY21fxxrV2kv11sI8NYn7rRz9bCsqr6IR5Up3Ox7P0tDqxhKI/px8c8LeWimuvzfSSPKN9I1Cy5zBhXKSoyUC4Jyq9UKJ+uH/SRkgjAC87wCiqaBgrMVFA0OzZfPs= 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 1761044248588641.1610507124215; Tue, 21 Oct 2025 03:57:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA2m-0006BE-12; Tue, 21 Oct 2025 06:56:44 -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 1vBA2K-0005jk-Ny; Tue, 21 Oct 2025 06:56:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBA2I-0001Z5-IB; Tue, 21 Oct 2025 06:56:16 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L4RVMo014748; Tue, 21 Oct 2025 10:56:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v33f6jbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:10 +0000 (GMT) Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LApUGq012143; Tue, 21 Oct 2025 10:56:09 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v33f6jbk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:09 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59L7BfSt017072; Tue, 21 Oct 2025 10:56:08 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 49vnkxte14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:08 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAu4XX42729756 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:56:04 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 71EFE20043; Tue, 21 Oct 2025 10:56:04 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C42062004D; Tue, 21 Oct 2025 10:56:01 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:56:01 +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=VsPixCQuXr0a3YA1K wWnXXRiIgqzlv8MPMc2bZkj0yA=; b=AT9aOm5ffcJR961Kp64BNpU+jDq6AQRXb RlgP5J4aqY3AJAfwTQGu21gIdwqZEqJsUjHJY4AI+FowU7QNCRImBb8PF0LfxgL+ 3h1gS6FMsI7yc4kSILXCaZISRhCRMXDXcrWv+3JO/Mv/GdJJXXj+MbUNTjJnP/Jt ctjYR1v2e6iG2sfJVKlBTHiWLYctDevi89JUOeYnSiAOPM9QqTpKu1ntIVclv/df cEzkOg1gGxp7k8rQtE8NULWw+SlF7I9nFR4CDlTaME8/uZoLYGKpajcFoy84N21z xEiSniwCeCd2IDFJ6M3m8hOOpMgTjzax8P2vmhyGQGpTPwFhD/vsw== From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com Cc: Vishal Chourasia Subject: [Patch v5 4/6] hw/core: Pass errp to load_image_targphys_as() Date: Tue, 21 Oct 2025 16:24:43 +0530 Message-ID: <20251021105442.1474602-8-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=FMYWBuos c=1 sm=1 tr=0 ts=68f766ca cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=WwcbXC5amFkfT6oAP7YA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-GUID: AhZsPAR1OyeQe53Sqc79PrgHAZifFCRt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfX8EVhrNZNf/GJ kcbgoinVlD/iyTNAz5UMC9hIaHndEbX8kK6WNI/80EKjNQda1Hn0G+vSuQutbBsUo0mmZNk2by/ ljF5e66INTvewPta5PwLTLXywB2t3EU1odPvKG9QOuOCLuGLDjj0LayXBmdEC4RuBGjbwfdMCkG bAcOmoWIjbZbswT1v9yLDyJdK+MW0edFq8bDNOJK3M3ZgdBD0LQD7LzEiw4idQVkZe2O24LUJhs kU/EN8eOzYKGKvGE7KPC/OGDS31j/zIVZg4Ni0i6RpI2pAh0S3UoyhMDRF47XoXUUPgHEha5Y4L ZjdKvfnNpAdI/OTEg6GP1hkKpOS47CvYCxmbMsB/3WEKTh1dul+KPgZ2kHiluQfcx1DW2wxQGf+ IyRcmqH6hEDcCnV/13HZ19CUqK6hKA== X-Proofpoint-ORIG-GUID: lMO4SeermxWUCX0X_yp3hOz9BETCANKD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 priorityscore=1501 adultscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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.156.1; envelope-from=vishalc@linux.ibm.com; helo=mx0a-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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1761044250778154100 Content-Type: text/plain; charset="utf-8" Pass errp to load_image_targphys_as() in generic-loader and guest-loader to capture detailed error information from the loader functions. Use error_prepend() instead of error_setg() to preserve the underlying error details while adding context about which image failed to load. Signed-off-by: Vishal Chourasia --- hw/core/generic-loader.c | 7 ++++--- hw/core/guest-loader.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index 6689847c33..35d4e5f4ea 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -60,6 +60,7 @@ static void generic_loader_reset(void *opaque) =20 static void generic_loader_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); GenericLoaderState *s =3D GENERIC_LOADER(dev); hwaddr entry; ssize_t size =3D 0; @@ -149,13 +150,13 @@ static void generic_loader_realize(DeviceState *dev, = Error **errp) if (size < 0 || s->force_raw) { /* Default to the maximum size being the machine's ram size */ size =3D load_image_targphys_as(s->file, s->addr, - current_machine->ram_size, as, NULL); + current_machine->ram_size, as, errp); } else { s->addr =3D entry; } =20 - if (size < 0) { - error_setg(errp, "Cannot load specified image %s", s->file); + if (*errp) { + error_prepend(errp, "Cannot load specified image %s: ", s->fil= e); return; } } diff --git a/hw/core/guest-loader.c b/hw/core/guest-loader.c index 59f325ad9c..dcbe8e4520 100644 --- a/hw/core/guest-loader.c +++ b/hw/core/guest-loader.c @@ -81,6 +81,7 @@ static void loader_insert_platform_data(GuestLoaderState = *s, int size, =20 static void guest_loader_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); GuestLoaderState *s =3D GUEST_LOADER(dev); char *file =3D s->kernel ? s->kernel : s->initrd; int size =3D 0; @@ -101,9 +102,9 @@ static void guest_loader_realize(DeviceState *dev, Erro= r **errp) =20 /* Default to the maximum size being the machine's ram size */ size =3D load_image_targphys_as(file, s->addr, current_machine->ram_si= ze, - NULL, NULL); - if (size < 0) { - error_setg(errp, "Cannot load specified image %s", file); + NULL, errp); + if (*errp) { + error_prepend(errp, "Cannot load specified image %s: ", file); return; } =20 --=20 2.51.0 From nobody Fri Nov 14 16:47:11 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=1761044252; cv=none; d=zohomail.com; s=zohoarc; b=FfqPNYLbXxIdTmZuDA+I4o49SVSot+/Tq2PK6kfRLm9xx69eU1kmNJKpWi8XvYPKPzEbgiPyKqTFqPYgz/o5pfV920qFvz+lALvmJ8tFxmfmGfgwkz6LOP0Oo9MB/zeXVAlWiOsC+jLIwBg8IMGBSSqU0FE5DAn1S5EihVXCb+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044252; 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=wICqCNOYkl/SO0IudQTMSf41t6cz8HYOHXuy0A6JdNg=; b=JceROGTZAqvAe0+SoghoddZ12NJ2LOclpdUrHCRGdEgaJ7mMtuB1TRtItYqpVmlLfwU+E5DIp9B0YjGPfb9Ro51cutn/RD7CN+d/dGTt3/2uaHpecb3XccdIrBh+rW6copK/62nRLa42kuHv9T56SpMylBovsR5NBuX11ngS158= 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 176104425258544.5922262286482; Tue, 21 Oct 2025 03:57:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA2m-0006CP-9V; Tue, 21 Oct 2025 06:56:44 -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 1vBA2R-0005oN-Fc; Tue, 21 Oct 2025 06:56:25 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBA2O-0001ao-SY; Tue, 21 Oct 2025 06:56:22 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L9vLIO002474; Tue, 21 Oct 2025 10:56:16 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v326phmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:16 +0000 (GMT) Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LAuFoU024419; Tue, 21 Oct 2025 10:56:15 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v326phmq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:15 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 59L7cPum032089; Tue, 21 Oct 2025 10:56:14 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 49vp7mt9n9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:14 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAuAkm52953346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:56:10 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94FDB2004B; Tue, 21 Oct 2025 10:56:10 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD14F20043; Tue, 21 Oct 2025 10:56:07 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:56: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=wICqCNOYkl/SO0Iud QTMSf41t6cz8HYOHXuy0A6JdNg=; b=W2WB+QT5C5tR6H+Nr4IN3BwskDBLqsGMs 2htP9dT35hL2y+W9zbmlW1KuWfdwfgGRDq7gVLb3/YlTwsQohFAgW5pVHELhEeld KTTQJTUVuPYz1Xh2/V3yQjMPFSDwYp4K31CsJuSx1Df8iq/m2cXeFnT0lO4WGU17 mtZp6hTKcGfBsl84Js81F1VPnRXfyk0gBZbE81BMMuIDL2tVmFAIouISzxKtYTeX yC3L8/k1UZeKz29izsckyyugDEr4Wxf/weSDdf1LIq8mIDxZDy6GKndDQDB7oho4 xGgbCOGWx4QuH8dgBEq39ChsTYgigoh6EDHop1GLyHPMLY/ke0oHQ== From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com Cc: Vishal Chourasia Subject: [Patch v5 5/6] hw/ppc/spapr: Rename resize_hpt_err to errp Date: Tue, 21 Oct 2025 16:24:44 +0530 Message-ID: <20251021105442.1474602-9-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=EJELElZC c=1 sm=1 tr=0 ts=68f766d0 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=YPwFAxgEYmRXNWQnHQUA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfX5+D+flEc7qMq VucXV55B3QP81CAhZDru0WymwtsNkrcPACLET27hey7LxQQ+/broLXpLdWaB+8gGRdAR3biElst AecnJfyabkAv/cRNJprLCVLpvhirxBP8las313RtiBmiU5dTwaNWZOFMR4dFtGtKLuxOxJhyMwZ JTkk6D3l67sTyPUoCdpkaQE4uDw5PMgxIp/X5yAc3yBWiC8SmYJ1ipWPYsMOGSomE/UwbGF+4uO 17FjwxqreZY/Cyx+t/GDtM2p6652Z0duf3RWzbMU6DRDULJXF6w7LmbsHLtJ5mc2PXLuucuFW54 VaOk1MkaJmeYIKyjChmCmpTXi0IjnAfbR9uTUHUZoWZuW8PqTW3chLOmyYzmLK4adWOuAxTt9mC kNr1r/Cqsne81LKiUu3sGGtMn1QhiQ== X-Proofpoint-GUID: jufNkKJscceU-zEkuSO4HOvT3nO3BU_I X-Proofpoint-ORIG-GUID: X3br-zG45zH2bN__5UNy4mD-hkkQ8R6B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 spamscore=0 malwarescore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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.156.1; envelope-from=vishalc@linux.ibm.com; helo=mx0a-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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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: 1761044254770158500 Content-Type: text/plain; charset="utf-8" Rename resize_hpt_err to standard errp naming convention. Signed-off-by: Vishal Chourasia Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/spapr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d69117d3b4..e51540a5ad 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2817,7 +2817,7 @@ static void spapr_machine_init(MachineState *machine) int i; MemoryRegion *sysmem =3D get_system_memory(); long load_limit, fw_size; - Error *resize_hpt_err =3D NULL; + Error *errp =3D NULL; NICInfo *nd; =20 if (!filename) { @@ -2845,7 +2845,7 @@ static void spapr_machine_init(MachineState *machine) /* Determine capabilities to run with */ spapr_caps_init(spapr); =20 - kvmppc_check_papr_resize_hpt(&resize_hpt_err); + kvmppc_check_papr_resize_hpt(&errp); if (spapr->resize_hpt =3D=3D SPAPR_RESIZE_HPT_DEFAULT) { /* * If the user explicitly requested a mode we should either @@ -2853,10 +2853,10 @@ static void spapr_machine_init(MachineState *machin= e) * it's not set explicitly, we reset our mode to something * that works */ - if (resize_hpt_err) { + if (errp) { spapr->resize_hpt =3D SPAPR_RESIZE_HPT_DISABLED; - error_free(resize_hpt_err); - resize_hpt_err =3D NULL; + error_free(errp); + errp =3D NULL; } else { spapr->resize_hpt =3D smc->resize_hpt_default; } @@ -2864,14 +2864,14 @@ static void spapr_machine_init(MachineState *machin= e) =20 assert(spapr->resize_hpt !=3D SPAPR_RESIZE_HPT_DEFAULT); =20 - if ((spapr->resize_hpt !=3D SPAPR_RESIZE_HPT_DISABLED) && resize_hpt_e= rr) { + if ((spapr->resize_hpt !=3D SPAPR_RESIZE_HPT_DISABLED) && errp) { /* * User requested HPT resize, but this host can't supply it. Bail= out */ - error_report_err(resize_hpt_err); + error_report_err(errp); exit(1); } - error_free(resize_hpt_err); + error_free(errp); =20 spapr->rma_size =3D spapr_rma_size(spapr, &error_fatal); =20 --=20 2.51.0 From nobody Fri Nov 14 16:47:11 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=1761044252; cv=none; d=zohomail.com; s=zohoarc; b=bBw028DeFdkqZWl7qlxLnLzaHODEvmDl5kADN7KGRG4ZAsG8/Qt7fIiuWwSqBjZ6eP8cFpyVkWydjxp7NFdOJS5iusUBsbebLRtZmTT9Uqeg47UyuZymwpLhLdWKjXPizS4rncYji4dR/buUWjO0XWkrC3Z99Af/t5X93cBcvIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761044252; 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=BwMvmF6NBJ0BtcWUBBphKD/P2wkYLgQqRs8FoUD1GkA=; b=agfZhw0xL9zyquAcDVrhOLGAM2EVIijIqCN3IXKk+nkAa0NOhE3x1qwMQPvUqTfImarXFx3a2EfBmkBk5+I3SMLnBMZlH1/+LWXDim9AwVQlWJ17V3Nn281bq1KNZIiMvQoXvvYAqTiRzbh4JPTvNN6ezlls/WLovM1PymANnwY= 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 1761044252204178.9505869968541; Tue, 21 Oct 2025 03:57:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBA2o-0006HM-4b; Tue, 21 Oct 2025 06:56:46 -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 1vBA2l-0006AH-Cm; Tue, 21 Oct 2025 06:56:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBA2g-0001fs-GR; Tue, 21 Oct 2025 06:56:42 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59L93Kq6023459; Tue, 21 Oct 2025 10:56:33 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 49v31rxj9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:33 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.1.12/8.18.0.8) with ESMTP id 59LAjwBk029145; Tue, 21 Oct 2025 10:56:32 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 49v31rxj9r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:32 +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 59LAtbJE014663; Tue, 21 Oct 2025 10:56:31 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 49vn7s2h9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 21 Oct 2025 10:56:31 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 59LAuSrT49938784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Oct 2025 10:56:28 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 27B6C2004E; Tue, 21 Oct 2025 10:56:28 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 62DF620043; Tue, 21 Oct 2025 10:56:25 +0000 (GMT) Received: from vishalc-ibm.ibm.com (unknown [9.39.24.196]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 21 Oct 2025 10:56:25 +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=BwMvmF6NBJ0BtcWUB BphKD/P2wkYLgQqRs8FoUD1GkA=; b=fbXfTg3X6BGd+VWHdP61LHJMS/mVrnHyc I6hvPxGnjpL1dPYH7/ECsIrg6o51zdp/JtHkqqQ6CxgruhTOcDXnlNkgG4rvbrnF DVrJPVGhtqBqivJoWOMWTvS1OY2whUTKHTmADGYVufKOyNI95VVqpkI0nsjQzmQb HBq5viHT49Q+qmY55B6gp970IwPZjLSPoCZnoK/hJrHXcc6WAaXAeDoOEXkqLvMS 7ynXOLmVGFO+r5zpfPQyJtnIbdy6fuw3TjmmuqxEqJVKxYPRxwp/jk3g//rzjfJZ KkEaU18mKqwVI26oUdJjKGvbUOPja8zJDapbT+tcDR/u0OGPaxGxw== From: Vishal Chourasia To: adityag@linux.ibm.com, harshpb@linux.ibm.com, milesg@linux.ibm.com, npiggin@gmail.com, peter.maydell@linaro.org, alistair23@gmail.com, balaton@eik.bme.hu, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, berrange@redhat.com, hpoussin@reactos.org Cc: Vishal Chourasia Subject: [Patch v5 6/6] hw/ppc: Pass errp to load_image_targphys() and report errors Date: Tue, 21 Oct 2025 16:24:46 +0530 Message-ID: <20251021105442.1474602-11-vishalc@linux.ibm.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251021105442.1474602-2-vishalc@linux.ibm.com> References: <20251021105442.1474602-2-vishalc@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: emSfr1n2UJ_-DHAtuaq-8fPiyRntpEYR X-Proofpoint-GUID: fQA9mU5xbtg0EadTgldoRIp3LlTmbdhS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDE4MDAyMiBTYWx0ZWRfXySC8ocCSzjhu cv/fEUyHErW2vooawExo3JDy/QchW/SDmgvpD+M6ALa7gOXm0N3cEs7XfE8R3p0BSKQUcQpaLnv +mxAb1yo3C3gRS59vTr29t2aUNc0mDCL91JT3MTMi08VLvh9YYYD34rXokiAdbJ0I7emfHwxmaP E3HtaGqfbkQfOph8ViYsC4Rc6eyYNz687800KrM4piLALpI3OJoi9nYEwmL5z7TDUCbi+ToHI/I yWt+6BKxXt+BStMWMwEAtDDe1hpzu9EXBKXu2DRjX12HjICuHWRRGAA8M0+KjVEmpwvBApEu18T UqoFGij9V64riUm8t7rZHllI22IyzJclDntohPrGIhnCr9BQZcuR0jpAUOeuiu8u9SF24eSsiLi i8HxODIgtnIWh2xjxOWznr5c/EgpMA== X-Authority-Analysis: v=2.4 cv=IJYPywvG c=1 sm=1 tr=0 ts=68f766e1 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VnNF1IyMAAAA:8 a=0IoJLJlfn07CT3Vb23kA:9 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-21_01,2025-10-13_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 spamscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2510020000 definitions=main-2510180022 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.156.1; envelope-from=vishalc@linux.ibm.com; helo=mx0a-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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_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: 1761044255032158500 Content-Type: text/plain; charset="utf-8" Pass errp to load_image_targphys() calls in ppc machine initialization to capture detailed error information when loading firmware, kernel, and initrd images. Use error_reportf_err() instead of error_report() to print the underlying error details along with context about which image failed to load. Signed-off-by: Vishal Chourasia --- hw/ppc/amigaone.c | 15 ++++++++------- hw/ppc/e500.c | 17 +++++++++-------- hw/ppc/mac_newworld.c | 25 +++++++++++++++---------- hw/ppc/mac_oldworld.c | 25 +++++++++++++++---------- hw/ppc/pegasos2.c | 17 +++++++++++------ hw/ppc/pnv.c | 31 ++++++++++++++----------------- hw/ppc/ppc440_bamboo.c | 9 +++++---- hw/ppc/prep.c | 25 +++++++++++++++---------- hw/ppc/sam460ex.c | 9 +++++---- hw/ppc/spapr.c | 15 ++++++++------- hw/ppc/virtex_ml507.c | 17 +++++++++++------ 11 files changed, 116 insertions(+), 89 deletions(-) diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c index 5c5acc9872..bd14bed243 100644 --- a/hw/ppc/amigaone.c +++ b/hw/ppc/amigaone.c @@ -276,6 +276,7 @@ static void amigaone_init(MachineState *machine) DriveInfo *di; hwaddr loadaddr; struct boot_info *bi =3D NULL; + Error *errp =3D NULL; =20 /* init CPU */ cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); @@ -324,9 +325,9 @@ static void amigaone_init(MachineState *machine) error_report("Could not find firmware '%s'", machine->firmware= ); exit(1); } - sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE, NULL); - if (sz <=3D 0 || sz > PROM_SIZE) { - error_report("Could not load firmware '%s'", filename); + sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE, &errp); + if (errp) { + error_reportf_err(errp, "Could not load firmware '%s': ", file= name); exit(1); } } @@ -413,10 +414,10 @@ static void amigaone_init(MachineState *machine) loadaddr =3D ROUND_UP(loadaddr + 4 * MiB, 4 * KiB); loadaddr =3D MAX(loadaddr, INITRD_MIN_ADDR); sz =3D load_image_targphys(machine->initrd_filename, loadaddr, - bi->bd_info - loadaddr, NULL); - if (sz <=3D 0) { - error_report("Could not load initrd '%s'", - machine->initrd_filename); + bi->bd_info - loadaddr, &errp); + if (errp) { + error_reportf_err(errp, "Could not load initrd '%s': ", + machine->initrd_filename); exit(1); } bi->initrd_start =3D loadaddr; diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 30937a4a92..48e238f3a4 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -932,6 +932,7 @@ void ppce500_init(MachineState *machine) MemoryRegion *ccsr_addr_space; SysBusDevice *s; I2CBus *i2c; + Error *errp =3D NULL; =20 irqs =3D g_new0(IrqLines, smp_cpus); for (i =3D 0; i < smp_cpus; i++) { @@ -1227,10 +1228,10 @@ void ppce500_init(MachineState *machine) kernel_base =3D cur_base; kernel_size =3D load_image_targphys(machine->kernel_filename, cur_base, - machine->ram_size - cur_base, NU= LL); - if (kernel_size < 0) { - error_report("could not load kernel '%s'", - machine->kernel_filename); + machine->ram_size - cur_base, &e= rrp); + if (errp) { + error_reportf_err(errp, "could not load kernel '%s': ", + machine->kernel_filename); exit(1); } =20 @@ -1242,11 +1243,11 @@ void ppce500_init(MachineState *machine) initrd_base =3D (cur_base + INITRD_LOAD_PAD) & ~INITRD_PAD_MASK; initrd_size =3D load_image_targphys(machine->initrd_filename, init= rd_base, machine->ram_size - initrd_base, - NULL); + &errp); =20 - if (initrd_size < 0) { - error_report("could not load initial ram disk '%s'", - machine->initrd_filename); + if (errp) { + error_reportf_err(errp, "could not load initial ram disk '%s':= ", + machine->initrd_filename); exit(1); } =20 diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 004efc6b97..b95a394a8d 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -156,6 +156,7 @@ static void ppc_core99_init(MachineState *machine) DeviceState *uninorth_internal_dev =3D NULL, *uninorth_agp_dev =3D NUL= L; hwaddr nvram_addr =3D 0xFFF04000; uint64_t tbfreq =3D kvm_enabled() ? kvmppc_get_tbfreq() : TBFREQ; + Error *errp =3D NULL; =20 /* init CPUs */ for (i =3D 0; i < machine->smp.cpus; i++) { @@ -189,12 +190,16 @@ static void ppc_core99_init(MachineState *machine) if (bios_size <=3D 0) { /* or load binary ROM image */ bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE, - NULL); + &errp); } g_free(filename); } if (bios_size < 0 || bios_size > PROM_SIZE) { - error_report("could not load PowerPC bios '%s'", bios_name); + if (!errp) { + error_setg(&errp, ": exceeds maximum file size (%" PRIu64 " Mi= B)", + PROM_SIZE / MiB); + } + error_reportf_err(errp, "could not load PowerPC bios '%s'", bios_n= ame); exit(1); } =20 @@ -212,11 +217,11 @@ static void ppc_core99_init(MachineState *machine) kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, machine->ram_size - kernel_b= ase, - NULL); + &errp); } - if (kernel_size < 0) { - error_report("could not load kernel '%s'", - machine->kernel_filename); + if (errp) { + error_reportf_err(errp, "could not load kernel '%s': ", + machine->kernel_filename); exit(1); } /* load initrd */ @@ -225,10 +230,10 @@ static void ppc_core99_init(MachineState *machine) initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, machine->ram_size - initrd_b= ase, - NULL); - if (initrd_size < 0) { - error_report("could not load initial ram disk '%s'", - machine->initrd_filename); + &errp); + if (errp) { + error_reportf_err(errp, "couldn't load initial ram disk '%= s': ", + machine->initrd_filename); exit(1); } cmdline_base =3D TARGET_PAGE_ALIGN(initrd_base + initrd_size); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index c7e44d49b0..f20497e949 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -108,6 +108,7 @@ static void ppc_heathrow_init(MachineState *machine) DriveInfo *dinfo, *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; uint64_t tbfreq =3D kvm_enabled() ? kvmppc_get_tbfreq() : TBFREQ; + Error *errp =3D NULL; =20 /* init CPUs */ for (i =3D 0; i < machine->smp.cpus; i++) { @@ -144,13 +145,17 @@ static void ppc_heathrow_init(MachineState *machine) if (bios_size <=3D 0) { /* or if could not load ELF try loading a binary ROM image */ bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE, - NULL); + &errp); bios_addr =3D PROM_BASE; } g_free(filename); } if (bios_size < 0 || bios_addr - PROM_BASE + bios_size > PROM_SIZE) { - error_report("could not load PowerPC bios '%s'", bios_name); + if (!errp) { + error_setg(&errp, ": exceeds maximum file size (%" PRIu64 " Mi= B)", + PROM_SIZE / MiB); + } + error_reportf_err(errp, "could not load PowerPC bios '%s'", bios_n= ame); exit(1); } =20 @@ -168,11 +173,11 @@ static void ppc_heathrow_init(MachineState *machine) kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, machine->ram_size - kernel_b= ase, - NULL); + &errp); } - if (kernel_size < 0) { - error_report("could not load kernel '%s'", - machine->kernel_filename); + if (errp) { + error_reportf_err(errp, "could not load kernel '%s': ", + machine->kernel_filename); exit(1); } /* load initrd */ @@ -182,10 +187,10 @@ static void ppc_heathrow_init(MachineState *machine) initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, machine->ram_size - initrd_b= ase, - NULL); - if (initrd_size < 0) { - error_report("could not load initial ram disk '%s'", - machine->initrd_filename); + &errp); + if (errp) { + error_reportf_err(errp, "couldn't load initial ram disk '%= s': ", + machine->initrd_filename); exit(1); } cmdline_base =3D TARGET_PAGE_ALIGN(initrd_base + initrd_size); diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 1f754df0e2..f1b45c3b2c 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -129,6 +129,7 @@ static void pegasos2_init(MachineState *machine) int i; ssize_t sz; uint8_t *spd_data; + Error *errp =3D NULL; =20 /* init CPU */ pm->cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); @@ -164,10 +165,14 @@ static void pegasos2_init(MachineState *machine) ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (sz <=3D 0) { sz =3D load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM= _SIZE, - NULL); + &errp); } if (sz <=3D 0 || sz > PROM_SIZE) { - error_report("Could not load firmware '%s'", filename); + if (!errp) { + error_setg(&errp, ": exceeds maximum file size (%" PRIu64 " Mi= B)", + PROM_SIZE / MiB); + } + error_reportf_err(errp, "Could not load firmware '%s'", filename); exit(1); } g_free(filename); @@ -260,10 +265,10 @@ static void pegasos2_init(MachineState *machine) pm->initrd_addr =3D ROUND_UP(pm->initrd_addr, 4); pm->initrd_addr =3D MAX(pm->initrd_addr, INITRD_MIN_ADDR); sz =3D load_image_targphys(machine->initrd_filename, pm->initrd_ad= dr, - machine->ram_size - pm->initrd_addr, NULL= ); - if (sz <=3D 0) { - error_report("Could not load initrd '%s'", - machine->initrd_filename); + machine->ram_size - pm->initrd_addr, &err= p); + if (errp) { + error_reportf_err(errp, "Could not load initrd '%s': ", + machine->initrd_filename); exit(1); } pm->initrd_size =3D sz; diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 1c0dadda87..f5224537d3 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1009,12 +1009,12 @@ static void pnv_init(MachineState *machine) PnvMachineClass *pmc =3D PNV_MACHINE_GET_CLASS(machine); int max_smt_threads =3D pmc->max_smt_threads; char *fw_filename; - long fw_size; uint64_t chip_ram_start =3D 0; int i; char *chip_typename; DriveInfo *pnor; DeviceState *dev; + Error *errp =3D NULL; =20 if (kvm_enabled()) { error_report("machine %s does not support the KVM accelerator", @@ -1068,24 +1068,21 @@ static void pnv_init(MachineState *machine) exit(1); } =20 - fw_size =3D load_image_targphys(fw_filename, pnv->fw_load_addr, FW_MAX= _SIZE, - NULL); - if (fw_size < 0) { - error_report("Could not load OPAL firmware '%s'", fw_filename); + if (load_image_targphys(fw_filename, pnv->fw_load_addr, FW_MAX_SIZE, + &errp) < 0) { + error_reportf_err(errp, "Could not load OPAL firmware '%s': ", + fw_filename); exit(1); } g_free(fw_filename); =20 /* load kernel */ if (machine->kernel_filename) { - long kernel_size; - - kernel_size =3D load_image_targphys(machine->kernel_filename, - KERNEL_LOAD_ADDR, KERNEL_MAX_SIZ= E, - NULL); - if (kernel_size < 0) { - error_report("Could not load kernel '%s'", - machine->kernel_filename); + if (load_image_targphys(machine->kernel_filename, + KERNEL_LOAD_ADDR, KERNEL_MAX_SIZE, + &errp) < 0) { + error_reportf_err(errp, "Could not load kernel '%s': ", + machine->kernel_filename); exit(1); } } @@ -1095,10 +1092,10 @@ static void pnv_init(MachineState *machine) pnv->initrd_base =3D INITRD_LOAD_ADDR; pnv->initrd_size =3D load_image_targphys(machine->initrd_filename, pnv->initrd_base, - INITRD_MAX_SIZE, NULL); - if (pnv->initrd_size < 0) { - error_report("Could not load initial ram disk '%s'", - machine->initrd_filename); + INITRD_MAX_SIZE, &errp); + if (errp) { + error_reportf_err(errp, "Could not load initial ram disk '%s':= ", + machine->initrd_filename); exit(1); } } diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 7c66912c10..64b5d9a4c4 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -141,6 +141,7 @@ static void bamboo_init(MachineState *machine) DeviceState *uicdev; SysBusDevice *uicsbd; int success; + Error *errp =3D NULL; =20 if (kvm_enabled()) { error_report("machine %s does not support the KVM accelerator", @@ -243,11 +244,11 @@ static void bamboo_init(MachineState *machine) if (initrd_filename) { initrd_size =3D load_image_targphys(initrd_filename, RAMDISK_ADDR, machine->ram_size - RAMDISK_ADDR, - NULL); + &errp); =20 - if (initrd_size < 0) { - error_report("could not load ram disk '%s' at %x", - initrd_filename, RAMDISK_ADDR); + if (errp) { + error_reportf_err(errp, "could not load ram disk '%s' at %x: ", + initrd_filename, RAMDISK_ADDR); exit(1); } } diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index edd3da7102..d25a98dd2b 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -250,6 +250,7 @@ static void ibm_40p_init(MachineState *machine) uint32_t kernel_base =3D 0, initrd_base =3D 0; long kernel_size =3D 0, initrd_size =3D 0; char boot_device; + Error *errp =3D NULL; =20 if (kvm_enabled()) { error_report("machine %s does not support the KVM accelerator", @@ -280,10 +281,14 @@ static void ibm_40p_init(MachineState *machine) bios_size =3D load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, N= ULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (bios_size < 0) { - bios_size =3D load_image_targphys(filename, BIOS_ADDR, BIOS_SIZE, = NULL); + bios_size =3D load_image_targphys(filename, BIOS_ADDR, BIOS_SIZE, = &errp); } if (bios_size < 0 || bios_size > BIOS_SIZE) { - error_report("Could not load bios image '%s'", filename); + if (!errp) { + error_setg(&errp, ": exceeds maximum file size (%" PRIu64 " Mi= B)", + BIOS_SIZE / MiB); + } + error_reportf_err(errp, "Could not load bios image '%s'", filename= ); return; } g_free(filename); @@ -381,10 +386,10 @@ static void ibm_40p_init(MachineState *machine) kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, machine->ram_size - kernel_base, - NULL); - if (kernel_size < 0) { - error_report("could not load kernel '%s'", - machine->kernel_filename); + &errp); + if (errp) { + error_reportf_err(errp, "could not load kernel '%s': ", + machine->kernel_filename); exit(1); } fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); @@ -395,10 +400,10 @@ static void ibm_40p_init(MachineState *machine) initrd_size =3D load_image_targphys(machine->initrd_filename, initrd_base, machine->ram_size - initrd_b= ase, - NULL); - if (initrd_size < 0) { - error_report("could not load initial ram disk '%s'", - machine->initrd_filename); + &errp); + if (errp) { + error_reportf_err(errp, "couldn't load initial ram disk '%= s': ", + machine->initrd_filename); exit(1); } fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_base); diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 68d3eacbff..9102bfb6d1 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -262,6 +262,7 @@ static void sam460ex_init(MachineState *machine) struct boot_info *boot_info; uint8_t *spd_data; int success; + Error *errp =3D NULL; =20 cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); env =3D &cpu->env; @@ -495,10 +496,10 @@ static void sam460ex_init(MachineState *machine) initrd_size =3D load_image_targphys(machine->initrd_filename, RAMDISK_ADDR, machine->ram_size - RAMDISK_ADDR, - NULL); - if (initrd_size < 0) { - error_report("could not load ram disk '%s' at %x", - machine->initrd_filename, RAMDISK_ADDR); + &errp); + if (errp) { + error_reportf_err(errp, "could not load ram disk '%s' at %x: ", + machine->initrd_filename, RAMDISK_ADDR); exit(1); } } diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e51540a5ad..18d73868ed 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2824,9 +2824,10 @@ static void spapr_machine_init(MachineState *machine) error_report("Could not find LPAR firmware '%s'", bios_name); exit(1); } - fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE, NULL); - if (fw_size <=3D 0) { - error_report("Could not load LPAR firmware '%s'", filename); + fw_size =3D load_image_targphys(filename, 0, FW_MAX_SIZE, &errp); + if (errp) { + error_reportf_err(errp, "Could not load LPAR firmware '%s': ", + filename); exit(1); } =20 @@ -3089,10 +3090,10 @@ static void spapr_machine_init(MachineState *machin= e) spapr->initrd_size =3D load_image_targphys(initrd_filename, spapr->initrd_base, load_limit - spapr->initrd= _base, - NULL); - if (spapr->initrd_size < 0) { - error_report("could not load initial ram disk '%s'", - initrd_filename); + &errp); + if (errp) { + error_reportf_err(errp, "couldn't load initial ram disk '%= s': ", + initrd_filename); exit(1); } } diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 00d9ab7509..e1b658bcda 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -195,6 +195,7 @@ static void virtex_init(MachineState *machine) qemu_irq irq[32], cpu_irq; int kernel_size; int i; + Error *errp =3D NULL; =20 /* init CPUs */ cpu =3D ppc440_init_xilinx(machine->cpu_type, 400000000); @@ -253,7 +254,12 @@ static void virtex_init(MachineState *machine) /* If we failed loading ELF's try a raw image. */ kernel_size =3D load_image_targphys(kernel_filename, boot_offset, - machine->ram_size, NULL); + machine->ram_size, &errp); + if (errp) { + error_reportf_err(errp, "couldn't load kernel '%s': ", + kernel_filename); + exit(1); + } boot_info.bootstrap_pc =3D boot_offset; high =3D boot_info.bootstrap_pc + kernel_size + 8192; } @@ -265,11 +271,10 @@ static void virtex_init(MachineState *machine) initrd_base =3D high =3D ROUND_UP(high, 4); initrd_size =3D load_image_targphys(machine->initrd_filename, high, machine->ram_size - hi= gh, - NULL); - - if (initrd_size < 0) { - error_report("couldn't load ram disk '%s'", - machine->initrd_filename); + &errp); + if (errp) { + error_reportf_err(errp, "couldn't load ram disk '%s': ", + machine->initrd_filename); exit(1); } high =3D ROUND_UP(high + initrd_size, 4); --=20 2.51.0