arch/x86/kernel/ldt.c
Source file repositories/reference/linux-study-clean/arch/x86/kernel/ldt.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/kernel/ldt.c- Extension
.c- Size
- 17331 bytes
- Lines
- 697
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/gfp.hlinux/sched.hlinux/string.hlinux/mm.hlinux/smp.hlinux/syscalls.hlinux/slab.hlinux/vmalloc.hlinux/uaccess.hasm/ldt.hasm/tlb.hasm/desc.hasm/mmu_context.hasm/pgtable_areas.hxen/xen.h
Detected Declarations
syscall modify_ldtfunction Copyrightfunction load_mm_ldtfunction switch_ldtfunction refresh_ldt_segmentsfunction flush_ldtfunction do_sanity_checkfunction map_ldt_struct_to_userfunction sanity_check_ldt_mappingfunction map_ldt_struct_to_userfunction sanity_check_ldt_mappingfunction map_ldt_structfunction unmap_ldt_structfunction map_ldt_structfunction unmap_ldt_structfunction finalize_ldt_structfunction install_ldtfunction free_ldt_structfunction arch_dup_mmapfunction destroy_context_ldtfunction ldt_arch_exit_mmapfunction read_ldtfunction read_default_ldtfunction allow_16bit_segmentsfunction write_ldt
Annotated Snippet
SYSCALL_DEFINE3(modify_ldt, int , func , void __user * , ptr ,
unsigned long , bytecount)
{
int ret = -ENOSYS;
switch (func) {
case 0:
ret = read_ldt(ptr, bytecount);
break;
case 1:
ret = write_ldt(ptr, bytecount, 1);
break;
case 2:
ret = read_default_ldt(ptr, bytecount);
break;
case 0x11:
ret = write_ldt(ptr, bytecount, 0);
break;
}
/*
* The SYSCALL_DEFINE() macros give us an 'unsigned long'
* return type, but the ABI for sys_modify_ldt() expects
* 'int'. This cast gives us an int-sized value in %rax
* for the return code. The 'unsigned' is necessary so
* the compiler does not try to sign-extend the negative
* return codes into the high half of the register when
* taking the value from int->long.
*/
return (unsigned int)ret;
}
Annotation
- Immediate include surface: `linux/errno.h`, `linux/gfp.h`, `linux/sched.h`, `linux/string.h`, `linux/mm.h`, `linux/smp.h`, `linux/syscalls.h`, `linux/slab.h`.
- Detected declarations: `syscall modify_ldt`, `function Copyright`, `function load_mm_ldt`, `function switch_ldt`, `function refresh_ldt_segments`, `function flush_ldt`, `function do_sanity_check`, `function map_ldt_struct_to_user`, `function sanity_check_ldt_mapping`, `function map_ldt_struct_to_user`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: core implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.