arch/mips/kernel/syscall.c
Source file repositories/reference/linux-study-clean/arch/mips/kernel/syscall.c
File Facts
- System
- Linux kernel
- Corpus path
arch/mips/kernel/syscall.c- Extension
.c- Size
- 5678 bytes
- Lines
- 244
- Domain
- Architecture Layer
- Bucket
- arch/mips
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/capability.hlinux/errno.hlinux/linkage.hlinux/fs.hlinux/smp.hlinux/ptrace.hlinux/string.hlinux/syscalls.hlinux/file.hlinux/utsname.hlinux/unistd.hlinux/sem.hlinux/msg.hlinux/shm.hlinux/compiler.hlinux/ipc.hlinux/uaccess.hlinux/slab.hlinux/elf.hlinux/sched/task_stack.hasm/asm.hasm/asm-eva.hasm/branch.hasm/cachectl.hasm/cacheflush.hasm/asm-offsets.hasm/signal.hasm/sim.hasm/shmparam.hasm/sync.hasm/sysmips.hasm/syscalls.h
Detected Declarations
syscall mips_mmapsyscall mips_mmap2syscall set_thread_areasyscall sysmipssyscall cachectlfunction Copyrightfunction mips_atomic_set
Annotated Snippet
SYSCALL_DEFINE6(mips_mmap, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags, unsigned long,
fd, off_t, offset)
{
if (offset & ~PAGE_MASK)
return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd,
offset >> PAGE_SHIFT);
}
SYSCALL_DEFINE6(mips_mmap2, unsigned long, addr, unsigned long, len,
unsigned long, prot, unsigned long, flags, unsigned long, fd,
unsigned long, pgoff)
{
if (pgoff & (~PAGE_MASK >> 12))
return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd,
pgoff >> (PAGE_SHIFT - 12));
}
save_static_function(sys_fork);
save_static_function(sys_clone);
save_static_function(sys_clone3);
SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
{
struct thread_info *ti = task_thread_info(current);
ti->tp_value = addr;
if (cpu_has_userlocal)
write_c0_userlocal(addr);
return 0;
}
static inline int mips_atomic_set(unsigned long addr, unsigned long new)
{
unsigned long old, tmp;
struct pt_regs *regs;
unsigned int err;
if (unlikely(addr & 3))
return -EINVAL;
if (unlikely(!access_ok((const void __user *)addr, 4)))
return -EINVAL;
if (cpu_has_llsc && IS_ENABLED(CONFIG_WAR_R10000_LLSC)) {
__asm__ __volatile__ (
" .set push \n"
" .set arch=r4000 \n"
" li %[err], 0 \n"
"1: ll %[old], (%[addr]) \n"
" move %[tmp], %[new] \n"
"2: sc %[tmp], (%[addr]) \n"
" beqzl %[tmp], 1b \n"
"3: \n"
" .insn \n"
" .section .fixup,\"ax\" \n"
"4: li %[err], %[efault] \n"
" j 3b \n"
" .previous \n"
" .section __ex_table,\"a\" \n"
" "STR(PTR_WD)" 1b, 4b \n"
" "STR(PTR_WD)" 2b, 4b \n"
" .previous \n"
" .set pop \n"
: [old] "=&r" (old),
[err] "=&r" (err),
[tmp] "=&r" (tmp)
: [addr] "r" (addr),
[new] "r" (new),
[efault] "i" (-EFAULT)
: "memory");
} else if (cpu_has_llsc) {
__asm__ __volatile__ (
" .set push \n"
" .set "MIPS_ISA_ARCH_LEVEL" \n"
" li %[err], 0 \n"
"1: \n"
" " __SYNC(full, loongson3_war) " \n"
user_ll("%[old]", "(%[addr])")
" move %[tmp], %[new] \n"
"2: \n"
user_sc("%[tmp]", "(%[addr])")
" beqz %[tmp], 1b \n"
"3: \n"
" .insn \n"
" .section .fixup,\"ax\" \n"
Annotation
- Immediate include surface: `linux/capability.h`, `linux/errno.h`, `linux/linkage.h`, `linux/fs.h`, `linux/smp.h`, `linux/ptrace.h`, `linux/string.h`, `linux/syscalls.h`.
- Detected declarations: `syscall mips_mmap`, `syscall mips_mmap2`, `syscall set_thread_area`, `syscall sysmips`, `syscall cachectl`, `function Copyright`, `function mips_atomic_set`.
- Atlas domain: Architecture Layer / arch/mips.
- 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.