From nobody Mon Oct 6 04:57:11 2025 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2067.outbound.protection.outlook.com [40.107.95.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F303F2E542F for ; Fri, 25 Jul 2025 11:07:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.95.67 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753441644; cv=fail; b=Z44eQDI3/m9jpT0sdsHUr6Zf1WgoPvMVia/zoglHSgRBKZhZvfMrY1TwXGdfL8ClGgTgmYGHGDZ3A1HvBFJT3blGez2jZZ2+56rr8moly5xW4m5hutG5E0WfmDWu2pwIqWFduAVAi4sRX8JiFJjBLclsxyPJkXfD+CXdRF1nILw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753441644; c=relaxed/simple; bh=ORuYilq97P5jYjPT9y+pjKEViAb3GkV4lxN4S/qjhMw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sopb/viX2j4Nrmg87/bCI5Tn+ErGdFjDVd3vHgjUUqooRSGM14smcZ6eH9DzqL85WKhnlknXK5hgRjIRY96uU4UU0f2WlpVbEdo/A7/bVbZ6OheZs5u/n6s6QGZHxF0fzxD9wAxmCp00wZ0fMiXgyiiL7L/SL6k2l/iEtMNBxmc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=KAHIyO2A; arc=fail smtp.client-ip=40.107.95.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="KAHIyO2A" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=frB3WBH/VWOU4x/t2feUzuRyJWx8BlebRrrSfQEiulQPbwEwUG2uSCD6Sa4coetfzzqH7O9r4OvUSRvsjZsErDE4Ys23XDraf9fqAu2HLIim6Dae4xyUnabdXyoZdU/wKwsrkeSa824w/1RkY+jkYvvTwcT95sTxTdw+D0/npYsnvWkii4O+YhFU5VEUpDPSNfwBejbm9YSIKVT8oCYqvYctC/3ESw8LLkGFkY1pbE6GMWcHEtBUFg284RTXJKu9EShxr+vZFud5V4jf9/9nLofOCncxaO8/sBh00T9PYgQLJFcxAxXurIUXbSkY4uQ58KWQ9Ib7nyqIb1SUZQPqDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mTJWnmfWHDlEqK3D21J0i3FL8ecV77/JKvQRl8HJwyI=; b=b0zosEY+paBA/t68QajWJFRG7EHgZmtlddnhoZ5hckkEah9lCFGJeyuBIAfrH4p5tbvS3nG2GTcBXaaCKhKQLF9+fj81xz8X/y1MYd25zb4bR41CMb/wxxmd0FuolxL6aztVO4uxOAsc1aD6tjs0LWWiMMQ8/N2/IAeZi4rPTx12ZThrAsPQaMMAvnRAJL4cAvvYw6awhSQVKAmXM+IBWLAwj0ti6u4ySuF8EP01QjEDRQjhhYPfEUDiYnnKz1Ds5khuRRrIUgKCh0Bo3+5pcVFT0YBKlXwTDc2TNiluec9FgSqG0Bla3STEiQlEwSIozPXDnPw6334bJrxBrGEXQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linutronix.de smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mTJWnmfWHDlEqK3D21J0i3FL8ecV77/JKvQRl8HJwyI=; b=KAHIyO2AQbdNOi7JqAHKxm2Zey/Z6FllISSsfk8WLDowlBJMHfkXjte8SvFXYs25ui/iiInXYsl9abQgSjg9ZK6pn9QLtfbGnKCK6yYKnPdEBgUZBEorzV3KNUuuAHG9sLeNIwdFhl6yxALczuC8aQZtuAFa0up5gucdQnse2GM= Received: from CY8PR11CA0010.namprd11.prod.outlook.com (2603:10b6:930:48::22) by MW3PR12MB4490.namprd12.prod.outlook.com (2603:10b6:303:2f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8964.21; Fri, 25 Jul 2025 11:07:20 +0000 Received: from CY4PEPF0000FCC3.namprd03.prod.outlook.com (2603:10b6:930:48:cafe::79) by CY8PR11CA0010.outlook.office365.com (2603:10b6:930:48::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8964.22 via Frontend Transport; Fri, 25 Jul 2025 11:07:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCC3.mail.protection.outlook.com (10.167.242.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8964.20 via Frontend Transport; Fri, 25 Jul 2025 11:07:19 +0000 Received: from BLRKPRNAYAK.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 25 Jul 2025 06:07:15 -0500 From: K Prateek Nayak To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , CC: Naveen rao , Sairaj Kodilkar , "H. Peter Anvin" , "Peter Zijlstra (Intel)" , "Xin Li (Intel)" , Pawan Gupta , , "Mario Limonciello" , "Gautham R. Shenoy" , Babu Moger , "Suravee Suthikulpanit" , K Prateek Nayak Subject: [PATCH v2 2/3] x86/cpu/topology: Always try cpu_parse_topology_ext() on AMD/Hygon Date: Fri, 25 Jul 2025 11:06:21 +0000 Message-ID: <20250725110622.59743-3-kprateek.nayak@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250725110622.59743-1-kprateek.nayak@amd.com> References: <20250725110622.59743-1-kprateek.nayak@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC3:EE_|MW3PR12MB4490:EE_ X-MS-Office365-Filtering-Correlation-Id: 4762aaca-d8a2-438d-4841-08ddcb6b6c8c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|7416014|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?3vEeTQr6r9vBPHA/QQ5HnkGMLWpqBIOYXNY5H/8j/vZGXC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+nPuCUwlwgyB5t0K5qAgnmgawpj4PaqAqdAigNS2OGo?= =?us-ascii?Q?pk9LGpk9rZdMaNy/rdQNl9bDa+s1sWsyVEVFl9BE7YqBZWjRPorHj4wMYrjl?= =?us-ascii?Q?tL3l4Mb1DUxqXFbaVsD80b7vUGwKldnTQt8VhiHy8ULeDYKl8nNN7Iv73a1c?= =?us-ascii?Q?OGGfvFI5L5aZKo60fdfuX3l8WHBKQuQIS6deaBuUHFWBvR8yMUC+Yt/MANaw?= =?us-ascii?Q?eAafmoq24O84XCruQ0z9ygsDksyqcQbCyo1z3BiC24yZefpADtzuK+RxNTel?= =?us-ascii?Q?2u534JVR4qETR2eF1wd7dFlZeo7UXBSiovKj+kqEYK6FwBamLMectJOQ2TTS?= =?us-ascii?Q?MKIaC0nWmV+uy7CU8JK4RDatz596mMBPK7Gbif9+qN2ArEMB5mtGt077gnV5?= =?us-ascii?Q?9tQuidleHV17KINMjQ0KxlhQ7QzdbmH2bdPYEjjysTCWKxw8YrRnDP2YJxgW?= =?us-ascii?Q?k5gO3chzczvcCOmxuZrVqKFJ2Btdz7djaIf1Vs6JQBvVTbg7SRDNc7IMjJZ+?= =?us-ascii?Q?1IKK4KGZYQzpCCr+I67pTwPFMdP62UjhsheZSemBAL+Zw9IUK1sC+/aTpaua?= =?us-ascii?Q?YJQgWvOfRoewPxD6cWpl3kDoV09GumfoDM5/ZHQg4dOM+jphTG69HqNAuQ?= =?us-ascii?Q?=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(7416014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2025 11:07:19.8681 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4762aaca-d8a2-438d-4841-08ddcb6b6c8c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000FCC3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4490 Content-Type: text/plain; charset="utf-8" Support for parsing the topology on AMD/Hygon processors using CPUID leaf 0xb was added in commit 3986a0a805e6 ("x86/CPU/AMD: Derive CPU topology from CPUID function 0xB when available"). In an effort to keep all the topology parsing bits in one place, this commit also introduced a pseudo dependency on the TOPOEXT feature to parse the CPUID leaf 0xb. TOPOEXT feature (CPUID 0x80000001 ECX[22]) advertises the support for Cache Properties leaf 0x8000001d and the CPUID leaf 0x8000001e EAX for "Extended APIC ID" however support for 0xb was introduced alongside the x2APIC support not only on AMD [1], but also historically on x86 [2]. Similar to 0xb, the support for extended CPU topology leaf 0x80000026 too does not depend on the TOPOEXT feature. The support for these leaves is expected to be confirmed by ensuring "leaf <=3D {extended_}cpuid_level" and then parsing the level 0 of the respective leaf to confirm ECX[15:8] (LevelType) is non-zero. This has not been a problem on baremetal platforms since support for TOPOEXT (Fam 0x15 and later) predates the support for CPUID leaf 0xb (Fam 0x17[Zen2] and later), however, for AMD guests on QEMU, "x2apic" feature can be enabled independent of the "topoext" feature where QEMU expects topology and the initial APICID to be parsed using the CPUID leaf 0xb (especially when number of cores > 255) which is populated independent of the "topoext" feature flag. Unconditionally call cpu_parse_topology_ext() on AMD and Hygon processors to first parse the topology using the XTOPOEXT leaves before using the TOPOEXT leaf. Link: https://lore.kernel.org/lkml/1529686927-7665-1-git-send-email-suravee= .suthikulpanit@amd.com/ [1] Link: https://lore.kernel.org/lkml/20080818181435.523309000@linux-os.sc.int= el.com/ [2] Suggested-by: Naveen N Rao (AMD) Signed-off-by: K Prateek Nayak --- Changelog v1..v2: o Moves this patch behind since this deviates from the original behavior. --- arch/x86/kernel/cpu/topology_amd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/topology_amd.c b/arch/x86/kernel/cpu/topol= ogy_amd.c index a0e3e177fc35..b392d91c6df4 100644 --- a/arch/x86/kernel/cpu/topology_amd.c +++ b/arch/x86/kernel/cpu/topology_amd.c @@ -178,18 +178,14 @@ static void topoext_fixup(struct topo_scan *tscan) =20 static void parse_topology_amd(struct topo_scan *tscan) { - bool has_topoext =3D false; - /* - * If the extended topology leaf 0x8000_001e is available - * try to get SMT, CORE, TILE, and DIE shifts from extended + * Try to get SMT, CORE, TILE, and DIE shifts from extended * CPUID leaf 0x8000_0026 on supported processors first. If * extended CPUID leaf 0x8000_0026 is not supported, try to * get SMT and CORE shift from leaf 0xb first, then try to * get the CORE shift from leaf 0x8000_0008. */ - if (cpu_feature_enabled(X86_FEATURE_TOPOEXT)) - has_topoext =3D cpu_parse_topology_ext(tscan); + bool has_topoext =3D cpu_parse_topology_ext(tscan); =20 if (cpu_feature_enabled(X86_FEATURE_AMD_HTR_CORES)) tscan->c->topo.cpu_type =3D cpuid_ebx(0x80000026); --=20 2.34.1