From: Xiaoyao Li <xiaoyao.li@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
Chenyi Qiang <chenyi.qiang@intel.com>,
lei4.wang@intel.com
Subject: [PATCH v4 3/8] target/i386/intel-pt: Introduce FeatureWordInfo for Intel PT CPUID leaf 0x14
Date: Wed, 31 May 2023 04:43:06 -0400 [thread overview]
Message-ID: <20230531084311.3807277-4-xiaoyao.li@intel.com> (raw)
In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com>
CPUID leaf 0x14 subleaf 0x0 and 0x1 enumerate the resource and
capability of Intel PT.
Introduce FeatureWord FEAT_14_0_EBX, FEAT_14_1_EAX and FEAT_14_1_EBX,
and complete FEAT_14_0_ECX. Thus all the features of Intel PT can be
expanded when "-cpu host/max" and can be configured in named CPU model.
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
---
v3:
- Add bit 7 and 8 of FEAT_14_0_EBX
---
target/i386/cpu.c | 138 +++++++++++++++++++++++++++++++++++++++++++---
target/i386/cpu.h | 3 +
2 files changed, 132 insertions(+), 9 deletions(-)
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 7d2f20c84c7a..e735c366bc97 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -1248,17 +1248,34 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
}
},
+ [FEAT_14_0_EBX] = {
+ .type = CPUID_FEATURE_WORD,
+ .feat_names = {
+ [0] = "intel-pt-cr3-filter",
+ [1] = "intel-pt-psb",
+ [2] = "intel-pt-ip-filter",
+ [3] = "intel-pt-mtc",
+ [4] = "intel-pt-ptwrite",
+ [5] = "intel-pt-power-event",
+ [6] = "intel-pt-psb-pmi-preservation",
+ [7] = "intel-pt-event-trace",
+ [8] = "intel-pt-tnt-disable",
+ },
+ .cpuid = {
+ .eax = 0x14,
+ .needs_ecx = true, .ecx = 0,
+ .reg = R_EBX,
+ },
+ },
+
[FEAT_14_0_ECX] = {
.type = CPUID_FEATURE_WORD,
.feat_names = {
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, "intel-pt-lip",
+ [0] = "intel-pt-topa",
+ [1] = "intel-pt-multi-topa-entries",
+ [2] = "intel-pt-single-range",
+ [3] = "intel-pt-trace-transport-subsystem",
+ [31] = "intel-pt-lip",
},
.cpuid = {
.eax = 0x14,
@@ -1268,6 +1285,79 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
.tcg_features = TCG_14_0_ECX_FEATURES,
},
+ [FEAT_14_1_EAX] = {
+ .type = CPUID_FEATURE_WORD,
+ .feat_names = {
+ [0] = "intel-pt-addr-range-num-bit0",
+ [1] = "intel-pt-addr-range-num-bit1",
+ [2] = "intel-pt-addr-range-num-bit2",
+ [16] = "intel-pt-mtc-period-encoding-0",
+ [17] = "intel-pt-mtc-period-encoding-1",
+ [18] = "intel-pt-mtc-period-encoding-2",
+ [19] = "intel-pt-mtc-period-encoding-3",
+ [20] = "intel-pt-mtc-period-encoding-4",
+ [21] = "intel-pt-mtc-period-encoding-5",
+ [22] = "intel-pt-mtc-period-encoding-6",
+ [23] = "intel-pt-mtc-period-encoding-7",
+ [24] = "intel-pt-mtc-period-encoding-8",
+ [25] = "intel-pt-mtc-period-encoding-9",
+ [26] = "intel-pt-mtc-period-encoding-10",
+ [27] = "intel-pt-mtc-period-encoding-11",
+ [28] = "intel-pt-mtc-period-encoding-12",
+ [29] = "intel-pt-mtc-period-encoding-13",
+ [30] = "intel-pt-mtc-period-encoding-14",
+ [31] = "intel-pt-mtc-period-encoding-15",
+ },
+ .cpuid = {
+ .eax = 0x14,
+ .needs_ecx = true, .ecx = 1,
+ .reg = R_EAX,
+ },
+ },
+
+ [FEAT_14_1_EBX] = {
+ .type = CPUID_FEATURE_WORD,
+ .feat_names = {
+ [0] = "intel-pt-cyc-thresh-0",
+ [1] = "intel-pt-cyc-thresh-1",
+ [2] = "intel-pt-cyc-thresh-2",
+ [3] = "intel-pt-cyc-thresh-4",
+ [4] = "intel-pt-cyc-thresh-8",
+ [5] = "intel-pt-cyc-thresh-16",
+ [6] = "intel-pt-cyc-thresh-32",
+ [7] = "intel-pt-cyc-thresh-64",
+ [8] = "intel-pt-cyc-thresh-128",
+ [9] = "intel-pt-cyc-thresh-256",
+ [10] = "intel-pt-cyc-thresh-512",
+ [11] = "intel-pt-cyc-thresh-1024",
+ [12] = "intel-pt-cyc-thresh-2048",
+ [13] = "intel-pt-cyc-thresh-4096",
+ [14] = "intel-pt-cyc-thresh-8192",
+ [15] = "intel-pt-cyc-thresh-16384",
+ [16] = "intel-pt-psb-freq-2k",
+ [17] = "intel-pt-psb-freq-4k",
+ [18] = "intel-pt-psb-freq-8k",
+ [19] = "intel-pt-psb-freq-16k",
+ [20] = "intel-pt-psb-freq-32k",
+ [21] = "intel-pt-psb-freq-64k",
+ [22] = "intel-pt-psb-freq-128k",
+ [23] = "intel-pt-psb-freq-256k",
+ [24] = "intel-pt-psb-freq-512k",
+ [25] = "intel-pt-psb-freq-1m",
+ [26] = "intel-pt-psb-freq-2m",
+ [27] = "intel-pt-psb-freq-4m",
+ [28] = "intel-pt-psb-freq-8m",
+ [29] = "intel-pt-psb-freq-16m",
+ [30] = "intel-pt-psb-freq-32m",
+ [31] = "intel-pt-psb-freq-64m",
+ },
+ .cpuid = {
+ .eax = 0x14,
+ .needs_ecx = true, .ecx = 1,
+ .reg = R_EBX,
+ },
+ },
+
[FEAT_SGX_12_0_EAX] = {
.type = CPUID_FEATURE_WORD,
.feat_names = {
@@ -1407,10 +1497,22 @@ static FeatureDep feature_dependencies[] = {
.from = { FEAT_7_0_EBX, CPUID_7_0_EBX_RDSEED },
.to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDSEED_EXITING },
},
+ {
+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT },
+ .to = { FEAT_14_0_EBX, ~0ull },
+ },
{
.from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT },
.to = { FEAT_14_0_ECX, ~0ull },
},
+ {
+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT },
+ .to = { FEAT_14_1_EAX, ~0ull },
+ },
+ {
+ .from = { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT },
+ .to = { FEAT_14_1_EBX, ~0ull },
+ },
{
.from = { FEAT_8000_0001_EDX, CPUID_EXT2_RDTSCP },
.to = { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDTSCP },
@@ -6871,7 +6973,25 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose)
uint64_t host_feat =
x86_cpu_get_supported_feature_word(w, false);
uint64_t requested_features = env->features[w];
- uint64_t unavailable_features = requested_features & ~host_feat;
+ uint64_t unavailable_features;
+
+ switch (w) {
+ case FEAT_14_1_EAX:
+ /* Handling the bits except INTEL_PT_ADDR_RANGES_NUM_MASK */
+ unavailable_features = (requested_features & ~host_feat) &
+ ~INTEL_PT_ADDR_RANGES_NUM_MASK;
+ /* Bits 2:0 are as a whole to represent INTEL_PT_ADDR_RANGES */
+ if ((requested_features & INTEL_PT_ADDR_RANGES_NUM_MASK) >
+ (host_feat & INTEL_PT_ADDR_RANGES_NUM_MASK)) {
+ unavailable_features |= requested_features &
+ INTEL_PT_ADDR_RANGES_NUM_MASK;
+ }
+ break;
+ default:
+ unavailable_features = requested_features & ~host_feat;
+ break;
+ }
+
mark_unavailable_features(cpu, w, unavailable_features, prefix);
}
diff --git a/target/i386/cpu.h b/target/i386/cpu.h
index 7201a71de863..500693eb9847 100644
--- a/target/i386/cpu.h
+++ b/target/i386/cpu.h
@@ -621,7 +621,10 @@ typedef enum FeatureWord {
FEAT_VMX_EPT_VPID_CAPS,
FEAT_VMX_BASIC,
FEAT_VMX_VMFUNC,
+ FEAT_14_0_EBX,
FEAT_14_0_ECX,
+ FEAT_14_1_EAX,
+ FEAT_14_1_EBX,
FEAT_SGX_12_0_EAX, /* CPUID[EAX=0x12,ECX=0].EAX (SGX) */
FEAT_SGX_12_0_EBX, /* CPUID[EAX=0x12,ECX=0].EBX (SGX MISCSELECT[31:0]) */
FEAT_SGX_12_1_EAX, /* CPUID[EAX=0x12,ECX=1].EAX (SGX ATTRIBUTES[31:0]) */
--
2.34.1
next prev parent reply other threads:[~2023-05-31 8:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-31 8:43 [PATCH v4 0/8] i386: Make Intel PT configurable Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 1/8] target/i386: Print CPUID subleaf info for unsupported feature Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 2/8] target/i386/intel-pt: Fix INTEL_PT_ADDR_RANGES_NUM_MASK Xiaoyao Li
2023-05-31 8:43 ` Xiaoyao Li [this message]
2023-05-31 8:43 ` [PATCH v4 4/8] target/i386/intel-pt: print special message for INTEL_PT_ADDR_RANGES_NUM Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 5/8] target/i386/intel-pt: Rework/rename the default INTEL-PT feature set Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 6/8] target/i386/intel-pt: Enable host pass through of Intel PT Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 7/8] target/i386/intel-pt: Define specific PT feature set for IceLake-server, Snowridge and SapphireRapids Xiaoyao Li
2023-05-31 8:43 ` [PATCH v4 8/8] target/i386/intel-pt: Access MSR_IA32_RTIT_ADDRn based on guest CPUID configuration Xiaoyao Li
2023-07-03 2:03 ` [PATCH v4 0/8] i386: Make Intel PT configurable Xiaoyao Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230531084311.3807277-4-xiaoyao.li@intel.com \
--to=xiaoyao.li@intel.com \
--cc=chenyi.qiang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=lei4.wang@intel.com \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).