From patchwork Fri Apr 25 08:13:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Poletaev X-Patchwork-Id: 342685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F2BA31400B9 for ; Fri, 25 Apr 2014 18:14:30 +1000 (EST) Received: from localhost ([::1]:56544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdbH9-00031L-PC for incoming@patchwork.ozlabs.org; Fri, 25 Apr 2014 04:14:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdbGm-0002Wu-MR for qemu-devel@nongnu.org; Fri, 25 Apr 2014 04:14:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WdbGg-0005eT-CS for qemu-devel@nongnu.org; Fri, 25 Apr 2014 04:14:04 -0400 Received: from forward19.mail.yandex.net ([95.108.253.144]:48601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WdbGg-0005eC-2Q for qemu-devel@nongnu.org; Fri, 25 Apr 2014 04:13:58 -0400 Received: from web22g.yandex.ru (web22g.yandex.ru [95.108.253.231]) by forward19.mail.yandex.net (Yandex) with ESMTP id DCCDC1121E14 for ; Fri, 25 Apr 2014 12:13:55 +0400 (MSK) Received: from 127.0.0.1 (localhost [127.0.0.1]) by web22g.yandex.ru (Yandex) with ESMTP id 7FA5114E06C1; Fri, 25 Apr 2014 12:13:55 +0400 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1398413635; bh=rkvMWk4phkIol2So0IU4dZ71WWggGywQiVsffCLgx+E=; h=From:To:Subject:Date; b=AGlGuHOScP/pjkYaCN2zN1BI8arz20SpgYT0BV3i2R1L9vMtkVKVK1ggsEs3hX+y8 HbpRNHb9AUvBy/p63Tp5meEvv178bRXnrvWbYAayQyTxyJhtqwxEfv6epeiPDtK6w8 6jLqdV59/n67cWUcgPv7+1CA3C+i9Ohp+j5rSKTM= Received: from core-gw.novsu.ac.ru (core-gw.novsu.ac.ru [80.250.189.177]) by web22g.yandex.ru with HTTP; Fri, 25 Apr 2014 12:13:55 +0400 From: Dmitry Poletaev To: qemu-devel@nongnu.org MIME-Version: 1.0 Message-Id: <209441398413635@web22g.yandex.ru> X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Fri, 25 Apr 2014 12:13:55 +0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 95.108.253.144 Subject: [Qemu-devel] [PATCH] improve emulation correctness X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 This patch improve correctness of emulator behavior. 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; }