thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
9ae3a8
From b05eb2cc7decc07ed044484861587b3490144d02 Mon Sep 17 00:00:00 2001
9ae3a8
From: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Date: Wed, 8 Jun 2016 13:04:21 +0200
9ae3a8
Subject: [PATCH 2/3] target-i386: fix pcmpxstrx equal-ordered (strstr) mode
9ae3a8
9ae3a8
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
Message-id: <1465391061-17748-1-git-send-email-pbonzini@redhat.com>
9ae3a8
Patchwork-id: 70570
9ae3a8
O-Subject: [RHEL7.3/7.2.z qemu-kvm PATCH] target-i386: fix pcmpxstrx equal-ordered (strstr) mode
9ae3a8
Bugzilla: 1340971
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
RH-Acked-by: Thomas Huth <thuth@redhat.com>
9ae3a8
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
9ae3a8
9ae3a8
Kindly requested by the Openstack folks, who sometimes uses TCG
9ae3a8
instead of nested virt.
9ae3a8
9ae3a8
In this mode, referring an invalid element of the source forces the
9ae3a8
result to false (table 4-7, last column) but referring an invalid
9ae3a8
element of the destination forces the result to true, so the outer
9ae3a8
loop should still be run even if some elements of the destination
9ae3a8
will be invalid.  They will be avoided in the inner loop, which
9ae3a8
correctly bounds "i" to validd, but they will still contribute to a
9ae3a8
positive outcome of the search.
9ae3a8
9ae3a8
This fixes tst_strstr in glibc 2.17.
9ae3a8
9ae3a8
Reported-by: Florian Weimer <fweimer@redhat.com>
9ae3a8
Cc: Richard Henderson <rth@twiddle.net>
9ae3a8
Cc: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
(cherry picked from commit 54c54f8b56047d3c2420e1ae06a6a8890c220ac4)
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 target-i386/ops_sse.h | 4 ++--
9ae3a8
 1 file changed, 2 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h
9ae3a8
index eb24b5f..5145d9e 100644
9ae3a8
--- a/target-i386/ops_sse.h
9ae3a8
+++ b/target-i386/ops_sse.h
9ae3a8
@@ -2034,10 +2034,10 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s,
9ae3a8
         }
9ae3a8
         break;
9ae3a8
     case 3:
9ae3a8
-        for (j = valids - validd; j >= 0; j--) {
9ae3a8
+        for (j = valids; j >= 0; j--) {
9ae3a8
             res <<= 1;
9ae3a8
             v = 1;
9ae3a8
-            for (i = MIN(upper - j, validd); i >= 0; i--) {
9ae3a8
+            for (i = MIN(valids - j, validd); i >= 0; i--) {
9ae3a8
                 v &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i));
9ae3a8
             }
9ae3a8
             res |= v;
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8