From patchwork Fri Feb 19 17:21:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 45866 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 A27DBB7D23 for ; Sat, 20 Feb 2010 04:27:58 +1100 (EST) Received: from localhost ([127.0.0.1]:52766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiWZV-0005QV-9I for incoming@patchwork.ozlabs.org; Fri, 19 Feb 2010 12:23:21 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NiWY9-0005QQ-Bt for qemu-devel@nongnu.org; Fri, 19 Feb 2010 12:21:57 -0500 Received: from [199.232.76.173] (port=44028 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NiWY8-0005QD-PX for qemu-devel@nongnu.org; Fri, 19 Feb 2010 12:21:56 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NiWY6-0000u3-D2 for qemu-devel@nongnu.org; Fri, 19 Feb 2010 12:21:56 -0500 Received: from david.siemens.de ([192.35.17.14]:19495) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NiWY2-0000sJ-1H for qemu-devel@nongnu.org; Fri, 19 Feb 2010 12:21:54 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by david.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JHLNId023840; Fri, 19 Feb 2010 18:21:25 +0100 Received: from [139.25.109.167] (mchn012c.mchp.siemens.de [139.25.109.167] (may be forged)) by mail1.siemens.de (8.12.11.20060308/8.12.11) with ESMTP id o1JHLKDo014061; Fri, 19 Feb 2010 18:21:21 +0100 Message-ID: <4B7EC890.8000309@siemens.com> Date: Fri, 19 Feb 2010 18:21:20 +0100 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Avi Kivity , Marcelo Tosatti X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6 Cc: Anthony Liguori , qemu-devel , kvm Subject: [Qemu-devel] [PATCH][uq/master] KVM: x86: 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 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 --- qemu-kvm is not affected as it has it own cpu loop - maybe the way to go for upstream as well on the long-term. 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;