From patchwork Mon Oct 22 15:03:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 193218 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE2822C014C for ; Tue, 23 Oct 2012 03:32:17 +1100 (EST) Received: from localhost ([::1]:43123 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQKvH-0002hz-OJ for incoming@patchwork.ozlabs.org; Mon, 22 Oct 2012 12:32:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJYP-0002gl-Oc for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:04:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQJYJ-0000hF-MB for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:04:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3049) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJYJ-0000gx-51 for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:04:27 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF4I4X015834 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Oct 2012 11:04:18 -0400 Received: from nial.brq.redhat.com (dhcp-1-247.brq.redhat.com [10.34.1.247]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF3OnI031350; Mon, 22 Oct 2012 11:04:15 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2012 17:03:03 +0200 Message-Id: <1350918203-25198-18-git-send-email-imammedo@redhat.com> In-Reply-To: <1350918203-25198-1-git-send-email-imammedo@redhat.com> References: <1350918203-25198-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, Don@CloudSwitch.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 17/37] target-i386: make 'f-kvmclock' compatible with legacy behaviour 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 It'll keep legacy behavior of kvmclock CPUID feature, which is toggles on KVM_FEATURE_CLOCKSOURCE and KVM_FEATURE_CLOCKSOURCE2 CPUID feature bits. Rename feature corresponding to KVM_FEATURE_CLOCKSOURCE to f-kvmclock1 to free f-kvmclock for use of legacy feature. Signed-off-by: Igor Mammedov Reviewed-by: Don Slutz --- target-i386/cpu.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 407c5ce..9cdcae8 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -112,6 +112,42 @@ static const char *cpuid_7_0_ebx_feature_name[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; +#if defined(CONFIG_KVM) +static void x86_cpu_get_kvmclock(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj); + bool value = cpu->env.cpuid_kvm_features; + value = (value & KVM_FEATURE_CLOCKSOURCE) && + (value & KVM_FEATURE_CLOCKSOURCE2); + visit_type_bool(v, &value, name, errp); +} + +static void x86_cpu_set_kvmclock(Object *obj, Visitor *v, void *opaque, + const char *name, Error **errp) +{ + X86CPU *cpu = X86_CPU(obj); + bool value; + visit_type_bool(v, &value, name, errp); + if (value == true) { + cpu->env.cpuid_kvm_features |= KVM_FEATURE_CLOCKSOURCE | + KVM_FEATURE_CLOCKSOURCE2; + } else { + cpu->env.cpuid_kvm_features &= ~(KVM_FEATURE_CLOCKSOURCE | + KVM_FEATURE_CLOCKSOURCE2); + } +} + +PropertyInfo qdev_prop_kvmclock = { + .name = "boolean", + .get = x86_cpu_get_kvmclock, + .set = x86_cpu_set_kvmclock, +}; +#define DEFINE_PROP_KVMCLOCK(_n, _s, _f) \ + DEFINE_PROP(_n, _s, _f, qdev_prop_kvmclock, uint32_t) + +#endif + static Property cpu_x86_properties[] = { DEFINE_PROP_BIT("f-fpu", X86CPU, env.cpuid_features, 0, false), DEFINE_PROP_BIT("f-vme", X86CPU, env.cpuid_features, 1, false), @@ -201,7 +237,7 @@ static Property cpu_x86_properties[] = { DEFINE_PROP_BIT("f-cvt16", X86CPU, env.cpuid_ext3_features, 18, false), DEFINE_PROP_BIT("f-nodeid_msr", X86CPU, env.cpuid_ext3_features, 19, false), #if defined(CONFIG_KVM) - DEFINE_PROP_BIT("f-kvmclock", X86CPU, env.cpuid_kvm_features, 0, true), + DEFINE_PROP_BIT("f-kvmclock1", X86CPU, env.cpuid_kvm_features, 0, true), DEFINE_PROP_BIT("f-kvm_nopiodelay", X86CPU, env.cpuid_kvm_features, 1, true), DEFINE_PROP_BIT("f-kvm_mmu", X86CPU, env.cpuid_kvm_features, 2, true), DEFINE_PROP_BIT("f-kvmclock2", X86CPU, env.cpuid_kvm_features, 3, true), @@ -209,6 +245,7 @@ static Property cpu_x86_properties[] = { DEFINE_PROP_BIT("f-kvm_steal_tm", X86CPU, env.cpuid_kvm_features, 5, true), DEFINE_PROP_BIT("f-kvm_pv_eoi", X86CPU, env.cpuid_kvm_features, 6, true), DEFINE_PROP_BIT("f-kvmclock_stable", X86CPU, env.cpuid_kvm_features, 24, true), + DEFINE_PROP_KVMCLOCK("f-kvmclock", X86CPU, env.cpuid_kvm_features), #endif DEFINE_PROP_BIT("f-npt", X86CPU, env.cpuid_svm_features, 0, false), DEFINE_PROP_BIT("f-lbrv", X86CPU, env.cpuid_svm_features, 1, false),