arch/x86/mm/pkeys.c
Source file repositories/reference/linux-study-clean/arch/x86/mm/pkeys.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/mm/pkeys.c- Extension
.c- Size
- 5442 bytes
- Lines
- 197
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/mm_types.hlinux/pkeys.huapi/asm-generic/mman-common.hasm/cpufeature.hasm/mmu_context.h
Detected Declarations
function Copyrightfunction vma_is_pkey_exec_onlyfunction __arch_override_mprotect_pkeyfunction init_pkru_read_filefunction init_pkru_write_filefunction create_init_pkru_valuefunction setup_init_pkru
Annotated Snippet
static const struct file_operations fops_init_pkru = {
.read = init_pkru_read_file,
.write = init_pkru_write_file,
.llseek = default_llseek,
};
static int __init create_init_pkru_value(void)
{
/* Do not expose the file if pkeys are not supported. */
if (!cpu_feature_enabled(X86_FEATURE_OSPKE))
return 0;
debugfs_create_file("init_pkru", S_IRUSR | S_IWUSR,
arch_debugfs_dir, NULL, &fops_init_pkru);
return 0;
}
late_initcall(create_init_pkru_value);
static __init int setup_init_pkru(char *opt)
{
u32 new_init_pkru;
if (kstrtouint(opt, 0, &new_init_pkru))
return 1;
WRITE_ONCE(init_pkru_value, new_init_pkru);
return 1;
}
__setup("init_pkru=", setup_init_pkru);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/mm_types.h`, `linux/pkeys.h`, `uapi/asm-generic/mman-common.h`, `asm/cpufeature.h`, `asm/mmu_context.h`.
- Detected declarations: `function Copyright`, `function vma_is_pkey_exec_only`, `function __arch_override_mprotect_pkey`, `function init_pkru_read_file`, `function init_pkru_write_file`, `function create_init_pkru_value`, `function setup_init_pkru`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.