Received: from eggs.gnu.org ([2001:4830:134:3::10]:57403) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZluS-0001PJ-4v for qemu-devel@nongnu.org; Fri, 25 Oct 2013 14:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZluR-0006ca-8Z for qemu-devel@nongnu.org; Fri, 25 Oct 2013 14:14:56 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:39254 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZluR-0006cU-1i for qemu-devel@nongnu.org; Fri, 25 Oct 2013 14:14:55 -0400 From: Peter Maydell Date: Fri, 25 Oct 2013 19:07:27 +0100 Message-Id: <1382724449-11944-5-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1382724449-11944-1-git-send-email-peter.maydell@linaro.org> References: <1382724449-11944-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 4/6] target-arm: sort TCG cpreg list by KVM-style 64 bit ID number List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org From: Alvise Rigo Both KVM and TCG populate the cpreg_list with 64 bit register IDs, but in the TCG side the cpreg_list is sorted using the 32 bit ID version while in the kvm side the 64 bit ID version is used. This patch makes the sorting of the cpreg_list consistent between KVM and TCG. Signed-off-by: Alvise Rigo Message-id: 1381513125-26802-1-git-send-email-a.rigo@virtualopensystems.com [PMM: fixed indent, coding style and commit message formatting] Signed-off-by: Peter Maydell --- target-arm/helper.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 73476ed..3445813 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -225,10 +225,16 @@ static void count_cpreg(gpointer key, gpointer opaque) static gint cpreg_key_compare(gconstpointer a, gconstpointer b) { - uint32_t aidx = *(uint32_t *)a; - uint32_t bidx = *(uint32_t *)b; + uint64_t aidx = cpreg_to_kvm_id(*(uint32_t *)a); + uint64_t bidx = cpreg_to_kvm_id(*(uint32_t *)b); - return aidx - bidx; + if (aidx > bidx) { + return 1; + } + if (aidx < bidx) { + return -1; + } + return 0; } static void cpreg_make_keylist(gpointer key, gpointer value, gpointer udata) -- 1.7.9.5