From nobody Wed May 15 09:15:16 2024 Delivered-To: importer@patchew.org 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1584003016; cv=none; d=zohomail.com; s=zohoarc; b=B3Gk/nuw48hvepzc0orFsWiCfqFa2AyVvk2wElSf6090koaBZ6RWjmqJnDU8K9QPTmy2JciIvW6d36p0YLrEbhHcApfym/mF+3PkmKFPt9oAYifA+lobcvKd8g8Brib4D8gl6fnjJdK4OWp/uWZ4GgSZuks/A5gj2jjmC8svVQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584003016; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=2POukjWJz7Xska0qr+Yeb04Dwc7K0aqn1ljOPTpZkgM=; b=CxqdxDLYSMb72cH/ITyHEz5a30hV+SG+AkrDl8c7PUh/XOvtHTWuJYuKYP7TZ0YUiIk+0TYsV6T2fnmjvbAcvnLGhNiFrq8OfMJlyWrHHprWS4qJXNvIbTDsVuhY5txy3nLX25V9XzIzlxUnDLRQODAWvSvXxRQvbe0uAi6JUww= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1584003015937976.4139113874039; Thu, 12 Mar 2020 01:50:15 -0700 (PDT) Received: from localhost ([::1]:37806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJXi-0002AZ-Uv for importer@patchew.org; Thu, 12 Mar 2020 04:50:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50186) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jCJX8-0001ZR-Ki for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:49:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jCJX6-0005EA-Sf for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:49:37 -0400 Received: from mga03.intel.com ([134.134.136.65]:6651) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jCJX6-0005AY-LG for qemu-devel@nongnu.org; Thu, 12 Mar 2020 04:49:36 -0400 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2020 01:49:31 -0700 Received: from snr.bj.intel.com ([10.240.193.90]) by fmsmga008.fm.intel.com with ESMTP; 12 Mar 2020 01:49:29 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,544,1574150400"; d="scan'208";a="236569414" From: Luwei Kang To: pbonzini@redhat.com, rth@twiddle.net, ehabkost@redhat.com Subject: [PATCH v2] target/i386: set the CPUID level to 0x14 on old machine-type Date: Fri, 13 Mar 2020 00:48:06 +0800 Message-Id: <1584031686-16444-1-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 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: Luwei Kang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The CPUID level need to be set to 0x14 manually on old machine-type if Intel PT is enabled in guest. E.g. the CPUID[0].EAX(level)=3D7 and CPUID[7].EBX[25](intel-pt)=3D1 when the Qemu with "-machine pc-i440fx-3.1 -cpu qemu64,+intel-pt" parameter. Some Intel PT capabilities are exposed by leaf 0x14 and the missing capabilities will cause some MSRs access failed. This patch add a warning message to inform the user to extend the CPUID level. Suggested-by: Eduardo Habkost Signed-off-by: Luwei Kang --- v1->v2: - Mask off Intel PT when the CPUID level < 0x14, not only a warning. qemu-system-x86_64: warning: Intel PT need CPUID leaf 0x14, please set by= "-cpu ...,+intel-pt,level=3D0x14": CPUID.07H:EBX.intel-pt [bit 25] - Remove the checking of kvm_enabled() because it is unnecessary. target/i386/cpu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 306d50a..cab44c5 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6302,9 +6302,14 @@ static void x86_cpu_expand_features(X86CPU *cpu, Err= or **errp) x86_cpu_adjust_feat_level(cpu, FEAT_XSAVE); =20 /* Intel Processor Trace requires CPUID[0x14] */ - if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && - kvm_enabled() && cpu->intel_pt_auto_level) { - x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14); + if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT)) { + if (cpu->intel_pt_auto_level) { + x86_cpu_adjust_level(cpu, &cpu->env.cpuid_min_level, 0x14); + } else if (cpu->env.cpuid_min_level < 0x14) { + mark_unavailable_features(cpu, FEAT_7_0_EBX, + CPUID_7_0_EBX_INTEL_PT, + "Intel PT need CPUID leaf 0x14, please set by \"-cpu .= ..,+intel-pt,level=3D0x14\""); + } } =20 /* CPU topology with multi-dies support requires CPUID[0x1F] */ --=20 1.8.3.1