Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
3d41009
Documentation
LICENSES
arch
alpha
arc
arm
arm64
csky
hexagon
loongarch
m68k
microblaze
mips
nios2
openrisc
parisc
powerpc
riscv
s390
sh
sparc
um
x86
boot
coco
configs
crypto
entry
events
hyperv
ia32
include
kernel
acpi
apic
cpu
mce
microcode
mtrr
resctrl
sgx
.gitignore
Makefile
acrn.c
amd.c
aperfmperf.c
bugs.c
cacheinfo.c
centaur.c
common.c
cpu.h
cpuid-deps.c
cyrix.c
debugfs.c
feat_ctl.c
hygon.c
hypervisor.c
intel.c
intel_epb.c
intel_pconfig.c
match.c
mkcapflags.sh
mshyperv.c
perfctr-watchdog.c
powerflags.c
proc.c
rdrand.c
scattered.c
topology.c
topology.h
topology_common.c
topology_ext.c
transmeta.c
tsx.c
umc.c
umwait.c
vmware.c
vortex.c
zhaoxin.c
fpu
kprobes
.gitignore
Makefile
alternative.c
amd_gart_64.c
amd_nb.c
aperture_64.c
apm_32.c
asm-offsets.c
asm-offsets_32.c
asm-offsets_64.c
audit_64.c
bootflag.c
callthunks.c
cet.c
cfi.c
check.c
cpuid.c
crash.c
crash_core_32.c
crash_core_64.c
crash_dump_32.c
crash_dump_64.c
devicetree.c
doublefault_32.c
dumpstack.c
dumpstack_32.c
dumpstack_64.c
e820.c
early-quirks.c
early_printk.c
ebda.c
eisa.c
espfix_64.c
ftrace.c
ftrace_32.S
ftrace_64.S
head32.c
head64.c
head_32.S
head_64.S
hpet.c
hw_breakpoint.c
i8237.c
i8253.c
i8259.c
ibt_selftest.S
idt.c
io_delay.c
ioport.c
irq.c
irq_32.c
irq_64.c
irq_work.c
irqflags.S
irqinit.c
itmt.c
jailhouse.c
jump_label.c
kdebugfs.c
kexec-bzimage64.c
kgdb.c
ksysfs.c
kvm.c
kvmclock.c
ldt.c
machine_kexec_32.c
machine_kexec_64.c
mmconf-fam10h_64.c
module.c
mpparse.c
msr.c
nmi.c
nmi_selftest.c
paravirt-spinlocks.c
paravirt.c
pci-dma.c
pcspeaker.c
perf_regs.c
platform-quirks.c
pmem.c
probe_roms.c
process.c
process.h
process_32.c
process_64.c
ptrace.c
pvclock.c
quirks.c
reboot.c
reboot_fixups_32.c
relocate_kernel_32.S
relocate_kernel_64.S
resource.c
rethook.c
rtc.c
setup.c
setup_percpu.c
sev-shared.c
sev.c
sev_verify_cbit.S
shstk.c
signal.c
signal_32.c
signal_64.c
smp.c
smpboot.c
stacktrace.c
static_call.c
step.c
sys_ia32.c
sys_x86_64.c
tboot.c
time.c
tls.c
tls.h
topology.c
trace.c
trace_clock.c
tracepoint.c
traps.c
tsc.c
tsc_msr.c
tsc_sync.c
umip.c
unwind_frame.c
unwind_guess.c
unwind_orc.c
uprobes.c
verify_cpu.S
vm86_32.c
vmlinux.lds.S
vsmp_64.c
x86_init.c
kvm
lib
math-emu
mm
net
pci
platform
power
purgatory
ras
realmode
tools
um
video
virt
xen
.gitignore
Kbuild
Kconfig
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile
Makefile.postlink
Makefile.um
Makefile_32.cpu
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.editorconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
arch
/
x86
/
kernel
/
cpu
/
topology_ext.c
Copy path
Blame
Blame
Latest commit
History
History
130 lines (111 loc) · 3.69 KB
Breadcrumbs
linux
/
arch
/
x86
/
kernel
/
cpu
/
topology_ext.c
Top
File metadata and controls
Code
Blame
130 lines (111 loc) · 3.69 KB
Raw
// SPDX-License-Identifier: GPL-2.0 #include <linux/cpu.h> #include <asm/apic.h> #include <asm/memtype.h> #include <asm/processor.h> #include "cpu.h" enum topo_types { INVALID_TYPE = 0, SMT_TYPE = 1, CORE_TYPE = 2, MAX_TYPE_0B = 3, MODULE_TYPE = 3, TILE_TYPE = 4, DIE_TYPE = 5, DIEGRP_TYPE = 6, MAX_TYPE_1F = 7, }; /* * Use a lookup table for the case that there are future types > 6 which * describe an intermediate domain level which does not exist today. */ static const unsigned int topo_domain_map_0b_1f[MAX_TYPE_1F] = { [SMT_TYPE] = TOPO_SMT_DOMAIN, [CORE_TYPE] = TOPO_CORE_DOMAIN, [MODULE_TYPE] = TOPO_MODULE_DOMAIN, [TILE_TYPE] = TOPO_TILE_DOMAIN, [DIE_TYPE] = TOPO_DIE_DOMAIN, [DIEGRP_TYPE] = TOPO_DIEGRP_DOMAIN, }; static inline bool topo_subleaf(struct topo_scan *tscan, u32 leaf, u32 subleaf, unsigned int *last_dom) { unsigned int dom, maxtype; const unsigned int *map; struct { // eax u32 x2apic_shift : 5, // Number of bits to shift APIC ID right // for the topology ID at the next level : 27; // Reserved // ebx u32 num_processors : 16, // Number of processors at current level : 16; // Reserved // ecx u32 level : 8, // Current topology level. Same as sub leaf number type : 8, // Level type. If 0, invalid : 16; // Reserved // edx u32 x2apic_id : 32; // X2APIC ID of the current logical processor } sl; switch (leaf) { case 0x0b: maxtype = MAX_TYPE_0B; map = topo_domain_map_0b_1f; break; case 0x1f: maxtype = MAX_TYPE_1F; map = topo_domain_map_0b_1f; break; default: return false; } cpuid_subleaf(leaf, subleaf, &sl); if (!sl.num_processors || sl.type == INVALID_TYPE) return false; if (sl.type >= maxtype) { pr_err_once("Topology: leaf 0x%x:%d Unknown domain type %u\n", leaf, subleaf, sl.type); /* * It really would have been too obvious to make the domain * type space sparse and leave a few reserved types between * the points which might change instead of following the * usual "this can be fixed in software" principle. */ dom = *last_dom + 1; } else { dom = map[sl.type]; *last_dom = dom; } if (!dom) { tscan->c->topo.initial_apicid = sl.x2apic_id; } else if (tscan->c->topo.initial_apicid != sl.x2apic_id) { pr_warn_once(FW_BUG "CPUID leaf 0x%x subleaf %d APIC ID mismatch %x != %x\n", leaf, subleaf, tscan->c->topo.initial_apicid, sl.x2apic_id); } topology_set_dom(tscan, dom, sl.x2apic_shift, sl.num_processors); return true; } static bool parse_topology_leaf(struct topo_scan *tscan, u32 leaf) { unsigned int last_dom; u32 subleaf; /* Read all available subleafs and populate the levels */ for (subleaf = 0, last_dom = 0; topo_subleaf(tscan, leaf, subleaf, &last_dom); subleaf++); /* If subleaf 0 failed to parse, give up */ if (!subleaf) return false; /* * There are machines in the wild which have shift 0 in the subleaf * 0, but advertise 2 logical processors at that level. They are * truly SMT. */ if (!tscan->dom_shifts[TOPO_SMT_DOMAIN] && tscan->dom_ncpus[TOPO_SMT_DOMAIN] > 1) { unsigned int sft = get_count_order(tscan->dom_ncpus[TOPO_SMT_DOMAIN]); pr_warn_once(FW_BUG "CPUID leaf 0x%x subleaf 0 has shift level 0 but %u CPUs. Fixing it up.\n", leaf, tscan->dom_ncpus[TOPO_SMT_DOMAIN]); topology_update_dom(tscan, TOPO_SMT_DOMAIN, sft, tscan->dom_ncpus[TOPO_SMT_DOMAIN]); } set_cpu_cap(tscan->c, X86_FEATURE_XTOPOLOGY); return true; } bool cpu_parse_topology_ext(struct topo_scan *tscan) { /* Intel: Try leaf 0x1F first. */ if (tscan->c->cpuid_level >= 0x1f && parse_topology_leaf(tscan, 0x1f)) return true; /* Intel/AMD: Fall back to leaf 0xB if available */ return tscan->c->cpuid_level >= 0x0b && parse_topology_leaf(tscan, 0x0b); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
You can’t perform that action at this time.