yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-target-i386-set-the-CPUID-level-to-0x14-on-old-machi.patch

ddf19c
From 72a1827006be22791017ff2b671eac1c96be5d12 Mon Sep 17 00:00:00 2001
ddf19c
From: "plai@redhat.com" <plai@redhat.com>
ddf19c
Date: Thu, 7 May 2020 22:09:23 +0100
ddf19c
Subject: [PATCH 01/26] target/i386: set the CPUID level to 0x14 on old
ddf19c
 machine-type
ddf19c
ddf19c
RH-Author: plai@redhat.com
ddf19c
Message-id: <20200507220923.13723-1-plai@redhat.com>
ddf19c
Patchwork-id: 96347
ddf19c
O-Subject: [RHEL8.2.1 AV qemu-kvm PATCH RESEND] target/i386: set the CPUID level to 0x14 on old machine-type
ddf19c
Bugzilla: 1513681
ddf19c
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
ddf19c
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
ddf19c
ddf19c
From: Luwei Kang <luwei.kang@intel.com>
ddf19c
ddf19c
BZ https://bugzilla.redhat.com/show_bug.cgi?id=1513681
ddf19c
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=28146304
ddf19c
Branch: rhel-av-8.2.1
ddf19c
ddf19c
Tested on intel-icelake-y-01.ml3.eng.bos.redhat.com.
ddf19c
ddf19c
The CPUID level need to be set to 0x14 manually on old
ddf19c
machine-type if Intel PT is enabled in guest. E.g. the
ddf19c
CPUID[0].EAX(level)=7 and CPUID[7].EBX[25](intel-pt)=1 when the
ddf19c
Qemu with "-machine pc-i440fx-3.1 -cpu qemu64,+intel-pt" parameter.
ddf19c
ddf19c
Some Intel PT capabilities are exposed by leaf 0x14 and the
ddf19c
missing capabilities will cause some MSRs access failed.
ddf19c
This patch add a warning message to inform the user to extend
ddf19c
the CPUID level.
ddf19c
ddf19c
Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
ddf19c
Message-Id: <1584031686-16444-1-git-send-email-luwei.kang@intel.com>
ddf19c
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
ddf19c
(cherry picked from commit ddc2fc9e4e42ebce48b088963dc7fbd1c08d5f33)
ddf19c
Signed-off-by: Paul Lai <plai@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 target/i386/cpu.c | 11 ++++++++---
ddf19c
 1 file changed, 8 insertions(+), 3 deletions(-)
ddf19c
ddf19c
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
ddf19c
index 1685a8c..0f0a2db 100644
ddf19c
--- a/target/i386/cpu.c
ddf19c
+++ b/target/i386/cpu.c
ddf19c
@@ -6206,9 +6206,14 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
ddf19c
         x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE);
ddf19c
 
ddf19c
         /* Intel Processor Trace requires CPUID[0x14] */
ddf19c
-        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
ddf19c
-             kvm_enabled() && cpu->intel_pt_auto_level) {
ddf19c
-            x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
ddf19c
+        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) {
ddf19c
+            if (cpu->intel_pt_auto_level) {
ddf19c
+                x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
ddf19c
+            } else if (cpu->env.cpuid_min_level < 0x14) {
ddf19c
+                mark_unavailable_features(cpu, FEAT_7_0_EBX,
ddf19c
+                    CPUID_7_0_EBX_INTEL_PT,
ddf19c
+                    "Intel PT need CPUID leaf 0x14, please set by \"-cpu ...,+intel-pt,level=0x14\"");
ddf19c
+            }
ddf19c
         }
ddf19c
 
ddf19c
         /* CPU topology with multi-dies support requires CPUID[0x1F] */
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c