[PATCH 03/18] target/i386/tcg: update cc_op after PUSHF

Paolo Bonzini posted 18 patches 2 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Zhao Liu <zhao1.liu@intel.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>
[PATCH 03/18] target/i386/tcg: update cc_op after PUSHF
Posted by Paolo Bonzini 2 months ago
PUSHF needs to compute the full eflags, set the cc_op to
CC_OP_EFLAGS.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/tcg/emit.c.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
index 1a7fab9333a..22e53f5b000 100644
--- a/target/i386/tcg/emit.c.inc
+++ b/target/i386/tcg/emit.c.inc
@@ -3250,6 +3250,8 @@ static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode)
     gen_update_cc_op(s);
     gen_helper_read_eflags(s->T0, tcg_env);
     gen_push_v(s, s->T0);
+    decode->cc_src = s->T0;
+    decode->cc_op = CC_OP_EFLAGS;
 }
 
 static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode,
-- 
2.52.0
Re: [PATCH 03/18] target/i386/tcg: update cc_op after PUSHF
Posted by Mark Cave-Ayland 1 month ago
On 10/12/2025 13:16, Paolo Bonzini wrote:

> PUSHF needs to compute the full eflags, set the cc_op to
> CC_OP_EFLAGS.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/tcg/emit.c.inc | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
> index 1a7fab9333a..22e53f5b000 100644
> --- a/target/i386/tcg/emit.c.inc
> +++ b/target/i386/tcg/emit.c.inc
> @@ -3250,6 +3250,8 @@ static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode)
>       gen_update_cc_op(s);
>       gen_helper_read_eflags(s->T0, tcg_env);
>       gen_push_v(s, s->T0);
> +    decode->cc_src = s->T0;
> +    decode->cc_op = CC_OP_EFLAGS;
>   }
>   
>   static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode,

Hi Paolo,

I noticed that my WFW 3.11 test image stopped working with master, and a 
quick session with git bisect pointed me towards this patch.

I'll see if I can dig further into it.


ATB,

Mark.
Re: [PATCH 03/18] target/i386/tcg: update cc_op after PUSHF
Posted by Paolo Bonzini 1 month ago
Il mar 6 gen 2026, 16:19 Mark Cave-Ayland <mark.caveayland@nutanix.com> ha
scritto:

> Hi Paolo,


> I noticed that my WFW 3.11 test image stopped working with master, and a
> quick session with git bisect pointed me towards this patch.
>
> I'll see if I can dig further into it.
>

I think s->T0 needs to be anded with CC_S|CC_O|CC_Z|CC_P|CC_A|CC_C before
placing it in cc_src. But there are probably better ways to fix it using
assume_cc_op, I will check tomorrow.

Paolo


> ATB,
>
> Mark.
>
>
Re: [PATCH 03/18] target/i386/tcg: update cc_op after PUSHF
Posted by Richard Henderson 2 months ago
On 12/10/25 07:16, Paolo Bonzini wrote:
> PUSHF needs to compute the full eflags, set the cc_op to
> CC_OP_EFLAGS.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/tcg/emit.c.inc | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/target/i386/tcg/emit.c.inc b/target/i386/tcg/emit.c.inc
> index 1a7fab9333a..22e53f5b000 100644
> --- a/target/i386/tcg/emit.c.inc
> +++ b/target/i386/tcg/emit.c.inc
> @@ -3250,6 +3250,8 @@ static void gen_PUSHF(DisasContext *s, X86DecodedInsn *decode)
>       gen_update_cc_op(s);
>       gen_helper_read_eflags(s->T0, tcg_env);
>       gen_push_v(s, s->T0);
> +    decode->cc_src = s->T0;
> +    decode->cc_op = CC_OP_EFLAGS;
>   }
>   
>   static MemOp gen_shift_count(DisasContext *s, X86DecodedInsn *decode,

Ah, as an optimization to not duplicate computation of these flags, not a bug fix.  You 
might expand the commit message by a few words there.  Anyway,

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~