arch/x86/boot/cpucheck.c
Source file repositories/reference/linux-study-clean/arch/x86/boot/cpucheck.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/boot/cpucheck.c- Extension
.c- Size
- 6149 bytes
- Lines
- 229
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
boot.hlinux/types.hasm/cpufeaturemasks.hasm/intel-family.hasm/processor-flags.hasm/msr-index.hasm/shared/msr.hstring.h
Detected Declarations
function is_amdfunction is_centaurfunction is_transmetafunction is_intelfunction check_cpuflagsfunction check_cpufunction is_centaurfunction is_intelfunction check_knl_erratum
Annotated Snippet
is_amd()) {
/* If this is an AMD and we're only missing SSE+SSE2, try to
turn them on */
struct msr m;
raw_rdmsr(MSR_K7_HWCR, &m);
m.l &= ~(1 << 15);
raw_wrmsr(MSR_K7_HWCR, &m);
get_cpuflags(); /* Make sure it really did something */
err = check_cpuflags();
} else if (err == 0x01 &&
!(err_flags[0] & ~(1 << X86_FEATURE_CX8)) &&
is_centaur() && cpu.model >= 6) {
/* If this is a VIA C3, we might have to enable CX8
explicitly */
struct msr m;
raw_rdmsr(MSR_VIA_FCR, &m);
m.l |= (1 << 1) | (1 << 7);
raw_wrmsr(MSR_VIA_FCR, &m);
set_bit(X86_FEATURE_CX8, cpu.flags);
err = check_cpuflags();
} else if (err == 0x01 && is_transmeta()) {
/* Transmeta might have masked feature bits in word 0 */
struct msr m, m_tmp;
u32 level = 1;
raw_rdmsr(0x80860004, &m);
m_tmp = m;
m_tmp.l = ~0;
raw_wrmsr(0x80860004, &m_tmp);
asm("cpuid"
: "+a" (level), "=d" (cpu.flags[0])
: : "ecx", "ebx");
raw_wrmsr(0x80860004, &m);
err = check_cpuflags();
} else if (err == 0x01 &&
!(err_flags[0] & ~(1 << X86_FEATURE_PAE)) &&
is_intel() && cpu.level == 6 &&
(cpu.model == 9 || cpu.model == 13)) {
/* PAE is disabled on this Pentium M but can be forced */
if (cmdline_find_option_bool("forcepae")) {
puts("WARNING: Forcing PAE in CPU flags\n");
set_bit(X86_FEATURE_PAE, cpu.flags);
err = check_cpuflags();
}
else {
puts("WARNING: PAE disabled. Use parameter 'forcepae' to enable at your own risk!\n");
}
}
if (!err)
err = check_knl_erratum();
if (err_flags_ptr)
*err_flags_ptr = err ? err_flags : NULL;
if (cpu_level_ptr)
*cpu_level_ptr = cpu.level;
if (req_level_ptr)
*req_level_ptr = req_level;
return (cpu.level < req_level || err) ? -1 : 0;
}
int check_knl_erratum(void)
{
/*
* First check for the affected model/family:
*/
if (!is_intel() ||
cpu.family != 6 ||
cpu.model != 0x57 /*INTEL_XEON_PHI_KNL*/)
return 0;
/*
* This erratum affects the Accessed/Dirty bits, and can
* cause stray bits to be set in !Present PTEs. We have
* enough bits in our 64-bit PTEs (which we have on real
* 64-bit mode or PAE) to avoid using these troublesome
* bits. But, we do not have enough space in our 32-bit
* PTEs. So, refuse to run on 32-bit non-PAE kernels.
*/
if (IS_ENABLED(CONFIG_X86_64) || IS_ENABLED(CONFIG_X86_PAE))
return 0;
Annotation
- Immediate include surface: `boot.h`, `linux/types.h`, `asm/cpufeaturemasks.h`, `asm/intel-family.h`, `asm/processor-flags.h`, `asm/msr-index.h`, `asm/shared/msr.h`, `string.h`.
- Detected declarations: `function is_amd`, `function is_centaur`, `function is_transmeta`, `function is_intel`, `function check_cpuflags`, `function check_cpu`, `function is_centaur`, `function is_intel`, `function check_knl_erratum`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.