From: David Gibson <david@gibson.dropbear.id.au>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Alistair Francis <alistair@alistair23.me>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org,
Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Artyom Tarasenko <atar4qemu@gmail.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH 5/5] hw/core/loader: Provide rom_add_file_fixed() a 'max_size' argument
Date: Tue, 10 Mar 2020 11:43:13 +1100 [thread overview]
Message-ID: <20200310004313.GC660117@umbus.fritz.box> (raw)
In-Reply-To: <20200309144353.26457-6-philmd@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3786 bytes --]
On Mon, Mar 09, 2020 at 03:43:53PM +0100, Philippe Mathieu-Daudé wrote:
> Let rom_add_file_fixed() call rom_add_file() with a 'max_size'
> argument, to avoid writing more than the available space for
> the ROMs.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ppc parts
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> include/hw/loader.h | 4 ++--
> hw/i386/x86.c | 2 +-
> hw/ppc/sam460ex.c | 2 +-
> hw/sparc64/niagara.c | 5 +++--
> 4 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/include/hw/loader.h b/include/hw/loader.h
> index 34ac630eb1..30ed80128e 100644
> --- a/include/hw/loader.h
> +++ b/include/hw/loader.h
> @@ -292,8 +292,8 @@ int rom_copy(uint8_t *dest, hwaddr addr, size_t size);
> void *rom_ptr(hwaddr addr, size_t size);
> void hmp_info_roms(Monitor *mon, const QDict *qdict);
>
> -#define rom_add_file_fixed(_f, _a, _i) \
> - rom_add_file(_f, NULL, _a, -1, _i, false, NULL, NULL)
> +#define rom_add_file_fixed(_f, _a, _ms, _i) \
> + rom_add_file(_f, NULL, _a, _ms, _i, false, NULL, NULL)
> #define rom_add_blob_fixed(_f, _b, _l, _a) \
> rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, NULL, NULL, true)
> #define rom_add_file_mr(_f, _mr, _i) \
> diff --git a/hw/i386/x86.c b/hw/i386/x86.c
> index 7f38e6ba8b..bdac66206a 100644
> --- a/hw/i386/x86.c
> +++ b/hw/i386/x86.c
> @@ -783,7 +783,7 @@ void x86_bios_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
> if (!isapc_ram_fw) {
> memory_region_set_readonly(bios, true);
> }
> - ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
> + ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), bios_size, -1);
> if (ret != 0) {
> bios_error:
> fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
> diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c
> index 898453cf30..5eab479ae5 100644
> --- a/hw/ppc/sam460ex.c
> +++ b/hw/ppc/sam460ex.c
> @@ -127,7 +127,7 @@ static int sam460ex_load_uboot(void)
> " using default u-boot image");*/
> rom_add_file_fixed(UBOOT_FILENAME,
> UBOOT_LOAD_BASE | ((hwaddr)FLASH_BASE_H << 32),
> - -1);
> + UBOOT_SIZE, -1);
> }
>
> return 0;
> diff --git a/hw/sparc64/niagara.c b/hw/sparc64/niagara.c
> index f58d008d3d..4dd9a77dcb 100644
> --- a/hw/sparc64/niagara.c
> +++ b/hw/sparc64/niagara.c
> @@ -91,7 +91,7 @@ static void add_rom_or_fail(const char *file, const hwaddr addr,
> /* XXX remove qtest_enabled() check once firmware files are
> * in the qemu tree
> */
> - if (!qtest_enabled() && rom_add_file_fixed(file, addr, -1)) {
> + if (!qtest_enabled() && rom_add_file_fixed(file, addr, region_size, -1)) {
> error_report("Unable to load a firmware for -M niagara");
> exit(1);
> }
> @@ -148,7 +148,8 @@ static void niagara_init(MachineState *machine)
> memory_region_add_subregion(get_system_memory(),
> NIAGARA_VDISK_BASE, &s->vdisk_ram);
> dinfo->is_default = 1;
> - rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE, -1);
> + rom_add_file_fixed(blk_bs(blk)->filename, NIAGARA_VDISK_BASE,
> + size, -1);
> } else {
> error_report("could not load ram disk '%s'",
> blk_bs(blk)->filename);
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2020-03-10 0:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 14:43 [PATCH 0/5] hw/core/loader: Prohibit loading ROMs bigger than memory region Philippe Mathieu-Daudé
2020-03-09 14:43 ` [PATCH 1/5] hw/sparc64/niagara: Pass available memory region size to add_rom_or_fail Philippe Mathieu-Daudé
2020-03-09 14:43 ` [PATCH 2/5] hw/core/loader: Prohibit loading ROMs bigger than memory region Philippe Mathieu-Daudé
2020-03-09 14:48 ` Peter Maydell
2020-03-09 15:41 ` Philippe Mathieu-Daudé
2020-03-09 14:43 ` [PATCH 3/5] hw/core/loader: Provide rom_add_file() a 'max_size' argument Philippe Mathieu-Daudé
2020-03-09 17:44 ` Taylor Simpson
2020-03-09 14:43 ` [PATCH 4/5] hw/core/loader: Restrict rom_add_file_mr() to available region size Philippe Mathieu-Daudé
2020-03-09 14:43 ` [PATCH 5/5] hw/core/loader: Provide rom_add_file_fixed() a 'max_size' argument Philippe Mathieu-Daudé
2020-03-10 0:43 ` David Gibson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200310004313.GC660117@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=alistair@alistair23.me \
--cc=atar4qemu@gmail.com \
--cc=ehabkost@redhat.com \
--cc=kraxel@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).