From nobody Tue Nov 26 08:48:34 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=1708532981; cv=none; d=zohomail.com; s=zohoarc; b=SD/m/m7+/XzQxVPawKrYk5Qpsw+1VlLnkdjlB1AIY7OmUMXPQWQRSl93Wnqo2ghoovVRDIf4sawqahFiOEuTwU/tGNPcqE9kKqNqjzG81Iqr+Gy7onrgt8HcBLjE2JHJo+PXlJmKNNCEYiJ29ZO5kSL9CLIMMhixRs4mtMfJY+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708532981; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2FUR5ACAYE7AoZwFKF5eHjz0RAbRxzO8XmgoE6ZZ/AI=; b=k6NyVhPiyJft0KGGWJnCdXZSy/yHde980DB0la/jcABq9eeUcjljuv6JyRlZ/1QVhlzfFLz+RW3LmsG6CPwooTPa6o2dGeETPY5uuHI5KUhDWs5lBN7vb768Kt0buQY3yFnfjKBebXlU8lAy/ugx2ASDR5xo/tSSY4DBDp+TPi8= 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 1708532981695960.1798255445428; Wed, 21 Feb 2024 08:29:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcpTG-0002V0-3b; Wed, 21 Feb 2024 11:29:22 -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 1rcpTE-0002UV-LX for qemu-devel@nongnu.org; Wed, 21 Feb 2024 11:29:20 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcpTC-0000yi-2b for qemu-devel@nongnu.org; Wed, 21 Feb 2024 11:29:20 -0500 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-210-L6KLWiKnNHOlCgBlmv8GTw-1; Wed, 21 Feb 2024 11:29:13 -0500 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-410d0660929so34025075e9.0 for ; Wed, 21 Feb 2024 08:29:13 -0800 (PST) Received: from [192.168.10.118] ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.gmail.com with ESMTPSA id jj2-20020a05600c6a0200b004126732390asm2982740wmb.37.2024.02.21.08.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:29:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708532955; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=2FUR5ACAYE7AoZwFKF5eHjz0RAbRxzO8XmgoE6ZZ/AI=; b=MPWHe5IFIXmGpcTMApTsIRO7mBJdb0cMUXVcKiJXCMUSLuP3G9+mXu/Q61G5Ahf3m6L0oy DVeQdyDLbGuhvmvLjX2ImcUEWKR3TFH2TXns7AVDBAR16pdYc8LzG3xSRD+u5fEqPKr9Gk 4LTcYWKdoseOCuKH4BmvBKGvrRsIFzc= X-MC-Unique: L6KLWiKnNHOlCgBlmv8GTw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532951; x=1709137751; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2FUR5ACAYE7AoZwFKF5eHjz0RAbRxzO8XmgoE6ZZ/AI=; b=DufjsbCZbepwcRNYRrDKtmngID3ja4lJSr36Z2vEqcC83T7DyNsNPuAw1B/1TJVMSn edyoW8Cqto0cfQrAG6y/UTw8gbx3PdGugoyOyD5ZGm/yP35jicNaKMAe2fcjT3DvpVbl YHVnoZT6UlVpNOksQvoUnL3t79qTy93BSZKfi5LdIBxsLUIDhgJtKCpySXJrg0BRd7Qi vAKEOg8AolyZt6S0VYNoz21lvCokcvflvIRXm9OOWZMYCmQ6UmXOCrqLwEOfxUBYPfp+ LuTKsP12XZz2kqnPLSCDQBFmBnop8Ziufvoj8GxJDCWPi1RIDKgAn0xBgor7OBH3ns26 1RBQ== X-Gm-Message-State: AOJu0YxFZA0HllIdFrWjr9B/huRb6ZNgl00326td4Mwhqu6vMfCreRWF g+RwMkKVr3LcZd/5oMHgm02DpOIJRTd8SBNZs67HTui7wvPKCNLyQlJEN3C/G+ufeCCI/yWhbgv CsFMiUui2oVrlD4ypGIyvA2qGCyxDbTrC0PwbqiYrIZjITQU0XpcS2RYiH4WZlyFoTl+mXW5xg6 iyy08fjvnqKna2x/kgaYYZtcev2EIwCuE9ekGi X-Received: by 2002:a05:600c:1e25:b0:412:77b5:da2c with SMTP id ay37-20020a05600c1e2500b0041277b5da2cmr5228wmb.6.1708532951810; Wed, 21 Feb 2024 08:29:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHtx2C7SSpmMQ13EGHWkopdbQLmvOjlJeGO8n/kWtxYGWBuNesZYrtDyfYNDqHoEDFeZC27oA== X-Received: by 2002:a05:600c:1e25:b0:412:77b5:da2c with SMTP id ay37-20020a05600c1e2500b0041277b5da2cmr5204wmb.6.1708532951405; Wed, 21 Feb 2024 08:29:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: thuth@redhat.com, Peter Maydell Subject: [PATCH] target/i386: do not filter processor tracing features except on KVM Date: Wed, 21 Feb 2024 17:29:10 +0100 Message-ID: <20240221162910.101327-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.43.0 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=170.10.133.124; envelope-from=pbonzini@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.05, 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_H4=0.001, RCVD_IN_MSPIKE_WL=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: 1708532983754100003 Content-Type: text/plain; charset="utf-8" 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 Reviewed-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 bca776e1fe9..7f908236767 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.0