thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
Pablo Greco e6a3ae
From d5526e43ccf3532aa3a0f592e6df5740983a94e2 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Paolo Bonzini <pbonzini@redhat.com>
Pablo Greco e6a3ae
Date: Fri, 22 Nov 2019 11:53:35 +0000
Pablo Greco e6a3ae
Subject: [PATCH 02/16] i386: Add x-force-features option for testing
Pablo Greco e6a3ae
MIME-Version: 1.0
Pablo Greco e6a3ae
Content-Type: text/plain; charset=UTF-8
Pablo Greco e6a3ae
Content-Transfer-Encoding: 8bit
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Pablo Greco e6a3ae
Message-id: <20191122115348.25000-3-pbonzini@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 92602
Pablo Greco e6a3ae
O-Subject: [RHEL8.2/rhel qemu-kvm PATCH 02/15] i386: Add x-force-features option for testing
Pablo Greco e6a3ae
Bugzilla: 1689270
Pablo Greco e6a3ae
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Maxim Levitsky <mlevitsk@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Add a new option that can be used to disable feature flag
Pablo Greco e6a3ae
filtering.  This will allow CPU model compatibility test cases to
Pablo Greco e6a3ae
work without host hardware dependencies.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
Message-Id: <20190628002844.24894-3-ehabkost@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit dac1deae658539e39966e12b12378a28e3dc8441)
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 target/i386/cpu.c | 8 ++++++--
Pablo Greco e6a3ae
 target/i386/cpu.h | 6 ++++++
Pablo Greco e6a3ae
 2 files changed, 12 insertions(+), 2 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
Pablo Greco e6a3ae
index c69116c..8c1338f 100644
Pablo Greco e6a3ae
--- a/target/i386/cpu.c
Pablo Greco e6a3ae
+++ b/target/i386/cpu.c
Pablo Greco e6a3ae
@@ -5019,8 +5019,11 @@ static int x86_cpu_filter_features(X86CPU *cpu)
Pablo Greco e6a3ae
         uint32_t host_feat =
Pablo Greco e6a3ae
             x86_cpu_get_supported_feature_word(w, false);
Pablo Greco e6a3ae
         uint32_t requested_features = env->features[w];
Pablo Greco e6a3ae
-        env->features[w] &= host_feat;
Pablo Greco e6a3ae
-        cpu->filtered_features[w] = requested_features & ~env->features[w];
Pablo Greco e6a3ae
+        uint32_t available_features = requested_features & host_feat;
Pablo Greco e6a3ae
+        if (!cpu->force_features) {
Pablo Greco e6a3ae
+            env->features[w] = available_features;
Pablo Greco e6a3ae
+        }
Pablo Greco e6a3ae
+        cpu->filtered_features[w] = requested_features & ~available_features;
Pablo Greco e6a3ae
         if (cpu->filtered_features[w]) {
Pablo Greco e6a3ae
             rv = 1;
Pablo Greco e6a3ae
         }
Pablo Greco e6a3ae
@@ -5680,6 +5683,7 @@ static Property x86_cpu_properties[] = {
Pablo Greco e6a3ae
     DEFINE_PROP_BOOL("hv-frequencies", X86CPU, hyperv_frequencies, false),
Pablo Greco e6a3ae
     DEFINE_PROP_BOOL("check", X86CPU, check_cpuid, true),
Pablo Greco e6a3ae
     DEFINE_PROP_BOOL("enforce", X86CPU, enforce_cpuid, false),
Pablo Greco e6a3ae
+    DEFINE_PROP_BOOL("x-force-features", X86CPU, force_features, false),
Pablo Greco e6a3ae
     DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true),
Pablo Greco e6a3ae
     DEFINE_PROP_UINT32("phys-bits", X86CPU, phys_bits, 0),
Pablo Greco e6a3ae
     DEFINE_PROP_BOOL("host-phys-bits", X86CPU, host_phys_bits, false),
Pablo Greco e6a3ae
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
Pablo Greco e6a3ae
index add8b60..1ad54bd 100644
Pablo Greco e6a3ae
--- a/target/i386/cpu.h
Pablo Greco e6a3ae
+++ b/target/i386/cpu.h
Pablo Greco e6a3ae
@@ -1394,6 +1394,12 @@ struct X86CPU {
Pablo Greco e6a3ae
     bool hyperv_frequencies;
Pablo Greco e6a3ae
     bool check_cpuid;
Pablo Greco e6a3ae
     bool enforce_cpuid;
Pablo Greco e6a3ae
+    /*
Pablo Greco e6a3ae
+     * Force features to be enabled even if the host doesn't support them.
Pablo Greco e6a3ae
+     * This is dangerous and should be done only for testing CPUID
Pablo Greco e6a3ae
+     * compatibility.
Pablo Greco e6a3ae
+     */
Pablo Greco e6a3ae
+    bool force_features;
Pablo Greco e6a3ae
     bool expose_kvm;
Pablo Greco e6a3ae
     bool expose_tcg;
Pablo Greco e6a3ae
     bool migratable;
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae