From patchwork Fri Nov 30 15:17:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152552 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779417ljp; Fri, 30 Nov 2018 07:17:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/XtpKhW8X4BFt2aabYSYTVWgDxtE+nrIkSu1MrgzmOubSmMubiFud+nsgz45sBT9SLARSJH X-Received: by 2002:a1c:8a09:: with SMTP id m9mr5909431wmd.27.1543591038064; Fri, 30 Nov 2018 07:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591038; cv=none; d=google.com; s=arc-20160816; b=chh6S1StroKTMTT5pVvKO1XZJxSmSNi8OXoWn64C7+oLu2XGTfKUknQwAnCitJAkSr tvzd7XYcHTSbTcA23wTAi+qtrAL5YiOjZOpM9gDh1dpzCxk7tK+gf12BLEaCLiKf0aQK 353IuqnL6Wx9s0bLaaYypxylEBBVV++u8oVhFo9O7HF77K5eXpNbh6fCIuLTnogw75Q1 6vNzbr8tTyg/svW6JYLtOPhy8VPztgbLwPUOMeuz5XzGgVpabeSSvimbS1EIf++QaPZl K6bimXGp2HtX7dwAJgDYygNQ77wKNKeGfe8p0VbwtFBwVLnhGXPzho6fc6w0JsAaX8z+ hV6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ll318e5i9jodtYn114EqXuc7j8+i9sDAqco903x5ZrI=; b=PgknEnYH1z/bils0b5R8TnOTz+5cNeSI7nUllVrvy7h6zNbFaUZcYXaaOo1fYirtoS pmUamlfDNOo81wZXcMfl8M5YAP8hlNYW5aeZuENHT3May814bZbQ1oy89JkfRRJKFUXc 4XQEPq6VbySgwanBmJmeyy4O/JzAfFESqUz8029Xr3aHLVjl+dZn8eu+4RPG9erdTk9F M/2hylaDcmUPcmQUkzRwd9vJqKGyd3Q8goME2Sphg56thlKvDFLmGOALnNqrg5vOJvth rbZp3so2ix7EcOa6UQex0hpwzqbaskH3Ez7mFBXVKWq2Thy7Y3/RU+0FyylsN7rqlPtI AnyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id v188si4622434wma.34.2018.11.30.07.17.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXZ-0005P0-T9; Fri, 30 Nov 2018 15:17:13 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 01/10] hw/ppc/mac_newworld, mac_oldworld: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:03 +0000 Message-Id: <20181130151712.2312-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Use the glib g_file_get_contents() function instead, which does the whole "allocate memory for the file and read it in" operation. Signed-off-by: Peter Maydell --- hw/ppc/mac_newworld.c | 10 ++++------ hw/ppc/mac_oldworld.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) -- 2.19.1 Reviewed-by: Eric Blake Acked-by: David Gibson diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 14273a123e5..7e45afae7c5 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -127,8 +127,7 @@ static void ppc_core99_init(MachineState *machine) MACIOIDEState *macio_ide; BusState *adb_bus; MacIONVRAMState *nvr; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -510,11 +509,10 @@ static void ppc_core99_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 9891c325a9b..817f70e52cf 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -99,8 +99,7 @@ static void ppc_heathrow_init(MachineState *machine) SysBusDevice *s; DeviceState *dev, *pic_dev; BusState *adb_bus; - int bios_size, ndrv_size; - uint8_t *ndrv_file; + int bios_size; uint16_t ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; @@ -361,11 +360,10 @@ static void ppc_heathrow_init(MachineState *machine) /* MacOS NDRV VGA driver */ filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, NDRV_VGA_FILENAME); if (filename) { - ndrv_size = get_image_size(filename); - if (ndrv_size != -1) { - ndrv_file = g_malloc(ndrv_size); - ndrv_size = load_image(filename, ndrv_file); + gchar *ndrv_file; + gsize ndrv_size; + if (g_file_get_contents(filename, &ndrv_file, &ndrv_size, NULL)) { fw_cfg_add_file(fw_cfg, "ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size); } g_free(filename); From patchwork Fri Nov 30 15:17:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152555 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779428ljp; Fri, 30 Nov 2018 07:17:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/WlnMS9ap3bKLZN0wViV76D7s5F6WnoiHRZNMbuQRJINxVm/BYIfAmFW37lKjc2SrR6vBhs X-Received: by 2002:a19:aace:: with SMTP id t197mr3795775lfe.7.1543591038561; Fri, 30 Nov 2018 07:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591038; cv=none; d=google.com; s=arc-20160816; b=0aCyNbuUfaQxVqpD1y6ZjOmjpm4fsneU4R/azaPEos+Ve8ltVt2qxEyDGvzcT3QAmg v1e5Cbp0ibchvoF1qqeGjfA01BipVQPQIjiVM2FWsQKUYv/41UvEin0RKeimKxCB8gbg 3e7CELNCrHsPDQUkbzgGZq220YGE8jiYBHIjcDG87BmUQdNkO8BtRP3oV4Ittc3D30tp 4uTqFoJgO1/Xt7znVNqhCfISkEZmH9IKVH0epdaF7J5VXO4AxCO0D13jfXMYdUyLeN1B 3YC6UW4UPpjJhQDD3OD0+dv9Bkkjme/OttwUdBPlxZUhyBo1rs5Ebvv9+rxJCt2FWom3 MLTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ECNRMrfZrTfVJfvgcrEk4pJPqYM2M1yqogFCaRg7B9o=; b=TuRe2CzDIiysHGZ1uyXOhp+PDTtnb1dZmgJjg363yLyL3FtgohKFVfA3sCfYfZymDs 3wnERThUMY3i8n5omdzfhsf4NRsLkB+2T+dZrQ4EUTuzpxdmKpnFcve4tbuWJhKo4RYF LHJlibhAxbMxYtHrwjy71K7JXCYEvKPqWug6fvVyToZkRjFaFfUUlOwjRr5n9P/yQaLq OC9K8v2UccX9xRfVPiC3QWSccp0W9qs4pWY8dy8oEXRoPcW3os1ZC041D93cqgP9jY6O XvT72Bww6MLj6khY2A1WUaCjSpOJ7KHqEozeqapDzwQAHuzO/Vrjz20UvS+TkZnvO/8i m26Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id q1si4877570lfi.19.2018.11.30.07.17.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXa-0005PD-DB; Fri, 30 Nov 2018 15:17:14 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 02/10] hw/ppc/ppc405_boards: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:04 +0000 Message-Id: <20181130151712.2312-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- hw/ppc/ppc405_boards.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) -- 2.19.1 Reviewed-by: Eric Blake Acked-by: David Gibson diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 3be3fe4432b..1b0a0a8ba3a 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -219,9 +219,11 @@ static void ref405ep_init(MachineState *machine) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); + bios_size = load_image_size(filename, + memory_region_get_ram_ptr(bios), + BIOS_SIZE); g_free(filename); - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } @@ -515,9 +517,11 @@ static void taihu_405ep_init(MachineState *machine) &error_fatal); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { - bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); + bios_size = load_image_size(filename, + memory_region_get_ram_ptr(bios), + BIOS_SIZE); g_free(filename); - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } From patchwork Fri Nov 30 15:17:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152554 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779429ljp; Fri, 30 Nov 2018 07:17:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/V72MRP8G195HOOuiaIfnKEMdpyZgvvMLHUhcZVD+c6/jXApCU8TtN8fpGKyvJWLfvtw9mL X-Received: by 2002:a19:5d42:: with SMTP id p2mr4135926lfj.83.1543591038584; Fri, 30 Nov 2018 07:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591038; cv=none; d=google.com; s=arc-20160816; b=h1YuHLWUwFyiUhgAWOV6whpeWDTqlGR/exjQvPe+/i/0Fq3yEp1mxztce5MYFSrTLo z3Kwq2s1h3aM9LDt/CGzlRt40m3pSwPDaW7xtBw1o+eJWMCGar+jVTUxPFu9HpgS60vW 7VrE8E7iqVDd2Y/7+/NCJPDJBoiRWymiEr8oZzkoIq/7ohWqhqMV+cZeMXE3EyFYpNTS 8eXcZHhFNRAavnJFCuONsOAK1P5nco3I5iyB9W/FYk4DEzdHuSDLOnd52ck4H13glgSW 1l2dHr2+gZCP/gnua+23vIrFh/A+DABTFGcAbO9itNpZD5wtJe2puR49xZ8J0vB+zrgs AUaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=0Gm0+XjVi4uqD+oDa3UUyw+AV083XUTEWVkZtDaKuZw=; b=bK9+j8tapmTrMBjJcqg/AW8sexHrwQiPccHXuAHbY/+Iatlb/Q8ImZMljFOeNfBXba ibMwNIHb/aFEiBjp8GwUdv9+Guj2x/a6q3EUJI8WjQ9ACyz/ebUtvFpFDxpRHcwapGiY PZDmBCFUBg37FJaRjL6Qx0cXF//kpP4lSyHVj3io5wdB+/5B3uBnGCAMBQVnYsfnsm3u S1FNTu1ttKIyDE4okv0rBuohhvHv5Rblx7AFX9QMq2ob2dL0pabIksCY4xOed+12ijy4 nkXsSmGm2Tx9qCbVi8kyyaTde1b6QdhvNIpn086Uo3sS24/Qd5vb1BTfac0dv1NGAAgG RAKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id p65-v6si5579432ljp.129.2018.11.30.07.17.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXa-0005PQ-U0; Fri, 30 Nov 2018 15:17:14 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 03/10] hw/smbios/smbios.c: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:05 +0000 Message-Id: <20181130151712.2312-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- hw/smbios/smbios.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c index 920939454e7..04811279a08 100644 --- a/hw/smbios/smbios.c +++ b/hw/smbios/smbios.c @@ -982,7 +982,7 @@ void smbios_entry_add(QemuOpts *opts, Error **errp) header = (struct smbios_structure_header *)(smbios_tables + smbios_tables_len); - if (load_image(val, (uint8_t *)header) != size) { + if (load_image_size(val, (uint8_t *)header, size) != size) { error_setg(errp, "Failed to load SMBIOS file %s", val); return; } From patchwork Fri Nov 30 15:17:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152561 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3786903ljp; Fri, 30 Nov 2018 07:24:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/V4lMUAcbLRGpS9+xeQMcwkcqXIOpmMn2hM/luwbXoe9gOCp60EPwOkyCyc3gCASbVtwgdL X-Received: by 2002:a25:c5c2:: with SMTP id v185-v6mr5768318ybe.110.1543591446639; Fri, 30 Nov 2018 07:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591446; cv=none; d=google.com; s=arc-20160816; b=JnvjGPG23BoNNzRyHGUjcZGW3ZpMlE2cFi8qMSutWc8yVwYJTzA1YoreFGKJ9psgjv NeWrCY9gqTA7krMXWqGM9iFrbj/ShjxAlyBI+Hk4w0fvwt7+25wYtVGiNbC5RqASgFh8 wqXymZlK6QJL+LREEQ3JHe2/IssaAarFZ/IfdnYynG+k45BiCGamFBBST5oRhuzF6ZIv lXjaJ60K8Vg34nUwlRTo37tzdMAcm4oVvxbe3a7JuZjW08Toz5BaLemqDN1gYquTo+uh kTYBTqD+CFJrN+3tpOsafFRpkOuIEECLZxqqou04r1PLqtgIrYHyNyzK5s8BecjfoXJE 8KyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=/fL3vDEK/yCJahvs9k0B3qA5+nos4bCRs7EUAVbfgCE=; b=YAvOwJq2mK1mh8eXAh2sbKem76Ah5H07+F+b50dMMr4tgO1RYCZc9wrrEb8CGO1+N/ 0ZEjnOtwLKf6B96mea9c9IJu0P9/ONKCo7sR18qdW4CdihCI7wECXsWoxf7z6pjz6L4X gnB/R+8OJz5dsPrv4d5Gysjp18kCUSOMw5rfp34sriWQ4wgmqOBV7i/Y8hBrQAh64gwa JqsJlfJ9wtwyL+4wghK8Vb/gy4dQi+9euEwVMLBCR0WNOtVKhYLd8uYD1d7Itv6FFeYD qTbhpRiqfWG4TlxAA63gSw/oOoJWmb4JrS/ksF4MlNXSHwbhz4gi9qOAU9RTfQEBQZFm vOjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a11-v6si3086194ybm.316.2018.11.30.07.24.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Nov 2018 07:24:06 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkeD-0001ov-Vt for patch@linaro.org; Fri, 30 Nov 2018 10:24:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkXx-0004kR-Lm for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:17:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSkXw-0005ZD-Sf for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:17:37 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:53042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSkXw-0005Th-Hl; Fri, 30 Nov 2018 10:17:36 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXb-0005Pd-EI; Fri, 30 Nov 2018 15:17:15 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 30 Nov 2018 15:17:06 +0000 Message-Id: <20181130151712.2312-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 04/10] hw/pci/pci.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-ppc@nongnu.org, Li Zhijian , patches@linaro.org, Peter Crosthwaite , Alexander Graf , Max Reitz , Philip Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Igor Mammedov , qemu-block@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- hw/pci/pci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 56b13b3320e..efb5ce196ff 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -2261,7 +2261,11 @@ static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, pdev->has_rom = true; memory_region_init_rom(&pdev->rom, OBJECT(pdev), name, size, &error_fatal); ptr = memory_region_get_ram_ptr(&pdev->rom); - load_image(path, ptr); + if (load_image_size(path, ptr, size) < 0) { + error_setg(errp, "failed to load romfile \"%s\"", pdev->romfile); + g_free(path); + return; + } g_free(path); if (is_default_rom) { From patchwork Fri Nov 30 15:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152562 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3787008ljp; Fri, 30 Nov 2018 07:24:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/W5IdIHSHuRAbFKKJXAQRlJkn7wG19fpIKFhToE/db93Wv8n1LSnhP92rUzQGwUtOu1e9B0 X-Received: by 2002:a1c:88c7:: with SMTP id k190mr5523925wmd.97.1543591452253; Fri, 30 Nov 2018 07:24:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591452; cv=none; d=google.com; s=arc-20160816; b=zEChUCVPfUhztPL7LAM17O0E50FkrqCQi2742KPV1/tYhgfc1AgbmmPOAS6rZfO536 akzbVFo4BhtBKQZP/emTTNXmOdWHrfAPPKJjX1ftEQ0SmULk/HQIaTA1shAiA3lwtoee oUrHQRuNAU6c27wBj7GrSA2BRNo+6ICRZyJydIcQ/fuDWScq2zmUqX9JdGR+m9UwShS0 U9bkVnzjST4UQ7FscY8AnLdeq3KiOfy8JhxnSeF32q7Cjm8dfNrwiGIrGduMdYNq/5xG QeH6akZEr9kwnNZX5qUN4rzcthS9baDfVWv78fkPX9k9M9AgmkEb9d1el8kg0d9P2LYv csNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=XkBbkLiwentOsJk1bho8mj47IzLUpNrMrfQelrLtJRo=; b=mKvXqhLkLBJp87qRJf3Eve8SrzZL7jFiQh6bats/NfaNgAY1UrG4HA9+yYGNccga5x EtPeIV0KJrXXSDxjW054y6qNbtC7u4r1bxT7aVCyrrDGeCqLn1FoMriY0FeOUVJ2vqhF kuajF3BOm42D8HviWVRBLKFnjc0N0reJHSEPul9kq0Wv915WFq5uvZq1L9gumQZWq+QH kQZbrEvqFACnvH4bCKJMd0m4OgP7ZyFIjyK83MyXr1MSYPpRdzM5v9eOfigdqsTdqWSL MmRc7AwJ6/3jwFC2rIXWKcx5vxPR3IfjyEHsQEvDJgVZ/EOtf4JOJGLwxWl4sphtIZBV V8Rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id j27si4680235wre.73.2018.11.30.07.24.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:24:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXb-0005Pq-Us; Fri, 30 Nov 2018 15:17:15 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 05/10] hw/i386/pc.c: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:07 +0000 Message-Id: <20181130151712.2312-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Use the glib g_file_get_contents() function instead, which does the whole "allocate memory for the file and read it in" operation. Signed-off-by: Peter Maydell --- hw/i386/pc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f095725dbab..067d23a992a 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -839,10 +839,9 @@ static void load_linux(PCMachineState *pcms, { uint16_t protocol; int setup_size, kernel_size, cmdline_size; - int64_t initrd_size = 0; int dtb_size, setup_data_offset; uint32_t initrd_max; - uint8_t header[8192], *setup, *kernel, *initrd_data; + uint8_t header[8192], *setup, *kernel; hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f; char *vmode; @@ -965,27 +964,30 @@ static void load_linux(PCMachineState *pcms, /* load initrd */ if (initrd_filename) { + gsize initrd_size; + gchar *initrd_data; + GError *gerr = NULL; + if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); exit(1); } - initrd_size = get_image_size(initrd_filename); - if (initrd_size < 0) { + if (!g_file_get_contents(initrd_filename, &initrd_data, + &initrd_size, &gerr)) { fprintf(stderr, "qemu: error reading initrd %s: %s\n", - initrd_filename, strerror(errno)); + initrd_filename, gerr->message); exit(1); - } else if (initrd_size >= initrd_max) { + } + if (initrd_size >= initrd_max) { fprintf(stderr, "qemu: initrd is too large, cannot support." - "(max: %"PRIu32", need %"PRId64")\n", initrd_max, initrd_size); + "(max: %"PRIu32", need %"PRId64")\n", + initrd_max, initrd_size); exit(1); } initrd_addr = (initrd_max-initrd_size) & ~4095; - initrd_data = g_malloc(initrd_size); - load_image(initrd_filename, initrd_data); - fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size); From patchwork Fri Nov 30 15:17:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152559 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779514ljp; Fri, 30 Nov 2018 07:17:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/VSs7nPzhqTFmdPn2w5b5q86rsIUGWsEKP/oc4iPa6XFFCoDnnjXqF6hTKCXB+cTxcO3TsY X-Received: by 2002:a63:e655:: with SMTP id p21mr5116058pgj.70.1543591041686; Fri, 30 Nov 2018 07:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591041; cv=none; d=google.com; s=arc-20160816; b=D6AKVAs6hT+QhbmyqxcF4US7dV0V49Ih6lIEAKjNIuy2JchTSHC8pyElo4V6+XwCUj bTKo3/R32i+kTXVJepfEey48KAQlmrh/GaDeFm2PLl64c8ECx2SF8WX7zE2zBUwPgFTR huHKyagaIhdOq4kVlgNvNnVdvlup3nzPwcJERchjVFGoM9u0YMkwtaol4XCj3fOGQy+1 wYppcqARavzA/o86M6zw8FBKQYxg7Z9UTJhaGgbLyuMdLRTKiycGDiS3DuMtTvq6B019 ej7h5TrccEy6PRgKUsyWyaO1ORuBJSVbKs3DHm36V/SPNtsQACnGjVnIaZYg2XYXregY yihg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=EtexVaJwnq2vPWw7MVdMcDkSVa8JircvQY+1IL6HTGc=; b=qhnSkAAznCOiWAfD3QeSRznhiib+if/r4pYvjO+zHtcWnYI2HxhFQI1wOVeGzi5t5x gM2JCQvduUc9EfsOBQIN2eEoeNqFSJcr5L9sZtESSPMYADcCgFnZlqqmpAEbKkLD5BKE hkytxlj2TYpoOIsUZ4WaxLSfUY1Gw8Gbk/QYwjbANV8cVoyFLUTpPLC7i60d7aMjbKNX /Jvifseye8BDKdSrVZA1ZbmgNPXn1Fd6OfDmYDehl7vF9rXAHqteSB6uxSRopICD7uvE caXiedYoKHNIX/UH37DekCkY0LmHabbw/k2/gqDh2w8v5A3zE8QLsWg8BMT9A7Tdj7+J 7Lzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id c8si5054188pgc.65.2018.11.30.07.17.21 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXc-0005Q3-Et; Fri, 30 Nov 2018 15:17:16 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 06/10] hw/i386/multiboot.c: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:08 +0000 Message-Id: <20181130151712.2312-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- hw/i386/multiboot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c index 1a4344f5fc3..62340687e8e 100644 --- a/hw/i386/multiboot.c +++ b/hw/i386/multiboot.c @@ -343,7 +343,11 @@ int load_multiboot(FWCfgState *fw_cfg, mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size); mbs.mb_buf = g_realloc(mbs.mb_buf, mbs.mb_buf_size); - load_image(one_file, (unsigned char *)mbs.mb_buf + offs); + if (load_image_size(one_file, (unsigned char *)mbs.mb_buf + offs, + mbs.mb_buf_size - offs) < 0) { + error_report("Error loading file '%s'", one_file); + exit(1); + } mb_add_mod(&mbs, mbs.mb_buf_phys + offs, mbs.mb_buf_phys + offs + mb_mod_length, c); From patchwork Fri Nov 30 15:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152557 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779462ljp; Fri, 30 Nov 2018 07:17:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/U1LC1eDOuAqrjL5n6NmPu9J4SYYrQJrFc4NSKJbV3def5cViRi9U6DtkMTWgHVmSj4wNev X-Received: by 2002:aa7:810c:: with SMTP id b12mr5956954pfi.44.1543591040304; Fri, 30 Nov 2018 07:17:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591040; cv=none; d=google.com; s=arc-20160816; b=dN0H6S/WfcVq+TUEt0vsQzLaFAuwJCUAqQodJIeM4nSwO3Om8WUoTECBXIIqekdjTn 2m0jDsGKon/YT7lj6f01o9VHUCyl8lQGm7iuGAu5XiCNmUnBCHUbJN0h3wxO9dB9lMvM QgbleNFxQNZK5nRvGdECNcPoHXIjRbgLCj7gHvN5ikaFizb1azX42iendSivqDjFHJLp l3/fxSDI+M9TJS5hG0vJrBkydASv/yqi4vqta4XTpAusIvj9fTPrbveHjnA0G7b7U8U5 KqyWfCX7IHg/Wq1FPcTpnoHUHte7Pglwte4G1AteHVMwPgU0Dxm4ow4W/HkXJIkbT4me oDyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TrB4X43hfniQHqa5c+DNxXcc7RtdPEdLiH/zQIPW4zs=; b=nOJWw+YO5CR2bAIQ2gKFjxTsHpXqFJhaMT1A0vcNCqyTW+I5QbOrBMU7lsXKxbKL2F OlnZW9fTjBzGxJp5LnPt8djlktBYeWZa19vjeeSL3D3F6+M682op1RBwlx3ZJ0rleUuG ZxIjjl78v/0dfzxg3d3u+QcNOUplf4IRyoPEuKVrC0WBdL+a5o9wPlQz0PlDVsFyneIs 6tvH1aVFQQZ96gph9ig5TEHZT9Y4rzD86FnUN+7CTtbIG2YMep5hG6MmXwQroY4fwsbZ PdNOSgPn8njI9ZRyT8jPObZVG9nQrZVD/6EPp5bwpM//Mrs9b+JmKFUQK8XtZHs5TzAs MbKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id t19si5593865pgk.163.2018.11.30.07.17.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXc-0005QG-W5; Fri, 30 Nov 2018 15:17:17 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 07/10] hw/block/tc58128.c: Don't use load_image() Date: Fri, 30 Nov 2018 15:17:09 +0000 Message-Id: <20181130151712.2312-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- hw/block/tc58128.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c index 808ad76ba60..d0fae248dcc 100644 --- a/hw/block/tc58128.c +++ b/hw/block/tc58128.c @@ -38,7 +38,8 @@ static void init_dev(tc58128_dev * dev, const char *filename) memset(dev->flash_contents, 0xff, FLASH_SIZE); if (filename) { /* Load flash image skipping the first block */ - ret = load_image(filename, dev->flash_contents + 528 * 32); + ret = load_image_size(filename, dev->flash_contents + 528 * 32, + FLASH_SIZE - 528 * 32); if (ret < 0) { if (!qtest_enabled()) { error_report("Could not load flash image %s", filename); From patchwork Fri Nov 30 15:17:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152560 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3783975ljp; Fri, 30 Nov 2018 07:21:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vx1w1djjH0fZ1HRWDoYhYsyHMT5gj47u8CgNYka9iGqFSL7exR0qv2ivtOIZgo/LNGpGov X-Received: by 2002:a25:e0c6:: with SMTP id x189-v6mr5699674ybg.520.1543591283935; Fri, 30 Nov 2018 07:21:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591283; cv=none; d=google.com; s=arc-20160816; b=fbKukX37R1lQOzskry8/wCW5xWQl2fpI2l3orjeyanJMimTd4xAo8o6TYNAMkkaTLe y04tYcOqsF/zy5nb/q+JOgRAk2VnnpMkFKEkZNaxMLb1c1G1+vorVzqhLpkvUNvaqnu7 dE1lYlW9Qp8LX1hKT4yAbZGBlilLM7uqcm77jIeKLiwjsHPidD8oxhe5I8pQdKnfHneN ko/shBGpmKQ01yUdVz8DvccsdoUvrtGW5rPHGYDE2HcgftNIJqFwDeB09zWPyl8zsku/ cX323V3gfLi2M1kvYcPrIETGUju9Oz/XrSbkEF7SqCXobTaal/7s3Fc6nV5VAITVlwyr Jvgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=vEULHHgMH6afxrcxwl0FOhOrsDV1zySoHPzTxcWziaE=; b=FhAzGRENL4N/jTJtLyLvrCoi7ZjR1Y7F/fZ5vr53RbzNwdWKlFOExcAhU24AVajlzl YF+VYyK9J+nhTSr5rRR9pX2P0xkwzjabz5UoZkaiFQPqMHUgiZ+RT+6mMcxt3IGsnxGg n7acRV+w6xHsWK/2WE82g9rTMNZy8gbPid0FfOVRhv4/IwqZXU7c/enYvC5VtVftMpZn H88j3JBWedxi9s5sMvwEJ86Ksa0oBk8oLbcOieaYqij56cmWjgG/Tv69ftCBCNRrHPsB 22ymub3drUU6uF+VWpii3FwxP+8Vf8NmXa+cgn+oUnAtB9mo9IokEmg9gC0zVDeHjuue 0T7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 186-v6si3108602ybp.433.2018.11.30.07.21.23 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 30 Nov 2018 07:21:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:33251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkbb-0000Md-9X for patch@linaro.org; Fri, 30 Nov 2018 10:21:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50595) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSkXr-0004c3-BG for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:17:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSkXq-0005UB-Ik for qemu-devel@nongnu.org; Fri, 30 Nov 2018 10:17:31 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:53042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gSkXq-0005Th-9D; Fri, 30 Nov 2018 10:17:30 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXd-0005QT-Lj; Fri, 30 Nov 2018 15:17:17 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 30 Nov 2018 15:17:10 +0000 Message-Id: <20181130151712.2312-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 08/10] device_tree.c: Don't use load_image() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-ppc@nongnu.org, Li Zhijian , patches@linaro.org, Peter Crosthwaite , Alexander Graf , Max Reitz , Philip Li , "Michael S. Tsirkin" , Stefan Hajnoczi , Igor Mammedov , qemu-block@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The load_image() function is deprecated, as it does not let the caller specify how large the buffer to read the file into is. Instead use load_image_size(). Signed-off-by: Peter Maydell --- device_tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/device_tree.c b/device_tree.c index 6d9c9726f66..296278e12ae 100644 --- a/device_tree.c +++ b/device_tree.c @@ -91,7 +91,7 @@ void *load_device_tree(const char *filename_path, int *sizep) /* First allocate space in qemu for device tree */ fdt = g_malloc0(dt_size); - dt_file_load_size = load_image(filename_path, fdt); + dt_file_load_size = load_image_size(filename_path, fdt, dt_size); if (dt_file_load_size < 0) { error_report("Unable to open device tree file '%s'", filename_path); From patchwork Fri Nov 30 15:17:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152553 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779435ljp; Fri, 30 Nov 2018 07:17:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/WbWk0kDaNvL+Zpd/j7O+G1vzuRKfOfo8n+7m0iO8EZouUtZaO+BV9q5o/pPOng3gvbrvNY X-Received: by 2002:adf:f2c6:: with SMTP id d6mr5051241wrp.37.1543591038818; Fri, 30 Nov 2018 07:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591038; cv=none; d=google.com; s=arc-20160816; b=qpzQY83F91cuB6wiiafMdTN1kItnDsQ2yRanEU6L/5qYj0cBVPEh9JbhZkN0N8G/Q5 N4B5VN162bqsgeAHNdx7RWaikIf2lB3X/5TvxZilv6zPEmyn/UU2n14BGKRj6HnWnCdk rqB90IsNLY8pKaew9CRnEz0nJ9R0YPQgWRY/qVk9GPMnooGNIQ4deNpqDwxT90ICWiqj 7cjK+VC5quaN8+Q/x64gENFswQFOszh2vXgef+qDdOKaRFHDi/8JnjxdhpYgjCd+3Meu ZfFI4YftE3kt5JDK+6/aX1OqAH57WBsaN0l6eQa4Xcp0UePHteGtjpNgVufJaF8+iXaz t09Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=28mEUWz9T71w4PwmDkU8FxL6DnfA01Oa1t+VwXzonG0=; b=XTTRSkzsP5JNujF7L2/yFrPvzBb3xI45cGMipnShmp1SzjaMfokOMWFxxK6qCs/xUN wdH+5pbV3YGMCQyamU3pnJeMDmIOzo4WcYM5vKksH3ye/L8C3QFD40g8BQvOrwBpN1we AFkNLcOxJopgVNynUhtfxlhxuSI2jh3Ihlfdu41EKj+uaDC5wvBMvWqPaFFI8kenjvuU DdZrAF3wQYYQPtG8VDMOOu6SAZ7Yf0flX1lRmOx+qXSHLe39vOmAbfb0/dOVd0BPumzw /EDU8a+eOs5twA5G89cU1EZ3Z1QJ0n/N/B3g4KNdgrt2Tbq1j/s97Bh5w9NqLWQxZ86T 0wMA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id v126si4433343wmf.58.2018.11.30.07.17.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXe-0005RA-Aw; Fri, 30 Nov 2018 15:17:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 09/10] hw/core/loader.c: Remove load_image() Date: Fri, 30 Nov 2018 15:17:11 +0000 Message-Id: <20181130151712.2312-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 The load_image() function is now no longer used anywhere, so we can remove it completely. (Use load_image_size() or g_file_get_contents() instead.) Signed-off-by: Peter Maydell --- include/hw/loader.h | 1 - hw/core/loader.c | 25 ------------------------- 2 files changed, 26 deletions(-) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/include/hw/loader.h b/include/hw/loader.h index 67a0af84ac3..3766559bc24 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -11,7 +11,6 @@ * On error, errno is also set as appropriate. */ int64_t get_image_size(const char *filename); -int load_image(const char *filename, uint8_t *addr); /* deprecated */ ssize_t load_image_size(const char *filename, void *addr, size_t size); /**load_image_targphys_as: diff --git a/hw/core/loader.c b/hw/core/loader.c index aa0b3fc8679..180d891b19c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -73,31 +73,6 @@ int64_t get_image_size(const char *filename) return size; } -/* return the size or -1 if error */ -/* deprecated, because caller does not specify buffer size! */ -int load_image(const char *filename, uint8_t *addr) -{ - int fd, size; - fd = open(filename, O_RDONLY | O_BINARY); - if (fd < 0) - return -1; - size = lseek(fd, 0, SEEK_END); - if (size == -1) { - fprintf(stderr, "file %-20s: get size error: %s\n", - filename, strerror(errno)); - close(fd); - return -1; - } - - lseek(fd, 0, SEEK_SET); - if (read(fd, addr, size) != size) { - close(fd); - return -1; - } - close(fd); - return size; -} - /* return the size or -1 if error */ ssize_t load_image_size(const char *filename, void *addr, size_t size) { From patchwork Fri Nov 30 15:17:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 152556 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3779444ljp; Fri, 30 Nov 2018 07:17:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WE7PgXBC0qjhW4Etn9hXur9EpUwILnVXQV2jZlyEuomRfOcsfdA5AjPPRbrixmCENHWOC0 X-Received: by 2002:a1c:282:: with SMTP id 124mr2596013wmc.113.1543591039619; Fri, 30 Nov 2018 07:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543591039; cv=none; d=google.com; s=arc-20160816; b=yW+Ko+WVfsOrLNoOQ7BYtdDqPCOJQKr/RIirG2Sxc81EWyGPzObBBKmBI48yUZyNZj g+id2rnDDNkDa0HRLME6dLmgGKYOBHmvYJtafxt+UdAyM0B91YCMTOr94BfECpkKUALY VF5tNtrO8fFiRU5bgIyEq4zxFs9CvD6JCQjHmPD1/Sv0zPFL2NM4Sz5nab1a45cWzBMh LPzQg2JN8cOf44pOijd5AwnlIZ+Nl8xvm1GTPmv03Sia2b/Eo035FniGw+CaEmSMiQgq DtMi+R0BxKqZ5XAIqvoWktYIolWQ82Szadoypq1LbwzEd6eSwhZFcPwUFVLKAUCi+3/g f//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=TZyHnF1wQ5eVZSACS4/yOTXC5JynBLIBUKirbbw/pfs=; b=OXRlc671i+Sr0uOtxT+kofyiNQk7pUcULmiYroUf+1++nov5WImoGaZI143St6/B/p +kTwF4q35ihoDdHSRDbQjhxtQ9kFLWCEOMK9VmUFkbbzI3xGjfYf0+Qt/e3gXPac6jco OVemoth4yLU/bW5BdTCUCiVdniB8V65YI53iLEyILSOvJurQQW+5Vl9+rZhVquuEqfXA qDRyMXxMcagCvjF1rfTDplwh+PguF5pPq9qb9F+R2amBA6xgyzKQnU+S9OEzQfciWWm3 bQQ+JeDwLNSPFiGsA2xSbYkJ0OvMT2m4kXknBS5+4xpkSYLBMS0KEPZdxR81xeP0oPEy h5Nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id u9si3815763wru.440.2018.11.30.07.17.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 07:17:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gSkXe-0005RU-Uw; Fri, 30 Nov 2018 15:17:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Hajnoczi , Eric Blake , "Daniel P . Berrange" , Li Zhijian , Philip Li , Peter Crosthwaite , Alexander Graf , Kevin Wolf , Max Reitz , "Michael S. Tsirkin" , Marcel Apfelbaum , David Gibson , Igor Mammedov , qemu-block@nongnu.org, qemu-ppc@nongnu.org Subject: [PATCH 10/10] include/hw/loader.h: Document load_image_size() Date: Fri, 30 Nov 2018 15:17:12 +0000 Message-Id: <20181130151712.2312-11-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181130151712.2312-1-peter.maydell@linaro.org> References: <20181130151712.2312-1-peter.maydell@linaro.org> MIME-Version: 1.0 Add a documentation comment for load_image_size(). Signed-off-by: Peter Maydell --- include/hw/loader.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.19.1 Reviewed-by: Eric Blake diff --git a/include/hw/loader.h b/include/hw/loader.h index 3766559bc24..0a0ad808ea3 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -11,6 +11,22 @@ * On error, errno is also set as appropriate. */ int64_t get_image_size(const char *filename); +/** + * load_image_size: load an image file into specified buffer + * @filename: Path to the image file + * @addr: Buffer to load image into + * @size: Size of buffer in bytes + * + * Load an image file from disk into the specified buffer. + * If the image is larger than the specified buffer, only + * @size bytes are read (this is not considered an error). + * + * Prefer to use the GLib function g_file_get_contents() rather + * than a "get_image_size()/g_malloc()/load_image_size()" sequence. + * + * Returns the number of bytes read, or -1 on error. On error, + * errno is also set as appropriate. + */ ssize_t load_image_size(const char *filename, void *addr, size_t size); /**load_image_targphys_as: