Adapt the core files for unsigned 128 bit arithmetic. Signed-off-by: Pierre Morel <pmo...@linux.vnet.ibm.com> --- exec.c | 32 ++++++++++++++++---------------- kvm-all.c | 16 ++++++++-------- 2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/exec.c b/exec.c index 0a4a0c5..7828f0b 100644 --- a/exec.c +++ b/exec.c @@ -343,7 +343,7 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x { MemoryRegionSection *section; MemoryRegion *mr; - Int128 diff; + UInt128 diff; section = address_space_lookup_region(d, addr, resolve_subpage); /* Compute offset within MemoryRegionSection */ @@ -366,8 +366,8 @@ address_space_translate_internal(AddressSpaceDispatch *d, hwaddr addr, hwaddr *x * the caller really has to do the clamping through memory_access_size. */ if (memory_region_is_ram(mr)) { - diff = int128_sub(section->size, int128_make64(addr)); - *plen = int128_get64(int128_min(diff, int128_make64(*plen))); + diff = uint128_sub(section->size, uint128_from_64(addr)); + *plen = uint128_to_64(uint128_min(diff, uint128_from_64(*plen))); } return section; } @@ -1046,7 +1046,7 @@ static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection *secti d->map.nodes, d->map.sections); MemoryRegionSection subsection = { .offset_within_address_space = base, - .size = int128_make64(TARGET_PAGE_SIZE), + .size = uint128_from_64(TARGET_PAGE_SIZE), }; hwaddr start, end; @@ -1062,7 +1062,7 @@ static void register_subpage(AddressSpaceDispatch *d, MemoryRegionSection *secti subpage = container_of(existing->mr, subpage_t, iomem); } start = section->offset_within_address_space & ~TARGET_PAGE_MASK; - end = start + int128_get64(section->size) - 1; + end = start + uint128_to_64(section->size) - 1; subpage_register(subpage, start, end, phys_section_add(&d->map, section)); } @@ -1073,7 +1073,7 @@ static void register_multipage(AddressSpaceDispatch *d, { hwaddr start_addr = section->offset_within_address_space; uint16_t section_index = phys_section_add(&d->map, section); - uint64_t num_pages = int128_get64(int128_rshift(section->size, + uint64_t num_pages = uint128_to_64(uint128_rshift(section->size, TARGET_PAGE_BITS)); assert(num_pages); @@ -1085,29 +1085,29 @@ static void mem_add(MemoryListener *listener, MemoryRegionSection *section) AddressSpace *as = container_of(listener, AddressSpace, dispatch_listener); AddressSpaceDispatch *d = as->next_dispatch; MemoryRegionSection now = *section, remain = *section; - Int128 page_size = int128_make64(TARGET_PAGE_SIZE); + UInt128 page_size = uint128_from_64(TARGET_PAGE_SIZE); if (now.offset_within_address_space & ~TARGET_PAGE_MASK) { uint64_t left = TARGET_PAGE_ALIGN(now.offset_within_address_space) - now.offset_within_address_space; - now.size = int128_min(int128_make64(left), now.size); + now.size = uint128_min(uint128_from_64(left), now.size); register_subpage(d, &now); } else { - now.size = int128_zero(); + now.size = uint128_zero(); } - while (int128_ne(remain.size, now.size)) { - remain.size = int128_sub(remain.size, now.size); - remain.offset_within_address_space += int128_get64(now.size); - remain.offset_within_region += int128_get64(now.size); + while (uint128_ne(remain.size, now.size)) { + remain.size = uint128_sub(remain.size, now.size); + remain.offset_within_address_space += uint128_to_64(now.size); + remain.offset_within_region += uint128_to_64(now.size); now = remain; - if (int128_lt(remain.size, page_size)) { + if (uint128_lt(remain.size, page_size)) { register_subpage(d, &now); } else if (remain.offset_within_address_space & ~TARGET_PAGE_MASK) { now.size = page_size; register_subpage(d, &now); } else { - now.size = int128_and(now.size, int128_neg(page_size)); + now.size = uint128_and(now.size, uint128_neg(page_size)); register_multipage(d, &now); } } @@ -2155,7 +2155,7 @@ static uint16_t dummy_section(PhysPageMap *map, AddressSpace *as, .mr = mr, .offset_within_address_space = 0, .offset_within_region = 0, - .size = int128_2_64(), + .size = uint128_2_64(), }; return phys_section_add(map, §ion); diff --git a/kvm-all.c b/kvm-all.c index 06e06f2..6a155a9 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -316,7 +316,7 @@ static int kvm_section_update_flags(KVMMemoryListener *kml, MemoryRegionSection *section) { hwaddr phys_addr = section->offset_within_address_space; - ram_addr_t size = int128_get64(section->size); + ram_addr_t size = uint128_to_64(section->size); KVMSlot *mem = kvm_lookup_matching_slot(kml, phys_addr, phys_addr + size); if (mem == NULL) { @@ -365,7 +365,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned long *bitmap) { ram_addr_t start = section->offset_within_region + section->mr->ram_addr; - ram_addr_t pages = int128_get64(section->size) / getpagesize(); + ram_addr_t pages = uint128_to_64(section->size) / getpagesize(); cpu_physical_memory_set_dirty_lebitmap(bitmap, start, pages); return 0; @@ -391,7 +391,7 @@ static int kvm_physical_sync_dirty_bitmap(KVMMemoryListener *kml, KVMSlot *mem; int ret = 0; hwaddr start_addr = section->offset_within_address_space; - hwaddr end_addr = start_addr + int128_get64(section->size); + hwaddr end_addr = start_addr + uint128_to_64(section->size); d.dirty_bitmap = NULL; while (start_addr < end_addr) { @@ -634,7 +634,7 @@ static void kvm_set_phys_mem(KVMMemoryListener *kml, MemoryRegion *mr = section->mr; bool writeable = !mr->readonly && !mr->rom_device; hwaddr start_addr = section->offset_within_address_space; - ram_addr_t size = int128_get64(section->size); + ram_addr_t size = uint128_to_64(section->size); void *ram = NULL; unsigned delta; @@ -825,7 +825,7 @@ static void kvm_mem_ioeventfd_add(MemoryListener *listener, int r; r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space, - data, true, int128_get64(section->size), + data, true, uint128_to_64(section->size), match_data); if (r < 0) { fprintf(stderr, "%s: error adding ioeventfd: %s\n", @@ -843,7 +843,7 @@ static void kvm_mem_ioeventfd_del(MemoryListener *listener, int r; r = kvm_set_ioeventfd_mmio(fd, section->offset_within_address_space, - data, false, int128_get64(section->size), + data, false, uint128_to_64(section->size), match_data); if (r < 0) { abort(); @@ -859,7 +859,7 @@ static void kvm_io_ioeventfd_add(MemoryListener *listener, int r; r = kvm_set_ioeventfd_pio(fd, section->offset_within_address_space, - data, true, int128_get64(section->size), + data, true, uint128_to_64(section->size), match_data); if (r < 0) { fprintf(stderr, "%s: error adding ioeventfd: %s\n", @@ -878,7 +878,7 @@ static void kvm_io_ioeventfd_del(MemoryListener *listener, int r; r = kvm_set_ioeventfd_pio(fd, section->offset_within_address_space, - data, false, int128_get64(section->size), + data, false, uint128_to_64(section->size), match_data); if (r < 0) { abort(); -- 1.7.1