diff options
Diffstat (limited to 'hw')
-rw-r--r-- | hw/block/dataplane/virtio-blk.c | 27 | ||||
-rw-r--r-- | hw/misc/vfio.c | 2 | ||||
-rw-r--r-- | hw/ppc/e500.c | 3 | ||||
-rw-r--r-- | hw/ppc/mac_newworld.c | 7 | ||||
-rw-r--r-- | hw/ppc/mac_oldworld.c | 8 | ||||
-rw-r--r-- | hw/ppc/ppc405_boards.c | 21 | ||||
-rw-r--r-- | hw/ppc/ppc405_uc.c | 5 | ||||
-rw-r--r-- | hw/ppc/ppc4xx_devs.c | 5 | ||||
-rw-r--r-- | hw/ppc/prep.c | 3 | ||||
-rw-r--r-- | hw/ppc/spapr.c | 21 | ||||
-rw-r--r-- | hw/ppc/spapr_iommu.c | 4 | ||||
-rw-r--r-- | hw/ppc/virtex_ml507.c | 3 |
12 files changed, 64 insertions, 45 deletions
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c index 227bb15efc..d6ba65ca23 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -34,6 +34,7 @@ struct VirtIOBlockDataPlane { VirtIODevice *vdev; Vring vring; /* virtqueue vring */ EventNotifier *guest_notifier; /* irq */ + QEMUBH *bh; /* bh for guest notification */ /* Note that these EventNotifiers are assigned by value. This is * fine as long as you do not call event_notifier_cleanup on them @@ -61,13 +62,28 @@ static void notify_guest(VirtIOBlockDataPlane *s) event_notifier_set(s->guest_notifier); } +static void notify_guest_bh(void *opaque) +{ + VirtIOBlockDataPlane *s = opaque; + + notify_guest(s); +} + static void complete_request_vring(VirtIOBlockReq *req, unsigned char status) { + VirtIOBlockDataPlane *s = req->dev->dataplane; stb_p(&req->in->status, status); vring_push(&req->dev->dataplane->vring, &req->elem, req->qiov.size + sizeof(*req->in)); - notify_guest(req->dev->dataplane); + + /* Suppress notification to guest by BH and its scheduled + * flag because requests are completed as a batch after io + * plug & unplug is introduced, and the BH can still be + * executed in dataplane aio context even after it is + * stopped, so needn't worry about notification loss with BH. + */ + qemu_bh_schedule(s->bh); } static void handle_notify(EventNotifier *e) @@ -125,7 +141,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk, Error **errp) { VirtIOBlockDataPlane *s; - VirtIOBlock *vblk = VIRTIO_BLK(vdev); Error *local_err = NULL; BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); @@ -173,13 +188,12 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, VirtIOBlkConf *blk, s->iothread = &s->internal_iothread_obj; } s->ctx = iothread_get_aio_context(s->iothread); + s->bh = aio_bh_new(s->ctx, notify_guest_bh, s); error_setg(&s->blocker, "block device is in use by data plane"); bdrv_op_block_all(blk->conf.bs, s->blocker); *dataplane = s; - s->saved_complete_request = vblk->complete_request; - vblk->complete_request = complete_request_vring; } /* Context: QEMU global mutex held */ @@ -193,6 +207,7 @@ void virtio_blk_data_plane_destroy(VirtIOBlockDataPlane *s) bdrv_op_unblock_all(s->blk->conf.bs, s->blocker); error_free(s->blocker); object_unref(OBJECT(s->iothread)); + qemu_bh_delete(s->bh); g_free(s); } @@ -201,6 +216,7 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s->vdev))); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); + VirtIOBlock *vblk = VIRTIO_BLK(s->vdev); VirtQueue *vq; if (s->started) { @@ -234,6 +250,9 @@ void virtio_blk_data_plane_start(VirtIOBlockDataPlane *s) } s->host_notifier = *virtio_queue_get_host_notifier(vq); + s->saved_complete_request = vblk->complete_request; + vblk->complete_request = complete_request_vring; + s->starting = false; s->started = true; trace_virtio_blk_data_plane_start(s); diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index aef4c9ce9d..0b9eba0c84 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -2489,7 +2489,7 @@ static void vfio_iommu_map_notify(Notifier *n, void *data) return; } - if (iotlb->perm != IOMMU_NONE) { + if ((iotlb->perm & IOMMU_RW) != IOMMU_NONE) { vaddr = memory_region_get_ram_ptr(mr) + xlat; ret = vfio_dma_map(container, iotlb->iova, diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index bb2e75fe1b..1a5b30d3ce 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -701,8 +701,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params) machine->ram_size = ram_size; /* Register Memory */ - memory_region_init_ram(ram, NULL, "mpc8544ds.ram", ram_size); - vmstate_register_ram_global(ram); + memory_region_allocate_system_memory(ram, NULL, "mpc8544ds.ram", ram_size); memory_region_add_subregion(address_space_mem, 0, ram); dev = qdev_create(NULL, "e500-ccsr"); diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 89d3cadf19..7e97af4a23 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -200,13 +200,12 @@ static void ppc_core99_init(MachineState *machine) } /* allocate RAM */ - memory_region_init_ram(ram, NULL, "ppc_core99.ram", ram_size); - vmstate_register_ram_global(ram); + memory_region_allocate_system_memory(ram, NULL, "ppc_core99.ram", ram_size); memory_region_add_subregion(get_system_memory(), 0, ram); /* allocate and load BIOS */ - memory_region_init_ram(bios, NULL, "ppc_core99.bios", BIOS_SIZE); - vmstate_register_ram_global(bios); + memory_region_allocate_system_memory(bios, NULL, "ppc_core99.bios", + BIOS_SIZE); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 4b5e905fc2..afae8253e9 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -130,13 +130,13 @@ static void ppc_heathrow_init(MachineState *machine) exit(1); } - memory_region_init_ram(ram, NULL, "ppc_heathrow.ram", ram_size); - vmstate_register_ram_global(ram); + memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram", + ram_size); memory_region_add_subregion(sysmem, 0, ram); /* allocate and load BIOS */ - memory_region_init_ram(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE); - vmstate_register_ram_global(bios); + memory_region_allocate_system_memory(bios, NULL, "ppc_heathrow.bios", + BIOS_SIZE); if (bios_name == NULL) bios_name = PROM_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c index 98ad2d75e7..6b566cd8e5 100644 --- a/hw/ppc/ppc405_boards.c +++ b/hw/ppc/ppc405_boards.c @@ -199,8 +199,8 @@ static void ref405ep_init(MachineState *machine) MemoryRegion *sysmem = get_system_memory(); /* XXX: fix this */ - memory_region_init_ram(&ram_memories[0], NULL, "ef405ep.ram", 0x08000000); - vmstate_register_ram_global(&ram_memories[0]); + memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram", + 0x08000000); ram_bases[0] = 0; ram_sizes[0] = 0x08000000; memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0); @@ -214,8 +214,7 @@ static void ref405ep_init(MachineState *machine) 33333333, &pic, kernel_filename == NULL ? 0 : 1); /* allocate SRAM */ sram_size = 512 * 1024; - memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size); - vmstate_register_ram_global(sram); + memory_region_allocate_system_memory(sram, NULL, "ef405ep.sram", sram_size); memory_region_add_subregion(sysmem, 0xFFF00000, sram); /* allocate and load BIOS */ #ifdef DEBUG_BOARD_INIT @@ -246,8 +245,8 @@ static void ref405ep_init(MachineState *machine) printf("Load BIOS from file\n"); #endif bios = g_new(MemoryRegion, 1); - memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE); - vmstate_register_ram_global(bios); + memory_region_allocate_system_memory(bios, NULL, "ef405ep.bios", + BIOS_SIZE); if (bios_name == NULL) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); @@ -518,14 +517,12 @@ static void taihu_405ep_init(MachineState *machine) DriveInfo *dinfo; /* RAM is soldered to the board so the size cannot be changed */ - memory_region_init_ram(&ram_memories[0], NULL, + memory_region_allocate_system_memory(&ram_memories[0], NULL, "taihu_405ep.ram-0", 0x04000000); - vmstate_register_ram_global(&ram_memories[0]); ram_bases[0] = 0; ram_sizes[0] = 0x04000000; - memory_region_init_ram(&ram_memories[1], NULL, + memory_region_allocate_system_memory(&ram_memories[1], NULL, "taihu_405ep.ram-1", 0x04000000); - vmstate_register_ram_global(&ram_memories[1]); ram_bases[1] = 0x04000000; ram_sizes[1] = 0x04000000; ram_size = 0x08000000; @@ -567,8 +564,8 @@ static void taihu_405ep_init(MachineState *machine) if (bios_name == NULL) bios_name = BIOS_FILENAME; bios = g_new(MemoryRegion, 1); - memory_region_init_ram(bios, NULL, "taihu_405ep.bios", BIOS_SIZE); - vmstate_register_ram_global(bios); + memory_region_allocate_system_memory(bios, NULL, "taihu_405ep.bios", + BIOS_SIZE); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c index 54ba59e73a..fcd5f2d917 100644 --- a/hw/ppc/ppc405_uc.c +++ b/hw/ppc/ppc405_uc.c @@ -23,6 +23,7 @@ */ #include "hw/hw.h" #include "hw/ppc/ppc.h" +#include "hw/boards.h" #include "ppc405.h" #include "hw/char/serial.h" #include "qemu/timer.h" @@ -973,8 +974,8 @@ static void ppc405_ocm_init(CPUPPCState *env) ocm = g_malloc0(sizeof(ppc405_ocm_t)); /* XXX: Size is 4096 or 0x04000000 */ - memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4096); - vmstate_register_ram_global(&ocm->isarc_ram); + memory_region_allocate_system_memory(&ocm->isarc_ram, NULL, "ppc405.ocm", + 4096); memory_region_init_alias(&ocm->dsarc_ram, NULL, "ppc405.dsarc", &ocm->isarc_ram, 0, 4096); qemu_register_reset(&ocm_reset, ocm); diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c index 8a43111a51..07f9d00ea7 100644 --- a/hw/ppc/ppc4xx_devs.c +++ b/hw/ppc/ppc4xx_devs.c @@ -24,6 +24,7 @@ #include "hw/hw.h" #include "hw/ppc/ppc.h" #include "hw/ppc/ppc4xx.h" +#include "hw/boards.h" #include "qemu/log.h" #include "exec/address-spaces.h" @@ -694,8 +695,8 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks, if (bank_size <= size_left) { char name[32]; snprintf(name, sizeof(name), "ppc4xx.sdram%d", i); - memory_region_init_ram(&ram_memories[i], NULL, name, bank_size); - vmstate_register_ram_global(&ram_memories[i]); + memory_region_allocate_system_memory(&ram_memories[i], NULL, + name, bank_size); ram_bases[i] = base; ram_sizes[i] = bank_size; base += bank_size; diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c index aa8717d75d..f0ef1af118 100644 --- a/hw/ppc/prep.c +++ b/hw/ppc/prep.c @@ -417,8 +417,7 @@ static void ppc_prep_init(MachineState *machine) } /* allocate RAM */ - memory_region_init_ram(ram, NULL, "ppc_prep.ram", ram_size); - vmstate_register_ram_global(ram); + memory_region_allocate_system_memory(ram, NULL, "ppc_prep.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); if (linux_boot) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index a23c0f080e..d01978f3dc 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1223,6 +1223,8 @@ static void ppc_spapr_init(MachineState *machine) int i; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *ram = g_new(MemoryRegion, 1); + MemoryRegion *rma_region; + void *rma = NULL; hwaddr rma_alloc_size; hwaddr node0_size = (nb_numa_nodes > 1) ? numa_info[0].node_mem : ram_size; uint32_t initrd_base = 0; @@ -1239,7 +1241,7 @@ static void ppc_spapr_init(MachineState *machine) cpu_ppc_hypercall = emulate_spapr_hypercall; /* Allocate RMA if necessary */ - rma_alloc_size = kvmppc_alloc_rma("ppc_spapr.rma", sysmem); + rma_alloc_size = kvmppc_alloc_rma(&rma); if (rma_alloc_size == -1) { hw_error("qemu: Unable to create RMA\n"); @@ -1333,13 +1335,16 @@ static void ppc_spapr_init(MachineState *machine) /* allocate RAM */ spapr->ram_limit = ram_size; - if (spapr->ram_limit > rma_alloc_size) { - ram_addr_t nonrma_base = rma_alloc_size; - ram_addr_t nonrma_size = spapr->ram_limit - rma_alloc_size; - - memory_region_init_ram(ram, NULL, "ppc_spapr.ram", nonrma_size); - vmstate_register_ram_global(ram); - memory_region_add_subregion(sysmem, nonrma_base, ram); + memory_region_allocate_system_memory(ram, NULL, "ppc_spapr.ram", + spapr->ram_limit); + memory_region_add_subregion(sysmem, 0, ram); + + if (rma_alloc_size && rma) { + rma_region = g_new(MemoryRegion, 1); + memory_region_init_ram_ptr(rma_region, NULL, "ppc_spapr.rma", + rma_alloc_size, rma); + vmstate_register_ram_global(rma_region); + memory_region_add_subregion(sysmem, 0, rma_region); } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin"); diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c index 698ae60953..f6e32a48af 100644 --- a/hw/ppc/spapr_iommu.c +++ b/hw/ppc/spapr_iommu.c @@ -81,7 +81,7 @@ static IOMMUTLBEntry spapr_tce_translate_iommu(MemoryRegion *iommu, hwaddr addr) ret.iova = addr & page_mask; ret.translated_addr = tce & page_mask; ret.addr_mask = ~page_mask; - ret.perm = tce; + ret.perm = tce & IOMMU_RW; } trace_spapr_iommu_xlate(tcet->liobn, addr, ret.iova, ret.perm, ret.addr_mask); @@ -223,7 +223,7 @@ static target_ulong put_tce_emu(sPAPRTCETable *tcet, target_ulong ioba, entry.iova = ioba & page_mask; entry.translated_addr = tce & page_mask; entry.addr_mask = ~page_mask; - entry.perm = tce; + entry.perm = tce & IOMMU_RW; memory_region_notify_iommu(&tcet->iommu, entry); return H_SUCCESS; diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 02b4f828d3..0de51481f3 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -222,8 +222,7 @@ static void virtex_init(MachineState *machine) env = &cpu->env; qemu_register_reset(main_cpu_reset, cpu); - memory_region_init_ram(phys_ram, NULL, "ram", ram_size); - vmstate_register_ram_global(phys_ram); + memory_region_allocate_system_memory(phys_ram, NULL, "ram", ram_size); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); |