arch/loongarch/kernel/syscall.c
Source file repositories/reference/linux-study-clean/arch/loongarch/kernel/syscall.c
File Facts
- System
- Linux kernel
- Corpus path
arch/loongarch/kernel/syscall.c- Extension
.c- Size
- 2272 bytes
- Lines
- 85
- Domain
- Architecture Layer
- Bucket
- arch/loongarch
- 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/capability.hlinux/entry-common.hlinux/errno.hlinux/linkage.hlinux/nospec.hlinux/objtool.hlinux/randomize_kstack.hlinux/syscalls.hlinux/unistd.hasm/asm.hasm/exception.hasm/loongarch.hasm/signal.hasm/switch_to.hasm-generic/syscalls.hasm/syscall_table_32.hasm/syscall_table_64.h
Detected Declarations
syscall mmapsyscall mmap2function Copyrightfunction do_syscall
Annotated Snippet
SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len, unsigned long,
prot, unsigned long, flags, unsigned long, fd, unsigned long, offset)
{
if (offset & ~PAGE_MASK)
return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd, offset >> PAGE_SHIFT);
}
SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, unsigned long,
prot, unsigned long, flags, unsigned long, fd, unsigned long, offset)
{
if (offset & (~PAGE_MASK >> 12))
return -EINVAL;
return ksys_mmap_pgoff(addr, len, prot, flags, fd, offset >> (PAGE_SHIFT - 12));
}
void *sys_call_table[__NR_syscalls] = {
[0 ... __NR_syscalls - 1] = sys_ni_syscall,
#ifdef CONFIG_32BIT
#include <asm/syscall_table_32.h>
#else
#include <asm/syscall_table_64.h>
#endif
};
typedef long (*sys_call_fn)(unsigned long, unsigned long,
unsigned long, unsigned long, unsigned long, unsigned long);
void noinstr __no_stack_protector do_syscall(struct pt_regs *regs)
{
unsigned long nr;
sys_call_fn syscall_fn;
nr = regs->regs[11];
/* Set for syscall restarting */
if (nr < NR_syscalls)
regs->regs[0] = nr + 1;
regs->csr_era += 4;
regs->orig_a0 = regs->regs[4];
regs->regs[4] = -ENOSYS;
nr = syscall_enter_from_user_mode(regs, nr);
add_random_kstack_offset();
if (nr < NR_syscalls) {
syscall_fn = sys_call_table[array_index_nospec(nr, NR_syscalls)];
regs->regs[4] = syscall_fn(regs->orig_a0, regs->regs[5], regs->regs[6],
regs->regs[7], regs->regs[8], regs->regs[9]);
}
syscall_exit_to_user_mode(regs);
}
Annotation
- Immediate include surface: `linux/capability.h`, `linux/entry-common.h`, `linux/errno.h`, `linux/linkage.h`, `linux/nospec.h`, `linux/objtool.h`, `linux/randomize_kstack.h`, `linux/syscalls.h`.
- Detected declarations: `syscall mmap`, `syscall mmap2`, `function Copyright`, `function do_syscall`.
- Atlas domain: Architecture Layer / arch/loongarch.
- 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.