diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-05-27 10:08:27 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2013-06-20 16:32:47 +0200 |
commit | 052e87b073cb70afcd767d32f45af2794a5a65de (patch) | |
tree | ef25073c63f9c7e2be0e2ddee46ce1524811becd /hw | |
parent | 733d5ef52721a836b1d9b5cd0f15a41db88829d0 (diff) |
memory: make section size a 128-bit integer
So far, the size of all regions passed to listeners could fit in 64 bits,
because artificial regions (containers and aliases) are eliminated by
the memory core, leaving only device regions which have reasonable sizes
An IOMMU however cannot be eliminated by the memory core, and may have
an artificial size, hence we may need 65 bits to represent its size.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/core/loader.c | 2 | ||||
-rw-r--r-- | hw/display/exynos4210_fimd.c | 4 | ||||
-rw-r--r-- | hw/display/framebuffer.c | 3 | ||||
-rw-r--r-- | hw/misc/vfio.c | 4 | ||||
-rw-r--r-- | hw/virtio/dataplane/hostmem.c | 2 | ||||
-rw-r--r-- | hw/virtio/vhost.c | 4 | ||||
-rw-r--r-- | hw/virtio/virtio-balloon.c | 2 | ||||
-rw-r--r-- | hw/xen/xen_pt.c | 6 |
8 files changed, 14 insertions, 13 deletions
diff --git a/hw/core/loader.c b/hw/core/loader.c index a711145178..d56963699b 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -726,7 +726,7 @@ int rom_load_all(void) addr = rom->addr; addr += rom->romsize; section = memory_region_find(get_system_memory(), rom->addr, 1); - rom->isrom = section.size && memory_region_is_rom(section.mr); + rom->isrom = int128_nz(section.size) && memory_region_is_rom(section.mr); } qemu_register_reset(rom_reset, NULL); roms_loaded = 1; diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index 6cb5016aa8..0da00a9f96 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -1133,7 +1133,7 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win) DPRINT_TRACE("Window %u framebuffer changed: address=0x%08x, len=0x%x\n", win, fb_start_addr, w->fb_len); - if (w->mem_section.size != w->fb_len || + if (int128_get64(w->mem_section.size) != w->fb_len || !memory_region_is_ram(w->mem_section.mr)) { DPRINT_ERROR("Failed to find window %u framebuffer region\n", win); goto error_return; @@ -1155,7 +1155,7 @@ static void fimd_update_memory_section(Exynos4210fimdState *s, unsigned win) error_return: w->mem_section.mr = NULL; - w->mem_section.size = 0; + w->mem_section.size = int128_zero(); w->host_fb_addr = NULL; w->fb_len = 0; } diff --git a/hw/display/framebuffer.c b/hw/display/framebuffer.c index 6be31db2b5..49c9e59043 100644 --- a/hw/display/framebuffer.c +++ b/hw/display/framebuffer.c @@ -54,7 +54,8 @@ void framebuffer_update_display( src_len = src_width * rows; mem_section = memory_region_find(address_space, base, src_len); - if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) { + if (int128_get64(mem_section.size) != src_len || + !memory_region_is_ram(mem_section.mr)) { return; } mem = mem_section.mr; diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 693a9ffdda..c89676b3ff 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -1953,7 +1953,7 @@ static void vfio_listener_region_add(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - end = (section->offset_within_address_space + section->size) & + end = (section->offset_within_address_space + int128_get64(section->size)) & TARGET_PAGE_MASK; if (iova >= end) { @@ -1997,7 +1997,7 @@ static void vfio_listener_region_del(MemoryListener *listener, } iova = TARGET_PAGE_ALIGN(section->offset_within_address_space); - end = (section->offset_within_address_space + section->size) & + end = (section->offset_within_address_space + int128_get64(section->size)) & TARGET_PAGE_MASK; if (iova >= end) { diff --git a/hw/virtio/dataplane/hostmem.c b/hw/virtio/dataplane/hostmem.c index 37292ffd00..7e46723eb1 100644 --- a/hw/virtio/dataplane/hostmem.c +++ b/hw/virtio/dataplane/hostmem.c @@ -90,7 +90,7 @@ static void hostmem_append_new_region(HostMem *hostmem, hostmem->new_regions[num] = (HostMemRegion){ .host_addr = ram_ptr + section->offset_within_region, .guest_addr = section->offset_within_address_space, - .size = section->size, + .size = int128_get64(section->size), .readonly = section->readonly, }; hostmem->num_new_regions++; diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index fbabf99f5e..baf84ea0bd 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -81,7 +81,7 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev, return 0; } start_addr = section->offset_within_address_space; - end_addr = range_get_last(start_addr, section->size); + end_addr = range_get_last(start_addr, int128_get64(section->size)); start_addr = MAX(first, start_addr); end_addr = MIN(last, end_addr); @@ -379,7 +379,7 @@ static void vhost_set_memory(MemoryListener *listener, struct vhost_dev *dev = container_of(listener, struct vhost_dev, memory_listener); hwaddr start_addr = section->offset_within_address_space; - ram_addr_t size = section->size; + ram_addr_t size = int128_get64(section->size); bool log_dirty = memory_region_is_logging(section->mr); int s = offsetof(struct vhost_memory, regions) + (dev->mem->nregions + 1) * sizeof dev->mem->regions[0]; diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index d669756a7f..a27051c2e7 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -197,7 +197,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq) /* FIXME: remove get_system_memory(), but how? */ section = memory_region_find(get_system_memory(), pa, 1); - if (!section.size || !memory_region_is_ram(section.mr)) + if (!int128_nz(section.size) || !memory_region_is_ram(section.mr)) continue; /* Using memory_region_get_ram_ptr is bending the rules a bit, but diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c index c199818dc6..c31a28a3a9 100644 --- a/hw/xen/xen_pt.c +++ b/hw/xen/xen_pt.c @@ -547,7 +547,7 @@ static void xen_pt_region_update(XenPCIPassthroughState *s, struct CheckBarArgs args = { .s = s, .addr = sec->offset_within_address_space, - .size = sec->size, + .size = int128_get64(sec->size), .rc = false, }; @@ -576,7 +576,7 @@ static void xen_pt_region_update(XenPCIPassthroughState *s, if (d->io_regions[bar].type & PCI_BASE_ADDRESS_SPACE_IO) { uint32_t guest_port = sec->offset_within_address_space; uint32_t machine_port = s->bases[bar].access.pio_base; - uint32_t size = sec->size; + uint32_t size = int128_get64(sec->size); rc = xc_domain_ioport_mapping(xen_xc, xen_domid, guest_port, machine_port, size, op); @@ -588,7 +588,7 @@ static void xen_pt_region_update(XenPCIPassthroughState *s, pcibus_t guest_addr = sec->offset_within_address_space; pcibus_t machine_addr = s->bases[bar].access.maddr + sec->offset_within_region; - pcibus_t size = sec->size; + pcibus_t size = int128_get64(sec->size); rc = xc_domain_memory_mapping(xen_xc, xen_domid, XEN_PFN(guest_addr + XC_PAGE_SIZE - 1), XEN_PFN(machine_addr + XC_PAGE_SIZE - 1), |