diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/core/loader-fit.c | 62 | ||||
-rw-r--r-- | hw/mips/boston.c | 6 | ||||
-rw-r--r-- | hw/pci/pci.c | 2 | ||||
-rw-r--r-- | hw/ppc/spapr_caps.c | 4 | ||||
-rw-r--r-- | hw/ppc/spapr_pci.c | 4 | ||||
-rw-r--r-- | hw/s390x/s390-virtio-ccw.c | 12 | ||||
-rw-r--r-- | hw/timer/hpet.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-mtp.c | 11 | ||||
-rw-r--r-- | hw/vfio/pci.c | 19 | ||||
-rw-r--r-- | hw/vfio/spapr.c | 2 |
10 files changed, 80 insertions, 44 deletions
diff --git a/hw/core/loader-fit.c b/hw/core/loader-fit.c index 447f60857d..f27b6af942 100644 --- a/hw/core/loader-fit.c +++ b/hw/core/loader-fit.c @@ -18,6 +18,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "qemu/units.h" #include "exec/memory.h" #include "hw/loader.h" @@ -33,7 +34,7 @@ #define FIT_LOADER_MAX_PATH (128) static const void *fit_load_image_alloc(const void *itb, const char *name, - int *poff, size_t *psz) + int *poff, size_t *psz, Error **errp) { const void *data; const char *comp; @@ -46,6 +47,7 @@ static const void *fit_load_image_alloc(const void *itb, const char *name, off = fdt_path_offset(itb, path); if (off < 0) { + error_setg(errp, "can't find node %s", path); return NULL; } if (poff) { @@ -54,6 +56,7 @@ static const void *fit_load_image_alloc(const void *itb, const char *name, data = fdt_getprop(itb, off, "data", &sz); if (!data) { + error_setg(errp, "can't get %s/data", path); return NULL; } @@ -73,7 +76,7 @@ static const void *fit_load_image_alloc(const void *itb, const char *name, uncomp_len = gunzip(uncomp_data, uncomp_len, (void *) data, sz); if (uncomp_len < 0) { - error_printf("unable to decompress %s image\n", name); + error_setg(errp, "unable to decompress %s image", name); g_free(uncomp_data); return NULL; } @@ -85,18 +88,19 @@ static const void *fit_load_image_alloc(const void *itb, const char *name, return data; } - error_printf("unknown compression '%s'\n", comp); + error_setg(errp, "unknown compression '%s'", comp); return NULL; } static int fit_image_addr(const void *itb, int img, const char *name, - hwaddr *addr) + hwaddr *addr, Error **errp) { const void *prop; int len; prop = fdt_getprop(itb, img, name, &len); if (!prop) { + error_setg(errp, "can't find %s address", name); return -ENOENT; } @@ -108,13 +112,14 @@ static int fit_image_addr(const void *itb, int img, const char *name, *addr = fdt64_to_cpu(*(fdt64_t *)prop); return 0; default: - error_printf("invalid %s address length %d\n", name, len); + error_setg(errp, "invalid %s address length %d", name, len); return -EINVAL; } } static int fit_load_kernel(const struct fit_loader *ldr, const void *itb, - int cfg, void *opaque, hwaddr *pend) + int cfg, void *opaque, hwaddr *pend, + Error **errp) { const char *name; const void *data; @@ -126,26 +131,26 @@ static int fit_load_kernel(const struct fit_loader *ldr, const void *itb, name = fdt_getprop(itb, cfg, "kernel", NULL); if (!name) { - error_printf("no kernel specified by FIT configuration\n"); + error_setg(errp, "no kernel specified by FIT configuration"); return -EINVAL; } - load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz); + load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, errp); if (!data) { - error_printf("unable to load kernel image from FIT\n"); + error_prepend(errp, "unable to load kernel image from FIT: "); return -EINVAL; } - err = fit_image_addr(itb, img_off, "load", &load_addr); + err = fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err) { - error_printf("unable to read kernel load address from FIT\n"); + error_prepend(errp, "unable to read kernel load address from FIT: "); ret = err; goto out; } - err = fit_image_addr(itb, img_off, "entry", &entry_addr); + err = fit_image_addr(itb, img_off, "entry", &entry_addr, errp); if (err) { - error_printf("unable to read kernel entry address from FIT\n"); + error_prepend(errp, "unable to read kernel entry address from FIT: "); ret = err; goto out; } @@ -172,7 +177,7 @@ out: static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, int cfg, void *opaque, const void *match_data, - hwaddr kernel_end) + hwaddr kernel_end, Error **errp) { const char *name; const void *data; @@ -187,16 +192,18 @@ static int fit_load_fdt(const struct fit_loader *ldr, const void *itb, return 0; } - load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz); + load_data = data = fit_load_image_alloc(itb, name, &img_off, &sz, errp); if (!data) { - error_printf("unable to load FDT image from FIT\n"); + error_prepend(errp, "unable to load FDT image from FIT: "); return -EINVAL; } - err = fit_image_addr(itb, img_off, "load", &load_addr); + err = fit_image_addr(itb, img_off, "load", &load_addr, errp); if (err == -ENOENT) { load_addr = ROUND_UP(kernel_end, 64 * KiB) + (10 * MiB); + error_free(*errp); } else if (err) { + error_prepend(errp, "unable to read FDT load address from FIT: "); ret = err; goto out; } @@ -229,7 +236,7 @@ static bool fit_cfg_compatible(const void *itb, int cfg, const char *compat) return false; } - fdt = fit_load_image_alloc(itb, fdt_name, NULL, NULL); + fdt = fit_load_image_alloc(itb, fdt_name, NULL, NULL, NULL); if (!fdt) { return false; } @@ -252,11 +259,12 @@ out: int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque) { + Error *err = NULL; const struct fit_loader_match *match; const void *itb, *match_data = NULL; const char *def_cfg_name; char path[FIT_LOADER_MAX_PATH]; - int itb_size, configs, cfg_off, off, err; + int itb_size, configs, cfg_off, off; hwaddr kernel_end; int ret; @@ -267,6 +275,7 @@ int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque) configs = fdt_path_offset(itb, "/configurations"); if (configs < 0) { + error_report("can't find node /configurations"); ret = configs; goto out; } @@ -301,20 +310,21 @@ int load_fit(const struct fit_loader *ldr, const char *filename, void *opaque) } if (cfg_off < 0) { - /* couldn't find a configuration to use */ + error_report("can't find configuration"); ret = cfg_off; goto out; } - err = fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end); - if (err) { - ret = err; + ret = fit_load_kernel(ldr, itb, cfg_off, opaque, &kernel_end, &err); + if (ret) { + error_report_err(err); goto out; } - err = fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end); - if (err) { - ret = err; + ret = fit_load_fdt(ldr, itb, cfg_off, opaque, match_data, kernel_end, + &err); + if (ret) { + error_report_err(err); goto out; } diff --git a/hw/mips/boston.c b/hw/mips/boston.c index e5bab3cadc..a8b29f62f5 100644 --- a/hw/mips/boston.c +++ b/hw/mips/boston.c @@ -528,21 +528,21 @@ static void boston_mach_init(MachineState *machine) fw_size = load_image_targphys(machine->firmware, 0x1fc00000, 4 * MiB); if (fw_size == -1) { - error_printf("unable to load firmware image '%s'\n", + error_report("unable to load firmware image '%s'", machine->firmware); exit(1); } } else if (machine->kernel_filename) { fit_err = load_fit(&boston_fit_loader, machine->kernel_filename, s); if (fit_err) { - error_printf("unable to load FIT image\n"); + error_report("unable to load FIT image"); exit(1); } gen_firmware(memory_region_get_ram_ptr(flash) + 0x7c00000, s->kernel_entry, s->fdt_base, is_64b); } else if (!qtest_enabled()) { - error_printf("Please provide either a -kernel or -bios argument\n"); + error_report("Please provide either a -kernel or -bios argument"); exit(1); } } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 6d13ef877b..1808b242dd 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -951,7 +951,7 @@ static uint16_t pci_req_id_cache_extract(PCIReqIDCache *cache) result = PCI_BUILD_BDF(bus_n, 0); break; default: - error_printf("Invalid PCI requester ID cache type: %d\n", + error_report("Invalid PCI requester ID cache type: %d", cache->type); exit(1); break; diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index edc5ed0e0c..9b1c10baa6 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -347,7 +347,7 @@ static void cap_hpt_maxpagesize_apply(SpaprMachineState *spapr, warn_report("Many guests require at least 64kiB hpt-max-page-size"); } - spapr_check_pagesize(spapr, qemu_getrampagesize(), errp); + spapr_check_pagesize(spapr, qemu_minrampagesize(), errp); } static bool spapr_pagesize_cb(void *opaque, uint32_t seg_pshift, @@ -609,7 +609,7 @@ static SpaprCapabilities default_caps_with_cpu(SpaprMachineState *spapr, uint8_t mps; if (kvmppc_hpt_needs_host_contiguous_pages()) { - mps = ctz64(qemu_getrampagesize()); + mps = ctz64(qemu_minrampagesize()); } else { mps = 34; /* allow everything up to 16GiB, i.e. everything */ } diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index f0b6b23afc..f62e6833b8 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1652,7 +1652,7 @@ static void spapr_phb_root_bus_class_init(ObjectClass *klass, void *data) pbc->allows_extended_config_space = spapr_phb_allows_extended_config_space; } -#define TYPE_SPAPR_PHB_ROOT_BUS "spapr-pci-host-bridge-root-bus" +#define TYPE_SPAPR_PHB_ROOT_BUS "pci" static const TypeInfo spapr_phb_root_bus_info = { .name = TYPE_SPAPR_PHB_ROOT_BUS, @@ -1761,7 +1761,7 @@ static void spapr_phb_realize(DeviceState *dev, Error **errp) memory_region_add_subregion(get_system_memory(), sphb->io_win_addr, &sphb->iowindow); - bus = pci_register_root_bus(dev, "pci.0", + bus = pci_register_root_bus(dev, NULL, pci_spapr_set_irq, pci_spapr_map_irq, sphb, &sphb->memspace, &sphb->iospace, PCI_DEVFN(0, 0), PCI_NUM_PINS, diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index d11069b860..7e256d3d31 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -15,6 +15,7 @@ #include "cpu.h" #include "hw/boards.h" #include "exec/address-spaces.h" +#include "exec/ram_addr.h" #include "hw/s390x/s390-virtio-hcall.h" #include "hw/s390x/sclp.h" #include "hw/s390x/s390_flic.h" @@ -163,6 +164,7 @@ static void s390_memory_init(ram_addr_t mem_size) MemoryRegion *sysmem = get_system_memory(); ram_addr_t chunk, offset = 0; unsigned int number = 0; + Error *local_err = NULL; gchar *name; /* allocate RAM for core */ @@ -182,6 +184,15 @@ static void s390_memory_init(ram_addr_t mem_size) } g_free(name); + /* + * Configure the maximum page size. As no memory devices were created + * yet, this is the page size of initial memory only. + */ + s390_set_max_pagesize(qemu_maxrampagesize(), &local_err); + if (local_err) { + error_report_err(local_err); + exit(EXIT_FAILURE); + } /* Initialize storage key device */ s390_skeys_init(); /* Initialize storage attributes device */ @@ -253,6 +264,7 @@ static void ccw_init(MachineState *machine) DeviceState *dev; s390_sclp_init(); + /* init memory + setup max page size. Required for the CPU model */ s390_memory_init(machine->ram_size); /* init CPUs (incl. CPU model) early so s390_has_feature() works */ diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index d97436bc7b..41024f39fb 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -744,7 +744,7 @@ static void hpet_realize(DeviceState *dev, Error **errp) HPETTimer *timer; if (!s->intcap) { - error_printf("Hpet's intcap not initialized.\n"); + warn_report("Hpet's intcap not initialized"); } if (hpet_cfg.count == UINT8_MAX) { /* first instance */ diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index ebf210fbf8..99548b012d 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1699,12 +1699,19 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen) MTPObject *o; MTPObject *p = usb_mtp_object_lookup(s, s->dataset.parent_handle); uint32_t next_handle = s->next_handle; + size_t filename_chars = dlen - offsetof(ObjectInfo, filename); + + /* + * filename is utf-16. We're intentionally doing + * integer division to truncate if malicious guest + * sent an odd number of bytes. + */ + filename_chars /= 2; assert(!s->write_pending); assert(p != NULL); - filename = utf16_to_str(MIN(dataset->length, - dlen - offsetof(ObjectInfo, filename)), + filename = utf16_to_str(MIN(dataset->length, filename_chars), dataset->filename); if (strchr(filename, '/')) { diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 504019c458..0142819ea6 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -947,8 +947,10 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) if (vdev->pdev.romfile || !vdev->pdev.rom_bar) { /* Since pci handles romfile, just print a message and return */ if (vfio_blacklist_opt_rom(vdev) && vdev->pdev.romfile) { - error_printf("Warning : Device at %s is known to cause system instability issues during option rom execution. Proceeding anyway since user specified romfile\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified romfile\n"); } return; } @@ -973,11 +975,16 @@ static void vfio_pci_size_rom(VFIOPCIDevice *vdev) if (vfio_blacklist_opt_rom(vdev)) { if (dev->opts && qemu_opt_get(dev->opts, "rombar")) { - error_printf("Warning : Device at %s is known to cause system instability issues during option rom execution. Proceeding anyway since user specified non zero value for rombar\n", - vdev->vbasedev.name); + warn_report("Device at %s is known to cause system instability" + " issues during option rom execution", + vdev->vbasedev.name); + error_printf("Proceeding anyway since user specified" + " non zero value for rombar\n"); } else { - error_printf("Warning : Rom loading for device at %s has been disabled due to system instability issues. Specify rombar=1 or romfile to force\n", - vdev->vbasedev.name); + warn_report("Rom loading for device at %s has been disabled" + " due to system instability issues", + vdev->vbasedev.name); + error_printf("Specify rombar=1 or romfile to force\n"); return; } } diff --git a/hw/vfio/spapr.c b/hw/vfio/spapr.c index 57fe758e54..96c0ad9d9b 100644 --- a/hw/vfio/spapr.c +++ b/hw/vfio/spapr.c @@ -148,7 +148,7 @@ int vfio_spapr_create_window(VFIOContainer *container, uint64_t pagesize = memory_region_iommu_get_min_page_size(iommu_mr); unsigned entries, bits_total, bits_per_level, max_levels; struct vfio_iommu_spapr_tce_create create = { .argsz = sizeof(create) }; - long rampagesize = qemu_getrampagesize(); + long rampagesize = qemu_minrampagesize(); /* * The host might not support the guest supported IOMMU page size, |