qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: vasilis.liaskovitis@profitbricks.com, andrey@xdel.ru, mst@redhat.com
Subject: [Qemu-devel] [PATCH 2/2] pc-dimm: fix large address sorting during auto-allocation
Date: Mon,  9 Jun 2014 19:28:01 +0200	[thread overview]
Message-ID: <1402334881-19310-3-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1402334881-19310-1-git-send-email-imammedo@redhat.com>

GCompareFunc(a, b) used by g_slist_insert_sorted() return 'gint',
however it might be too small to fit difference between
2 addresses. So use 128bit calculate difference and normalize
result to -1/0/1 return values.

Reported-By: Andrey Korolyov <andrey@xdel.ru>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/mem/pc-dimm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 9f091c6..8c26568 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -73,8 +73,14 @@ static gint pc_dimm_addr_sort(gconstpointer a, gconstpointer b)
 {
     PCDIMMDevice *x = PC_DIMM(a);
     PCDIMMDevice *y = PC_DIMM(b);
+    Int128 diff = int128_sub(int128_make64(x->addr), int128_make64(y->addr));
 
-    return x->addr - y->addr;
+    if (int128_lt(diff, int128_zero())) {
+        return -1;
+    } else if (int128_gt(diff, int128_zero())) {
+        return 1;
+    }
+    return 0;
 }
 
 static int pc_dimm_built_list(Object *obj, void *opaque)
-- 
1.9.3

  parent reply	other threads:[~2014-06-09 17:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-09 17:27 [Qemu-devel] [PATCH 0/2] pc: memory hotplug fixes Igor Mammedov
2014-06-09 17:28 ` [Qemu-devel] [PATCH 1/2] pc: q35: acpi: report error to user on unsupported unplug request Igor Mammedov
2014-06-09 17:28 ` Igor Mammedov [this message]
2014-06-10 11:05 ` [Qemu-devel] [PATCH 0/2] pc: memory hotplug fixes Michael S. Tsirkin
2014-06-10 14:25   ` Igor Mammedov
2014-06-19 12:42 ` Vasilis Liaskovitis

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=1402334881-19310-3-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=andrey@xdel.ru \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vasilis.liaskovitis@profitbricks.com \
    /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).