diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/nvme.c | 26 | ||||
-rw-r--r-- | hw/block/nvme.h | 1 | ||||
-rw-r--r-- | hw/block/virtio-blk.c | 4 | ||||
-rw-r--r-- | hw/core/generic-loader.c | 9 | ||||
-rw-r--r-- | hw/display/jazz_led.c | 4 | ||||
-rw-r--r-- | hw/microblaze/boot.c | 2 | ||||
-rw-r--r-- | hw/nios2/boot.c | 2 | ||||
-rw-r--r-- | hw/ppc/pnv.c | 2 | ||||
-rw-r--r-- | hw/ppc/ppc_booke.c | 1 | ||||
-rw-r--r-- | hw/s390x/sclp.c | 4 | ||||
-rw-r--r-- | hw/tricore/tricore_testboard.c | 2 | ||||
-rw-r--r-- | hw/usb/dev-smartcard-reader.c | 5 |
12 files changed, 45 insertions, 17 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index ae303d44e5..7428db9f0c 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -227,6 +227,29 @@ static uint16_t nvme_flush(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, return NVME_NO_COMPLETE; } +static uint16_t nvme_write_zeros(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, + NvmeRequest *req) +{ + NvmeRwCmd *rw = (NvmeRwCmd *)cmd; + const uint8_t lba_index = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); + const uint8_t data_shift = ns->id_ns.lbaf[lba_index].ds; + uint64_t slba = le64_to_cpu(rw->slba); + uint32_t nlb = le16_to_cpu(rw->nlb) + 1; + uint64_t aio_slba = slba << (data_shift - BDRV_SECTOR_BITS); + uint32_t aio_nlb = nlb << (data_shift - BDRV_SECTOR_BITS); + + if (slba + nlb > ns->id_ns.nsze) { + return NVME_LBA_RANGE | NVME_DNR; + } + + req->has_sg = false; + block_acct_start(blk_get_stats(n->conf.blk), &req->acct, 0, + BLOCK_ACCT_WRITE); + req->aiocb = blk_aio_pwrite_zeroes(n->conf.blk, aio_slba, aio_nlb, + BDRV_REQ_MAY_UNMAP, nvme_rw_cb, req); + return NVME_NO_COMPLETE; +} + static uint16_t nvme_rw(NvmeCtrl *n, NvmeNamespace *ns, NvmeCmd *cmd, NvmeRequest *req) { @@ -279,6 +302,8 @@ static uint16_t nvme_io_cmd(NvmeCtrl *n, NvmeCmd *cmd, NvmeRequest *req) switch (cmd->opcode) { case NVME_CMD_FLUSH: return nvme_flush(n, ns, cmd, req); + case NVME_CMD_WRITE_ZEROS: + return nvme_write_zeros(n, ns, cmd, req); case NVME_CMD_WRITE: case NVME_CMD_READ: return nvme_rw(n, ns, cmd, req); @@ -895,6 +920,7 @@ static int nvme_init(PCIDevice *pci_dev) id->sqes = (0x6 << 4) | 0x6; id->cqes = (0x4 << 4) | 0x4; id->nn = cpu_to_le32(n->num_namespaces); + id->oncs = cpu_to_le16(NVME_ONCS_WRITE_ZEROS); id->psd[0].mp = cpu_to_le16(0x9c4); id->psd[0].enlat = cpu_to_le32(0x10); id->psd[0].exlat = cpu_to_le32(0x4); diff --git a/hw/block/nvme.h b/hw/block/nvme.h index 8fb0c10756..a0d15649f9 100644 --- a/hw/block/nvme.h +++ b/hw/block/nvme.h @@ -179,6 +179,7 @@ enum NvmeIoCommands { NVME_CMD_READ = 0x02, NVME_CMD_WRITE_UNCOR = 0x04, NVME_CMD_COMPARE = 0x05, + NVME_CMD_WRITE_ZEROS = 0x08, NVME_CMD_DSM = 0x09, }; diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 98c16a7a9a..604d37dfc8 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -42,9 +42,7 @@ static void virtio_blk_init_request(VirtIOBlock *s, VirtQueue *vq, static void virtio_blk_free_request(VirtIOBlockReq *req) { - if (req) { - g_free(req); - } + g_free(req); } static void virtio_blk_req_complete(VirtIOBlockReq *req, unsigned char status) diff --git a/hw/core/generic-loader.c b/hw/core/generic-loader.c index 58f1f02902..46012673c3 100644 --- a/hw/core/generic-loader.c +++ b/hw/core/generic-loader.c @@ -137,20 +137,21 @@ static void generic_loader_realize(DeviceState *dev, Error **errp) #endif if (s->file) { + AddressSpace *as = s->cpu ? s->cpu->as : NULL; + if (!s->force_raw) { size = load_elf_as(s->file, NULL, NULL, &entry, NULL, NULL, - big_endian, 0, 0, 0, s->cpu->as); + big_endian, 0, 0, 0, as); if (size < 0) { size = load_uimage_as(s->file, &entry, NULL, NULL, NULL, NULL, - s->cpu->as); + as); } } if (size < 0 || s->force_raw) { /* Default to the maximum size being the machine's ram size */ - size = load_image_targphys_as(s->file, s->addr, ram_size, - s->cpu->as); + size = load_image_targphys_as(s->file, s->addr, ram_size, as); } else { s->addr = entry; } diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c index b72fdb1717..3c97d56434 100644 --- a/hw/display/jazz_led.c +++ b/hw/display/jazz_led.c @@ -227,13 +227,13 @@ static void jazz_led_invalidate_display(void *opaque) static void jazz_led_text_update(void *opaque, console_ch_t *chardata) { LedState *s = opaque; - char buf[2]; + char buf[3]; dpy_text_cursor(s->con, -1, -1); qemu_console_resize(s->con, 2, 1); /* TODO: draw the segments */ - snprintf(buf, 2, "%02hhx\n", s->segments); + snprintf(buf, 3, "%02hhx", s->segments); console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE, QEMU_COLOR_BLACK, 1)); console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE, diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 1834d22a61..457a08a2fe 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -189,7 +189,7 @@ void microblaze_load_kernel(MicroBlazeCPU *cpu, hwaddr ddr_base, ram_size - initrd_offset); } if (initrd_size < 0) { - error_report("qemu: could not load initrd '%s'", + error_report("could not load initrd '%s'", initrd_filename); exit(EXIT_FAILURE); } diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index e0a9aff2f4..2b31f5b844 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -197,7 +197,7 @@ void nios2_load_kernel(Nios2CPU *cpu, hwaddr ddr_base, ram_size - initrd_offset); } if (initrd_size < 0) { - error_report("qemu: could not load initrd '%s'", + error_report("could not load initrd '%s'", initrd_filename); exit(EXIT_FAILURE); } diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 251baea5d6..231ed9735b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -610,7 +610,7 @@ static void ppc_powernv_init(MachineState *machine) /* Create the processor chips */ chip_typename = g_strdup_printf(TYPE_PNV_CHIP "-%s", machine->cpu_model); if (!object_class_by_name(chip_typename)) { - error_report("qemu: invalid CPU model '%s' for %s machine", + error_report("invalid CPU model '%s' for %s machine", machine->cpu_model, MACHINE_GET_CLASS(machine)->name); exit(1); } diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c index 60baffaf1d..23bcf1b138 100644 --- a/hw/ppc/ppc_booke.c +++ b/hw/ppc/ppc_booke.c @@ -282,7 +282,6 @@ void store_booke_tcr(CPUPPCState *env, target_ulong val) ppc_tb_t *tb_env = env->tb_env; booke_timer_t *booke_timer = tb_env->opaque; - tb_env = env->tb_env; env->spr[SPR_BOOKE_TCR] = val; kvmppc_set_tcr(cpu); diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index b4f6dd58dd..83d6023894 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -505,10 +505,10 @@ static void sclp_realize(DeviceState *dev, Error **errp) ret = s390_set_memory_limit(machine->maxram_size, &hw_limit); if (ret == -E2BIG) { - error_setg(&err, "qemu: host supports a maximum of %" PRIu64 " GB", + error_setg(&err, "host supports a maximum of %" PRIu64 " GB", hw_limit >> 30); } else if (ret) { - error_setg(&err, "qemu: setting the guest size failed"); + error_setg(&err, "setting the guest size failed"); } out: diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c index 19dd587207..8910bf0f27 100644 --- a/hw/tricore/tricore_testboard.c +++ b/hw/tricore/tricore_testboard.c @@ -50,7 +50,7 @@ static void tricore_load_kernel(CPUTriCoreState *env) NULL, 0, EM_TRICORE, 1, 0); if (kernel_size <= 0) { - error_report("qemu: no kernel file '%s'", + error_report("no kernel file '%s'", tricoretb_binfo.kernel_filename); exit(1); } diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 757b8b3f5a..49cb1829b5 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -813,7 +813,10 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq, if (p->b.bError) { DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError); } - memcpy(p->abData, data, len); + if (len) { + g_assert_nonnull(data); + memcpy(p->abData, data, len); + } ccid_reset_error_status(s); usb_wakeup(s->bulk, 0); } |