From nobody Sun Nov 22 03:01:59 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jXDPh3tT5z72XjL for ; Sun, 22 Nov 2026 03:02:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXDPg6bG2z4Lfs for ; Sun, 22 Nov 2026 03:01:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795316519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5gPMz7K3+a7XR528L/aFbSIncPSQBtRUlhNVenHw3y8=; b=CWCwTiKa/b9MZPBbHUPprpCGTOara31gUY6GAVwGrwIILOk+uGVkq+fzlFpopj0WYMzsYa AnCD2yjw+daf4tJmZ7frkPjb81apAuF63KoDh2VcEfrchHSc3RVE/YbIIBdtK9OVQvK8UU gBcDhjTEernXQoW47+U1p4ze3vPcQCsZqBgEkZ/5yo+UiZbK0gcJ+6Lyx455yZhDOA1BrF i3dJUUfwCh+YZ2M7ikbWF//4EIV+HOVjUobnv8u5WdrSq/NgoArnTpOHsNZDcrFAzVj2q9 lF75dqBXXSEPaqu+ZcE+j1vdWrlETQ1ltr+yHDuAG6ni/hV3bwydUYanrQRmOw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795316519; b=JFJrJvnzeK5biqg0nU80+LtGAg9GwplZzLH1IO0OzZA4MuNODJnobyz5xa0QnmfjqgDwe/ 6iO5CtVT93yJn3ZUVpWPt7PSQmzXZb/TNjn4sT8QOa6VOY0gGduFwhekJTstMFi/YFldSw A/U36zXJfpaupVy7dsbO9S9vQmvvYie67XSyKeozBF2u7a5ayYPatDi5A0J9/RxnTVzx2s qQBLghOVoZo1EEQrO9d3F8FujzA/hqPwT4Lv/OtFKX6cl/sKfnb9pXXApKTc8najUKAj/I 1rTpUFaGUQF3tyN5jvt5ZWkF+Lc57Rd0ydTPFreEclbs3EC4nj1fjAd8fpBZKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795316519; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5gPMz7K3+a7XR528L/aFbSIncPSQBtRUlhNVenHw3y8=; b=hiLWbxBPYgouJqfUMWTPNrSvoXttoDR4nHdIp/9leG6nPxGlWYOjvwRdl8ITqfVM3vGLGQ BZOUY7qNb/1FOUNMVxMo3LGlwGsmKYk3EeQTh/MCHSwb0uj/3fiD39uZpz+U/eIO1k/hPE wer3vYG4ljlYE80q5jjHV0PfBdg9XiuVH352j3srhk6WEBg/GgHDb6L5Ezw1p6LrD9dQLL st1OWmxvc+e9GJDCvIgZOUpKezcPkPPzjLnLBkRRogOXY/ZUI64OSOgpszk+MV9/WTCGCZ xBaJI8vJICXld1vwXRRazzSc7LxBajGZ6qDVTtI4yKd7Ra5DRGNnNlS11GftGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jXDPg6F90z119K for ; Sun, 22 Nov 2026 03:01:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 26c5b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Nov 2026 03:01:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: R. Christian McDonald Subject: git: c6e1457a1cdb - main - x86: Do not take a CPUID leaf 1Fh module for the package List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c6e1457a1cdbb0edd10bdce1e9e6c384a3b256e4 Auto-Submitted: auto-generated Date: Sun, 22 Nov 2026 03:01:59 +0000 Message-Id: <6b025b27.26c5b.64d6d466@gitrepo.freebsd.org> The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=c6e1457a1cdbb0edd10bdce1e9e6c384a3b256e4 commit c6e1457a1cdbb0edd10bdce1e9e6c384a3b256e4 Author: R. Christian McDonald AuthorDate: 2026-11-22 03:00:59 +0000 Commit: R. Christian McDonald CommitDate: 2026-11-22 03:00:59 +0000 x86: Do not take a CPUID leaf 1Fh module for the package Each level of CPUID leaf 0Bh or 1Fh reports the shift that addresses the next level up. Leaf 0Bh has only the SMT and core levels, so the core level's shift identifies the package. Leaf 1Fh may enumerate module, tile, die and die group levels above the core level, and then the core level's shift identifies one of those instead. topo_probe_intel_0xb() used the core level's shift for the package in both cases. On a processor that enumerates a module level, every module became a package, and the L3 cache was cut down to the module with "WARNING: L3 data cache covers more APIC IDs than a package", so the scheduler did not see that the modules share it. An Atom x7809C (Amston Lake), which reports shifts of 1, 3 and 7 for its SMT, core and module levels, came up as two packages of four cores. The N150 (Twin Lake) in the PR is affected in the same way. Use the shift of the last level enumerated for the package. The SDM describes the package as the unenumerated domain above the last valid sub-leaf, and no level type marks it. This also covers a leaf that reports only an SMT level, which used to make every thread a package. A processor that enumerates a die level is now counted as one package per socket and not one per die; its dies remain visible through their caches. Cross-check what the leaf reports. Ignore a level whose shift is smaller than that of the level below it. Warn about a level type that is out of the order the SDM fixes for the types defined so far, or that leaf 0Bh reserves, but still use its shift, which bounds the package in any case. Accept a type that leaf 1Fh does not define yet wherever it appears: the SDM does not order the type values and allows for a new level between two existing ones. While here, name the remaining leaf 1Fh level types, and test only EBX[15:0], the field that is defined, when choosing between leaves 1Fh, 0Bh and 04h. PR: 297032 Reviewed by: kib Fixes: 6badb512a94d ("Prefer CPUID leaf 1Fh for Intel CPU...") MFC after: 1 month Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D61521 --- sys/x86/include/specialreg.h | 4 ++++ sys/x86/x86/mp_x86.c | 55 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h index 888d0bfe8a41..aca1d0ddf7b5 100644 --- a/sys/x86/include/specialreg.h +++ b/sys/x86/include/specialreg.h @@ -402,6 +402,10 @@ #define CPUID_TYPE_INVAL 0 #define CPUID_TYPE_SMT 1 #define CPUID_TYPE_CORE 2 +#define CPUID_TYPE_MODULE 3 +#define CPUID_TYPE_TILE 4 +#define CPUID_TYPE_DIE 5 +#define CPUID_TYPE_DIEGRP 6 /* * CPUID instruction 0xd Processor Extended State Enumeration Sub-leaf 1 diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 0adcb7077256..f9373c70c39e 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -404,6 +404,8 @@ topo_probe_intel_0xb(void) u_int leaf; u_int p[4] = { 0 }; int bits; + int max_type; + int prev_type; int type; int i; @@ -413,17 +415,27 @@ topo_probe_intel_0xb(void) cpuid_count(leaf, 0, p); } /* Fall back to leaf 0Bh (Extended Topology Enumeration). */ - if (p[1] == 0) { + if ((p[1] & 0xffff) == 0) { leaf = 0x0b; cpuid_count(leaf, 0, p); } /* Fall back to leaf 04h (Deterministic Cache Parameters). */ - if (p[1] == 0) { + if ((p[1] & 0xffff) == 0) { topo_probe_intel_0x4(); return; } - /* We only support three levels for now. */ + /* + * The sub-leaves are ordered from the smallest domain to the largest, + * and each reports the shift that addresses the next domain up. The + * package is not enumerated: it is the domain above the last valid + * sub-leaf, so the last shift is the package's. Leaf 1Fh may + * enumerate module, tile, die and die group levels above the core + * level; they are not represented in the topology, but they must not + * be mistaken for the package boundary. + */ + max_type = leaf == 0x1f ? CPUID_TYPE_DIEGRP : CPUID_TYPE_CORE; + prev_type = CPUID_TYPE_INVAL; for (i = 0; ; i++) { cpuid_count(leaf, i, p); @@ -433,12 +445,41 @@ topo_probe_intel_0xb(void) if (type == 0) break; + /* + * No level type marks the package, so cross-check what is + * reported instead. A level cannot cover fewer APIC IDs than + * the level below it; ignore one that claims to. + */ + if (bits < pkg_id_shift) { + printf("WARNING: ignoring CPUID leaf %#x sub-leaf %d: " + "type %d shift %d is below shift %d\n", leaf, i, + type, bits, pkg_id_shift); + continue; + } + + /* + * The order of the level types defined so far is fixed, but + * their values are not ordered in general: leaf 1Fh may come + * to report a new type, with a larger value, between two of + * them. Leaf 0Bh defines only the SMT and core levels. + * Whatever its type, a level's shift still bounds the package. + */ + if (type <= max_type) { + if (type <= prev_type) + printf("WARNING: CPUID leaf %#x sub-leaf %d " + "has level type %d out of order\n", leaf, + i, type); + prev_type = type; + } else if (leaf == 0x0b) + printf("WARNING: CPUID leaf 0xb sub-leaf %d has " + "reserved level type %d\n", i, type); + + pkg_id_shift = bits; if (type == CPUID_TYPE_SMT) core_id_shift = bits; - else if (type == CPUID_TYPE_CORE) - pkg_id_shift = bits; - else if (bootverbose) - printf("Topology level type %d shift: %d\n", type, bits); + else if (type != CPUID_TYPE_CORE && bootverbose) + printf("Topology level type %d shift: %d\n", type, + bits); } if (pkg_id_shift < core_id_shift) {