yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-target-i386-Convert-check-and-enforce-to-static-prop.patch

9ae3a8
From f60e83f9ba3436243c247fe81a53b0158f982b2a Mon Sep 17 00:00:00 2001
9ae3a8
From: Vadim Rozenfeld <vrozenfe@redhat.com>
9ae3a8
Date: Mon, 3 Mar 2014 12:09:22 +0100
9ae3a8
Subject: [PATCH 10/12] target-i386: Convert 'check' and 'enforce' to static properties
9ae3a8
MIME-Version: 1.0
9ae3a8
Content-Type: text/plain; charset=UTF-8
9ae3a8
Content-Transfer-Encoding: 8bit
9ae3a8
9ae3a8
RH-Author: Vadim Rozenfeld <vrozenfe@redhat.com>
9ae3a8
Message-id: <1393848564-10511-11-git-send-email-vrozenfe@redhat.com>
9ae3a8
Patchwork-id: 57966
9ae3a8
O-Subject: [RHEL-7.0 qemu-kvm v4 PATCH 10/12] target-i386: Convert 'check' and 'enforce' to static properties
9ae3a8
Bugzilla: 1004773
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
RH-Acked-by: Juan Quintela <quintela@redhat.com>
9ae3a8
9ae3a8
From: Igor Mammedov <imammedo@redhat.com>
9ae3a8
9ae3a8
* Additionally convert check_cpuid & enforce_cpuid to bool and make them
9ae3a8
  members of X86CPU
9ae3a8
* Make 'enforce' feature independent from 'check'
9ae3a8
9ae3a8
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
9ae3a8
Signed-off-by: Andreas Färber <afaerber@suse.de>
9ae3a8
(cherry picked from commit 912ffc479c0008bd983f5733daa52438b359be6f)
9ae3a8
---
9ae3a8
 target-i386/cpu-qom.h |  2 ++
9ae3a8
 target-i386/cpu.c     | 13 ++++++-------
9ae3a8
 2 files changed, 8 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 target-i386/cpu-qom.h |    2 ++
9ae3a8
 target-i386/cpu.c     |   13 ++++++-------
9ae3a8
 2 files changed, 8 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
diff --git a/target-i386/cpu-qom.h b/target-i386/cpu-qom.h
9ae3a8
index ac56fec..99ba65f 100644
9ae3a8
--- a/target-i386/cpu-qom.h
9ae3a8
+++ b/target-i386/cpu-qom.h
9ae3a8
@@ -69,6 +69,8 @@ typedef struct X86CPU {
9ae3a8
     bool hyperv_vapic;
9ae3a8
     bool hyperv_relaxed_timing;
9ae3a8
     int hyperv_spinlock_attempts;
9ae3a8
+    bool check_cpuid;
9ae3a8
+    bool enforce_cpuid;
9ae3a8
 
9ae3a8
     /* Features that were filtered out because of missing host capabilities */
9ae3a8
     uint32_t filtered_features[FEATURE_WORDS];
9ae3a8
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
9ae3a8
index db51f72..9f2a04e 100644
9ae3a8
--- a/target-i386/cpu.c
9ae3a8
+++ b/target-i386/cpu.c
9ae3a8
@@ -242,9 +242,6 @@ typedef struct model_features_t {
9ae3a8
     FeatureWord feat_word;
9ae3a8
 } model_features_t;
9ae3a8
 
9ae3a8
-int check_cpuid = 0;
9ae3a8
-int enforce_cpuid = 0;
9ae3a8
-
9ae3a8
 static uint32_t kvm_default_features = (1 << KVM_FEATURE_CLOCKSOURCE) |
9ae3a8
         (1 << KVM_FEATURE_NOP_IO_DELAY) |
9ae3a8
         (1 << KVM_FEATURE_CLOCKSOURCE2) |
9ae3a8
@@ -1687,9 +1684,9 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
9ae3a8
                 goto out;
9ae3a8
             }
9ae3a8
         } else if (!strcmp(featurestr, "check")) {
9ae3a8
-            check_cpuid = 1;
9ae3a8
+            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
9ae3a8
         } else if (!strcmp(featurestr, "enforce")) {
9ae3a8
-            check_cpuid = enforce_cpuid = 1;
9ae3a8
+            object_property_parse(OBJECT(cpu), "on", featurestr, errp);
9ae3a8
         } else if (!strcmp(featurestr, "hv_relaxed")) {
9ae3a8
             object_property_parse(OBJECT(cpu), "on", "hv-relaxed", errp);
9ae3a8
         } else if (!strcmp(featurestr, "hv_vapic")) {
9ae3a8
@@ -2490,8 +2487,8 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
9ae3a8
         env->features[FEAT_8000_0001_ECX] &= TCG_EXT3_FEATURES;
9ae3a8
         env->features[FEAT_SVM] &= TCG_SVM_FEATURES;
9ae3a8
     } else {
9ae3a8
-        if (check_cpuid && kvm_check_features_against_host(cpu)
9ae3a8
-            && enforce_cpuid) {
9ae3a8
+        if ((cpu->check_cpuid || cpu->enforce_cpuid)
9ae3a8
+            && kvm_check_features_against_host(cpu) && cpu->enforce_cpuid) {
9ae3a8
             error_setg(&local_err,
9ae3a8
                        "Host's CPU doesn't support requested features");
9ae3a8
             goto out;
9ae3a8
@@ -2633,6 +2630,8 @@ static Property x86_cpu_properties[] = {
9ae3a8
     { .name  = "hv-spinlocks", .info  = &qdev_prop_spinlocks },
9ae3a8
     DEFINE_PROP_BOOL("hv-relaxed", X86CPU, hyperv_relaxed_timing, false),
9ae3a8
     DEFINE_PROP_BOOL("hv-vapic", X86CPU, hyperv_vapic, false),
9ae3a8
+    DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, false),
9ae3a8
+    DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
9ae3a8
     DEFINE_PROP_END_OF_LIST()
9ae3a8
 };
9ae3a8
 
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8