arch/x86/kernel/sys_x86_64.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/sys_x86_64.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/sys_x86_64.c- Extension
.c- Size
- 6315 bytes
- Lines
- 241
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: syscall or user/kernel boundary
- Status
- core 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 participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compat.hlinux/errno.hlinux/sched.hlinux/sched/mm.hlinux/syscalls.hlinux/mm.hlinux/fs.hlinux/smp.hlinux/sem.hlinux/msg.hlinux/shm.hlinux/stat.hlinux/mman.hlinux/file.hlinux/utsname.hlinux/personality.hlinux/random.hlinux/uaccess.hlinux/elf.hlinux/hugetlb.hasm/elf.hasm/ia32.h
Detected Declarations
syscall mmapfunction get_align_maskfunction vm_unmapped_areafunction control_va_addr_alignmentfunction find_start_endfunction stack_guard_placementfunction arch_get_unmapped_areafunction arch_get_unmapped_area_topdown
Annotated Snippet
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags,
unsigned long, fd, unsigned long, off)
{
if (off & ~PAGE_MASK)
return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd, off >> PAGE_SHIFT);
}
static void find_start_end(unsigned long addr, unsigned long flags,
unsigned long *begin, unsigned long *end)
{
if (!in_32bit_syscall() && (flags & MAP_32BIT)) {
/* This is usually used needed to map code in small
model, so it needs to be in the first 31bit. Limit
it to that. This means we need to move the
unmapped base down for this case. This can give
conflicts with the heap, but we assume that glibc
malloc knows how to fall back to mmap. Give it 1GB
of playground for now. -AK */
*begin = 0x40000000;
*end = 0x80000000;
if (current->flags & PF_RANDOMIZE) {
*begin = randomize_page(*begin, 0x02000000);
}
return;
}
*begin = get_mmap_base(1);
if (in_32bit_syscall())
*end = task_size_32bit();
else
*end = task_size_64bit(addr > DEFAULT_MAP_WINDOW);
}
static inline unsigned long stack_guard_placement(vm_flags_t vm_flags)
{
if (vm_flags & VM_SHADOW_STACK)
return PAGE_SIZE;
return 0;
}
unsigned long
arch_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len,
unsigned long pgoff, unsigned long flags, vm_flags_t vm_flags)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
struct vm_unmapped_area_info info = {};
unsigned long begin, end;
if (flags & MAP_FIXED)
return addr;
find_start_end(addr, flags, &begin, &end);
if (len > end)
return -ENOMEM;
if (addr) {
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (end - len >= addr &&
(!vma || addr + len <= vm_start_gap(vma)))
return addr;
}
info.length = len;
info.low_limit = begin;
info.high_limit = end;
if (!(filp && is_file_hugepages(filp))) {
info.align_offset = pgoff << PAGE_SHIFT;
info.start_gap = stack_guard_placement(vm_flags);
}
if (filp) {
info.align_mask = get_align_mask(filp);
info.align_offset += get_align_bits();
}
return vm_unmapped_area(&info);
}
unsigned long
arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr0,
unsigned long len, unsigned long pgoff,
unsigned long flags, vm_flags_t vm_flags)
{
struct vm_area_struct *vma;
Annotation
- Immediate include surface: `linux/compat.h`, `linux/errno.h`, `linux/sched.h`, `linux/sched/mm.h`, `linux/syscalls.h`, `linux/mm.h`, `linux/fs.h`, `linux/smp.h`.
- Detected declarations: `syscall mmap`, `function get_align_mask`, `function vm_unmapped_area`, `function control_va_addr_alignment`, `function find_start_end`, `function stack_guard_placement`, `function arch_get_unmapped_area`, `function arch_get_unmapped_area_topdown`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: core 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.