qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Dmitry Poletaev <poletaev-qemu@yandex.ru>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] target-i386: fix handling of ZF in btx instructions
Date: Wed, 07 May 2014 08:31:14 +0200	[thread overview]
Message-ID: <5369D332.2020300@redhat.com> (raw)
In-Reply-To: <40331399383189@web21g.yandex.ru>

Il 06/05/2014 15:33, Dmitry Poletaev ha scritto:
> Eflags for bt/bts/btr/btc instructions compute as for shift(SAR) instructions. According to Intel A2 manual, for btx instructions zf is unaffected under any condition, but for SAR group, when evaluate eflags, we compute zf.

This patch makes zf=0, it doesn't leave it unaffected.

Paolo

> So I suggest add another group, specifically for computing eflags after btx instructions.
>
> Signed-off-by: Dmitry Poletaev <poletaev-qemu@yandex.ru>
>
> diff --git a/target-i386/cc_helper.c b/target-i386/cc_helper.c
> index 05dd12b..272e2f1 100644
> --- a/target-i386/cc_helper.c
> +++ b/target-i386/cc_helper.c
> @@ -168,6 +168,12 @@ target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,
>      case CC_OP_SHLL:
>          return compute_all_shll(dst, src1);
>
> +    case CC_OP_BTXB:
> +        return compute_all_btxb(dst, src1);
> +    case CC_OP_BTXW:
> +        return compute_all_btxw(dst, src1);
> +    case CC_OP_BTXL:
> +        return compute_all_btxl(dst, src1);
>      case CC_OP_SARB:
>          return compute_all_sarb(dst, src1);
>      case CC_OP_SARW:
> @@ -208,6 +214,8 @@ target_ulong helper_cc_compute_all(target_ulong dst, target_ulong src1,
>          return compute_all_decq(dst, src1);
>      case CC_OP_SHLQ:
>          return compute_all_shlq(dst, src1);
> +    case CC_OP_BTXQ:
> +        return compute_all_btxq(dst, src1);
>      case CC_OP_SARQ:
>          return compute_all_sarq(dst, src1);
>      case CC_OP_BMILGQ:
> @@ -234,6 +242,10 @@ target_ulong helper_cc_compute_c(target_ulong dst, target_ulong src1,
>          return 0;
>
>      case CC_OP_EFLAGS:
> +    case CC_OP_BTXB:
> +    case CC_OP_BTXW:
> +    case CC_OP_BTXL:
> +    case CC_OP_BTXQ:
>      case CC_OP_SARB:
>      case CC_OP_SARW:
>      case CC_OP_SARL:
> diff --git a/target-i386/cc_helper_template.h b/target-i386/cc_helper_template.h
> index 607311f..04375f1 100644
> --- a/target-i386/cc_helper_template.h
> +++ b/target-i386/cc_helper_template.h
> @@ -187,6 +187,19 @@ static int glue(compute_c_shl, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1)
>      return (src1 >> (DATA_BITS - 1)) & CC_C;
>  }
>
> +static int glue(compute_all_btx, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1)
> +{
> +    int cf, pf, af, sf, of;
> +
> +    cf = src1 & CC_C;
> +    pf = 0; /* undefined */
> +    af = 0; /* undefined */
> +    /* zf unaffected */
> +    sf = 0;  /* undefined */
> +    of = 0; /* undefined */
> +    return cf | pf | af | sf | of;
> +}
> +
>  static int glue(compute_all_sar, SUFFIX)(DATA_TYPE dst, DATA_TYPE src1)
>  {
>      int cf, pf, af, zf, sf, of;
> diff --git a/target-i386/cpu.h b/target-i386/cpu.h
> index 2a22a7d..506037d 100644
> --- a/target-i386/cpu.h
> +++ b/target-i386/cpu.h
> @@ -660,6 +660,10 @@ typedef enum {
>      CC_OP_SHLL,
>      CC_OP_SHLQ,
>
> +    CC_OP_BTXB, /* modify only C, CC_SRC.msb = C */
> +    CC_OP_BTXW,
> +    CC_OP_BTXL,
> +    CC_OP_BTXQ,
>      CC_OP_SARB, /* modify all flags, CC_DST = res, CC_SRC.lsb = C */
>      CC_OP_SARW,
>      CC_OP_SARL,
> diff --git a/target-i386/translate.c b/target-i386/translate.c
> index 02625e3..e77ba0b 100644
> --- a/target-i386/translate.c
> +++ b/target-i386/translate.c
> @@ -200,6 +200,7 @@ static const uint8_t cc_op_live[CC_OP_NB] = {
>      [CC_OP_INCB ... CC_OP_INCQ] = USES_CC_DST | USES_CC_SRC,
>      [CC_OP_DECB ... CC_OP_DECQ] = USES_CC_DST | USES_CC_SRC,
>      [CC_OP_SHLB ... CC_OP_SHLQ] = USES_CC_DST | USES_CC_SRC,
> +    [CC_OP_BTXB ... CC_OP_BTXQ] = USES_CC_DST | USES_CC_SRC,
>      [CC_OP_SARB ... CC_OP_SARQ] = USES_CC_DST | USES_CC_SRC,
>      [CC_OP_BMILGB ... CC_OP_BMILGQ] = USES_CC_DST | USES_CC_SRC,
>      [CC_OP_ADCX] = USES_CC_DST | USES_CC_SRC,
> @@ -6734,7 +6735,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s,
>              tcg_gen_xor_tl(cpu_T[0], cpu_T[0], cpu_tmp0);
>              break;
>          }
> -        set_cc_op(s, CC_OP_SARB + ot);
> +        set_cc_op(s, CC_OP_BTXB + ot);
>          if (op != 0) {
>              if (mod != 3) {
>                  gen_op_st_v(s, ot, cpu_T[0], cpu_A0);
>
>
>
>

  reply	other threads:[~2014-05-07  6:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-06 13:33 [Qemu-devel] [PATCH] target-i386: fix handling of ZF in btx instructions Dmitry Poletaev
2014-05-07  6:31 ` Paolo Bonzini [this message]
2014-05-07  9:03 ` Peter Maydell
2014-05-12 21:24   ` Richard Henderson

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=5369D332.2020300@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=poletaev-qemu@yandex.ru \
    --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 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).