From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522650; cv=none; d=zohomail.com; s=zohoarc; b=j+E0+dTgT/N72eqiGgNzXgxuDu3NGsku+kgO2cme6anPkyjeCWBUuJCK05GPBlKS0tfXyvYH6VwZoL5TpfOALAzjHLcL9xkVDTov5BlKLxbEkXIGuXR6Lze7GdBFlvvRERtBr/2s7sQOaAmTCWiiG2CmkgKyI6wEW+qWWpKJ6NM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522650; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zn1owIUptbne5UoAFporusUyqCAOh7f3UigBw1S7aMk=; b=Rk+6Cht8IXOOd6KCwGSu8v6G7KpjiGleO11XfugVh9SrD6Cq3PtiYNYnb1ahs8AmF80yHhNOiXURAq+mLKZLizmh4zq8Aum3ecyxeW3IFR3cBsLIz5g3F7lH4pD7IqhUDWBr5iQox6lbcQnnGRfHavUfugJOsNojBRd26ias7Jk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 168552265095371.19602711296693; Wed, 31 May 2023 01:44:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQZ-00029u-VK; Wed, 31 May 2023 04:43:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQV-00028m-Eb for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:27 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQP-0005fO-ED for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:26 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:19 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522601; x=1717058601; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tCe2NK+4wo5tYFcR9V7u1zkUeKhtImrp9c2scYoxMcc=; b=chGVtOS/xmsrpyXMcKItWYV/XaSF57sVVhYWiUaYu9/PgnOlixttcfy3 ty6gaUXUA4aHwJoBDjLjM0X7FWb6PNjkaP5SNiY4PYy3S/uhNRatlQhGF 1tX7C3oOr/tQrpwqc69qwqrQZ9tQrFCqtBdlqg8i7XOv795hhnJ7nYPDy XK4n6bLWJb19aY8yGMImlUy14Rf1e+tzebnb0cDmEwpVdkfJ2GWEOvV8s je4orI+iEm5Z4oOJWPF7VggpzoFfrWR+MC8oyaX4lvIusbLIyWsEWAznG qfRdm1YAFi0mm/pIwqLHnp891P7SF6/gQ27pgLU3KHHv2A6J/v0JIZsTM Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669242" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669242" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956395" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956395" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 1/8] target/i386: Print CPUID subleaf info for unsupported feature Date: Wed, 31 May 2023 04:43:04 -0400 Message-Id: <20230531084311.3807277-2-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522651421100001 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 1242bd541a53..88e90c1f7b7c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4745,8 +4745,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.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522651; cv=none; d=zohomail.com; s=zohoarc; b=HbB4NTH6c2uzXmMQuLwAEE3YX96aWr0qNP6yX9Zr1KyxMmsid4PzA+4Z61EPRM7Jnpe1qcLA5402bnp/uHPAXbiA4+bpj8cX2MDjca1jzUGlbnw4S2r5BPC6yCzXRWqa4ezALUiMtB8GNlRFNF8DOS/SNo5SefSzjiY+qbpacm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522651; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tMt75tfESyIpCahCMIIRLjLlIn55/t45A4jhzYNpezo=; b=bBcQcNHhVtNHhC4XbfL2P5WDMG8eaRJpYrTL0Q5xT9n3bGTpYZTLvoKNUgh/zXxbLghCR5ytp0LgSsftLb6+aw7Gh/d8Kjq2JRTNHaNiO5L7p45azunGVnC3fF//8al0fDQvtNPTCWYGA5onzah4K8rD07C8Fn7FKvM07IimVss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522651011443.43378590421617; Wed, 31 May 2023 01:44:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQZ-00029f-Uc; Wed, 31 May 2023 04:43:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQT-000276-Td for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:26 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQR-0005fZ-6c for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:25 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:20 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522603; x=1717058603; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PUiPWRxoJu35zk6JisuELImdtxTwEvzqb0+TEiNmcuc=; b=fu8NaIJcanO3fmYdkVGMR9CeleDETskL/G+g0vIAcCzkjFLvSTAlOe2i g14oZyP0NAdnUDMfww7riKZm3XgFVItSB6Eb+s6brWgEbrhIrgSPd1wkA maKUu2L2P2FQNr9yrrAHmjwy0O7bwxeKn5/QdC9vPkoprqqSyHCEPU7rf qK3uRaxs+4tyMIbWGtJsBatVW/OZlEdMIX5/DTSrhFUbR/Dl13tbQnS64 4CsA191jq2cULihy5ULjSvxnZYSXD8C84o9a6U2N+bES0EVGz5fIDuDkP UXx0xrmBoIZOB4YTnPccCb7PYW0FDLybF9FKvRbUFiwZ9Oc+kIv9rAokd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669250" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669250" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956407" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956407" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 2/8] target/i386/intel-pt: Fix INTEL_PT_ADDR_RANGES_NUM_MASK Date: Wed, 31 May 2023 04:43:05 -0400 Message-Id: <20230531084311.3807277-3-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522651423100002 Content-Type: text/plain; charset="utf-8" Per Intel SDM, bits 2:0 of CPUID(0x14,0x1).EAX indicate the number of address ranges for INTEL-PT. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 88e90c1f7b7c..7d2f20c84c7a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -573,7 +573,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 */ --=20 2.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522680; cv=none; d=zohomail.com; s=zohoarc; b=Xx5UUd4+G6jsfE7fXOmQJsr4JLd+GYDoHg4gn3jwWpRkGzwCUa4qsX3bcw53dYbo/icluLt0iAs2uRh7D7TirLTOiPLFWWfRQWrByuwnFLnSbOIRQyB7HAy0pg79mhr5iS2MVcT+Pk/Cxwv5m/cZAXD/O5NMF9teB6eLPxgHz8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522680; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hx2cyNoXP1kfE2dE4nH65Xv8ekYgv1ZXncpConsXez8=; b=aK2TQ6f2Q02OhXYYycE7fK6buO0X7M+kXYxkI122iG+U7miMk9yzBQC9OAcStY8LuQQSpIJBA5UilgD8BOQYjwwdkxCLtggIGprZ0a+bUUGkldVRfMP5mx+zMOBsxiG66drEzPvOOfhVsxf5KjMV0ZNtGtKslFuUS1hxR9RGXQY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522680037310.16341197334293; Wed, 31 May 2023 01:44:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQx-0002Da-Nh; Wed, 31 May 2023 04:43:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQV-00028l-EF for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:27 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQS-0005fJ-Vh for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:27 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:22 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522604; x=1717058604; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tdHez5vp4jS9ioxnU93LsxbiSFFkxThteRjsc69/woI=; b=Bwv7l80b+3gODY6gaOVu0qgzExGMuBy/t9fUqOcwL6R2CiN3VnpvzdJ+ 8hAKHltdwoExCU+1/0YRKor7jwyJ9sfHzyUBTxMh8iU1hKzELe4ScMCRV d29p15wj+qj+Q1Q1AWQcJqww/aWZO8b4AXuB82EPIjBldbsU1mospkBZo zf3UYVkNbzI97g5ZgEq32VR2+nBhBqmL+eSs1SL/oPzNxvwVQC3QpR/Rc THvU6vPyYV4YG6p2pYdhnDv6HUg8d7IEvgroRq5beRkbrpt8bnXfp0tkM mqoT4hW7Sn5oE+U+eTRA7ISr4yPD0u8es+QhyElpWgj2BF2+w/UXjwjcg g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669265" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669265" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956422" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956422" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , 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 Message-Id: <20230531084311.3807277-4-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522681936100003 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. Signed-off-by: Xiaoyao Li --- 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] = =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", + [7] =3D "intel-pt-event-trace", + [8] =3D "intel-pt-tnt-disable", + }, + .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, @@ -1268,6 +1285,79 @@ 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, + .feat_names =3D { + [0] =3D "intel-pt-addr-range-num-bit0", + [1] =3D "intel-pt-addr-range-num-bit1", + [2] =3D "intel-pt-addr-range-num-bit2", + [16] =3D "intel-pt-mtc-period-encoding-0", + [17] =3D "intel-pt-mtc-period-encoding-1", + [18] =3D "intel-pt-mtc-period-encoding-2", + [19] =3D "intel-pt-mtc-period-encoding-3", + [20] =3D "intel-pt-mtc-period-encoding-4", + [21] =3D "intel-pt-mtc-period-encoding-5", + [22] =3D "intel-pt-mtc-period-encoding-6", + [23] =3D "intel-pt-mtc-period-encoding-7", + [24] =3D "intel-pt-mtc-period-encoding-8", + [25] =3D "intel-pt-mtc-period-encoding-9", + [26] =3D "intel-pt-mtc-period-encoding-10", + [27] =3D "intel-pt-mtc-period-encoding-11", + [28] =3D "intel-pt-mtc-period-encoding-12", + [29] =3D "intel-pt-mtc-period-encoding-13", + [30] =3D "intel-pt-mtc-period-encoding-14", + [31] =3D "intel-pt-mtc-period-encoding-15", + }, + .cpuid =3D { + .eax =3D 0x14, + .needs_ecx =3D true, .ecx =3D 1, + .reg =3D R_EAX, + }, + }, + + [FEAT_14_1_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + .feat_names =3D { + [0] =3D "intel-pt-cyc-thresh-0", + [1] =3D "intel-pt-cyc-thresh-1", + [2] =3D "intel-pt-cyc-thresh-2", + [3] =3D "intel-pt-cyc-thresh-4", + [4] =3D "intel-pt-cyc-thresh-8", + [5] =3D "intel-pt-cyc-thresh-16", + [6] =3D "intel-pt-cyc-thresh-32", + [7] =3D "intel-pt-cyc-thresh-64", + [8] =3D "intel-pt-cyc-thresh-128", + [9] =3D "intel-pt-cyc-thresh-256", + [10] =3D "intel-pt-cyc-thresh-512", + [11] =3D "intel-pt-cyc-thresh-1024", + [12] =3D "intel-pt-cyc-thresh-2048", + [13] =3D "intel-pt-cyc-thresh-4096", + [14] =3D "intel-pt-cyc-thresh-8192", + [15] =3D "intel-pt-cyc-thresh-16384", + [16] =3D "intel-pt-psb-freq-2k", + [17] =3D "intel-pt-psb-freq-4k", + [18] =3D "intel-pt-psb-freq-8k", + [19] =3D "intel-pt-psb-freq-16k", + [20] =3D "intel-pt-psb-freq-32k", + [21] =3D "intel-pt-psb-freq-64k", + [22] =3D "intel-pt-psb-freq-128k", + [23] =3D "intel-pt-psb-freq-256k", + [24] =3D "intel-pt-psb-freq-512k", + [25] =3D "intel-pt-psb-freq-1m", + [26] =3D "intel-pt-psb-freq-2m", + [27] =3D "intel-pt-psb-freq-4m", + [28] =3D "intel-pt-psb-freq-8m", + [29] =3D "intel-pt-psb-freq-16m", + [30] =3D "intel-pt-psb-freq-32m", + [31] =3D "intel-pt-psb-freq-64m", + }, + .cpuid =3D { + .eax =3D 0x14, + .needs_ecx =3D true, .ecx =3D 1, + .reg =3D R_EBX, + }, + }, + [FEAT_SGX_12_0_EAX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { @@ -1407,10 +1497,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 }, @@ -6871,7 +6973,25 @@ 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; + + switch (w) { + case FEAT_14_1_EAX: + /* Handling the bits except INTEL_PT_ADDR_RANGES_NUM_MASK */ + unavailable_features =3D (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 |=3D requested_features & + INTEL_PT_ADDR_RANGES_NUM_MASK; + } + break; + default: + unavailable_features =3D requested_features & ~host_feat; + break; + } + mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 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=3D0x12,ECX=3D0].EAX (SGX) */ FEAT_SGX_12_0_EBX, /* CPUID[EAX=3D0x12,ECX=3D0].EBX (SGX MISCSELECT[3= 1:0]) */ FEAT_SGX_12_1_EAX, /* CPUID[EAX=3D0x12,ECX=3D1].EAX (SGX ATTRIBUTES[3= 1:0]) */ --=20 2.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522700; cv=none; d=zohomail.com; s=zohoarc; b=Y6K+cmJbBfiUP66K50dFeSzug76fbtOh3nEmB3nKA70xm88EEIeeHhHYvLf+KO1zSC4ASZ80zhYoeOWhe9zoE93w/G/huGbtQoVBd3fOzNiZmqqf3y5RFcDzd+dalQzJejpFuBaVJtm97tmXj1K12WRDx4zXWLifVLp2wmqCvPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522700; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZwppC6GrykV47XRrhfsHa+A2dBmUuorz91X8OkUNQig=; b=D2hTuO4aK4LKT4xPJWXH9YWAUV2PtqVlmnmQPz3ESU/Ek7ZIQQuBhAODF5Sur2/KtFd9mtTXDGG0nhJDdSi5rXAduVFi3oDPD3pCHuIhpliTUCE3tEkobP3rhwBm/5LcfBcGckP+aKIi8WlRgWPLRRhYUt9d0qCek43sSk52NMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522700175109.80879693683823; Wed, 31 May 2023 01:45:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQy-0002Dr-5n; Wed, 31 May 2023 04:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQW-000296-HH for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:29 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQU-0005fZ-8W for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:28 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:24 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:22 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522606; x=1717058606; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=COnzqPMSLYOBORO/c5DfjIidhTqe6fjVzZt1QcuYJos=; b=HvrX4QvcyGN7RfKP6YSKz4DGiDEJliYE9SacMbGAHgcaGjJLz3Q0HpHn cC0Bl/lDm5pt9N7q11EzP60X02N+zN3mGx8KKEY8Ikixe/G+Nc6yi6Uey pdRgAFFvuNI6AvoVO4ysMX0cutFS5Vd9TzK06Xb8r0jlPCK5fkTGPCoVh aSJjZPwBjJJ7/t8jSNKGl+6AZ5/3lo2FpC7WK8y606W4JeEiJChOKuAik P6PiAei3DoZAGohlIKggF7QCJyhoQ0+J7n+2LStiJN5sdHBMdisWiFnP2 D+CN0yQvL2qCukAVccxdsC57bohR6HV1l8GKkvch9AGyHRH796ofQlIHI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669276" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669276" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956432" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956432" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 4/8] target/i386/intel-pt: print special message for INTEL_PT_ADDR_RANGES_NUM Date: Wed, 31 May 2023 04:43:07 -0400 Message-Id: <20230531084311.3807277-5-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522701952100003 Content-Type: text/plain; charset="utf-8" Bit[2:0] of CPUID.14H_01H:EAX stands as a whole for the number of INTEL PT ADDR RANGES. For unsupported value that exceeds what KVM reports, report it as a whole in mark_unavailable_features() as well. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e735c366bc97..03471efee66b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4888,7 +4888,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]", --=20 2.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522793; cv=none; d=zohomail.com; s=zohoarc; b=LuYOD6OhDmfRe63y//znc3LdEZFLBI36XY0YBXQ++1WgVLjqBLSstykTa3EO3bnGDfzcEKDWh7VnEqWfE1q1mTLlWSXsDvN1wMztOFqmWm2PR5JaBR0NLVxGrB9wZnCPJI/B9B223Z3H2bQBh8xvrMktqny5Rv/Pv6Qoq3R76IU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522793; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z7UCe/M+WOfPV/IwM36pbzBXfQGePRqBvVHSDsTo2s0=; b=fQD781e7T/++4JYpHX7KnAN4iYQ3wV8fH21fqxRCkTw+Xe4cJbypI6MhF2iBGqCVToGVTZaZ67XGlds2A0H5lft6jYAPIW+8kAOSiAW8F+EsanFkhddJ7OE21biCqnV2H4PA1RlVvDnRFKYl2dwNdFhh96ns92ezO1TaN4OiQoQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522793626977.8803094139756; Wed, 31 May 2023 01:46:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HSw-0006NY-07; Wed, 31 May 2023 04:45:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQY-00029M-Ij for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:30 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQV-0005fO-RA for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:29 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:26 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522607; x=1717058607; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ks5EXBLJa/uaxyfMQgNRGBftxob2zbvIKcIqiQJ+JbM=; b=dpjL8swdD85j50qNVK8T/+5nIf7fOnQZ8Ensn8EKEIXMM24FbZIQtGIE 9Xtl1fm7fHFkuImdINJ1VDVyp//LMZcrg1uZwwQsNF4BDkbQo7sRXpEdc zVKDVPFa9KUY9gWHHedKVufrd4iQ20Q7n/J4loz6ij+5kYr5Uwgx+MKjx b650l2cA5TV0uWUq7igGchaMxM0+YdomqxMdS8Vjloe9CTJYfuVwLFBUd wWkqlyPUzxQow/v4v5YIl5b9Okv3NnZCwlgpb3UH42hICtAPD8OnZE2hG AapBs3rVz/VRZ1l0v3vrkYGoY9zjcfXzZum5dSMf90cdiyQK9zdwcrSE6 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669283" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669283" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956444" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956444" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 5/8] target/i386/intel-pt: Rework/rename the default INTEL-PT feature set Date: Wed, 31 May 2023 04:43:08 -0400 Message-Id: <20230531084311.3807277-6-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522794148100001 Content-Type: text/plain; charset="utf-8" Historically the Intel PT feature set reported from ICX silicon was chosen as the fixed feature set for Intel PT. If want to enable and expose INTEL-PT to guest, the supported Intel PT capabilities reported by KVM must cover this fixed feature set, which are named with MINIMAL in INTEL_PT_MINIMAL_EBX and INTEL_PT_MINIMAL_ECX. However, the name is inaccurate that it's more proper as default than minimal because SPR has less capabilities regarding CPUID(0x14,1):EBX[15:0]. Rename the feature set name to avoid future confusion and opportunistically define each feature bit. No functional change intended. Signed-off-by: Xiaoyao Li --- target/i386/cpu.c | 70 ++++++++++++++++++++++------------------------- target/i386/cpu.h | 34 ++++++++++++++++++++++- 2 files changed, 65 insertions(+), 39 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 03471efee66b..29dd79b16f6b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -549,34 +549,29 @@ 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 */ +/* INTEL PT definitions: */ + +#define INTEL_PT_MAX_SUBLEAF 0x1 + +#define INTEL_PT_ADDR_RANGES_NUM_MASK 0x7 +#define INTEL_PT_DEFAULT_ADDR_RANGES_NUM 0x2 + +/* Support ART(0,3,6,9) */ +#define INTEL_PT_DEFAULT_MTC_BITMAP (0x0249 << 16) +/* 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 << 16) + +#define INTEL_PT_DEFAULT_0_EBX (CPUID_14_0_EBX_CR3_FILTER | CPUID_14_0_EB= X_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_MULT= I_ENTRIES | \ + CPUID_14_0_ECX_SINGLE_RANGE) + +#define INTEL_PT_DEFAULT_1_EAX (INTEL_PT_DEFAULT_MTC_BITMAP | INTEL_PT_DE= FAULT_ADDR_RANGES_NUM) + +#define INTEL_PT_DEFAULT_1_EBX (INTEL_PT_DEFAULT_PSB_BITMAP | INTEL_PT_DE= FAULT_CYCLE_BITMAP) =20 /* CPUID Leaf 0x1D constants: */ #define INTEL_AMX_TILE_MAX_SUBLEAF 0x1 @@ -6250,14 +6245,14 @@ 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; + *ebx =3D INTEL_PT_DEFAULT_0_EBX; + *ecx =3D INTEL_PT_DEFAULT_0_ECX; if (env->features[FEAT_14_0_ECX] & CPUID_14_0_ECX_LIP) { *ecx |=3D CPUID_14_0_ECX_LIP; } } 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 INTEL_PT_DEFAULT_1_EAX; + *ebx =3D INTEL_PT_DEFAULT_1_EBX; } break; } @@ -7012,13 +7007,12 @@ static void x86_cpu_filter_features(X86CPU *cpu, bo= ol verbose) uint32_t ebx_1 =3D kvm_arch_get_supported_cpuid(s, 0x14, 1, R_EBX); =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) || + ((ebx_0 & INTEL_PT_DEFAULT_0_EBX) !=3D INTEL_PT_DEFAULT_0_EBX) = || + ((ecx_0 & INTEL_PT_DEFAULT_0_ECX) !=3D INTEL_PT_DEFAULT_0_ECX) = || + ((eax_1 & INTEL_PT_DEFAULT_MTC_BITMAP) !=3D INTEL_PT_DEFAULT_MT= C_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)) || + INTEL_PT_DEFAULT_ADDR_RANGES_NUM) || + ((ebx_1 & INTEL_PT_DEFAULT_1_EBX) !=3D INTEL_PT_DEFAULT_1_EBX) = || ((ecx_0 & CPUID_14_0_ECX_LIP) !=3D (env->features[FEAT_14_0_ECX] & CPUID_14_0_ECX_LIP))) { /* diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 500693eb9847..71b83102b75e 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -938,8 +938,40 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWor= d w, /* XFD Extend Feature Disabled */ #define CPUID_D_1_EAX_XFD (1U << 4) =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.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522664; cv=none; d=zohomail.com; s=zohoarc; b=M1ZhUQVjaBBzEI4Q/f7Gw/yGhhlJB5URkbeTqeVPsSf3e+yQEVlA6rVIsJopt7++l3a+h1DfeHrCWJb34spMxDVtcpDm3YF3sVN6d/8ymkD3RAyD8rtbnePS9Vuu+GyJZZ+DUJwDeYS6ainWTdw9udHwZSnuWCITiFfkSr0mChA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=oOXsrYlJ79LNeKqqoUipKsPhqybnoJJ/ju+pyCG+A/g=; b=i3a7fxOsmLm9k/e1U/CnJM2/kHQF77WCKUc8YOqrbu9H6sZTGK63CW4Y6KiMGeqpA/DicuuWRv/sG93DTg5w1D0Vv4AJaNlqUK2JXgK78t+HdXOJcsZCBxdlRk1G/5A9GmBac9xvxtAcrkXL3EeoRdbpY0IoGAFHFKl7MaI8GhI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522664192407.0258457954885; Wed, 31 May 2023 01:44:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQg-0002B8-66; Wed, 31 May 2023 04:43:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQb-0002AH-4M for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:33 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQY-0005iE-ET for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:32 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:28 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522610; x=1717058610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qtxSQy+gTKsjprIgvXTBFPFgWEaxZXOK+kQoREo9KPY=; b=FJBVgAD4Scxwe5OcaNjr6t9jBcubN28cRMReoi1fkMpRiIugu7Zz9PWs gzt/jzIBOvq4gtjK0y7xCKivWwR9dqj92ehGvZlxYpxfGnNd+JWX65kyJ z2CW+EyhZes2qYvUZoIMDv5fMO/nL3tlLImSeo92jkxLSDeQjASIFi8A5 p06tWn+XMtCTZk8YsDSiVA1NyffATg4gUTX4hurEXuxx9kuS5qiDZhF+L h5vwhyIcy+6O862MONk5jaKtufNSnDFAlhyHKrNfBFlLQUjbaSifJJEda Lx/MP0khFeFEwT58d9QtpFvyO2LdiaBLT1m3F3QbClNSCNTzklQy3vcpZ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669298" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669298" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956464" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956464" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 6/8] target/i386/intel-pt: Enable host pass through of Intel PT Date: Wed, 31 May 2023 04:43:09 -0400 Message-Id: <20230531084311.3807277-7-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522665859100003 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 exposure on Intel SPR platform because SPR has less supported bitmap of CPUID(0x14,1):EBX[15:0] than ICX. To fix the problem, enable pass through of host's PT capabilities for the cases "-cpu host/max" that it won't use default fixed PT feature set of ICX but expand automatically based on get_supported_cpuid() reported by KVM. Meanwhile, it needs to ensure (old) named CPU models still have the fixed Intel PT feature set to not break the live migration case of "-cpu named_cpu_model,+intel-pt" wiht old QEMU. To achieve this, assign default Intel PT feature values to named CPU models if no value defined in CPU models explicitly. In the future, new named CPU model, e.g., Sapphire Rapids, can define its own PT feature set by providing their own FEAT_14_0_EBX, FEAT_14_0_ECX, FEAT_14_1_EAX and FEAT_14_1_EBX. Signed-off-by: Xiaoyao Li --- Changes in v4: - drop use_default_intel_pt flag and the handling of validating final env->features[FEAT_14*] matches with INTEL_PT_DEFAULT_*. It's found unnecessary because old QEMU has no ability to customize Intel PT feature set with +/-feature. --- target/i386/cpu.c | 62 ++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 29dd79b16f6b..e47629aff68e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5723,6 +5723,24 @@ static void x86_cpu_load_model(X86CPU *cpu, X86CPUMo= del *model) env->features[w] =3D def->features[w]; } =20 + /* + * All (old) named CPU models have the same default values for INTEL_P= T if + * the leaf values are not explicitly specified. + * + * Assign the default value here since we don't want to manually copy/= paste + * it to all entries in builtin_x86_defs[]. + * + * It's safe to set values for Intel PT leaves here because they will = be + * cleared due to feature_dependencies if CPUID_7_0_EBX_INTEL_PT is ab= sent. + */ + if (!env->features[FEAT_14_0_EBX] && !env->features[FEAT_14_0_ECX] && + !env->features[FEAT_14_1_EAX] && !env->features[FEAT_14_1_EBX]) { + 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 !x86_cpu_get_versioned_cache_info(cpu, model); =20 @@ -6245,14 +6263,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_DEFAULT_0_EBX; - *ecx =3D INTEL_PT_DEFAULT_0_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_DEFAULT_1_EAX; - *ebx =3D INTEL_PT_DEFAULT_1_EBX; + *eax =3D env->features[FEAT_14_1_EAX]; + *ebx =3D env->features[FEAT_14_1_EBX]; } break; } @@ -6964,6 +6979,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() @@ -6972,8 +6988,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; =20 @@ -6997,30 +7012,11 @@ 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 (!eax_0 || - ((ebx_0 & INTEL_PT_DEFAULT_0_EBX) !=3D INTEL_PT_DEFAULT_0_EBX) = || - ((ecx_0 & INTEL_PT_DEFAULT_0_ECX) !=3D INTEL_PT_DEFAULT_0_ECX) = || - ((eax_1 & INTEL_PT_DEFAULT_MTC_BITMAP) !=3D INTEL_PT_DEFAULT_MT= C_BITMAP) || - ((eax_1 & INTEL_PT_ADDR_RANGES_NUM_MASK) < - INTEL_PT_DEFAULT_ADDR_RANGES_NUM) || - ((ebx_1 & INTEL_PT_DEFAULT_1_EBX) !=3D INTEL_PT_DEFAULT_1_EBX) = || - ((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. - */ - mark_unavailable_features(cpu, FEAT_7_0_EBX, CPUID_7_0_EBX_INT= EL_PT, prefix); + 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); + 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 2.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522682; cv=none; d=zohomail.com; s=zohoarc; b=VtS2LMSX3dVvZD/M7LQ8FvEwEwcAtJyM9UOKWsng9H1AhlZvyrvgCmDBXgL8/YY329wtBp/kNfgBJXfitcY4VHxBiRwzcHhur12YFAf0Y1kZ4bsTA2EvM3N0Wrx5ARY+j15DASkJRYcVcDQgDwEWwllXDFs70r9SXdlOcgNnRBw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522682; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WCJ5wFKaUFHECr45LB7+1CqtC6cTWwNJRrDTd9/oEKY=; b=n3o6kKvVzPQGbdAIJiw3G4RVyl0reOXXyrkLfDBTN0eJJ1W89ErcFKlMt1cP3/HKSXLhtAy1rl8HhgJ+EE2Jp+/b6fvViaPagOqGXar89K4BILIHRgMyggPAHBmCQylU5iP7c37rYpp9aBy+ywhXBY0ey5hfWicV+0eErrVRhVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522682196808.1250875174078; Wed, 31 May 2023 01:44:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQf-0002As-6s; Wed, 31 May 2023 04:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQa-0002AF-US for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:33 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQY-0005iF-Ol for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:32 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:29 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522610; x=1717058610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=peLHOea+vLgXw1wTEoUDkKyMN9jSNL+bEhw7hF1VivU=; b=bCd15qKZqiqHarTe0bqcQ0gRro3xlhXZ+m/lW3pfe3esavAAW3KMYLSR 6jG5o76jfw3j1ETFMO4r9uhAdG2b/bLJGYmFhJQyHKVmGyKlwMShnwngO 7MJ9oObeZtsXMg/v2QSaBSQVVSK8NS7uPsk7nePEbOYS2qvAZeAyR9HUc Cio2NdiqEySIgkskDayH+EsO6E2okEebsmfPjLd51ACD1VaGzfetwVsjs nBHhpYswa5X+0cKO4perKz5ayGrImy3Pbdg66Q8j0yEaj+CmPRoJR8bTQ JcrRNv1coK7o8+hor4aUEUJSBLQUNtILNcmqJFTwLs0b/AI+/tlNltKoG w==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669307" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669307" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956478" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956478" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 7/8] target/i386/intel-pt: Define specific PT feature set for IceLake-server, Snowridge and SapphireRapids Date: Wed, 31 May 2023 04:43:10 -0400 Message-Id: <20230531084311.3807277-8-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522683536100005 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 and SapphireRapids, define it according to real silicon capabilities. Signed-off-by: Xiaoyao Li --- Changes in v4: - Add Intel PT capabilities for SapphireRapids cpu model; --- target/i386/cpu.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e47629aff68e..182ba02e2fee 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -3699,6 +3699,14 @@ 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 */ + .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 | @@ -3869,6 +3877,15 @@ static const X86CPUDefinition builtin_x86_defs[] =3D= { .features[FEAT_7_1_EAX] =3D CPUID_7_1_EAX_AVX_VNNI | CPUID_7_1_EAX_AVX512_BF16 | CPUID_7_1_EAX_FZRM | CPUID_7_1_EAX_FSRS | CPUID_7_1_EAX_FSRC, + .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_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, + .features[FEAT_14_1_EAX] =3D 0x249 << 16 | 0x2, + .features[FEAT_14_1_EBX] =3D 0x003f << 16 | 0x3f, .features[FEAT_VMX_BASIC] =3D MSR_VMX_BASIC_INS_OUTS | MSR_VMX_BASIC_TRUE_CTLS, .features[FEAT_VMX_ENTRY_CTLS] =3D @@ -4105,6 +4122,16 @@ static const X86CPUDefinition builtin_x86_defs[] =3D= { CPUID_XSAVE_XGETBV1, .features[FEAT_6_EAX] =3D CPUID_6_EAX_ARAT, + .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.34.1 From nobody Sun May 5 06:00:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.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=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1685522694; cv=none; d=zohomail.com; s=zohoarc; b=C8z4+SwrLtRfG++pxokd3k5ClGEVQwRWhOs6zL5Tlf8soNiH96GyX/qtSp8DtvDDb7YQugrKBcigDquQYG3AeWW7x/0i/9fmsrLdfNr9sPfuyN2hsdpVC467XdkxkyazCzK33uBMRfZoOMYPWlxitc+prNF98fi59/U7pi8RtXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685522694; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IWAOeEfBk/hMtxIEJ9qzbHnZCbrKJawJ6FCJpOFhuq4=; b=XNzwtRBlu76Y1dprp2bfrZPN3fKFI7z9L6kTO5jyUyk9Dl+zcY6xqyiHLPT9pXlHQAO6eRHbMBQhkhCFXZsG/W+E1JLd4Kb4maRKxrIuW7oOb+FdqmmTko3Mh0UiaaH/SbUgpQecUSnAQ1cvGq+Cxkt7KesyKoCyDZJIeVSDfuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685522694319857.8387670765802; Wed, 31 May 2023 01:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4HQy-0002ES-Mk; Wed, 31 May 2023 04:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQc-0002AX-7J for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:34 -0400 Received: from mga06b.intel.com ([134.134.136.31] helo=mga06.intel.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q4HQa-0005fO-Cp for qemu-devel@nongnu.org; Wed, 31 May 2023 04:43:33 -0400 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2023 01:43:31 -0700 Received: from lxy-clx-4s.sh.intel.com ([10.239.48.46]) by fmsmga005.fm.intel.com with ESMTP; 31 May 2023 01:43:30 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685522612; x=1717058612; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KkICQLUL0N6wno1F6DhwOg202/VMAVLCyaivtde70OQ=; b=cItuCOca4j8pXAWixaItTHvtyE5I9ids7IGyTlvhdKTDTDyLFv7MhTX1 TGGzXAgWszFhPUu6XFwCROBJx7Q47FStKNHu7BskYYq7ThkkGxMKLvZ8m 0JqjQVol9V/N/ww4SPmltA4Vo96vdoswQtSv7Oa7/mJI1g6fVK0x9w/cD A7hlww6f2+Edgx7HeR5Ja52z0N8BLA/EjjQCPaMnbdEvK2herR/GdHaTu v+Oji16PoywlzNSpptCwyhawQ60Hy1ZEo9Op7UOCuWblml1+LjgR5UNyh bFjfl/Klmog7VyODYD0o2koHw/WO2uIc3comk0dj2CvwzGtJGuxz9g1ln g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="418669318" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="418669318" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="1036956500" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="1036956500" From: Xiaoyao Li To: Paolo Bonzini , Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, Chenyi Qiang , lei4.wang@intel.com Subject: [PATCH v4 8/8] target/i386/intel-pt: Access MSR_IA32_RTIT_ADDRn based on guest CPUID configuration Date: Wed, 31 May 2023 04:43:11 -0400 Message-Id: <20230531084311.3807277-9-xiaoyao.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230531084311.3807277-1-xiaoyao.li@intel.com> References: <20230531084311.3807277-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.31; envelope-from=xiaoyao.li@intel.com; helo=mga06.intel.com X-Spam_score_int: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HK_RANDOM_ENVFROM=0.001, HK_RANDOM_FROM=0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1685522695967100003 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.h | 2 ++ target/i386/kvm/kvm.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 71b83102b75e..d745ba2ad77a 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -973,6 +973,8 @@ uint64_t x86_cpu_get_supported_feature_word(FeatureWord= w, /* 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 de531842f6b1..e68846100ddb 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -3561,8 +3561,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); @@ -4004,8 +4004,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.34.1