From: Pierre Morel <pmorel@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: cornelia.huck@de.ibm.com, pbonzini@redhat.com,
pmorel@linux.vnet.ibm.com, peter.maydell@linaro.org
Subject: [Qemu-devel] [PATCH 3/7] 128bit: adapt core files for unsigned 128bits
Date: Thu, 5 Nov 2015 17:18:55 +0100 [thread overview]
Message-ID: <1446740339-31366-4-git-send-email-pmorel@linux.vnet.ibm.com> (raw)
In-Reply-To: <1446740339-31366-1-git-send-email-pmorel@linux.vnet.ibm.com>
Adapt the core files for unsigned 128 bit arithmetic.
Signed-off-by: Pierre Morel <pmorel@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
next prev parent reply other threads:[~2015-11-05 16:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-05 16:18 [Qemu-devel] [PATCH 0/7] int128: reparing broken 128 bit memory calculations Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 1/7] int128: use unsigned 128 bit arithmetic Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 2/7] memory: modify memory size for an unsigned 128bit int Pierre Morel
2015-11-05 16:18 ` Pierre Morel [this message]
2015-11-05 16:18 ` [Qemu-devel] [PATCH 4/7] 128bit: adapt sparc mmu_helper for UInt128 Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 5/7] 128bit: adapt VFIO for UInt128 arithmetic Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 6/7] 128bit: adapt Virtio " Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 7/7] 128bits: some HW components use 128bit arithmetic Pierre Morel
2015-11-05 16:32 ` [Qemu-devel] [PATCH 0/7] int128: reparing broken 128 bit memory calculations Paolo Bonzini
2015-11-06 8:36 ` Pierre Morel
2015-11-06 16:33 ` Paolo Bonzini
[not found] ` <56408B28.8070408@linux.vnet.ibm.com>
2015-11-09 12:20 ` Paolo Bonzini
2015-11-10 9:08 ` Pierre Morel
2015-11-10 12:12 ` Pierre Morel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446740339-31366-4-git-send-email-pmorel@linux.vnet.ibm.com \
--to=pmorel@linux.vnet.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).