All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: fweimer@redhat.com, Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] target-i386: fix pcmpxstrx equal-ordered (strstr) mode
Date: Tue, 13 Oct 2015 09:16:00 +1100	[thread overview]
Message-ID: <561C3120.9080402@twiddle.net> (raw)
In-Reply-To: <1444643442-8487-1-git-send-email-pbonzini@redhat.com>

On 10/12/2015 08:50 PM, Paolo Bonzini wrote:
> 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 culled in the inner loop, which
> correctly bounds "i" to validd.
>
> This fix tst_strstr in glibc 2.17.
>
> Reported-by: Florian Weimer <fweimer@redhat.com>
> Cc: Richard Henderson <rth@twiddle.net>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target-i386/ops_sse.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h
> index 7aa693a..268f3e1 100644
> --- a/target-i386/ops_sse.h
> +++ b/target-i386/ops_sse.h
> @@ -2037,7 +2037,7 @@ 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--) {

I don't see how the bounding is properly done.  In particular,

>                 v &= (pcmp_val(s, ctrl, i + j) == pcmp_val(d, ctrl, i));

We're bounding j by valids, but accessing i+j?

I think this would be a lot simpler if we simply followed the pseudocode in 
table 4-3, doing overrideIfDataInvalid after comparison.


r~

  reply	other threads:[~2015-10-12 22:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12  9:50 [Qemu-devel] [PATCH] target-i386: fix pcmpxstrx equal-ordered (strstr) mode Paolo Bonzini
2015-10-12 22:16 ` Richard Henderson [this message]
2015-10-13  7:41   ` Paolo Bonzini

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=561C3120.9080402@twiddle.net \
    --to=rth@twiddle.net \
    --cc=ehabkost@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=pbonzini@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.