thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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