From nobody Fri May 3 06:20:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631198849214287.48635578203107; Thu, 9 Sep 2021 07:47:29 -0700 (PDT) Received: from localhost ([::1]:54758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLKq-0003mq-5C for importer@patchew.org; Thu, 09 Sep 2021 10:47:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33774) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFc-0003yp-W7 for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:05 -0400 Received: from mga07.intel.com ([134.134.136.100]:11389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFa-0001Q1-1o for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:04 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 07:41:54 -0700 Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2021 07:41:52 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="284510175" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="284510175" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="696346331" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Subject: [RFC PATCH 1/5] target/i386: Print CPUID subleaf info for unsupported feature Date: Thu, 9 Sep 2021 22:41:46 +0800 Message-Id: <20210909144150.1728418-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210909144150.1728418-1-xiaoyao.li@intel.com> References: <20210909144150.1728418-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.100; envelope-from=xiaoyao.li@intel.com; helo=mga07.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631198850019100001 Content-Type: text/plain; charset="utf-8" Some CPUID leaves have meaningful subleaf index. Print the subleaf info in feature_word_description for CPUID features. Signed-off-by: Xiaoyao Li Reviewed-by: Eduardo Habkost --- target/i386/cpu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 97e250e8760d..a06473c9e84c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4219,8 +4219,9 @@ static char *feature_word_description(FeatureWordInfo= *f, uint32_t bit) { const char *reg =3D get_register_name_32(f->cpuid.reg); assert(reg); - return g_strdup_printf("CPUID.%02XH:%s", - f->cpuid.eax, reg); + return g_strdup_printf("CPUID.%02XH_%02XH:%s", + f->cpuid.eax, + f->cpuid.needs_ecx ? f->cpuid.ecx : 0, = reg); } case MSR_FEATURE_WORD: return g_strdup_printf("MSR(%02XH)", --=20 2.27.0 From nobody Fri May 3 06:20:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631198637165594.6361329547765; Thu, 9 Sep 2021 07:43:57 -0700 (PDT) Received: from localhost ([::1]:46836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLHP-0006gW-IF for importer@patchew.org; Thu, 09 Sep 2021 10:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFc-0003yS-9L for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:04 -0400 Received: from mga07.intel.com ([134.134.136.100]:11393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFZ-0001Ru-NL for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:04 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 07:41:55 -0700 Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2021 07:41:54 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="284510182" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="284510182" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="696346343" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Subject: [RFC PATCH 2/5] target/i386: Introduce FeatureWordInfo for Intel PT CPUID leaf 0xD Date: Thu, 9 Sep 2021 22:41:47 +0800 Message-Id: <20210909144150.1728418-3-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210909144150.1728418-1-xiaoyao.li@intel.com> References: <20210909144150.1728418-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.100; envelope-from=xiaoyao.li@intel.com; helo=mga07.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631198637938100001 Content-Type: text/plain; charset="utf-8" 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. Regarding FEAT_14_1_EAX and FEAT_14_1_EBX, don't define the name for them since each bit of them doesn't represent a standalone sub-feature of Intel PT. However, explicitly mark them as migratable. So the meaningful bits of them can be autoenabled in x86_cpu_expand_features(). It has special handling for FEAT_14_1_EAX[2:0], because the 3 bits as a whole represents the number of PT ADDRn_CFG ranges. Thus it has special handling in mark_unavailable_features() and x86_cpu_filter_features(). Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 87 +++++++++++++++++++++++++++++++++++++++++------ target/i386/cpu.h | 37 +++++++++++++++++++- 2 files changed, 112 insertions(+), 12 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index a06473c9e84c..58e98210f219 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -567,7 +567,7 @@ static CPUCacheInfo legacy_l3_cache =3D { /* generated packets which contain IP payloads have LIP values */ #define INTEL_PT_IP_LIP (1 << 31) #define INTEL_PT_ADDR_RANGES_NUM 0x2 /* Number of configurable address ran= ges */ -#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x3 +#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 #define INTEL_PT_MTC_BITMAP (0x0249 << 16) /* Support ART(0,3,6,9) */ #define INTEL_PT_CYCLE_BITMAP 0x1fff /* Support 0,2^(0~11) */ #define INTEL_PT_PSB_BITMAP (0x003f << 16) /* Support 2K,4K,8K,16K,32= K,64K */ @@ -1161,17 +1161,32 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] = =3D { } }, =20 + [FEAT_14_0_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + [0] =3D "intel-pt-cr3-filter", + [1] =3D "intel-pt-PSB", + [2] =3D "intel-pt-ip-filter", + [3] =3D "intel-pt-mtc", + [4] =3D "intel-pt-ptwrite", + [5] =3D "intel-pt-power-event", + [6] =3D "intel-pt-psb-pmi-preservation", + }, + .cpuid =3D { + .eax =3D 0x14, + .needs_ecx =3D true, .ecx =3D 0, + .reg =3D R_EBX, + }, + }, + [FEAT_14_0_ECX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { - 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] =3D "intel-pt-topa", + [1] =3D "intel-pt-multi-topa-entries", + [2] =3D "intel-pt-single-range", + [3] =3D "intel-pt-trace-transport-subsystem", + [31] =3D "intel-pt-lip", }, .cpuid =3D { .eax =3D 0x14, @@ -1181,6 +1196,26 @@ FeatureWordInfo feature_word_info[FEATURE_WORDS] =3D= { .tcg_features =3D TCG_14_0_ECX_FEATURES, }, =20 + [FEAT_14_1_EAX] =3D { + .type =3D CPUID_FEATURE_WORD, + .cpuid =3D { + .eax =3D 0x14, + .needs_ecx =3D true, .ecx =3D 1, + .reg =3D R_EAX, + }, + .migratable_flags =3D ~0ull, + }, + + [FEAT_14_1_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .cpuid =3D { + .eax =3D 0x14, + .needs_ecx =3D true, .ecx =3D 1, + .reg =3D R_EBX, + }, + .migratable_flags =3D ~0ull, + }, + }; =20 typedef struct FeatureMask { @@ -1253,10 +1288,22 @@ static FeatureDep feature_dependencies[] =3D { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_RDSEED }, .to =3D { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDSEED_EX= ITING }, }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT }, + .to =3D { FEAT_14_0_EBX, ~0ull }, + }, { .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT }, .to =3D { FEAT_14_0_ECX, ~0ull }, }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT }, + .to =3D { FEAT_14_1_EAX, ~0ull }, + }, + { + .from =3D { FEAT_7_0_EBX, CPUID_7_0_EBX_INTEL_PT }, + .to =3D { FEAT_14_1_EBX, ~0ull }, + }, { .from =3D { FEAT_8000_0001_EDX, CPUID_EXT2_RDTSCP }, .to =3D { FEAT_VMX_SECONDARY_CTLS, VMX_SECONDARY_EXEC_RDTSCP }, @@ -4260,7 +4307,14 @@ static void mark_unavailable_features(X86CPU *cpu, F= eatureWord w, uint64_t mask, return; } =20 - for (i =3D 0; i < 64; ++i) { + if ((w =3D=3D FEAT_14_1_EAX) && (mask & INTEL_PT_ADDR_RANGES_NUM_MASK)= ) { + warn_report("%s: CPUID.14H_01H:EAX [bit 2:0]", verbose_prefix); + i =3D 3; + } else { + i =3D 0; + } + + for (; i < 64; ++i) { if ((1ULL << i) & mask) { g_autofree char *feat_word_str =3D feature_word_description(f,= i); warn_report("%s: %s%s%s [bit %d]", @@ -6038,7 +6092,18 @@ static void x86_cpu_filter_features(X86CPU *cpu, boo= l verbose) uint64_t host_feat =3D x86_cpu_get_supported_feature_word(w, false); uint64_t requested_features =3D env->features[w]; - uint64_t unavailable_features =3D requested_features & ~host_feat; + uint64_t unavailable_features; + if (w =3D=3D FEAT_14_1_EAX) { + unavailable_features =3D (requested_features & ~host_feat) & + ~INTEL_PT_ADDR_RANGES_NUM_MASK; + if ((requested_features & INTEL_PT_ADDR_RANGES_NUM_MASK) > + (host_feat & INTEL_PT_ADDR_RANGES_NUM_MASK)) { + unavailable_features |=3D requested_features & + INTEL_PT_ADDR_RANGES_NUM_MASK; + } + } else { + unavailable_features =3D requested_features & ~host_feat; + } mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 6c50d3ab4f1d..f5478a169f9a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -566,7 +566,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, FEATURE_WORDS, } FeatureWord; =20 @@ -835,8 +838,40 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; /* AVX512 BFloat16 Instruction */ #define CPUID_7_1_EAX_AVX512_BF16 (1U << 5) =20 +/* + * IA32_RTIT_CTL.CR3 filter can be set to 1 and + * IA32_RTIT_CR3_MATCH can be accessed + */ +#define CPUID_14_0_EBX_CR3_FILTER (1U << 0) +/* Support Configurable PSB and Cycle-Accurate Mode */ +#define CPUID_14_0_EBX_PSB (1U << 1) +/* + * Support IP Filtering, IP TraceStop, and preservation + * of Intel PT MSRs across warm reset + */ +#define CPUID_14_0_EBX_IP_FILTER (1U << 2) +/* Support MTC timing packet */ +#define CPUID_14_0_EBX_MTC (1U << 3) +/* Support PTWRITE */ +#define CPUID_14_0_EBX_PTWRITE (1U << 4) +/* Support Power Event Trace packet generation */ +#define CPUID_14_0_EBX_POWER_EVENT (1U << 5) +/* Support PSB and PMI Preservation */ +#define CPUID_14_0_EBX_PSB_PMI_PRESERVATION (1U << 6) + +/* Tracing can be enabled with IA32_RTIT_CTL.ToPA =3D 1 */ +#define CPUID_14_0_ECX_TOPA (1U << 0) +/* + * ToPA tables can hold any number of output entries, up to the maximum al= lowed + * by the MaskOrTableOffset field of IA32_RTIT_OUTPUT_MASK_PTRS + */ +#define CPUID_14_0_ECX_MULTI_ENTRIES (1U << 1) +/* Support Single-Range Output scheme */ +#define CPUID_14_0_ECX_SINGLE_RANGE (1U << 2) +/* Support IA32_RTIT_CTL.FabricEn */ +#define CPUID_14_0_ECX_TRACE_TRANS_SUBSYSTEM (1U << 3) /* Packets which contain IP payload have LIP values */ -#define CPUID_14_0_ECX_LIP (1U << 31) +#define CPUID_14_0_ECX_LIP (1U << 31) =20 /* CLZERO instruction */ #define CPUID_8000_0008_EBX_CLZERO (1U << 0) --=20 2.27.0 From nobody Fri May 3 06:20:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631198655018464.57304308596883; Thu, 9 Sep 2021 07:44:15 -0700 (PDT) Received: from localhost ([::1]:47302 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLHh-000719-UR for importer@patchew.org; Thu, 09 Sep 2021 10:44:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFe-00040D-5z for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:06 -0400 Received: from mga07.intel.com ([134.134.136.100]:11385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFc-0001Nx-7n for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:05 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 07:41:58 -0700 Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2021 07:41:56 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="284510183" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="284510183" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="696346350" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Subject: [RFC PATCH 3/5] target/i386: Enable host pass through of Intel PT Date: Thu, 9 Sep 2021 22:41:48 +0800 Message-Id: <20210909144150.1728418-4-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210909144150.1728418-1-xiaoyao.li@intel.com> References: <20210909144150.1728418-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.100; envelope-from=xiaoyao.li@intel.com; helo=mga07.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631198655533100001 Content-Type: text/plain; charset="utf-8" commit e37a5c7fa459 ("i386: Add Intel Processor Trace feature support") added the support of Intel PT by making CPUID[14] of PT as fixed feature set (from ICX) for any CPU model on any host. This truly breaks the PT exposing on Intel SPR platform because SPR has less supported bitmap CPUID(0x14,1):EBX[15:0] than ICX. This patch enables passing through host's PT capabilities for the case "-cpu host/max" while ensure named CPU model still has the fixed PT feature set to not break the live migration. It introduces @has_specific_intel_pt_feature_set field for name CPU model. If a named CPU model has this field as false, it will use fixed PT feature set of ICX. Besides same to previous behavior, if fixed PT feature set of ICX cannot be satisfied/supported by host, it disables PT instead of adjusting the feature set based on host's capabilities. In the future, new named CPU model, e.g., Sapphire Rapids, can define its own PT feature set by setting @has_specific_intel_pt_feature_set to true and defines it's own FEAT_14_0_EBX, FEAT_14_0_ECX, FEAT_14_1_EAX and FEAT_14_1_EBX. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 106 ++++++++++++++++++++-------------------------- target/i386/cpu.h | 1 + 2 files changed, 47 insertions(+), 60 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 58e98210f219..00c4ad23110d 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -543,34 +543,24 @@ static CPUCacheInfo legacy_l3_cache =3D { #define L2_ITLB_4K_ASSOC 4 #define L2_ITLB_4K_ENTRIES 512 =20 -/* CPUID Leaf 0x14 constants: */ -#define INTEL_PT_MAX_SUBLEAF 0x1 -/* - * bit[00]: IA32_RTIT_CTL.CR3 filter can be set to 1 and IA32_RTIT_CR3_MAT= CH - * MSR can be accessed; - * bit[01]: Support Configurable PSB and Cycle-Accurate Mode; - * bit[02]: Support IP Filtering, TraceStop filtering, and preservation - * of Intel PT MSRs across warm reset; - * bit[03]: Support MTC timing packet and suppression of COFI-based packet= s; - */ -#define INTEL_PT_MINIMAL_EBX 0xf -/* - * bit[00]: Tracing can be enabled with IA32_RTIT_CTL.ToPA =3D 1 and - * IA32_RTIT_OUTPUT_BASE and IA32_RTIT_OUTPUT_MASK_PTRS MSRs can = be - * accessed; - * bit[01]: ToPA tables can hold any number of output entries, up to the - * maximum allowed by the MaskOrTableOffset field of - * IA32_RTIT_OUTPUT_MASK_PTRS; - * bit[02]: Support Single-Range Output scheme; - */ -#define INTEL_PT_MINIMAL_ECX 0x7 -/* generated packets which contain IP payloads have LIP values */ -#define INTEL_PT_IP_LIP (1 << 31) -#define INTEL_PT_ADDR_RANGES_NUM 0x2 /* Number of configurable address ran= ges */ -#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 -#define INTEL_PT_MTC_BITMAP (0x0249 << 16) /* Support ART(0,3,6,9) */ -#define INTEL_PT_CYCLE_BITMAP 0x1fff /* Support 0,2^(0~11) */ -#define INTEL_PT_PSB_BITMAP (0x003f << 16) /* Support 2K,4K,8K,16K,32= K,64K */ +#define INTEL_PT_MAX_SUBLEAF 0x1 +#define INTEL_PT_DEFAULT_ADDR_RANGES_NUM 0x2 +#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 +/* Support ART(0,3,6,9) */ +#define INTEL_PT_DEFAULT_MTC_BITMAP 0x0249 +/* Support 0,2^(0~11) */ +#define INTEL_PT_DEFAULT_CYCLE_BITMAP 0x1fff +/* Support 2K,4K,8K,16K,32K,64K */ +#define INTEL_PT_DEFAULT_PSB_BITMAP 0x003f + +#define INTEL_PT_DEFAULT_0_EBX (CPUID_14_0_EBX_CR3_FILTER | \ + CPUID_14_0_EBX_PSB | CPUID_14_0_EBX_IP_FILTER | CPUID_14_0_EBX= _MTC) +#define INTEL_PT_DEFAULT_0_ECX (CPUID_14_0_ECX_TOPA | \ + CPUID_14_0_ECX_MULTI_ENTRIES | CPUID_14_0_ECX_SINGLE_RANGE) +#define INTEL_PT_DEFAULT_1_EAX (INTEL_PT_DEFAULT_MTC_BITMAP << 16 | \ + INTEL_PT_DEFAULT_ADDR_RANGES_NUM) +#define INTEL_PT_DEFAULT_1_EBX (INTEL_PT_DEFAULT_PSB_BITMAP << 16 | \ + INTEL_PT_DEFAULT_CYCLE_BITMAP) =20 void x86_cpu_vendor_words2str(char *dst, uint32_t vendor1, uint32_t vendor2, uint32_t vendor3) @@ -1517,6 +1507,7 @@ typedef struct X86CPUDefinition { int family; int model; int stepping; + bool has_specific_intel_pt_feature_set; FeatureWordArray features; const char *model_id; const CPUCaches *const cache_info; @@ -5061,6 +5052,14 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUMo= del *model) env->features[w] =3D def->features[w]; } =20 + if (!def->has_specific_intel_pt_feature_set) { + env->use_default_intel_pt =3D true; + env->features[FEAT_14_0_EBX] =3D INTEL_PT_DEFAULT_0_EBX; + env->features[FEAT_14_0_ECX] =3D INTEL_PT_DEFAULT_0_ECX; + env->features[FEAT_14_1_EAX] =3D INTEL_PT_DEFAULT_1_EAX; + env->features[FEAT_14_1_EBX] =3D INTEL_PT_DEFAULT_1_EBX; + } + /* legacy-cache defaults to 'off' if CPU model provides cache info */ cpu->legacy_cache =3D !def->cache_info; =20 @@ -5465,14 +5464,11 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index= , uint32_t count, =20 if (count =3D=3D 0) { *eax =3D INTEL_PT_MAX_SUBLEAF; - *ebx =3D INTEL_PT_MINIMAL_EBX; - *ecx =3D INTEL_PT_MINIMAL_ECX; - if (env->features[FEAT_14_0_ECX] & CPUID_14_0_ECX_LIP) { - *ecx |=3D CPUID_14_0_ECX_LIP; - } + *ebx =3D env->features[FEAT_14_0_EBX]; + *ecx =3D env->features[FEAT_14_0_ECX]; } else if (count =3D=3D 1) { - *eax =3D INTEL_PT_MTC_BITMAP | INTEL_PT_ADDR_RANGES_NUM; - *ebx =3D INTEL_PT_PSB_BITMAP | INTEL_PT_CYCLE_BITMAP; + *eax =3D env->features[FEAT_14_1_EAX]; + *ebx =3D env->features[FEAT_14_1_EBX]; } break; } @@ -6081,6 +6077,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool= verbose) CPUX86State *env =3D &cpu->env; FeatureWord w; const char *prefix =3D NULL; + uint64_t host_feat; =20 if (verbose) { prefix =3D accel_uses_host_cpuid() @@ -6089,8 +6086,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool= verbose) } =20 for (w =3D 0; w < FEATURE_WORDS; w++) { - uint64_t host_feat =3D - x86_cpu_get_supported_feature_word(w, false); + host_feat =3D x86_cpu_get_supported_feature_word(w, false); uint64_t requested_features =3D env->features[w]; uint64_t unavailable_features; if (w =3D=3D FEAT_14_1_EAX) { @@ -6107,32 +6103,22 @@ static void x86_cpu_filter_features(X86CPU *cpu, bo= ol verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && - kvm_enabled()) { - KVMState *s =3D CPU(cpu)->kvm_state; - uint32_t eax_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EAX); - uint32_t ebx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_EBX); - uint32_t ecx_0 =3D kvm_arch_get_supported_cpuid(s, 0x14, 0, R_ECX); - uint32_t eax_1 =3D kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EAX); - uint32_t ebx_1 =3D kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EBX); + if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { + host_feat =3D x86_cpu_get_supported_feature_word(FEAT_14_0_ECX, fa= lse); =20 - if (!eax_0 || - ((ebx_0 & INTEL_PT_MINIMAL_EBX) !=3D INTEL_PT_MINIMAL_EBX) || - ((ecx_0 & INTEL_PT_MINIMAL_ECX) !=3D INTEL_PT_MINIMAL_ECX) || - ((eax_1 & INTEL_PT_MTC_BITMAP) !=3D INTEL_PT_MTC_BITMAP) || - ((eax_1 & INTEL_PT_ADDR_RANGES_NUM_MASK) < - INTEL_PT_ADDR_RANGES_NUM) || - ((ebx_1 & (INTEL_PT_PSB_BITMAP | INTEL_PT_CYCLE_BITMAP)) !=3D - (INTEL_PT_PSB_BITMAP | INTEL_PT_CYCLE_BITMAP)) || - ((ecx_0 & CPUID_14_0_ECX_LIP) !=3D - (env->features[FEAT_14_0_ECX] & CPUID_14_0_ECX_LIP))) { - /* - * Processor Trace capabilities aren't configurable, so if the - * host can't emulate the capabilities we report on - * cpu_x86_cpuid(), intel-pt can't be enabled on the current h= ost. - */ + if (env->use_default_intel_pt && + ((env->features[FEAT_14_0_EBX] !=3D INTEL_PT_DEFAULT_0_EBX) || + ((env->features[FEAT_14_0_ECX] & ~CPUID_14_0_ECX_LIP) !=3D + INTEL_PT_DEFAULT_0_ECX) || + (env->features[FEAT_14_1_EAX] !=3D INTEL_PT_DEFAULT_1_EAX) || + (env->features[FEAT_14_1_EBX] !=3D INTEL_PT_DEFAULT_1_EBX))) { mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INT= EL_PT, prefix); } + + if ((env->features[FEAT_14_0_ECX] ^ host_feat) & CPUID_14_0_ECX_LI= P) { + warn_report("Cannot configure different Intel PT IP payload fo= rmat than hardware"); + mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INT= EL_PT, NULL); + } } } =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index f5478a169f9a..e6236c371c4f 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1639,6 +1639,7 @@ typedef struct CPUX86State { uint32_t cpuid_vendor2; uint32_t cpuid_vendor3; uint32_t cpuid_version; + bool use_default_intel_pt; FeatureWordArray features; /* Features that were explicitly enabled/disabled */ FeatureWordArray user_features; --=20 2.27.0 From nobody Fri May 3 06:20:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631198852701457.9010595130652; Thu, 9 Sep 2021 07:47:32 -0700 (PDT) Received: from localhost ([::1]:55122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLKt-00042e-N2 for importer@patchew.org; Thu, 09 Sep 2021 10:47:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33828) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFg-00043L-Bt for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:08 -0400 Received: from mga07.intel.com ([134.134.136.100]:11393) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFd-0001Ru-L2 for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:08 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 07:41:59 -0700 Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2021 07:41:58 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="284510194" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="284510194" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="696346363" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Subject: [RFC PATCH 4/5] target/i386: Define specific PT feature set for IceLake-server and Snowridge Date: Thu, 9 Sep 2021 22:41:49 +0800 Message-Id: <20210909144150.1728418-5-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210909144150.1728418-1-xiaoyao.li@intel.com> References: <20210909144150.1728418-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.100; envelope-from=xiaoyao.li@intel.com; helo=mga07.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631198854229100001 Content-Type: text/plain; charset="utf-8" For IceLake-server, it's just the same as using the default PT feature set since the default one is exact taken from ICX. For Snowridge, define it according to real SNR silicon capabilities. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 00c4ad23110d..2b50ccf79b92 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3383,6 +3383,15 @@ static const X86CPUDefinition builtin_x86_defs[] =3D= { .features[FEAT_6_EAX] =3D CPUID_6_EAX_ARAT, /* Missing: Mode-based execute control (XS/XU), processor tracing,= TSC scaling */ + .has_specific_intel_pt_feature_set =3D true, + .features[FEAT_14_0_EBX] =3D + CPUID_14_0_EBX_CR3_FILTER | CPUID_14_0_EBX_PSB | + CPUID_14_0_EBX_IP_FILTER | CPUID_14_0_EBX_MTC, + .features[FEAT_14_0_ECX] =3D + CPUID_14_0_ECX_TOPA | CPUID_14_0_ECX_MULTI_ENTRIES | + CPUID_14_0_ECX_SINGLE_RANGE, + .features[FEAT_14_1_EAX] =3D 0x249 << 16 | 0x2, + .features[FEAT_14_1_EBX] =3D 0x003f << 16 | 0x1fff, .features[FEAT_VMX_BASIC] =3D MSR_VMX_BASIC_INS_OUTS | MSR_VMX_BASIC_TRUE_CTLS, .features[FEAT_VMX_ENTRY_CTLS] =3D VMX_VM_ENTRY_IA32E_MODE | @@ -3652,6 +3661,17 @@ static const X86CPUDefinition builtin_x86_defs[] =3D= { CPUID_XSAVE_XGETBV1, .features[FEAT_6_EAX] =3D CPUID_6_EAX_ARAT, + .has_specific_intel_pt_feature_set =3D true, + .features[FEAT_14_0_EBX] =3D + CPUID_14_0_EBX_CR3_FILTER | CPUID_14_0_EBX_PSB | + CPUID_14_0_EBX_IP_FILTER | CPUID_14_0_EBX_MTC | + CPUID_14_0_EBX_PTWRITE | CPUID_14_0_EBX_POWER_EVENT | + CPUID_14_0_EBX_PSB_PMI_PRESERVATION, + .features[FEAT_14_0_ECX] =3D + CPUID_14_0_ECX_TOPA | CPUID_14_0_ECX_MULTI_ENTRIES | + CPUID_14_0_ECX_SINGLE_RANGE | CPUID_14_0_ECX_LIP, + .features[FEAT_14_1_EAX] =3D 0x249 << 16 | 0x2, + .features[FEAT_14_1_EBX] =3D 0x003f << 16 | 0xffff, .features[FEAT_VMX_BASIC] =3D MSR_VMX_BASIC_INS_OUTS | MSR_VMX_BASIC_TRUE_CTLS, .features[FEAT_VMX_ENTRY_CTLS] =3D VMX_VM_ENTRY_IA32E_MODE | --=20 2.27.0 From nobody Fri May 3 06:20:41 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631198640663710.3466108210671; Thu, 9 Sep 2021 07:44:00 -0700 (PDT) Received: from localhost ([::1]:46912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOLHT-0006jz-Fy for importer@patchew.org; Thu, 09 Sep 2021 10:43:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFf-00041P-0I for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:07 -0400 Received: from mga07.intel.com ([134.134.136.100]:11389) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOLFd-0001Q1-Cb for qemu-devel@nongnu.org; Thu, 09 Sep 2021 10:42:06 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2021 07:42:01 -0700 Received: from lxy-dell.sh.intel.com ([10.239.159.31]) by fmsmga005.fm.intel.com with ESMTP; 09 Sep 2021 07:41:59 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10101"; a="284510200" X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="284510200" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,280,1624345200"; d="scan'208";a="696346388" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Subject: [RFC PATCH 5/5] target/i386: Access MSR_IA32_RTIT_ADDRn based on guest CPUID configuration Date: Thu, 9 Sep 2021 22:41:50 +0800 Message-Id: <20210909144150.1728418-6-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210909144150.1728418-1-xiaoyao.li@intel.com> References: <20210909144150.1728418-1-xiaoyao.li@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=134.134.136.100; envelope-from=xiaoyao.li@intel.com; helo=mga07.intel.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=1, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xiaoyao.li@intel.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1631198641505100001 Content-Type: text/plain; charset="utf-8" KVM only allows userspace to access legal number of MSR_IA32_RTIT_ADDRn, which is enumrated by guest's CPUID(0x14,0x1):EAX[2:0], i.e., env->features[FEAT_14_1_EAX] & INTEL_PT_ADDR_RANGES_NUM_MASK Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 1 - target/i386/cpu.h | 2 ++ target/i386/kvm/kvm.c | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2b50ccf79b92..5ff70a8cba54 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -545,7 +545,6 @@ static CPUCacheInfo legacy_l3_cache =3D { =20 #define INTEL_PT_MAX_SUBLEAF 0x1 #define INTEL_PT_DEFAULT_ADDR_RANGES_NUM 0x2 -#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 /* Support ART(0,3,6,9) */ #define INTEL_PT_DEFAULT_MTC_BITMAP 0x0249 /* Support 0,2^(0~11) */ diff --git a/target/i386/cpu.h b/target/i386/cpu.h index e6236c371c4f..20e579f147f8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -873,6 +873,8 @@ typedef uint64_t FeatureWordArray[FEATURE_WORDS]; /* Packets which contain IP payload have LIP values */ #define CPUID_14_0_ECX_LIP (1U << 31) =20 +#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 + /* CLZERO instruction */ #define CPUID_8000_0008_EBX_CLZERO (1U << 0) /* Always save/restore FP error pointers */ diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 500d2e0e686f..a90115da9ee5 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3088,8 +3088,8 @@ static int kvm_put_msrs(X86CPU *cpu, int level) } } if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { - int addr_num =3D kvm_arch_get_supported_cpuid(kvm_state, - 0x14, 1, R_EAX) & 0x7; + int addr_num =3D env->features[FEAT_14_1_EAX] & + INTEL_PT_ADDR_RANGES_NUM_MASK; =20 kvm_msr_entry_add(cpu, MSR_IA32_RTIT_CTL, env->msr_rtit_ctrl); @@ -3433,8 +3433,8 @@ static int kvm_get_msrs(X86CPU *cpu) } =20 if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { - int addr_num =3D - kvm_arch_get_supported_cpuid(kvm_state, 0x14, 1, R_EAX) & 0x7; + int addr_num =3D env->features[FEAT_14_1_EAX] & + INTEL_PT_ADDR_RANGES_NUM_MASK; =20 kvm_msr_entry_add(cpu, MSR_IA32_RTIT_CTL, 0); kvm_msr_entry_add(cpu, MSR_IA32_RTIT_STATUS, 0); --=20 2.27.0