qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 5/7] 128bit: adapt VFIO for UInt128 arithmetic
Date: Thu,  5 Nov 2015 17:18:57 +0100	[thread overview]
Message-ID: <1446740339-31366-6-git-send-email-pmorel@linux.vnet.ibm.com> (raw)
In-Reply-To: <1446740339-31366-1-git-send-email-pmorel@linux.vnet.ibm.com>

VFIO is using 128bit arithmetic for memory areas.
Let's adapt to unsigned 128bit arithmetic.

Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
---
 hw/vfio/common.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 85ee9b0..f819cd5 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -318,7 +318,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
     VFIOContainer *container = container_of(listener, VFIOContainer,
                                             iommu_data.type1.listener);
     hwaddr iova, end;
-    Int128 llend;
+    UInt128 llend;
     void *vaddr;
     int ret;
 
@@ -326,7 +326,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
         trace_vfio_listener_region_add_skip(
                 section->offset_within_address_space,
                 section->offset_within_address_space +
-                int128_get64(int128_sub(section->size, int128_one())));
+                uint128_to_64(uint128_sub(section->size, uint128_one())));
         return;
     }
 
@@ -337,11 +337,11 @@ static void vfio_listener_region_add(MemoryListener *listener,
     }
 
     iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
-    llend = int128_make64(section->offset_within_address_space);
-    llend = int128_add(llend, section->size);
-    llend = int128_and(llend, int128_exts64(TARGET_PAGE_MASK));
+    llend = uint128_from_64(section->offset_within_address_space);
+    llend = uint128_add(llend, section->size);
+    llend = uint128_and(llend, uint128_exts64(TARGET_PAGE_MASK));
 
-    if (int128_ge(int128_make64(iova), llend)) {
+    if (uint128_ge(uint128_from_64(iova), llend)) {
         return;
     }
 
@@ -351,7 +351,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
         VFIOGuestIOMMU *giommu;
 
         trace_vfio_listener_region_add_iommu(iova,
-                    int128_get64(int128_sub(llend, int128_one())));
+                    uint128_to_64(uint128_sub(llend, uint128_one())));
         /*
          * FIXME: We should do some checking to see if the
          * capabilities of the host VFIO IOMMU are adequate to model
@@ -388,7 +388,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
 
     /* Here we assume that memory_region_is_ram(section->mr)==true */
 
-    end = int128_get64(llend);
+    end = uint128_to_64(llend);
     vaddr = memory_region_get_ram_ptr(section->mr) +
             section->offset_within_region +
             (iova - section->offset_within_address_space);
@@ -428,7 +428,7 @@ static void vfio_listener_region_del(MemoryListener *listener,
         trace_vfio_listener_region_del_skip(
                 section->offset_within_address_space,
                 section->offset_within_address_space +
-                int128_get64(int128_sub(section->size, int128_one())));
+                uint128_to_64(uint128_sub(section->size, uint128_one())));
         return;
     }
 
@@ -460,7 +460,7 @@ static void vfio_listener_region_del(MemoryListener *listener,
     }
 
     iova = TARGET_PAGE_ALIGN(section->offset_within_address_space);
-    end = (section->offset_within_address_space + int128_get64(section->size)) &
+    end = (section->offset_within_address_space + uint128_to_64(section->size)) &
           TARGET_PAGE_MASK;
 
     if (iova >= end) {
-- 
1.7.1

  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 ` [Qemu-devel] [PATCH 3/7] 128bit: adapt core files for unsigned 128bits Pierre Morel
2015-11-05 16:18 ` [Qemu-devel] [PATCH 4/7] 128bit: adapt sparc mmu_helper for UInt128 Pierre Morel
2015-11-05 16:18 ` Pierre Morel [this message]
2015-11-05 16:18 ` [Qemu-devel] [PATCH 6/7] 128bit: adapt Virtio for UInt128 arithmetic 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-6-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).