From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: [PATCH][uq/master] KVM: x86: Fix eflags corruption in kvm mode Date: Fri, 19 Feb 2010 18:21:20 +0100 Message-ID: <4B7EC890.8000309@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: qemu-devel , kvm , Anthony Liguori To: Avi Kivity , Marcelo Tosatti Return-path: Received: from david.siemens.de ([192.35.17.14]:19633 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751669Ab0BSRWa (ORCPT ); Fri, 19 Feb 2010 12:22:30 -0500 Sender: kvm-owner@vger.kernel.org List-ID: 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;