From nobody Sat Nov 15 07:40:56 2025 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=1754284551; cv=none; d=zohomail.com; s=zohoarc; b=bQP+q+e1B+x1GUKeN0I4yJ5A4N4fcmX3afmejkPmhZlXgaN3ZZpQOWCfq7J+3A9KwUA74qK9raAupeKN20fVhxnDfseryX+8HagcHxAULKTlQJoVQDSEnZPW9tdIJDIIqRolpfFBfGzKBjdVkBFJyzF9m82esx3tCti4YHnmKJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754284551; h=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=1kxJTfJXg5kL8cwT18KlShAEwHpJrfTp5lKKpTx6uYs=; b=cM0QnE2dPGN0VGrGVUSTHWS7/78cIoBT5Xr4KW0ZGu8VJM37mR1mKAQgFXrGnCWd61p44CPShjdfzLpH/8ztZXQt1ZTNPJZ4c5EDqAIhhHfHL54j+hGRGK2FL1OsNBEdNSi3vz77BqtYmj2Xe42POS7G/HF/j3v3KK3ualGZF+o= 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 1754284550734821.2274259084257; Sun, 3 Aug 2025 22:15:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uinX9-0000xL-0P; Mon, 04 Aug 2025 01:14:51 -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 1uinWt-0000rh-JG; Mon, 04 Aug 2025 01:14:37 -0400 Received: from mgamail.intel.com ([198.175.65.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uinWq-0002jt-Nf; Mon, 04 Aug 2025 01:14:35 -0400 Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2025 22:14:28 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by fmviesa008.fm.intel.com with ESMTP; 03 Aug 2025 22:14:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754284473; x=1785820473; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=eAash09ynJi/5Z1480JePS6uGwe/HI/5Jxdso0UCAuk=; b=R+Lu8wyi9+7B1jG/XVcH08u2prGESjgFSObIDKRcLiHN6Il3gMAbdWwh S6A8K3aDtR505djf/En3UnJTm/3D3jK2NVI79xzKKZ5EJgk+BPJjeYqOs JdIr5D7Rkg1mLLkeymYUUaqzIWEeCi8SXPuEMQ8UqyAE7OGuHU8KzXJLx MqwPH+kGI7VGxqkQV5tFAp1fIjQD9Hrk/zHs9vrFqFLHg4Q5QkmXjFFoO 9bRGlRdQ2bmEiGzOI6c1/6huxt4+ydjLW0kSVtM+KenQd/YfwABew779S 1rUh6oDEtBuHiPo5a4/sATmODqv0Ieujqn3cJNiH4dj34KQorJVPtRJEs w==; X-CSE-ConnectionGUID: ybetperpRqa+vNIBTqlUzw== X-CSE-MsgGUID: Q9oJtorcRaO0Tf3jjqJtTQ== X-IronPort-AV: E=McAfee;i="6800,10657,11511"; a="67984539" X-IronPort-AV: E=Sophos;i="6.17,258,1747724400"; d="scan'208";a="67984539" X-CSE-ConnectionGUID: SE3GmI7+Q8mHr0BWKUob/Q== X-CSE-MsgGUID: K9zzfTQ8Qpig6S62sFz/tw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,258,1747724400"; d="scan'208";a="164515751" From: Zhao Liu To: Paolo Bonzini , Michael Tokarev Cc: qemu-devel@nongnu.org, qemu-stable@nongnu.org, Zhao Liu , Chuang Xu Subject: [PATCH for v10.1] i386/cpu: Move addressable ID encoding out of compat property in CPUID[0x1] Date: Mon, 4 Aug 2025 13:35:48 +0800 Message-Id: <20250804053548.1808629-1-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 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=198.175.65.12; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1754284557130116600 Content-Type: text/plain; charset="utf-8" Currently, the addressable ID encoding for CPUID[0x1].EBX[bits 16-23] (Maximum number of addressable IDs for logical processors in this physical package) is covered by vendor_cpuid_only_v2 compat property. The previous consideration was to avoid breaking migration and this compat property makes it unfriendly to backport the commit f985a1195ba2 ("i386/cpu: Fix number of addressable IDs field for CPUID.01H.EBX [23:16]"). However, NetBSD booting is broken since the commit 88dd4ca06c83 ("i386/cpu: Use APIC ID info to encode cache topo in CPUID[4]"), because NetBSD calculates smt information via `lp_max` / `core_max` for legacy Intel CPUs which doesn't support 0xb leaf, where `lp_max` is from CPUID[0x1].EBX.bits[16-23] and `core_max` is from CPUID[0x4].0x0.bits[26 -31]. The commit 88dd4ca0 changed the encoding rule of `core_max` but didn't update `lp_max`, so that NetBSD would get the wrong smt information, which leads to the module loading failure. Luckily, the commit f985a1195ba2 ("i386/cpu: Fix number of addressable IDs field for CPUID.01H.EBX[23:16]") updated the encoding rule for `lp_max` and accidentally fixed the NetBSD issue too. This also shows that using CPUID[0x1] and CPUID[0x4].0x0 to calculate HT/SMT information is a common practice to detect CPU topology on legacy Intel CPUs. Therefore, it's necessary to backport the commit f985a1195ba2 to previous stable QEMU to help address the similar issues as well. Then the compat property is not needed any more since all stable QEMUs will follow the same encoding way. So, in CPUID[0x1], move addressable ID encoding out of compat property. Reported-by: Michael Tokarev Inspired-by: Chuang Xu Fixes: commit f985a1195ba2 ("i386/cpu: Fix number of addressable IDs field = for CPUID.01H.EBX[23:16]") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3061 Signed-off-by: Zhao Liu Reviewed-by: Michael Tokarev Tested-by: Michael Tokarev --- target/i386/cpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 251d5760a0bd..673f8583c809 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -7885,8 +7885,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, * count, but Intel needs maximum number of addressable IDs for * logical processors per package. */ - if (cpu->vendor_cpuid_only_v2 && - (IS_INTEL_CPU(env) || IS_ZHAOXIN_CPU(env))) { + if ((IS_INTEL_CPU(env) || IS_ZHAOXIN_CPU(env))) { num =3D 1 << apicid_pkg_offset(topo_info); } else { num =3D threads_per_pkg; --=20 2.34.1