qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] target/i386: set the CPUID level to 0x14 on old machine-type
@ 2020-03-12 16:48 Luwei Kang
  2020-03-12  9:19 ` no-reply
  2020-03-23 18:32 ` Eduardo Habkost
  0 siblings, 2 replies; 3+ messages in thread
From: Luwei Kang @ 2020-03-12 16:48 UTC (permalink / raw)
  To: pbonzini, rth, ehabkost; +Cc: Luwei Kang, qemu-devel

The CPUID level need to be set to 0x14 manually on old
machine-type if Intel PT is enabled in guest. E.g. the
CPUID[0].EAX(level)=7 and CPUID[7].EBX[25](intel-pt)=1 when the
Qemu with "-machine pc-i440fx-3.1 -cpu qemu64,+intel-pt" parameter.

Some Intel PT capabilities are exposed by leaf 0x14 and the
missing capabilities will cause some MSRs access failed.
This patch add a warning message to inform the user to extend
the CPUID level.

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Luwei Kang <luwei.kang@intel.com>
---
v1->v2:
- Mask off Intel PT when the CPUID level < 0x14, not only a warning.
  qemu-system-x86_64: warning: Intel PT need CPUID leaf 0x14, please set by "-cpu ...,+intel-pt,level=0x14": CPUID.07H:EBX.intel-pt [bit 25]
- Remove the checking of kvm_enabled() because it is unnecessary.

 target/i386/cpu.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 306d50a..cab44c5 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -6302,9 +6302,14 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
         x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE);
 
         /* Intel Processor Trace requires CPUID[0x14] */
-        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) &&
-             kvm_enabled() && cpu->intel_pt_auto_level) {
-            x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
+        if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) {
+            if (cpu->intel_pt_auto_level) {
+                x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14);
+            } else if (cpu->env.cpuid_min_level < 0x14) {
+                mark_unavailable_features(cpu, FEAT_7_0_EBX,
+                    CPUID_7_0_EBX_INTEL_PT,
+                    "Intel PT need CPUID leaf 0x14, please set by \"-cpu ...,+intel-pt,level=0x14\"");
+            }
         }
 
         /* CPU topology with multi-dies support requires CPUID[0x1F] */
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-23 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-12 16:48 [PATCH v2] target/i386: set the CPUID level to 0x14 on old machine-type Luwei Kang
2020-03-12  9:19 ` no-reply
2020-03-23 18:32 ` Eduardo Habkost

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).