arch/x86/include/asm/special_insns.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/special_insns.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/special_insns.h- Extension
.h- Size
- 7791 bytes
- Lines
- 309
- 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.
Dependency Surface
asm/nops.hasm/processor-flags.hlinux/errno.hlinux/irqflags.hlinux/jump_label.hasm/paravirt.h
Detected Declarations
function native_read_cr0function native_read_cr2function native_write_cr2function __native_read_cr3function native_write_cr3function native_read_cr4function rdpkrufunction wrpkrufunction rdpkrufunction wrpkrufunction wbnoinvdfunction __read_cr4function read_cr0function write_cr0function read_cr2function write_cr2function read_cr3_pafunction write_cr3function __write_cr4function clflushfunction clflushoptfunction clwbfunction write_user_shstk_64function serializefunction movdir64bfunction movdir64b_iofunction enqcmdsfunction tile_release
Annotated Snippet
#ifndef _ASM_X86_SPECIAL_INSNS_H
#define _ASM_X86_SPECIAL_INSNS_H
#ifdef __KERNEL__
#include <asm/nops.h>
#include <asm/processor-flags.h>
#include <linux/errno.h>
#include <linux/irqflags.h>
#include <linux/jump_label.h>
void native_write_cr0(unsigned long val);
static inline unsigned long native_read_cr0(void)
{
unsigned long val;
asm volatile("mov %%cr0,%0" : "=r" (val));
return val;
}
static __always_inline unsigned long native_read_cr2(void)
{
unsigned long val;
asm volatile("mov %%cr2,%0" : "=r" (val));
return val;
}
static __always_inline void native_write_cr2(unsigned long val)
{
asm volatile("mov %0,%%cr2": : "r" (val) : "memory");
}
static __always_inline unsigned long __native_read_cr3(void)
{
unsigned long val;
asm volatile("mov %%cr3,%0" : "=r" (val));
return val;
}
static __always_inline void native_write_cr3(unsigned long val)
{
asm volatile("mov %0,%%cr3": : "r" (val) : "memory");
}
static inline unsigned long native_read_cr4(void)
{
unsigned long val;
#ifdef CONFIG_X86_32
/*
* This could fault if CR4 does not exist. Non-existent CR4
* is functionally equivalent to CR4 == 0. Keep it simple and pretend
* that CR4 == 0 on CPUs that don't have CR4.
*/
asm volatile("1: mov %%cr4, %0\n"
"2:\n"
_ASM_EXTABLE(1b, 2b)
: "=r" (val) : "0" (0));
#else
/* CR4 always exists on x86_64. */
asm volatile("mov %%cr4,%0" : "=r" (val));
#endif
return val;
}
void native_write_cr4(unsigned long val);
#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
static inline u32 rdpkru(void)
{
u32 ecx = 0;
u32 edx, pkru;
/*
* "rdpkru" instruction. Places PKRU contents in to EAX,
* clears EDX and requires that ecx=0.
*/
asm volatile("rdpkru" : "=a" (pkru), "=d" (edx) : "c" (ecx));
return pkru;
}
static inline void wrpkru(u32 pkru)
{
u32 ecx = 0, edx = 0;
/*
* "wrpkru" instruction. Loads contents in EAX to PKRU,
* requires that ecx = edx = 0.
*/
asm volatile("wrpkru" : : "a" (pkru), "c"(ecx), "d"(edx));
}
Annotation
- Immediate include surface: `asm/nops.h`, `asm/processor-flags.h`, `linux/errno.h`, `linux/irqflags.h`, `linux/jump_label.h`, `asm/paravirt.h`.
- Detected declarations: `function native_read_cr0`, `function native_read_cr2`, `function native_write_cr2`, `function __native_read_cr3`, `function native_write_cr3`, `function native_read_cr4`, `function rdpkru`, `function wrpkru`, `function rdpkru`, `function wrpkru`.
- 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.