From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu0ll-0003ig-1L for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:18:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zu0lj-0002MB-V5 for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:18:40 -0500 Received: from mail-wi0-x229.google.com ([2a00:1450:400c:c05::229]:35807) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zu0lj-0002Ly-N3 for qemu-devel@nongnu.org; Wed, 04 Nov 2015 11:18:39 -0500 Received: by wicll6 with SMTP id ll6so93058113wic.0 for ; Wed, 04 Nov 2015 08:18:39 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 4 Nov 2015 17:18:21 +0100 Message-Id: <1446653912-116150-4-git-send-email-pbonzini@redhat.com> In-Reply-To: <1446653912-116150-1-git-send-email-pbonzini@redhat.com> References: <1446653912-116150-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 03/14] target-i386: fix pcmpxstrx equal-ordered (strstr) mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Eduardo Habkost , Richard Henderson In this mode, referring an invalid element of the source forces the result to false (table 4-7, last column) but referring an invalid element of the destination forces the result to true, so the outer loop should still be run even if some elements of the destination will be invalid. They will be avoided in the inner loop, which correctly bounds "i" to validd, but they will still contribute to a positive outcome of the search. This fixes tst_strstr in glibc 2.17. Reported-by: Florian Weimer Cc: Richard Henderson Cc: Eduardo Habkost Signed-off-by: Paolo Bonzini --- target-i386/ops_sse.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h index 7aa693a..1780d1d 100644 --- a/target-i386/ops_sse.h +++ b/target-i386/ops_sse.h @@ -2037,10 +2037,10 @@ static inline unsigned pcmpxstrx(CPUX86State *env, Reg *d, Reg *s, } break; case 3: - for (j = valids - validd; j >= 0; j--) { + for (j = valids; j >= 0; j--) { res <<= 1; v = 1; - for (i = MIN(upper - j, validd); i >= 0; i--) { + for (i = MIN(valids - j, validd); i >= 0; i--) { v &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i)); } res |= v; -- 1.8.3.1