From patchwork Mon Sep 30 21:20:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 279275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 558F22C00BC for ; Tue, 1 Oct 2013 07:29:26 +1000 (EST) Received: from localhost ([::1]:51684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQl1w-0008W3-FG for incoming@patchwork.ozlabs.org; Mon, 30 Sep 2013 17:29:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQku3-0007lg-5e for qemu-devel@nongnu.org; Mon, 30 Sep 2013 17:21:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VQktx-0008Dq-9Q for qemu-devel@nongnu.org; Mon, 30 Sep 2013 17:21:15 -0400 Received: from dan.rpsys.net ([93.97.175.187]:49981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VQktw-0008DT-Ue for qemu-devel@nongnu.org; Mon, 30 Sep 2013 17:21:09 -0400 Received: from localhost (dan.rpsys.net [127.0.0.1]) by dan.rpsys.net (8.14.4/8.14.4/Debian-2.1ubuntu1) with ESMTP id r8ULL6pc026519 for ; Mon, 30 Sep 2013 22:21:06 +0100 X-Virus-Scanned: Debian amavisd-new at dan.rpsys.net Received: from dan.rpsys.net ([127.0.0.1]) by localhost (dan.rpsys.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id pGtDbi5EmGVz for ; Mon, 30 Sep 2013 22:21:06 +0100 (BST) Received: from [192.168.3.10] (rpvlan0 [192.168.3.10]) (authenticated bits=0) by dan.rpsys.net (8.14.4/8.14.4/Debian-2.1ubuntu1) with ESMTP id r8ULL01v026514 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NOT) for ; Mon, 30 Sep 2013 22:21:02 +0100 Message-ID: <1380576057.18603.465.camel@ted> From: Richard Purdie To: qemu-devel@nongnu.org Date: Mon, 30 Sep 2013 22:20:57 +0100 X-Mailer: Evolution 3.6.4-0ubuntu1 Mime-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 93.97.175.187 X-Mailman-Approved-At: Mon, 30 Sep 2013 17:26:22 -0400 Subject: [Qemu-devel] [BUG/PATCH] Fix i386 SSE status flag corruption 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 This is a combination of bug report and patch. I'm not sure if you'll want to fix it like this but it illustrates the problem and should be easy to fix based on this. When we restore the mxcsr register with FXRSTOR, we need to update the various SSE status flags in CPUX86State by calling update_sse_status(). If we don't, we end up using the status bits from some other context with interesting results. I used a function prototype since it makes the fix clear, some code rearrangement might be needed ultimately. Signed-off-by: Richard Purdie Index: qemu-1.5.0/target-i386/fpu_helper.c =================================================================== --- qemu-1.5.0.orig/target-i386/fpu_helper.c 2013-09-30 18:46:39.283377648 +0000 +++ qemu-1.5.0/target-i386/fpu_helper.c 2013-09-30 18:46:56.895377232 +0000 @@ -1149,6 +1149,8 @@ } } +static void update_sse_status(CPUX86State *env); + void helper_fxrstor(CPUX86State *env, target_ulong ptr, int data64) { int i, fpus, fptag, nb_xmm_regs; @@ -1180,6 +1182,7 @@ if (env->cr[4] & CR4_OSFXSR_MASK) { /* XXX: finish it */ env->mxcsr = cpu_ldl_data(env, ptr + 0x18); + update_sse_status(env); /* cpu_ldl_data(env, ptr + 0x1c); */ if (env->hflags & HF_CS64_MASK) { nb_xmm_regs = 16;