]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
csky: Use in_syscall & forget_syscall instead of r11_sig
authorGuo Ren <ren_guo@c-sky.com>
Sat, 30 Mar 2019 15:44:34 +0000 (23:44 +0800)
committerGuo Ren <ren_guo@c-sky.com>
Mon, 22 Apr 2019 05:44:57 +0000 (13:44 +0800)
We could use regs->sr 16-24 bits to detect syscall: VEC_TRAP0 and
r11_sig is no necessary for current implementation.

In this patch, we implement the in_syscall and forget_syscall which are
inspired from arm & nds32, but csky pt_regs has no syscall_num element
and we just set zero to regs->sr's vector-bits-field instead.

For ret_from_fork, current task was forked from parent which is in syscall
progress and its regs->sr has been already setted with VEC_TRAP0. See:
arch/csky/kernel/process.c: copy_thread()

Signed-off-by: Guo Ren <ren_guo@c-sky.com>
arch/csky/abiv1/inc/abi/regdef.h
arch/csky/abiv2/inc/abi/regdef.h
arch/csky/include/asm/ptrace.h
arch/csky/kernel/entry.S
arch/csky/kernel/signal.c

index 876689291b716802f3a38f29af12ac69ad807c66..9e7e692dd271d3a8b091537778aacbff5e789b25 100644 (file)
@@ -5,8 +5,6 @@
 #define __ASM_CSKY_REGDEF_H
 
 #define syscallid      r1
-#define r11_sig                r11
-
 #define regs_syscallid(regs) regs->regs[9]
 
 /*
index c72abb781bdc4c1e43a20c2611e13df4f6b9ca53..652f5ce4c3dd566cc6a61da8e6f7fc86d5285e8d 100644 (file)
@@ -5,8 +5,6 @@
 #define __ASM_CSKY_REGDEF_H
 
 #define syscallid      r7
-#define r11_sig                r11
-
 #define regs_syscallid(regs) regs->regs[3]
 
 /*
index 1e00578166f09485de58ee3b797f8bcbdded2809..d0aba7b32417a021bff332992d02d8b587f3fa41 100644 (file)
@@ -5,6 +5,8 @@
 #define __ASM_CSKY_PTRACE_H
 
 #include <uapi/asm/ptrace.h>
+#include <asm/traps.h>
+#include <linux/types.h>
 
 #ifndef __ASSEMBLY__
 
 #define instruction_pointer(regs) ((regs)->pc)
 #define profile_pc(regs) instruction_pointer(regs)
 
+static inline bool in_syscall(struct pt_regs const *regs)
+{
+       return ((regs->sr >> 16) & 0xff) == VEC_TRAP0;
+}
+
+static inline void forget_syscall(struct pt_regs *regs)
+{
+       regs->sr &= ~(0xff << 16);
+}
+
 static inline unsigned long regs_return_value(struct pt_regs *regs)
 {
        return regs->a0;
index ecc6e7d2e95d8f5bb91348ac3483036b3627c075..b3b3b0bbfcc7ec4996ae192290577b4fec16712a 100644 (file)
@@ -99,7 +99,6 @@ ENTRY(csky_\name)
        mov     a0, sp
        movi    a1, \is_write
        jbsr    do_page_fault
-       movi    r11_sig, 0             /* r11 = 0, Not a syscall. */
        jmpi    ret_from_exception
 .endm
 
@@ -189,7 +188,6 @@ ENTRY(ret_from_fork)
        bmaski  r10, THREAD_SHIFT
        andn    r9, r10
        ldw     r8, (r9, TINFO_FLAGS)
-       movi    r11_sig, 1
        ANDI_R3 r8, (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_SYSCALL_AUDIT)
        cmpnei  r8, 0
        bf      3f
@@ -224,12 +222,8 @@ exit_work:
        /* If thread_info->flag is empty, RESTORE_ALL */
        cmpnei  r8, 0
        bf      1b
-       mov     a1, sp
        mov     a0, r8
-       mov     a2, r11_sig             /* syscall? */
-       btsti   r8, TIF_SIGPENDING      /* delivering a signal? */
-       /* prevent further restarts(set r11 = 0) */
-       clrt    r11_sig
+       mov     a1, sp
        jbsr    do_notify_resume        /* do signals */
        br      resume_userspace
 
@@ -239,13 +233,11 @@ work_resched:
        jmpi    schedule
 
 ENTRY(sys_rt_sigreturn)
-       movi    r11_sig, 0
        jmpi    do_rt_sigreturn
 
 ENTRY(csky_trap)
        SAVE_ALL EPC_KEEP
        psrset  ee
-       movi    r11_sig, 0             /* r11 = 0, Not a syscall. */
        mov     a0, sp                 /* Push Stack pointer arg */
        jbsr    trap_c                 /* Call C-level trap handler */
        jmpi    ret_from_exception
@@ -279,7 +271,6 @@ ENTRY(csky_get_tls)
 ENTRY(csky_irq)
        SAVE_ALL EPC_KEEP
        psrset  ee
-       movi    r11_sig, 0              /* r11 = 0, Not a syscall. */
 
 #ifdef CONFIG_PREEMPT
        mov     r9, sp                  /* Get current stack  pointer */
index 207a891479d26e63100ea88c7665a673a6574f62..5a18940f0b09ce10da21aa664dbd8e6549c7b262 100644 (file)
@@ -224,7 +224,7 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs)
  * that the kernel can handle, and then we build all the user-level signal
  * handling stack-frames in one go after that.
  */
-static void do_signal(struct pt_regs *regs, int syscall)
+static void do_signal(struct pt_regs *regs)
 {
        unsigned int retval = 0, continue_addr = 0, restart_addr = 0;
        struct ksignal ksig;
@@ -241,7 +241,9 @@ static void do_signal(struct pt_regs *regs, int syscall)
        /*
         * If we were from a system call, check for system call restarting...
         */
-       if (syscall) {
+       if (in_syscall(regs)) {
+               forget_syscall(regs);
+
                continue_addr = regs->pc;
 #if defined(__CSKYABIV2__)
                restart_addr = continue_addr - 4;
@@ -249,7 +251,6 @@ static void do_signal(struct pt_regs *regs, int syscall)
                restart_addr = continue_addr - 2;
 #endif
                retval = regs->a0;
-
                /*
                 * Prepare for system call restart.  We do this here so that a
                 * debugger will see the already changed.
@@ -304,7 +305,9 @@ static void do_signal(struct pt_regs *regs, int syscall)
        }
 
 no_signal:
-       if (syscall) {
+       if (in_syscall(regs)) {
+               forget_syscall(regs);
+
                /*
                 * Handle restarting a different system call.  As above,
                 * if a debugger has chosen to restart at a different PC,
@@ -333,10 +336,10 @@ static void do_signal(struct pt_regs *regs, int syscall)
 }
 
 asmlinkage void
-do_notify_resume(unsigned int thread_flags, struct pt_regs *regs, int syscall)
+do_notify_resume(unsigned int thread_flags, struct pt_regs *regs)
 {
        if (thread_flags & _TIF_SIGPENDING)
-               do_signal(regs, syscall);
+               do_signal(regs);
 
        if (thread_flags & _TIF_NOTIFY_RESUME) {
                clear_thread_flag(TIF_NOTIFY_RESUME);