Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178017085
D61521.1795766248.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D61521.1795766248.diff
View Options
diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h
--- 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
--- a/sys/x86/x86/mp_x86.c
+++ b/sys/x86/x86/mp_x86.c
@@ -404,6 +404,8 @@
u_int leaf;
u_int p[4] = { 0 };
int bits;
+ int max_type;
+ int prev_type;
int type;
int i;
@@ -413,17 +415,27 @@
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 @@
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) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 27, 7:57 AM (13 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41893853
Default Alt Text
D61521.1795766248.diff (3 KB)
Attached To
Mode
D61521: x86: Do not take a CPUID leaf 1Fh module for the package
Attached
Detach File
Event Timeline