yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-i386-Add-x-force-features-option-for-testing.patch

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