[PATCH] target/i386: hvf: fix lflags_to_rflags

Paolo Bonzini posted 1 patch 7 months, 2 weeks ago
Failed in applying to current master (apply log)
target/i386/hvf/x86_flags.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] target/i386: hvf: fix lflags_to_rflags
Posted by Paolo Bonzini 7 months, 2 weeks ago
Clear the flags before adding in the ones computed from lflags.

Cc: Wei Liu <liuwe@linux.microsoft.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/hvf/x86_flags.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/target/i386/hvf/x86_flags.c b/target/i386/hvf/x86_flags.c
index 32772c359e9..31d76c067bf 100644
--- a/target/i386/hvf/x86_flags.c
+++ b/target/i386/hvf/x86_flags.c
@@ -284,6 +284,7 @@ void set_SF(CPUX86State *env, bool val)
 
 void lflags_to_rflags(CPUX86State *env)
 {
+    env->eflags &= ~(CC_C|CC_P|CC_A|CC_P|CC_Z|CC_S|CC_O);
     env->eflags |= get_CF(env) ? CC_C : 0;
     env->eflags |= get_PF(env) ? CC_P : 0;
     env->eflags |= get_AF(env) ? CC_A : 0;
-- 
2.49.0
Re: [PATCH] target/i386: hvf: fix lflags_to_rflags
Posted by Philippe Mathieu-Daudé 7 months, 2 weeks ago
On 3/4/25 21:47, Paolo Bonzini wrote:
> Clear the flags before adding in the ones computed from lflags.
> 
> Cc: Wei Liu <liuwe@linux.microsoft.com>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>   target/i386/hvf/x86_flags.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/target/i386/hvf/x86_flags.c b/target/i386/hvf/x86_flags.c
> index 32772c359e9..31d76c067bf 100644
> --- a/target/i386/hvf/x86_flags.c
> +++ b/target/i386/hvf/x86_flags.c
> @@ -284,6 +284,7 @@ void set_SF(CPUX86State *env, bool val)
>   
>   void lflags_to_rflags(CPUX86State *env)
>   {
> +    env->eflags &= ~(CC_C|CC_P|CC_A|CC_P|CC_Z|CC_S|CC_O);

CC_P is twice, otherwise:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

>       env->eflags |= get_CF(env) ? CC_C : 0;
>       env->eflags |= get_PF(env) ? CC_P : 0;
>       env->eflags |= get_AF(env) ? CC_A : 0;