From patchwork Thu Dec 22 20:13:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 132911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6BA8CB7183 for ; Fri, 23 Dec 2011 08:15:34 +1100 (EST) Received: from localhost ([::1]:37111 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rdpz1-0002JR-8L for incoming@patchwork.ozlabs.org; Thu, 22 Dec 2011 16:15:23 -0500 Received: from eggs.gnu.org ([140.186.70.92]:42580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rdpyp-00028J-IA for qemu-devel@nongnu.org; Thu, 22 Dec 2011 16:15:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rdpyo-0008V3-Cy for qemu-devel@nongnu.org; Thu, 22 Dec 2011 16:15:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:61683) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rdpyo-0008Uv-4p for qemu-devel@nongnu.org; Thu, 22 Dec 2011 16:15:10 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBMLF9Lu005847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 22 Dec 2011 16:15:09 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBMLEv2u027838; Thu, 22 Dec 2011 16:15:08 -0500 Received: from amt.cnet (vpn-11-232.rdu.redhat.com [10.11.11.232]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id pBMKFWH8032222; Thu, 22 Dec 2011 15:15:32 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 5212D652105; Thu, 22 Dec 2011 18:13:58 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id pBMKDuhg016199; Thu, 22 Dec 2011 18:13:56 -0200 From: Marcelo Tosatti To: Anthony Liguori Date: Thu, 22 Dec 2011 18:13:46 -0200 Message-Id: <6b42494b219a3beb755bc52419c731aa70efe93d.1324584830.git.mtosatti@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 1/5] kvm: x86: Use symbols for all xsave field 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 From: Jan Kiszka Field 0 (FCW+FSW) and 1 (FTW+FOP) were hard-coded so far. Signed-off-by: Jan Kiszka Signed-off-by: Marcelo Tosatti --- target-i386/kvm.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 5bfc21f..d2f70f9 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -759,6 +759,8 @@ static int kvm_put_fpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_FPU, &fpu); } +#define XSAVE_FCW_FSW 0 +#define XSAVE_FTW_FOP 1 #define XSAVE_CWD_RIP 2 #define XSAVE_CWD_RDP 4 #define XSAVE_MXCSR 6 @@ -786,8 +788,8 @@ static int kvm_put_xsave(CPUState *env) for (i = 0; i < 8; ++i) { twd |= (!env->fptags[i]) << i; } - xsave->region[0] = (uint32_t)(swd << 16) + cwd; - xsave->region[1] = (uint32_t)(env->fpop << 16) + twd; + xsave->region[XSAVE_FCW_FSW] = (uint32_t)(swd << 16) + cwd; + xsave->region[XSAVE_FTW_FOP] = (uint32_t)(env->fpop << 16) + twd; memcpy(&xsave->region[XSAVE_CWD_RIP], &env->fpip, sizeof(env->fpip)); memcpy(&xsave->region[XSAVE_CWD_RDP], &env->fpdp, sizeof(env->fpdp)); memcpy(&xsave->region[XSAVE_ST_SPACE], env->fpregs, @@ -991,10 +993,10 @@ static int kvm_get_xsave(CPUState *env) return ret; } - cwd = (uint16_t)xsave->region[0]; - swd = (uint16_t)(xsave->region[0] >> 16); - twd = (uint16_t)xsave->region[1]; - env->fpop = (uint16_t)(xsave->region[1] >> 16); + cwd = (uint16_t)xsave->region[XSAVE_FCW_FSW]; + swd = (uint16_t)(xsave->region[XSAVE_FCW_FSW] >> 16); + twd = (uint16_t)xsave->region[XSAVE_FTW_FOP]; + env->fpop = (uint16_t)(xsave->region[XSAVE_FTW_FOP] >> 16); env->fpstt = (swd >> 11) & 7; env->fpus = swd; env->fpuc = cwd;