From patchwork Thu Jul 7 14:13:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 103678 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 661A4B6F18 for ; Fri, 8 Jul 2011 00:55:35 +1000 (EST) Received: from localhost ([::1]:47079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QepzI-0001Dy-71 for incoming@patchwork.ozlabs.org; Thu, 07 Jul 2011 10:55:32 -0400 Received: from eggs.gnu.org ([140.186.70.92]:55215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QepKm-0007lS-KH for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QepKg-0001bp-K8 for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:40 -0400 Received: from ch1ehsobe005.messaging.microsoft.com ([216.32.181.185]:37452 helo=CH1EHSOBE004.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QepKf-0001bK-Ub for qemu-devel@nongnu.org; Thu, 07 Jul 2011 10:13:34 -0400 Received: from mail99-ch1-R.bigfish.com (216.32.181.171) by CH1EHSOBE004.bigfish.com (10.43.70.54) with Microsoft SMTP Server id 14.1.225.22; Thu, 7 Jul 2011 14:13:32 +0000 Received: from mail99-ch1 (localhost.localdomain [127.0.0.1]) by mail99-ch1-R.bigfish.com (Postfix) with ESMTP id 3405BA50261; Thu, 7 Jul 2011 14:13:32 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzzz1202hzz8275bhz32i668h839h62h) X-Forefront-Antispam-Report: CIP:163.181.249.109; KIP:(null); UIP:(null); IPVD:NLI; H:ausb3twp02.amd.com; RD:none; EFVD:NLI Received: from mail99-ch1 (localhost.localdomain [127.0.0.1]) by mail99-ch1 (MessageSwitch) id 131004801269574_12507; Thu, 7 Jul 2011 14:13:32 +0000 (UTC) Received: from CH1EHSMHS011.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.251]) by mail99-ch1.bigfish.com (Postfix) with ESMTP id 0D0EE71804B; Thu, 7 Jul 2011 14:13:32 +0000 (UTC) Received: from ausb3twp02.amd.com (163.181.249.109) by CH1EHSMHS011.bigfish.com (10.43.70.11) with Microsoft SMTP Server id 14.1.225.22; Thu, 7 Jul 2011 14:13:29 +0000 X-WSS-ID: 0LNYVID-02-FW9-02 X-M-MSG: Received: from sausexedgep01.amd.com (sausexedgep01-ext.amd.com [163.181.249.72]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Axway MailGate 3.8.1) with ESMTP id 28A9BC8115; Thu, 7 Jul 2011 09:13:25 -0500 (CDT) Received: from SAUSEXDAG01.amd.com (163.181.3.36) by sausexedgep01.amd.com (163.181.36.54) with Microsoft SMTP Server (TLS) id 8.3.106.1; Thu, 7 Jul 2011 09:14:05 -0500 Received: from storexhtp01.amd.com (172.24.4.3) by sausexdag01.amd.com (163.181.3.36) with Microsoft SMTP Server (TLS) id 14.1.289.1; Thu, 7 Jul 2011 09:13:28 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.3.83.0; Thu, 7 Jul 2011 10:13:17 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 9754349C5EB; Thu, 7 Jul 2011 15:13:16 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 89C3DFFDC5; Thu, 7 Jul 2011 16:13:16 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti Date: Thu, 7 Jul 2011 16:13:13 +0200 Message-ID: <1310047993-7649-4-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1310047993-7649-1-git-send-email-joerg.roedel@amd.com> References: <1310047993-7649-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-OriginatorOrg: amd.com X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP2+, XP SP1+ (seldom 98) X-Received-From: 216.32.181.185 Cc: Joerg Roedel , qemu-devel@nongnu.org, kvm@vger.kernel.org Subject: [Qemu-devel] [PATCH 3/3] qemu-x86: Set tsc_khz in kvm when supported 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 Make use of the KVM_TSC_CONTROL feature if available. Signed-off-by: Joerg Roedel --- target-i386/kvm.c | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 10fb2c4..923d2d5 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -354,6 +354,7 @@ int kvm_arch_init_vcpu(CPUState *env) uint32_t unused; struct kvm_cpuid_entry2 *c; uint32_t signature[3]; + int r; env->cpuid_features &= kvm_arch_get_supported_cpuid(s, 1, 0, R_EDX); @@ -499,7 +500,22 @@ int kvm_arch_init_vcpu(CPUState *env) qemu_add_vm_change_state_handler(cpu_update_state, env); - return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); + r = kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); + if (r) + return r; + +#ifdef KVM_CAP_TSC_CONTROL + r = kvm_check_extension(env->kvm_state, KVM_CAP_TSC_CONTROL); + if (r && env->tsc_khz) { + r = kvm_vcpu_ioctl(env, KVM_SET_TSC_KHZ, env->tsc_khz); + if (r < 0) { + fprintf(stderr, "KVM_SET_TSC_KHZ failed\n"); + return r; + } + } +#endif + + return 0; } void kvm_arch_reset_vcpu(CPUState *env)