From nobody Tue Nov 26 10:40:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1708717719; cv=none; d=zohomail.com; s=zohoarc; b=iV/hx49QAMZhOCIYPdWRo0ioXQydpd7YLz1WbApr5CvmE5Waey8NFqxiIm6EUVfMj1To9Koj0TU9BM42szmgCP1BVHG5yks7uj4BqWzyzQ+f/ged9uL6IYuLuxsG8gcO9KIx1+4EhZocNo+hfX0WxdGW5YpeqnMFhYO3f766xtY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708717719; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=KWnvkcpd64dmJIVKz8lboK1m9g0wbAxCnQNFypzKJRE=; b=PHZAHQ+mpvEgONAoJ1mqz6IIIU1filqRXLYqE5blUPa6IboR8E3sM6THWoejVs+1n5Y0vdp0YAIFVJmKi7CDPe0W/4FPEhuLMyYegCy1bZIRAN6d3zR3FKr3isk1QbSF2ug42O6ThHztt5HDTIyICUSNqiE2lLR2xjMMOFbhR3o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1708717719741133.59947968029837; Fri, 23 Feb 2024 11:48:39 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdbWT-0004jH-5X; Fri, 23 Feb 2024 14:47:53 -0500 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 1rdawI-0005ns-Fy for qemu-devel@nongnu.org; Fri, 23 Feb 2024 14:10:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rdawG-0005HI-Ge for qemu-devel@nongnu.org; Fri, 23 Feb 2024 14:10:30 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-AaD5nQ2JOUKvzLGCW6cT-A-1; Fri, 23 Feb 2024 14:10:21 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B8EE106D021; Fri, 23 Feb 2024 19:10:21 +0000 (UTC) Received: from thuth-p1g4.redhat.com (unknown [10.39.192.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F163E8CED; Fri, 23 Feb 2024 19:10:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708715425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KWnvkcpd64dmJIVKz8lboK1m9g0wbAxCnQNFypzKJRE=; b=PaT9srlu3cPNG/9JCAAUtbW9HyICIKU83NVuyKkcXIcyE4xZWJKXqgziQ/AeBU0TKoq27i yuHGKfv4RSwcicZQxEKjeyqYWd205Murla7ZLulzUdGD7q1pJQpDYzXxhuNy2ioDFi7yCm YFXRGOaRs2QjOCph5lRRvA2EhGtAeJQ= X-MC-Unique: AaD5nQ2JOUKvzLGCW6cT-A-1 From: Thomas Huth To: qemu-devel@nongnu.org Cc: Peter Maydell , Paolo Bonzini Subject: [PULL 11/11] target/i386: do not filter processor tracing features except on KVM Date: Fri, 23 Feb 2024 20:10:03 +0100 Message-ID: <20240223191003.6268-12-thuth@redhat.com> In-Reply-To: <20240223191003.6268-1-thuth@redhat.com> References: <20240223191003.6268-1-thuth@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=170.10.129.124; envelope-from=thuth@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.066, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1708717721408100003 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini The processor tracing features in cpu_x86_cpuid() are hardcoded to a set that should be safe on all processor that support PT virtualization. But as an additional check, x86_cpu_filter_features() also checks that the accelerator supports that safe subset, and if not it marks CPUID_7_0_EBX_INTEL_PT as unavailable. This check fails on accelerators other than KVM, but it is actually unnecessary to do it because KVM is the only accelerator that uses the safe subset. Everything else just provides nonzero values for CPUID leaf 0x14 (TCG/HVF because processor tracing is not supported; qtest because nothing is able to read CPUID anyway). Restricting the check to KVM fixes a warning with the qtest accelerator: $ qemu-system-x86_64 -display none -cpu max,mmx=3Doff -accel qtest qemu-system-x86_64: warning: TCG doesn't support requested feature: CPU= ID.07H:EBX.intel-pt [bit 25] The warning also happens in the test-x86-cpuid-compat qtest. Reported-by: Peter Maydell Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2096 Signed-off-by: Paolo Bonzini Message-ID: <20240221162910.101327-1-pbonzini@redhat.com> Fixes: d047402436 ("target/i386: Call accel-agnostic x86_cpu_get_supported_= cpuid()") Reviewed-by: Thomas Huth Signed-off-by: Thomas Huth --- target/i386/cpu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index bca776e1fe..7f90823676 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6412,6 +6412,10 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index,= uint32_t count, break; } =20 + /* + * If these are changed, they should stay in sync with + * x86_cpu_filter_features(). + */ if (count =3D=3D 0) { *eax =3D INTEL_PT_MAX_SUBLEAF; *ebx =3D INTEL_PT_MINIMAL_EBX; @@ -7156,7 +7160,12 @@ static void x86_cpu_filter_features(X86CPU *cpu, boo= l verbose) mark_unavailable_features(cpu, w, unavailable_features, prefix); } =20 - if (env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) { + /* + * Check that KVM actually allows the processor tracing features that + * are advertised by cpu_x86_cpuid(). Keep these two in sync. + */ + if ((env->features[FEAT_7_0_EBX] & CPUID_7_0_EBX_INTEL_PT) && + kvm_enabled()) { uint32_t eax_0, ebx_0, ecx_0, edx_0_unused; uint32_t eax_1, ebx_1, ecx_1_unused, edx_1_unused; =20 --=20 2.43.2