i386: extended the cpuid_level when Intel PT is enabled
PATCH v2 1/1 i386: extended the cpuid_level when Intel PT is enabled
Intel Processor Trace required CPUID[0x14] but the cpuid_level have no change when create a kvm guest with
e.g. "-cpu qemu64,+intel-pt".
--- hw/i386/pc.c | 1 + target/i386/cpu.c | 9 +++++++++ target/i386/cpu.h | 3 +++ 3 files changed, 13 insertions(+)
hw/i386/pc.c +1 -0
@@ -122,6 +122,7 @@ GlobalProperty pc_compat_3_1[] = { { "Cascadelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Client" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, + { TYPE_X86_CPU, "x-intel-pt-auto-level", "off" }, };const size_t pc_compat_3_1_len =G_N_ELEMENTS (pc_compat_3_1);
target/i386/cpu.c +9 -0
@@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );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 ); + } +/* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) {x86_cpu_adjust_level (cpu, &env->cpuid_min_xlevel,0x8000000A );
@@ -5816,6 +5823,8 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_INT32 ("x-hv-max-vps" ,X86CPU , hv_max_vps,-1 ),DEFINE_PROP_BOOL ("x-hv-synic-kvm-only" ,X86CPU , hyperv_synic_kvm_only, false), +DEFINE_PROP_BOOL ("x-intel-pt-auto-level" ,X86CPU , intel_pt_auto_level, + true), DEFINE_PROP_END_OF_LIST() };
target/i386/cpu.h +3 -0
@@ -1455,6 +1455,9 @@ struct X86CPU {/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level; +/* Enable auto level-increase for Intel Processor Trace leave */ +bool intel_pt_auto_level; +/* if true fill the top bits of the MTRR_PHYSMASKn variable range */ bool fill_mtrr_mask;
Signature · 1 line
1.8.3.1
Quoted 11 lines
-----Original Message-----
From: Kang, Luwei
Sent: Wednesday, January 30, 2019 7:53 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Kang, Luwei <[email protected]>
Subject: [PATCH V2] i386: extended thecpuid_levelwhen Intel PT is enabledIntel Processor Trace required CPUID[0x14] but the
cpuid_levelhave no change when create a kvm guest with e.g. "-cpu qemu64,+intel-pt".Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Luwei Kang <[email protected]>
Resend this patch to add " Signed-off-by: Eduardo Habkost <[email protected]>" and fix a typo.
Thanks,
Luwei Kang
Quoted 58 lines
--- hw/i386/pc.c | 1 + target/i386/cpu.c | 9 +++++++++ target/i386/cpu.h | 3 +++ 3 files changed, 13 insertions(+)hw/i386/pc.c +1
-0@@ -122,6 +122,7 @@ GlobalProperty pc_compat_3_1[] = { { "Cascadelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Client" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, + { TYPE_X86_CPU, "x-intel-pt-auto-level", "off" }, };const size_t pc_compat_3_1_len =G_N_ELEMENTS (pc_compat_3_1);target/i386/cpu.c +7
-0@@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );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 ); + } +/* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); @@ -5816,6 +5823,8 @@ static Property x86_cpu_properties[] ={ DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1), DEFINE_PROP_BOOL("x-hv-synic-kvm-only", X86CPU, hyperv_synic_kvm_only, false),target/i386/cpu.c +2
-0+DEFINE_PROP_BOOL ("x-intel-pt-auto-level" ,X86CPU , intel_pt_auto_level, + true), DEFINE_PROP_END_OF_LIST() };target/i386/cpu.h +3
-1@@ -1455,6 +1455,9 @@ struct X86CPU {/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level; +/* Enable auto level-increase for Intel Processor Trace leave */ +bool intel_pt_auto_level; +/* if true fill the top bits of the MTRR_PHYSMASKn variable range */ bool fill_mtrr_mask; --1.8.3.1
Quoted 10 lines
-----Original Message-----
From: Kang, Luwei
Sent: Wednesday, January 30, 2019 7:53 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; Kang, Luwei <[email protected]>
Subject: [PATCH V2] i386: extended thecpuid_levelwhen Intel PT is enabledIntel Processor Trace required CPUID[0x14] but the
cpuid_levelhave no change when create a kvm guest with e.g. "-cpu qemu64,+intel-pt".
Ping.
Quoted 61 lines
Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Luwei Kang <[email protected]>--- hw/i386/pc.c | 1 + target/i386/cpu.c | 9 +++++++++ target/i386/cpu.h | 3 +++ 3 files changed, 13 insertions(+)hw/i386/pc.c +1
-0@@ -122,6 +122,7 @@ GlobalProperty pc_compat_3_1[] = { { "Cascadelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Client" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, + { TYPE_X86_CPU, "x-intel-pt-auto-level", "off" }, };const size_t pc_compat_3_1_len =G_N_ELEMENTS (pc_compat_3_1);target/i386/cpu.c +7
-0@@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );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 ); + } +/* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel, 0x8000000A); @@ -5816,6 +5823,8 @@ static Property x86_cpu_properties[] ={ DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1), DEFINE_PROP_BOOL("x-hv-synic-kvm-only", X86CPU, hyperv_synic_kvm_only, false),target/i386/cpu.c +2
-0+DEFINE_PROP_BOOL ("x-intel-pt-auto-level" ,X86CPU , intel_pt_auto_level, + true), DEFINE_PROP_END_OF_LIST() };target/i386/cpu.h +3
-1@@ -1455,6 +1455,9 @@ struct X86CPU {/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level; +/* Enable auto level-increase for Intel Processor Trace leave */ +bool intel_pt_auto_level; +/* if true fill the top bits of the MTRR_PHYSMASKn variable range */ bool fill_mtrr_mask; --1.8.3.1
Quoted 57 lines · Luwei Kang
Intel Processor Trace required CPUID[0x14] but the
cpuid_levelhave no change when create a kvm guest with
e.g. "-cpu qemu64,+intel-pt".Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Luwei Kang <[email protected]>--- hw/i386/pc.c | 1 + target/i386/cpu.c | 9 +++++++++ target/i386/cpu.h | 3 +++ 3 files changed, 13 insertions(+)hw/i386/pc.c +1
-0@@ -122,6 +122,7 @@ GlobalProperty pc_compat_3_1[] = { { "Cascadelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Client" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, + { TYPE_X86_CPU, "x-intel-pt-auto-level", "off" }, };const size_t pc_compat_3_1_len =G_N_ELEMENTS (pc_compat_3_1);target/i386/cpu.c +9
-0@@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );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 ); + } +/* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) {x86_cpu_adjust_level (cpu, &env->cpuid_min_xlevel,0x8000000A );@@ -5816,6 +5823,8 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_INT32 ("x-hv-max-vps" ,X86CPU , hv_max_vps,-1 ),DEFINE_PROP_BOOL ("x-hv-synic-kvm-only" ,X86CPU , hyperv_synic_kvm_only, false), +DEFINE_PROP_BOOL ("x-intel-pt-auto-level" ,X86CPU , intel_pt_auto_level, + true), DEFINE_PROP_END_OF_LIST() };target/i386/cpu.h +0
-0
target/i386/cpu.h struct X86CPU { · line 1463
Quoted 9 lines
target/i386/cpu.h +3
-0@@ -1455,6 +1455,9 @@ struct X86CPU {/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level; +/* Enable auto level-increase for Intel Processor Trace leave */ +bool intel_pt_auto_level; +/* if true fill the top bits of the MTRR_PHYSMASKn variable range */ bool fill_mtrr_mask;
Eduardo is back, but I've queued this anyway.
Thanks,
Paolo
Quoted 67 lines
-----Original Message-----
From: Paolo Bonzini [mailto:[email protected]]
Sent: Thursday, February 28, 2019 7:02 PM
To: Kang, Luwei <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]
Subject: Re: [PATCH V2] i386: extended thecpuid_levelwhen Intel PT is enabledQuoted 57 lines · Luwei Kang
Intel Processor Trace required CPUID[0x14] but the
cpuid_levelhave no change when create a kvm guest with e.g. "-cpu qemu64,+intel-pt".Signed-off-by Eduardo Habkost <[email protected]>Signed-off-by Luwei Kang <[email protected]>--- hw/i386/pc.c | 1 + target/i386/cpu.c | 9 +++++++++ target/i386/cpu.h | 3 +++ 3 files changed, 13 insertions(+)hw/i386/pc.c +1
-0@@ -122,6 +122,7 @@ GlobalProperty pc_compat_3_1[] = { { "Cascadelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Client" "-" TYPE_X86_CPU, "mpx", "on" }, { "Icelake-Server" "-" TYPE_X86_CPU, "mpx", "on" }, + { TYPE_X86_CPU, "x-intel-pt-auto-level", "off" }, };const size_t pc_compat_3_1_len =G_N_ELEMENTS (pc_compat_3_1);target/i386/cpu.c index renamed from target/i386/cpu.c +0
-02f54125..6dddd99 100644
target/i386/cpu.c +7
-0@@ -5023,6 +5023,13 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp)x86_cpu_adjust_feat_level (cpu,FEAT_C000_0001_EDX );x86_cpu_adjust_feat_level (cpu,FEAT_SVM );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 ); + } +/* SVM requires CPUID[0x8000000A] */ if (env->features[FEAT_8000_0001_ECX ] &CPUID_EXT3_SVM ) { x86_cpu_adjust_level(cpu, &env->cpuid_min_xlevel,0x8000000A); @@ -5816,6 +5823,8 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_INT32("x-hv-max-vps", X86CPU, hv_max_vps, -1), DEFINE_PROP_BOOL("x-hv-synic-kvm-only", X86CPU, hyperv_synic_kvm_only, false),target/i386/cpu.c +2
-0+DEFINE_PROP_BOOL ("x-intel-pt-auto-level" ,X86CPU , intel_pt_auto_level, + true), DEFINE_PROP_END_OF_LIST() };target/i386/cpu.h index renamed from target/i386/cpu.h +0
-059656a7..090baa4 100644
target/i386/cpu.h +0
-0@@ -1455,6 +1455,9 @@ struct X86CPU {/* Enable auto level-increase for all CPUID leaves */ bool full_cpuid_auto_level;
Quoted 10 lines
target/i386/cpu.h struct X86CPU { · line 1463
Quoted 7 lines
target/i386/cpu.h +3
-0+/* Enable auto level-increase for Intel Processor Trace leave */ +bool intel_pt_auto_level; +/* if true fill the top bits of the MTRR_PHYSMASKn variable range */ bool fill_mtrr_mask;Eduardo is back, but I've queued this anyway.
Get it. Thanks!
Luwei Kang