Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
9606de3
Documentation
arch
alpha
arc
arm
arm64
avr32
blackfin
c6x
cris
frv
h8300
hexagon
ia64
m32r
m68k
metag
microblaze
mips
alchemy
ar7
ath25
ath79
bcm47xx
bcm63xx
bmips
boot
cavium-octeon
cobalt
configs
dec
emma
fw
generic
include
jazz
jz4740
kernel
.gitignore
8250-platform.c
Makefile
asm-offsets.c
binfmt_elfn32.c
binfmt_elfo32.c
bmips_5xxx_init.S
bmips_vec.S
branch.c
cacheinfo.c
cevt-bcm1480.c
cevt-ds1287.c
cevt-gt641xx.c
cevt-r4k.c
cevt-sb1250.c
cevt-txx9.c
cps-vec-ns16550.S
cps-vec.S
cpu-bugs64.c
cpu-probe.c
crash.c
crash_dump.c
csrc-bcm1480.c
csrc-ioasic.c
csrc-r4k.c
csrc-sb1250.c
early_printk.c
early_printk_8250.c
elf.c
entry.S
ftrace.c
genex.S
gpio_txx9.c
head.S
i8253.c
idle.c
irq-gt641xx.c
irq-msc01.c
irq-rm7000.c
irq.c
irq_txx9.c
jump_label.c
kgdb.c
kprobes.c
linux32.c
machine_kexec.c
mcount.S
mips-cm.c
mips-cpc.c
mips-mt-fpaff.c
mips-mt.c
mips-r2-to-r6-emul.c
mips_machine.c
module-rela.c
module.c
octeon_switch.S
perf_event.c
perf_event_mipsxx.c
pm-cps.c
pm.c
probes-common.h
proc.c
process.c
prom.c
ptrace.c
ptrace32.c
r2300_fpu.S
r2300_switch.S
r4k_fpu.S
r4k_switch.S
r6000_fpu.S
relocate.c
relocate_kernel.S
reset.c
rtlx-cmp.c
rtlx-mt.c
rtlx.c
scall32-o32.S
scall64-64.S
scall64-n32.S
scall64-o32.S
segment.c
setup.c
signal-common.h
signal.c
signal32.c
signal_n32.c
signal_o32.c
smp-bmips.c
smp-cmp.c
smp-cps.c
smp-mt.c
smp-up.c
smp.c
spinlock_test.c
spram.c
stacktrace.c
sync-r4k.c
syscall.c
sysrq.c
time.c
topology.c
traps.c
unaligned.c
uprobes.c
vdso.c
vmlinux.lds.S
vpe-cmp.c
vpe-mt.c
vpe.c
watch.c
kvm
lantiq
lasat
lib
loongson32
loongson64
math-emu
mm
mti-malta
net
netlogic
oprofile
paravirt
pci
pic32
pistachio
pmcs-msp71xx
pnx833x
power
ralink
rb532
sgi-ip22
sgi-ip27
sgi-ip32
sibyte
sni
txx9
vdso
vr41xx
xilfpga
Kbuild
Kbuild.platforms
Kconfig
Kconfig.debug
Makefile
Makefile.postlink
mn10300
nios2
openrisc
parisc
powerpc
s390
score
sh
sparc
tile
um
unicore32
x86
xtensa
.gitignore
Kconfig
block
certs
crypto
drivers
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
arch
/
mips
/
kernel
/
syscall.c
Copy path
Blame
Blame
Latest commit
Wei Yongjun
and
James Hogan
MIPS: sysmips: Remove duplicated include from syscall.c
Feb 14, 2017
9606de3
·
Feb 14, 2017
History
History
238 lines (212 loc) · 5.32 KB
Breadcrumbs
linux
/
arch
/
mips
/
kernel
/
syscall.c
Top
File metadata and controls
Code
Blame
238 lines (212 loc) · 5.32 KB
Raw
/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 1995, 1996, 1997, 2000, 2001, 05 by Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 2001 MIPS Technologies, Inc. */ #include <linux/capability.h> #include <linux/errno.h> #include <linux/linkage.h> #include <linux/fs.h> #include <linux/smp.h> #include <linux/ptrace.h> #include <linux/string.h> #include <linux/syscalls.h> #include <linux/file.h> #include <linux/utsname.h> #include <linux/unistd.h> #include <linux/sem.h> #include <linux/msg.h> #include <linux/shm.h> #include <linux/compiler.h> #include <linux/ipc.h> #include <linux/uaccess.h> #include <linux/slab.h> #include <linux/elf.h> #include <asm/asm.h> #include <asm/branch.h> #include <asm/cachectl.h> #include <asm/cacheflush.h> #include <asm/asm-offsets.h> #include <asm/signal.h> #include <asm/sim.h> #include <asm/shmparam.h> #include <asm/sysmips.h> #include <asm/switch_to.h> /* * For historic reasons the pipe(2) syscall on MIPS has an unusual calling * convention. It returns results in registers $v0 / $v1 which means there * is no need for it to do verify the validity of a userspace pointer * argument. Historically that used to be expensive in Linux. These days * the performance advantage is negligible. */ asmlinkage int sysm_pipe(void) { int fd[2]; int error = do_pipe_flags(fd, 0); if (error) return error; current_pt_regs()->regs[3] = fd[1]; return fd[0]; } 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 sys_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 sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> (PAGE_SHIFT-12)); } save_static_function(sys_fork); save_static_function(sys_clone); 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(VERIFY_WRITE, addr, 4))) return -EINVAL; if (cpu_has_llsc && R10000_LLSC_WAR) { __asm__ __volatile__ ( " .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)" 1b, 4b \n" " "STR(PTR)" 2b, 4b \n" " .previous \n" " .set mips0 \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 "MIPS_ISA_ARCH_LEVEL" \n" " li %[err], 0 \n" "1: ll %[old], (%[addr]) \n" " move %[tmp], %[new] \n" "2: sc %[tmp], (%[addr]) \n" " bnez %[tmp], 4f \n" "3: \n" " .insn \n" " .subsection 2 \n" "4: b 1b \n" " .previous \n" " \n" " .section .fixup,\"ax\" \n" "5: li %[err], %[efault] \n" " j 3b \n" " .previous \n" " .section __ex_table,\"a\" \n" " "STR(PTR)" 1b, 5b \n" " "STR(PTR)" 2b, 5b \n" " .previous \n" " .set mips0 \n" : [old] "=&r" (old), [err] "=&r" (err), [tmp] "=&r" (tmp) : [addr] "r" (addr), [new] "r" (new), [efault] "i" (-EFAULT) : "memory"); } else { do { preempt_disable(); ll_bit = 1; ll_task = current; preempt_enable(); err = __get_user(old, (unsigned int *) addr); err |= __put_user(new, (unsigned int *) addr); if (err) break; rmb(); } while (!ll_bit); } if (unlikely(err)) return err; regs = current_pt_regs(); regs->regs[2] = old; regs->regs[7] = 0; /* No error */ /* * Don't let your children do this ... */ __asm__ __volatile__( " move $29, %0 \n" " j syscall_exit \n" : /* no outputs */ : "r" (regs)); /* unreached. Honestly. */ unreachable(); } SYSCALL_DEFINE3(sysmips, long, cmd, long, arg1, long, arg2) { switch (cmd) { case MIPS_ATOMIC_SET: return mips_atomic_set(arg1, arg2); case MIPS_FIXADE: if (arg1 & ~3) return -EINVAL; if (arg1 & 1) set_thread_flag(TIF_FIXADE); else clear_thread_flag(TIF_FIXADE); if (arg1 & 2) set_thread_flag(TIF_LOGADE); else clear_thread_flag(TIF_LOGADE); return 0; case FLUSH_CACHE: __flush_cache_all(); return 0; } return -EINVAL; } /* * No implemented yet ... */ SYSCALL_DEFINE3(cachectl, char *, addr, int, nbytes, int, op) { return -ENOSYS; } /* * If we ever come here the user sp is bad. Zap the process right away. * Due to the bad stack signaling wouldn't work. */ asmlinkage void bad_stack(void) { do_exit(SIGSEGV); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
You can’t perform that action at this time.