From patchwork Thu Jun 17 10:00:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sheng Yang X-Patchwork-Id: 106651 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o5HA0g8P031834 for ; Thu, 17 Jun 2010 10:00:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932852Ab0FQKAk (ORCPT ); Thu, 17 Jun 2010 06:00:40 -0400 Received: from mga11.intel.com ([192.55.52.93]:3275 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932851Ab0FQKAj (ORCPT ); Thu, 17 Jun 2010 06:00:39 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 17 Jun 2010 03:00:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.53,431,1272870000"; d="scan'208";a="808868975" Received: from syang10-desktop.sh.intel.com (HELO syang10-desktop) ([10.239.36.189]) by fmsmga001.fm.intel.com with ESMTP; 17 Jun 2010 03:00:37 -0700 Received: from yasker by syang10-desktop with local (Exim 4.71) (envelope-from ) id 1OPBtz-0008BA-Lf; Thu, 17 Jun 2010 18:00:51 +0800 From: Sheng Yang To: Jan Kiszka Cc: Marcelo Tosatti , Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org, Sheng Yang Subject: [PATCH] qemu-kvm: Replace kvm_set/get_fpu() with upstream version. Date: Thu, 17 Jun 2010 18:00:51 +0800 Message-Id: <1276768851-31415-1-git-send-email-sheng@linux.intel.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <4C19E086.9010801@web.de> References: <4C19E086.9010801@web.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 17 Jun 2010 10:00:42 +0000 (UTC) diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 3c33e64..49218ae 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -775,7 +775,6 @@ static void get_seg(SegmentCache *lhs, const struct kvm_segment *rhs) void kvm_arch_load_regs(CPUState *env, int level) { struct kvm_regs regs; - struct kvm_fpu fpu; struct kvm_sregs sregs; struct kvm_msr_entry msrs[100]; int rc, n, i; @@ -806,16 +805,7 @@ void kvm_arch_load_regs(CPUState *env, int level) kvm_set_regs(env, ®s); - memset(&fpu, 0, sizeof fpu); - fpu.fsw = env->fpus & ~(7 << 11); - fpu.fsw |= (env->fpstt & 7) << 11; - fpu.fcw = env->fpuc; - for (i = 0; i < 8; ++i) - fpu.ftwx |= (!env->fptags[i]) << i; - memcpy(fpu.fpr, env->fpregs, sizeof env->fpregs); - memcpy(fpu.xmm, env->xmm_regs, sizeof env->xmm_regs); - fpu.mxcsr = env->mxcsr; - kvm_set_fpu(env, &fpu); + kvm_put_fpu(env); memset(sregs.interrupt_bitmap, 0, sizeof(sregs.interrupt_bitmap)); if (env->interrupt_injected >= 0) { @@ -933,7 +923,6 @@ void kvm_arch_load_regs(CPUState *env, int level) void kvm_arch_save_regs(CPUState *env) { struct kvm_regs regs; - struct kvm_fpu fpu; struct kvm_sregs sregs; struct kvm_msr_entry msrs[100]; uint32_t hflags; @@ -965,15 +954,7 @@ void kvm_arch_save_regs(CPUState *env) env->eflags = regs.rflags; env->eip = regs.rip; - kvm_get_fpu(env, &fpu); - env->fpstt = (fpu.fsw >> 11) & 7; - env->fpus = fpu.fsw; - env->fpuc = fpu.fcw; - for (i = 0; i < 8; ++i) - env->fptags[i] = !((fpu.ftwx >> i) & 1); - memcpy(env->fpregs, fpu.fpr, sizeof env->fpregs); - memcpy(env->xmm_regs, fpu.xmm, sizeof env->xmm_regs); - env->mxcsr = fpu.mxcsr; + kvm_get_fpu(env); kvm_get_sregs(env, &sregs); diff --git a/qemu-kvm.c b/qemu-kvm.c index 96d458c..114cb5e 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -461,16 +461,6 @@ int kvm_set_regs(CPUState *env, struct kvm_regs *regs) return kvm_vcpu_ioctl(env, KVM_SET_REGS, regs); } -int kvm_get_fpu(CPUState *env, struct kvm_fpu *fpu) -{ - return kvm_vcpu_ioctl(env, KVM_GET_FPU, fpu); -} - -int kvm_set_fpu(CPUState *env, struct kvm_fpu *fpu) -{ - return kvm_vcpu_ioctl(env, KVM_SET_FPU, fpu); -} - int kvm_get_sregs(CPUState *env, struct kvm_sregs *sregs) { return kvm_vcpu_ioctl(env, KVM_GET_SREGS, sregs); diff --git a/qemu-kvm.h b/qemu-kvm.h index 6f6c6d8..ebe7893 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -222,36 +222,6 @@ int kvm_get_regs(CPUState *env, struct kvm_regs *regs); * \return 0 on success */ int kvm_set_regs(CPUState *env, struct kvm_regs *regs); -/*! - * \brief Read VCPU fpu registers - * - * This gets the FPU registers from the VCPU and outputs them - * into a kvm_fpu structure - * - * \note This function returns a \b copy of the VCPUs registers.\n - * If you wish to modify the VCPU FPU registers, you should call kvm_set_fpu() - * - * \param kvm Pointer to the current kvm_context - * \param vcpu Which virtual CPU should get dumped - * \param fpu Pointer to a kvm_fpu which will be populated with the VCPUs - * fpu registers values - * \return 0 on success - */ -int kvm_get_fpu(CPUState *env, struct kvm_fpu *fpu); - -/*! - * \brief Write VCPU fpu registers - * - * This sets the FPU registers on the VCPU from a kvm_fpu structure - * - * \note When this function returns, the fpu pointer and the data it points to - * can be discarded - * \param kvm Pointer to the current kvm_context - * \param vcpu Which virtual CPU should get dumped - * \param fpu Pointer to a kvm_fpu which holds the new vcpu fpu state - * \return 0 on success - */ -int kvm_set_fpu(CPUState *env, struct kvm_fpu *fpu); /*! * \brief Read VCPU system registers diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 9cb9cf4..9c13f62 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -488,6 +488,7 @@ static int kvm_getput_regs(CPUState *env, int set) return ret; } +#endif /* KVM_UPSTREAM */ static int kvm_put_fpu(CPUState *env) { @@ -507,6 +508,7 @@ static int kvm_put_fpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_FPU, &fpu); } +#ifdef KVM_UPSTREAM static int kvm_put_sregs(CPUState *env) { struct kvm_sregs sregs; @@ -605,7 +607,7 @@ static int kvm_put_msrs(CPUState *env, int level) return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); } - +#endif /* KVM_UPSTREAM */ static int kvm_get_fpu(CPUState *env) { @@ -628,6 +630,7 @@ static int kvm_get_fpu(CPUState *env) return 0; } +#ifdef KVM_UPSTREAM static int kvm_get_sregs(CPUState *env) { struct kvm_sregs sregs;