[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 20/25] fw_cfg: fix the life cycle and the name of "qe
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 20/25] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw" |
Date: |
Mon, 4 Feb 2019 09:43:57 -0500 |
From: Laszlo Ersek <address@hidden>
Commit 19bcc4bc3213 ("fw_cfg: Make qemu_extra_params_fw locally",
2019-01-04) changed the storage duration of the "qemu_extra_params_fw"
array from static to automatic. This broke the interface contract on the
fw_cfg_add_file() function, which is documented as follows, in
"include/hw/nvram/fw_cfg.h":
> [...] The data referenced by the starting pointer is only linked, NOT
> copied, into the data structure of the fw_cfg device. [...]
As a result, when guest firmware fetches the "etc/boot-menu-wait" fw_cfg
file, it now sees garbage. Fix the regression by changing the storage
duration to allocated. (The call is reached at most once, on the realize
path of the board-specific fw_cfg sysbus device.)
While at it, clean up the name and the assignment of the object as well.
Cc: Gerd Hoffmann <address@hidden>
Cc: Markus Armbruster <address@hidden>
Cc: Philippe Mathieu-Daudé <address@hidden>
Fixes: 19bcc4bc3213e78c303ad480a7a578f62258252d
Signed-off-by: Laszlo Ersek <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Gerd Hoffmann <address@hidden>
Reviewed-by: Li Qiang <address@hidden>
Reviewed-by: Stefano Garzarella <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
---
hw/nvram/fw_cfg.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 53e8e010a8..7fdf04adc9 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -118,7 +118,6 @@ static void fw_cfg_bootsplash(FWCfgState *s)
{
const char *boot_splash_filename = NULL;
const char *boot_splash_time = NULL;
- uint8_t qemu_extra_params_fw[2];
char *filename, *file_data;
gsize file_size;
int file_type;
@@ -132,6 +131,8 @@ static void fw_cfg_bootsplash(FWCfgState *s)
/* insert splash time if user configurated */
if (boot_splash_time) {
int64_t bst_val = qemu_opt_get_number(opts, "splash-time", -1);
+ uint16_t bst_le16;
+
/* validate the input */
if (bst_val < 0 || bst_val > 0xffff) {
error_report("splash-time is invalid,"
@@ -139,9 +140,9 @@ static void fw_cfg_bootsplash(FWCfgState *s)
exit(1);
}
/* use little endian format */
- qemu_extra_params_fw[0] = (uint8_t)(bst_val & 0xff);
- qemu_extra_params_fw[1] = (uint8_t)((bst_val >> 8) & 0xff);
- fw_cfg_add_file(s, "etc/boot-menu-wait", qemu_extra_params_fw, 2);
+ bst_le16 = cpu_to_le16(bst_val);
+ fw_cfg_add_file(s, "etc/boot-menu-wait",
+ g_memdup(&bst_le16, sizeof bst_le16), sizeof bst_le16);
}
/* insert splash file if user configurated */
--
MST
- [Qemu-devel] [PULL 00/25] pci, pc, virtio: fixes, cleanups, features, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 21/25] i386, acpi: cleanup build_facs by removing second unused argument, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 23/25] mmap-alloc: fix hugetlbfs misaligned length in ppc64, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 25/25] contrib/libvhost-user: cleanup casts, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 20/25] fw_cfg: fix the life cycle and the name of "qemu_extra_params_fw",
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 24/25] r2d: fix build on mingw, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 06/25] vhost-net-user: add stubs for when no virtio-net device is present, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 22/25] mmap-alloc: unfold qemu_ram_mmap(), Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 17/25] vhost-user-blk: add discard/write zeroes features support, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 18/25] hw/virtio: Use CONFIG_VIRTIO_PCI switch instead of CONFIG_PCI, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 19/25] acpi: Make TPM 2.0 with TIS available as MSFT0101, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 16/25] contrib/vhost-user-blk: fix the compilation issue, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 14/25] i386/kvm: ignore masked irqs when update msi routes, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 07/25] vhost: restrict Linux dependency to kernel vhost, Michael S. Tsirkin, 2019/02/04
- [Qemu-devel] [PULL 11/25] intel_iommu: fix operator in vtd_switch_address_space, Michael S. Tsirkin, 2019/02/04