From patchwork Sun Jan 17 21:58:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 8051081 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88AA3BEEE5 for ; Sun, 17 Jan 2016 22:04:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB684205EA for ; Sun, 17 Jan 2016 22:04:38 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08463205F1 for ; Sun, 17 Jan 2016 22:03:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aKvNB-0003TO-Ka; Sun, 17 Jan 2016 22:00:33 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aKvNA-0003Sg-RI for xen-devel@lists.xen.org; Sun, 17 Jan 2016 22:00:32 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id DF/50-02745-00F0C965; Sun, 17 Jan 2016 22:00:32 +0000 X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1453068030!16482355!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41317 invoked from network); 17 Jan 2016 22:00:31 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-8.tower-31.messagelabs.com with SMTP; 17 Jan 2016 22:00:31 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 17 Jan 2016 14:00:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,309,1449561600"; d="scan'208";a="635191784" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.13.26]) by FMSMGA003.fm.intel.com with ESMTP; 17 Jan 2016 14:00:28 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org, Jan Beulich , Boris Ostrovsky , Kevin Tian Date: Mon, 18 Jan 2016 05:58:57 +0800 Message-Id: <1453067939-9121-9-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1453067939-9121-1-git-send-email-haozhong.zhang@intel.com> References: <1453067939-9121-1-git-send-email-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Keir Fraser , Suravee Suthikulpanit , Andrew Cooper , Aravind Gopalakrishnan , Jun Nakajima Subject: [Xen-devel] [PATCH v4 08/10] x86/hvm: Move saving/loading vcpu's TSC to common code X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Both VMX and SVM save/load vcpu's TSC when saving/loading vcpu's context, so this patch moves saving/loading vcpu's TSC to the common functions hvm_[save|load]_cpu_ctxt(). Signed-off-by: Haozhong Zhang Acked-by: Jan Beulich Acked-by: Kevin Tian Reviewed-by: Boris Ostrovsky --- xen/arch/x86/hvm/hvm.c | 4 ++++ xen/arch/x86/hvm/svm/svm.c | 5 ----- xen/arch/x86/hvm/vmx/vmx.c | 5 ----- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 8549dab..ddc60a7 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1774,6 +1774,8 @@ static int hvm_save_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) /* Architecture-specific vmcs/vmcb bits */ hvm_funcs.save_cpu_ctxt(v, &ctxt); + ctxt.tsc = hvm_get_guest_tsc_fixed(v, d->arch.hvm_domain.sync_tsc); + ctxt.msr_tsc_aux = hvm_msr_tsc_aux(v); hvm_get_segment_register(v, x86_seg_idtr, &seg); @@ -2070,6 +2072,8 @@ static int hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h) v->arch.hvm_vcpu.msr_tsc_aux = ctxt.msr_tsc_aux; + hvm_set_guest_tsc_fixed(v, ctxt.tsc, d->arch.hvm_domain.sync_tsc); + seg.limit = ctxt.idtr_limit; seg.base = ctxt.idtr_base; hvm_set_segment_register(v, x86_seg_idtr, &seg); diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index a4ac38c..bc8843a 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -357,9 +357,6 @@ static void svm_save_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) data->msr_syscall_mask = vmcb->sfmask; data->msr_efer = v->arch.hvm_vcpu.guest_efer; data->msr_flags = -1ULL; - - data->tsc = hvm_get_guest_tsc_fixed(v, - v->domain->arch.hvm_domain.sync_tsc); } @@ -374,8 +371,6 @@ static void svm_load_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) vmcb->sfmask = data->msr_syscall_mask; v->arch.hvm_vcpu.guest_efer = data->msr_efer; svm_update_guest_efer(v); - - hvm_set_guest_tsc_fixed(v, data->tsc, v->domain->arch.hvm_domain.sync_tsc); } static void svm_save_vmcb_ctxt(struct vcpu *v, struct hvm_hw_cpu *ctxt) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 7917fb7..6285689 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -587,9 +587,6 @@ static void vmx_save_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) data->msr_lstar = guest_state->msrs[VMX_INDEX_MSR_LSTAR]; data->msr_star = guest_state->msrs[VMX_INDEX_MSR_STAR]; data->msr_syscall_mask = guest_state->msrs[VMX_INDEX_MSR_SYSCALL_MASK]; - - data->tsc = hvm_get_guest_tsc_fixed(v, - v->domain->arch.hvm_domain.sync_tsc); } static void vmx_load_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) @@ -604,8 +601,6 @@ static void vmx_load_cpu_state(struct vcpu *v, struct hvm_hw_cpu *data) v->arch.hvm_vmx.cstar = data->msr_cstar; v->arch.hvm_vmx.shadow_gs = data->shadow_gs; - - hvm_set_guest_tsc_fixed(v, data->tsc, v->domain->arch.hvm_domain.sync_tsc); }