From patchwork Mon Feb 25 01:03:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 222815 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 B9E202C02AD for ; Mon, 25 Feb 2013 12:47:56 +1100 (EST) Received: from localhost ([::1]:35312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9mYH-0004un-4k for incoming@patchwork.ozlabs.org; Sun, 24 Feb 2013 20:08:21 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9mXs-0004iS-1a for qemu-devel@nongnu.org; Sun, 24 Feb 2013 20:07:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U9mXo-0006xF-4g for qemu-devel@nongnu.org; Sun, 24 Feb 2013 20:07:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:17688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U9mXn-0006wW-S2 for qemu-devel@nongnu.org; Sun, 24 Feb 2013 20:07:52 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1P17pG9014428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 24 Feb 2013 20:07:51 -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-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r1P17eLu016755; Sun, 24 Feb 2013 20:07:50 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2013 02:03:06 +0100 Message-Id: <1361754189-29809-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1361754189-29809-1-git-send-email-imammedo@redhat.com> References: <1361754189-29809-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: ehabkost@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 07/10] target-i386: convert 'check' and 'enforce' to static properties 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 * additionally convert check_cpuid & enforce_cpuid to bool and make them members of CPUX86State * make 'enforce' feature independent from 'check' Signed-off-by: Igor Mammedov --- v2: - make check_cpuid & enforce_cpuid members of CPUX86State and use DEFINE_PROP_BOOL instead of custom property setters --- target-i386/cpu.c | 13 ++++++------- target-i386/cpu.h | 2 ++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 8f7132a..6826224 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -216,9 +216,6 @@ typedef struct model_features_t { FeatureWord feat_word; } 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) | @@ -1351,6 +1348,8 @@ static Property cpu_x86_properties[] = { DEFINE_PROP_HV_SPINLOCKS("hv-spinlocks", HYPERV_SPINLOCK_NEVER_RETRY), DEFINE_PROP_BOOL("hv-relaxed", X86CPU, env.hyperv_relaxed_timing, false), DEFINE_PROP_BOOL("hv-vapic", X86CPU, env.hyperv_vapic, false), + DEFINE_PROP_BOOL("check", X86CPU, env.check_cpuid, false), + DEFINE_PROP_BOOL("enforce", X86CPU, env.enforce_cpuid, false), DEFINE_PROP_END_OF_LIST(), }; @@ -1487,9 +1486,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp) goto out; } } else if (!strcmp(featurestr, "check")) { - check_cpuid = 1; + object_property_parse(OBJECT(cpu), "on", featurestr, errp); } else if (!strcmp(featurestr, "enforce")) { - check_cpuid = enforce_cpuid = 1; + object_property_parse(OBJECT(cpu), "on", featurestr, errp); } else if (!strcmp(featurestr, "hv_relaxed")) { object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp); } else if (!strcmp(featurestr, "hv_vapic")) { @@ -2236,8 +2235,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) #ifdef CONFIG_KVM filter_features_for_kvm(cpu); #endif - if (check_cpuid && kvm_check_features_against_host(cpu) - && enforce_cpuid) { + if ((env->check_cpuid || env->enforce_cpuid) + && kvm_check_features_against_host(cpu) && env->enforce_cpuid) { error_setg(errp, "Host's CPU doesn't support requested features"); return; } diff --git a/target-i386/cpu.h b/target-i386/cpu.h index e3723c2..cdec0da 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -847,6 +847,8 @@ typedef struct CPUX86State { bool hyperv_vapic; bool hyperv_relaxed_timing; int hyperv_spinlock_attempts; + bool check_cpuid; + bool enforce_cpuid; /* MTRRs */ uint64_t mtrr_fixed[11];