Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

score: add generic sys_call_table

This adds back a sys_call_table to the score architecture, which
got lost in the conversion to the generic unistd.h file.
It's rather worrying that the code got submitted without a
system call table, which evidently means that it got zero
testing.

Since the system call table has a different layout from the old
one (which was modeled after the mips-o32 one), I also try to
fix the entry.S path to use it. In the modified calling conventions,
all system call arguments are passed as registers r4 through r9,
instead of r4 through r7 plus stack for the fifth and sixth argument.

This matches what other architectures to when they normally pass
arguments on the stack.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

+18 -53
+2 -1
arch/score/kernel/Makefile
··· 5 5 extra-y := head.o vmlinux.lds 6 6 7 7 obj-y += entry.o init_task.o irq.o process.o ptrace.o \ 8 - setup.o signal.o sys_score.o time.o traps.o 8 + setup.o signal.o sys_score.o time.o traps.o \ 9 + sys_call_table.o 9 10 10 11 obj-$(CONFIG_MODULES) += module.o
+3 -44
arch/score/kernel/entry.S
··· 400 400 sw r4, [r0, PT_ORIG_R4] #for restart syscall 401 401 sw r7, [r0, PT_ORIG_R7] #for restart syscall 402 402 sw r27, [r0, PT_IS_SYSCALL] # it from syscall 403 + sw r8, [r0, 16] # argument 5 from user r8 404 + sw r9, [r0, 20] # argument 6 from user r9 403 405 404 406 lw r9, [r0, PT_EPC] # skip syscall on return 405 407 addi r9, 4 ··· 410 408 cmpi.c r27, __NR_syscalls # check syscall number 411 409 bgtu illegal_syscall 412 410 413 - slli r8, r27, 3 # get syscall routine 411 + slli r8, r27, 2 # get syscall routine 414 412 la r11, sys_call_table 415 413 add r11, r11, r8 416 414 lw r10, [r11] # get syscall entry 417 - lw r11, [r11, 4] # get number of args 418 415 419 416 cmpz.c r10 420 417 beq illegal_syscall 421 418 422 - cmpi.c r11, 4 # more than 4 arguments? 423 - bgtu stackargs 424 - 425 - stack_done: 426 419 lw r8, [r28, TI_FLAGS] 427 420 li r9, _TIF_SYSCALL_TRACE 428 421 and.c r8, r8, r9 ··· 471 474 # restarting 472 475 1: sw r4, [r0, PT_R2] # result 473 476 j syscall_exit 474 - 475 - stackargs: 476 - lw r8, [r0, PT_R0] 477 - andri.c r9, r8, 3 # test whether user sp is align a word 478 - bne bad_stack 479 - subi r11, 5 480 - slli r9, r11, 2 481 - add.c r9, r9, r8 482 - 483 - bmi bad_stack 484 - la r9, 3f # calculate branch address 485 - slli r11, r11, 3 486 - sub r9, r9, r11 487 - br r9 488 - 489 - 2: lw r9, [r8, 20] # argument 6 from usp 490 - sw r9, [r0, 20] 491 - 492 - 3: lw r9, [r8, 16] # argument 5 from usp 493 - sw r9, [r0, 16] 494 - j stack_done 495 - 496 - .section __ex_table,"a" 497 - .word 2b, bad_stack 498 - .word 3b, bad_stack 499 - .previous 500 - 501 - /* 502 - * The stackpointer for a call with more than 4 arguments is bad. 503 - * We probably should handle this case a bit more drastic. 504 - */ 505 - bad_stack: 506 - neg r27, r27 # error 507 - sw r27, [r0, PT_ORIG_R4] 508 - sw r27, [r0, PT_R4] 509 - ldi r8, 1 # set error flag 510 - sw r8, [r0, PT_R7] 511 - j syscall_return 512 477 513 478 illegal_syscall: 514 479 ldi r4, -ENOSYS # error
+12
arch/score/kernel/sys_call_table.c
··· 1 + #include <linux/syscalls.h> 2 + #include <linux/signal.h> 3 + #include <linux/unistd.h> 4 + 5 + #include <asm/syscalls.h> 6 + 7 + #undef __SYSCALL 8 + #define __SYSCALL(nr, call) [nr] = (call), 9 + 10 + void *sys_call_table[__NR_syscalls] = { 11 + #include <asm/unistd.h> 12 + };
+1 -8
arch/score/kernel/sys_score.c
··· 75 75 if (!newsp) 76 76 newsp = regs->regs[0]; 77 77 parent_tidptr = (int __user *)regs->regs[6]; 78 - 79 - child_tidptr = NULL; 80 - if (clone_flags & (CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID)) { 81 - int __user *__user *usp = (int __user *__user *)regs->regs[0]; 82 - 83 - if (get_user(child_tidptr, &usp[4])) 84 - return -EFAULT; 85 - } 78 + child_tidptr = (int __user *)regs->regs[8]; 86 79 87 80 return do_fork(clone_flags, newsp, regs, 0, 88 81 parent_tidptr, child_tidptr);