From patchwork Mon Sep 28 05:38:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 7275151 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8C42A9F36A for ; Mon, 28 Sep 2015 05:38:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C297D206E6 for ; Mon, 28 Sep 2015 05:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB50C207AE for ; Mon, 28 Sep 2015 05:38:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751668AbbI1Fiz (ORCPT ); Mon, 28 Sep 2015 01:38:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:12829 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751962AbbI1Fix (ORCPT ); Mon, 28 Sep 2015 01:38:53 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP; 27 Sep 2015 22:38:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,601,1437462000"; d="scan'208";a="778728907" Received: from hzzhang-optiplex-9020.sh.intel.com (HELO localhost) ([10.239.12.62]) by orsmga001.jf.intel.com with ESMTP; 27 Sep 2015 22:38:51 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Paolo Bonzini , Marcelo Tosatti , Richard Henderson , Eduardo Habkost , Haozhong Zhang Subject: [PATCH 2/3] target-i386: initialize vcpu's TSC rate to the value from KVM Date: Mon, 28 Sep 2015 13:38:30 +0800 Message-Id: <1443418711-24106-3-git-send-email-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.4.8 In-Reply-To: <1443418711-24106-1-git-send-email-haozhong.zhang@intel.com> References: <1443418711-24106-1-git-send-email-haozhong.zhang@intel.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 When creating a vcpu, we initialize its TSC rate to the value from KVM (through ioctl KVM_GET_TSC_KHZ). Signed-off-by: Haozhong Zhang --- target-i386/kvm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 7b0ba17..c2b161a 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -751,6 +751,13 @@ int kvm_arch_init_vcpu(CPUState *cs) } } + r = kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ); + if (r < 0) { + fprintf(stderr, "KVM_GET_TSC_KHZ failed\n"); + return r; + } + env->tsc_khz = r; + if (kvm_has_xsave()) { env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave)); }