thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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