cryptospore / rpms / qemu-kvm

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