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: 56003 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 A8916B7D86 for ; Thu, 17 Jun 2010 20:02:45 +1000 (EST) Received: from localhost ([127.0.0.1]:39287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPBvm-0005yZ-AM for incoming@patchwork.ozlabs.org; Thu, 17 Jun 2010 06:02:42 -0400 Received: from [140.186.70.92] (port=40198 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OPBtr-0005pe-8e for qemu-devel@nongnu.org; Thu, 17 Jun 2010 06:00:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OPBtp-0003LV-H4 for qemu-devel@nongnu.org; Thu, 17 Jun 2010 06:00:42 -0400 Received: from mga11.intel.com ([192.55.52.93]:47870) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OPBtp-0003L7-3i for qemu-devel@nongnu.org; Thu, 17 Jun 2010 06:00:41 -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 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Marcelo Tosatti , Sheng Yang , Avi Kivity , kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] qemu-kvm: Replace kvm_set/get_fpu() with upstream version. 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 Signed-off-by: Sheng Yang --- Would send out XSAVE patch after the upstream ones have been merged, since the patch would be affected by the merge. qemu-kvm-x86.c | 23 ++--------------------- qemu-kvm.c | 10 ---------- qemu-kvm.h | 30 ------------------------------ target-i386/kvm.c | 5 ++++- 4 files changed, 6 insertions(+), 62 deletions(-) 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;