From patchwork Tue Feb 5 16:39:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 218317 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 E318C2C02C4 for ; Wed, 6 Feb 2013 05:52:08 +1100 (EST) Received: from localhost ([::1]:37667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2lcN-0001J3-VX for incoming@patchwork.ozlabs.org; Tue, 05 Feb 2013 11:43:35 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49361) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2lbn-0008Mh-1n for qemu-devel@nongnu.org; Tue, 05 Feb 2013 11:43:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2lbl-0006Kc-Ab for qemu-devel@nongnu.org; Tue, 05 Feb 2013 11:42:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21259) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2lbl-0006KU-0K for qemu-devel@nongnu.org; Tue, 05 Feb 2013 11:42:57 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r15Ggsgs031445 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 5 Feb 2013 11:42:54 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r15Ggg5v025940; Tue, 5 Feb 2013 11:42:53 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Tue, 5 Feb 2013 17:39:24 +0100 Message-Id: <1360082364-12475-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1360082364-12475-1-git-send-email-imammedo@redhat.com> References: <1360082364-12475-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, gleb@redhat.com, blauwirbel@gmail.com, anthony@codemonkey.ws, afaerber@suse.de, rth@twiddle.net Subject: [Qemu-devel] [PATCH 5/5] target-i386: fix kvm_default_features overwriting kvm_arch_get_supported_cpuid() 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 ORing kvm_default_features to def->kvm_features might set unsupported bits if kvm_arch_get_supported_cpuid() returns less bits set than in kvm_default_features. Fix it by removing kvm_default_features and using only what kvm_arch_get_supported_cpuid() returns. Mark disable_kvm_pv_eoi() to be removed in favor of compat_props when available. Signed-off-by: Igor Mammedov --- target-i386/cpu.c | 20 ++++++++------------ target-i386/cpu.h | 2 ++ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 62fdc84..e66362e 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -220,17 +220,12 @@ typedef struct model_features_t { int check_cpuid = 0; int enforce_cpuid = 0; -static uint32_t kvm_default_features = (1 << KVM_FEATURE_CLOCKSOURCE) | - (1 << KVM_FEATURE_NOP_IO_DELAY) | - (1 << KVM_FEATURE_CLOCKSOURCE2) | - (1 << KVM_FEATURE_ASYNC_PF) | - (1 << KVM_FEATURE_STEAL_TIME) | - (1 << KVM_FEATURE_PV_EOI) | - (1 << KVM_FEATURE_CLOCKSOURCE_STABLE_BIT); - +/* TODO: replace it with compat properties when feature bits + * are converted into static properties */ +bool x86_cpu_no_pv_eoi; void disable_kvm_pv_eoi(void) { - kvm_default_features &= ~(1UL << KVM_FEATURE_PV_EOI); + x86_cpu_no_pv_eoi = true; } void host_cpuid(uint32_t function, uint32_t count, @@ -2061,9 +2056,6 @@ static void x86_cpu_initfn(Object *obj) env->cpuid_ext3_features = def->ext3_features; object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", NULL); env->cpuid_kvm_features = def->kvm_features; - if (kvm_enabled()) { - env->cpuid_kvm_features |= kvm_default_features; - } env->cpuid_svm_features = def->svm_features; env->cpuid_ext4_features = def->ext4_features; env->cpuid_7_0_ebx_features = def->cpuid_7_0_ebx_features; @@ -2107,6 +2099,10 @@ static void x86_cpu_def_class_init(ObjectClass *oc, void *data) */ memcpy(xcc->info.vendor, hostcc->info.vendor, sizeof(xcc->info.vendor)); + xcc->info.kvm_features = xcc->info.kvm_features; + if (x86_cpu_no_pv_eoi) { + xcc->info.kvm_features &= ~(1UL << KVM_FEATURE_PV_EOI); + } } /* Look for specific models that have the QEMU version in .model_id */ diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 11ef942..51f20b6 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1246,6 +1246,8 @@ void do_smm_enter(CPUX86State *env1); void cpu_report_tpr_access(CPUX86State *env, TPRAccess access); +/* TODO: convert to compat_props */ +extern bool x86_cpu_no_pv_eoi; void disable_kvm_pv_eoi(void); /* Return name of 32-bit register, from a R_* constant */