qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] improve emulation correctness


From: Richard Henderson
Subject: Re: [Qemu-devel] [PATCH] improve emulation correctness
Date: Fri, 25 Apr 2014 10:09:28 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 04/25/2014 01:13 AM, Dmitry Poletaev wrote:
> There is a set of test, that checks QEMU CPU for similar behavior with real 
> hardware (http://roberto.greyhats.it/projects/pills.html). Test 
> reg/pill2579.c can detect, that program is execute in emulated environment. 
> It is related with behavior of rcl instruction. If the number of shifted bits 
> more than 1, OF of eflags become undefined. Real CPUs does not change OF, if 
> it is undefined. QEMU do it anyway.
> Emulated program can execute that test and after that can understand 
> environment not real.
> 
> Signed-off-by: Dmitry Poletaev <address@hidden>
> 
> diff --git a/target-i386/shift_helper_template.h 
> b/target-i386/shift_helper_template.h
> index cf91a2d..d5bd321 100644
> --- a/target-i386/shift_helper_template.h
> +++ b/target-i386/shift_helper_template.h
> @@ -64,8 +64,10 @@ target_ulong glue(helper_rcl, SUFFIX)(CPUX86State *env, 
> target_ulong t0,
>          }
>          t0 = res;
>          env->cc_src = (eflags & ~(CC_C | CC_O)) |
> -            (lshift(src ^ t0, 11 - (DATA_BITS - 1)) & CC_O) |
>              ((src >> (DATA_BITS - count)) & CC_C);
> +        if (count == 1) {
> +            env->cc_src |= (lshift(src ^ t0, 11 - (DATA_BITS - 1)) & CC_O);
> +        }

This doesn't do what you say it does.  It doesn't leave O unchanged,
it always resets it to 0, and only sets it back to 1 if count == 1.


r~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]