thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-Fix-backport-of-target-i386-add-feature-flags-for-CP.patch

9ae3a8
From 7530a2f3975b76711467226f8b279baf36d92e46 Mon Sep 17 00:00:00 2001
9ae3a8
From: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Date: Tue, 6 Sep 2016 21:45:05 +0200
9ae3a8
Subject: [PATCH 1/2] Fix backport of "target-i386: add feature flags for
9ae3a8
 CPUID[EAX=0xd, ECX=1]"
9ae3a8
9ae3a8
RH-Author: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Message-id: <1473198305-8442-1-git-send-email-ehabkost@redhat.com>
9ae3a8
Patchwork-id: 72260
9ae3a8
O-Subject: [RHEL-7.3 qemu-kvm PATCH] Fix backport of "target-i386: add feature flags for CPUID[EAX=0xd, ECX=1]"
9ae3a8
Bugzilla: 1371619
9ae3a8
RH-Acked-by: Bandan Das <bsd@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
Upstream status: commit 0bb0b2d2fe7f645ddaf1f0ff40ac669c9feb4aa1
9ae3a8
9ae3a8
commit 5fcaf5176d7545518c76f3aa8ea7ce6fb063c62d (the backport of
9ae3a8
upstream commit 0bb0b2d2fe7f645ddaf1f0ff40ac669c9feb4aa1) had a
9ae3a8
serious bug: as the qemu-kvm-1.5.3 code doesn't have
9ae3a8
FeatureWordInfo and loops for assigning cpu->features,
9ae3a8
cpu->features[FEAT_XSAVE] was always zero, so that commit
9ae3a8
basically cleared all XSAVE feature bits in all CPU models.
9ae3a8
9ae3a8
Fix it by handling FEAT_XSAVE everywhere it matters: in the
9ae3a8
plus_features/minus_features handling, in the loading of CPU
9ae3a8
model definition, and kvm_cpu_fill_host().
9ae3a8
9ae3a8
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 target-i386/cpu.c | 8 ++++++++
9ae3a8
 1 file changed, 8 insertions(+)
9ae3a8
9ae3a8
diff --git a/target-i386/cpu.c b/target-i386/cpu.c
9ae3a8
index 80106ba..1001c47 100644
9ae3a8
--- a/target-i386/cpu.c
9ae3a8
+++ b/target-i386/cpu.c
9ae3a8
@@ -1201,6 +1201,8 @@ static void kvm_cpu_fill_host(x86_def_t *x86_cpu_def)
9ae3a8
     } else {
9ae3a8
         x86_cpu_def->features[FEAT_7_0_EBX] = 0;
9ae3a8
     }
9ae3a8
+    x86_cpu_def->features[FEAT_XSAVE] =
9ae3a8
+                kvm_arch_get_supported_cpuid(s, 0xd, 1, R_EAX);
9ae3a8
 
9ae3a8
     x86_cpu_def->xlevel = kvm_arch_get_supported_cpuid(s, 0x80000000, 0, R_EAX);
9ae3a8
     x86_cpu_def->features[FEAT_8000_0001_EDX] =
9ae3a8
@@ -1281,6 +1283,9 @@ static int kvm_check_features_against_host(X86CPU *cpu)
9ae3a8
         {&env->features[FEAT_7_0_EBX],
9ae3a8
             &host_def.features[FEAT_7_0_EBX],
9ae3a8
             FEAT_7_0_EBX },
9ae3a8
+        {&env->features[FEAT_XSAVE],
9ae3a8
+            &host_def.features[FEAT_XSAVE],
9ae3a8
+            FEAT_XSAVE },
9ae3a8
         {&env->features[FEAT_SVM],
9ae3a8
             &host_def.features[FEAT_SVM],
9ae3a8
             FEAT_SVM },
9ae3a8
@@ -1819,6 +1824,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
9ae3a8
     env->features[FEAT_KVM] |= plus_features[FEAT_KVM];
9ae3a8
     env->features[FEAT_SVM] |= plus_features[FEAT_SVM];
9ae3a8
     env->features[FEAT_7_0_EBX] |= plus_features[FEAT_7_0_EBX];
9ae3a8
+    env->features[FEAT_XSAVE] |= plus_features[FEAT_XSAVE];
9ae3a8
     env->features[FEAT_1_EDX] &= ~minus_features[FEAT_1_EDX];
9ae3a8
     env->features[FEAT_1_ECX] &= ~minus_features[FEAT_1_ECX];
9ae3a8
     env->features[FEAT_8000_0001_EDX] &= ~minus_features[FEAT_8000_0001_EDX];
9ae3a8
@@ -1827,6 +1833,7 @@ static void cpu_x86_parse_featurestr(X86CPU *cpu, char *features, Error **errp)
9ae3a8
     env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM];
9ae3a8
     env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM];
9ae3a8
     env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX];
9ae3a8
+    env->features[FEAT_XSAVE] &= ~minus_features[FEAT_XSAVE];
9ae3a8
 
9ae3a8
 out:
9ae3a8
     return;
9ae3a8
@@ -1962,6 +1969,7 @@ static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
9ae3a8
     env->features[FEAT_SVM] = def->features[FEAT_SVM];
9ae3a8
     env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
9ae3a8
     env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
9ae3a8
+    env->features[FEAT_XSAVE] = def->features[FEAT_XSAVE];
9ae3a8
     env->cpuid_xlevel2 = def->xlevel2;
9ae3a8
 
9ae3a8
     object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8