From patchwork Mon Feb 22 21:26:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 46014 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 C4F46B7CEA for ; Tue, 23 Feb 2010 08:40:12 +1100 (EST) Received: from localhost ([127.0.0.1]:32923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjfzN-0001U6-2Y for incoming@patchwork.ozlabs.org; Mon, 22 Feb 2010 16:38:49 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Njfos-0006vi-Oq for qemu-devel@nongnu.org; Mon, 22 Feb 2010 16:27:58 -0500 Received: from [199.232.76.173] (port=56406 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Njfos-0006vF-3I for qemu-devel@nongnu.org; Mon, 22 Feb 2010 16:27:58 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Njfoo-000371-24 for qemu-devel@nongnu.org; Mon, 22 Feb 2010 16:27:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31795) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Njfon-00036d-4O for qemu-devel@nongnu.org; Mon, 22 Feb 2010 16:27:53 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1MLRndo004429 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Feb 2010 16:27:49 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1MLRmkm019204; Mon, 22 Feb 2010 16:27:49 -0500 Received: from amt.cnet (vpn-11-163.rdu.redhat.com [10.11.11.163]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o1MLRl5B016404; Mon, 22 Feb 2010 16:27:47 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 360A966E0AC; Mon, 22 Feb 2010 18:27:05 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o1MLR18a000785; Mon, 22 Feb 2010 18:27:01 -0300 From: Marcelo Tosatti To: Anthony Liguori Date: Mon, 22 Feb 2010 18:26:44 -0300 Message-Id: <14dcc3e2ac52d7a2a1cfe2e54c332d8042485a39.1266874009.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Jan Kiszka , qemu-devel@nongnu.org, kvm@vger.kernel.org, Avi Kivity Subject: [Qemu-devel] [PATCH 2/8] 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 6a290fd..4029ea2 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -228,11 +228,13 @@ int cpu_exec(CPUState *env1) env = env1; #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;