qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] improve emulation correctness


From: poletaev
Subject: [Qemu-devel] [PATCH] improve emulation correctness
Date: Thu, 24 Apr 2014 12:35:24 +0400

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);

+        }

     }

     return t0;

}

 

This patch improve correctness of emulator behavior.


reply via email to

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