From patchwork Tue Feb 23 14:54:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avi Kivity X-Patchwork-Id: 46064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8EABBB7CEF for ; Wed, 24 Feb 2010 02:07:17 +1100 (EST) Received: from localhost ([127.0.0.1]:57898 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjwC1-0006YF-02 for incoming@patchwork.ozlabs.org; Tue, 23 Feb 2010 09:56:57 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Njw9k-0006L8-6j for qemu-devel@nongnu.org; Tue, 23 Feb 2010 09:54:36 -0500 Received: from [199.232.76.173] (port=51439 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Njw9j-0006Kq-MM for qemu-devel@nongnu.org; Tue, 23 Feb 2010 09:54:35 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Njw9i-0002Zo-3S for qemu-devel@nongnu.org; Tue, 23 Feb 2010 09:54:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48183) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Njw9h-0002ZQ-LX for qemu-devel@nongnu.org; Tue, 23 Feb 2010 09:54:33 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1NEsVnj006743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 23 Feb 2010 09:54:31 -0500 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1NEsUVs016544; Tue, 23 Feb 2010 09:54:30 -0500 Received: from localhost.localdomain (file.tlv.redhat.com [10.35.255.8]) by cleopatra.tlv.redhat.com (Postfix) with ESMTP id C6D08250059; Tue, 23 Feb 2010 16:54:29 +0200 (IST) From: Avi Kivity To: Anthony Liguori Date: Tue, 23 Feb 2010 16:54:29 +0200 Message-Id: <1266936869-9700-2-git-send-email-avi@redhat.com> In-Reply-To: <1266936869-9700-1-git-send-email-avi@redhat.com> References: <1266936869-9700-1-git-send-email-avi@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 1/1] kvm: Fix eflags corruption in kvm mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jan Kiszka This should explain a lot of the weird breakages of upstream KVM we've seen recently (actually we should have seen it much earlier): Stop translating eflags into TCG format when in kvm mode as we never translate it back and rather sync this broken state into the kernel. Signed-off-by: Jan Kiszka Signed-off-by: Avi Kivity --- cpu-exec.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index af4595b..3246c9e 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -232,11 +232,13 @@ int cpu_exec(CPUState *env1) env_to_regs(); #if defined(TARGET_I386) - /* put eflags in CPU temporary format */ - CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); - DF = 1 - (2 * ((env->eflags >> 10) & 1)); - CC_OP = CC_OP_EFLAGS; - env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); + if (!kvm_enabled()) { + /* put eflags in CPU temporary format */ + CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); + DF = 1 - (2 * ((env->eflags >> 10) & 1)); + CC_OP = CC_OP_EFLAGS; + env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); + } #elif defined(TARGET_SPARC) #elif defined(TARGET_M68K) env->cc_op = CC_OP_FLAGS;