From patchwork Thu Jan 21 15:09:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 8082431 Return-Path: X-Original-To: patchwork-qemu-devel@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 2309E9F440 for ; Thu, 21 Jan 2016 15:15:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88A6320502 for ; Thu, 21 Jan 2016 15:15:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8574D204A7 for ; Thu, 21 Jan 2016 15:15:52 +0000 (UTC) Received: from localhost ([::1]:48250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMGxj-0005v5-Pa for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jan 2016 10:15:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMGsY-0004S9-F2 for qemu-devel@nongnu.org; Thu, 21 Jan 2016 10:10:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aMGsU-0006uK-Gi for qemu-devel@nongnu.org; Thu, 21 Jan 2016 10:10:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aMGsU-0006uD-Aw for qemu-devel@nongnu.org; Thu, 21 Jan 2016 10:10:26 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id EC4A88EFEB; Thu, 21 Jan 2016 15:10:25 +0000 (UTC) Received: from localhost (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0LFAOTl019614; Thu, 21 Jan 2016 10:10:25 -0500 From: Eduardo Habkost To: Peter Maydell Date: Thu, 21 Jan 2016 13:09:38 -0200 Message-Id: <1453388981-24807-10-git-send-email-ehabkost@redhat.com> In-Reply-To: <1453388981-24807-1-git-send-email-ehabkost@redhat.com> References: <1453388981-24807-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Haozhong Zhang , Richard Henderson Subject: [Qemu-devel] [PULL 09/12] target-i386: Fallback vcpu's TSC rate to value returned by KVM 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 From: Haozhong Zhang If no user-specified TSC rate is present, we will try to set env->tsc_khz to the value returned by KVM_GET_TSC_KHZ. This patch does not change the current functionality of QEMU and just prepares for later patches to enable migrating vcpu's TSC rate. Signed-off-by: Haozhong Zhang Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- target-i386/kvm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 0551a5c..1212b50 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -868,6 +868,20 @@ int kvm_arch_init_vcpu(CPUState *cs) } } + /* vcpu's TSC frequency is either specified by user, or following + * the value used by KVM if the former is not present. In the + * latter case, we query it from KVM and record in env->tsc_khz, + * so that vcpu's TSC frequency can be migrated later via this field. + */ + if (!env->tsc_khz) { + r = kvm_check_extension(cs->kvm_state, KVM_CAP_GET_TSC_KHZ) ? + kvm_vcpu_ioctl(cs, KVM_GET_TSC_KHZ) : + -ENOTSUP; + if (r > 0) { + env->tsc_khz = r; + } + } + if (has_xsave) { env->kvm_xsave_buf = qemu_memalign(4096, sizeof(struct kvm_xsave)); }