From patchwork Tue Dec 24 12:58:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 304961 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9A28C2C00A6 for ; Wed, 25 Dec 2013 00:00:09 +1100 (EST) Received: from localhost ([::1]:38202 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvRag-0005hm-QW for incoming@patchwork.ozlabs.org; Tue, 24 Dec 2013 08:00:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvRZt-0005KC-Bd for qemu-devel@nongnu.org; Tue, 24 Dec 2013 07:59:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VvRZi-00041Q-DE for qemu-devel@nongnu.org; Tue, 24 Dec 2013 07:59:17 -0500 Received: from cantor2.suse.de ([195.135.220.15]:51997 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VvRZi-00040y-7C for qemu-devel@nongnu.org; Tue, 24 Dec 2013 07:59:06 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DD34BAC19; Tue, 24 Dec 2013 12:59:05 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 24 Dec 2013 13:58:59 +0100 Message-Id: <1387889941-9896-9-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1387889941-9896-1-git-send-email-afaerber@suse.de> References: <1387889941-9896-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.135.220.15 Cc: Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PULL 08/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 From: Igor Mammedov * Additionally convert check_cpuid & enforce_cpuid to bool and make them members of X86CPU * Make 'enforce' feature independent from 'check' Signed-off-by: Igor Mammedov Signed-off-by: Andreas Färber --- target-i386/cpu-qom.h | 2 ++ target-i386/cpu.c | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h index dbe3e29..d1751a4 100644 --- a/target-i386/cpu-qom.h +++ b/target-i386/cpu-qom.h @@ -69,6 +69,8 @@ typedef struct X86CPU { bool hyperv_vapic; bool hyperv_relaxed_timing; int hyperv_spinlock_attempts; + bool check_cpuid; + bool enforce_cpuid; /* if true the CPUID code directly forward host cache leaves to the guest */ bool cache_info_passthrough; diff --git a/target-i386/cpu.c b/target-i386/cpu.c index 39c57f8..6055035 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -354,9 +354,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) | @@ -1772,9 +1769,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")) { @@ -2608,8 +2605,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp) env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES; env->features[FEAT_SVM] &= TCG_SVM_FEATURES; } else { - if (check_cpuid && kvm_check_features_against_host(cpu) - && enforce_cpuid) { + if ((cpu->check_cpuid || cpu->enforce_cpuid) + && kvm_check_features_against_host(cpu) && cpu->enforce_cpuid) { error_setg(&local_err, "Host's CPU doesn't support requested features"); goto out; @@ -2771,6 +2768,8 @@ static Property x86_cpu_properties[] = { { .name = "hv-spinlocks", .info = &qdev_prop_spinlocks }, DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false), DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false), + DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false), + DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false), DEFINE_PROP_END_OF_LIST() };