1. 13 Feb, 2021 1 commit
    • Tiezhu Yang's avatar
      MIPS: Add basic support for ptrace single step · 7c86ff99
      Tiezhu Yang authored
      In the current code, arch_has_single_step() is not defined on MIPS,
      that means MIPS does not support instruction single-step for user mode.
      
      Delve is a debugger for the Go programming language, the ptrace syscall
      PtraceSingleStep() failed [1] on MIPS and then the single step function
      can not work well, we can see that PtraceSingleStep() definition returns
      ptrace(PTRACE_SINGLESTEP) [2].
      
      So it is necessary to support ptrace single step on MIPS.
      
      At the beginning, we try to use the Debug Single Step exception on the
      Loongson 3A4000 platform, but it has no effect when set CP0_DEBUG SSt
      bit, this is because CP0_DEBUG NoSSt bit is 1 which indicates no
      single-step feature available [3], so this way which is dependent on the
      hardware is almost impossible.
      
      With further research, we find out there exists a common way used with
      break instruction in arch/alpha/kernel/ptrace.c, it is workable.
      
      For the above analysis, define arch_has_single_step(), add the common
      function user_enable_single_step() and user_disable_single_step(), set
      flag TIF_SINGLESTEP for child process, use break instruction to set
      breakpoint.
      
      We can use the following testcase to test it:
      tools/testing/selftests/breakpoints/step_after_suspend_test.c
      
       $ make -C tools/testing/selftests TARGETS=breakpoints
       $ cd tools/testing/selftests/breakpoints
      
      Without this patch:
      
       $ ./step_after_suspend_test -n
       TAP version 13
       1..4
       # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output error
       ok 1 # SKIP CPU 0
       # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output error
       ok 2 # SKIP CPU 1
       # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output error
       ok 3 # SKIP CPU 2
       # ptrace(PTRACE_SINGLESTEP) not supported on this architecture: Input/output error
       ok 4 # SKIP CPU 3
       # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:4 error:0
      
      With this patch:
      
       $ ./step_after_suspend_test -n
       TAP version 13
       1..4
       ok 1 CPU 0
       ok 2 CPU 1
       ok 3 CPU 2
       ok 4 CPU 3
       # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
      
      [1] https://github.com/go-delve/delve/blob/master/pkg/proc/native/threads_linux.go#L50
      [2] https://github.com/go-delve/delve/blob/master/vendor/golang.org/x/sys/unix/syscall_linux.go#L1573
      [3] http://www.t-es-t.hu/download/mips/md00047f.pdfReported-by: default avatarGuoqi Chen <chenguoqi@loongson.cn>
      Signed-off-by: default avatarXingxing Su <suxingxing@loongson.cn>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarThomas Bogendoerfer <tsbogend@alpha.franken.de>
      7c86ff99
  2. 11 Feb, 2021 3 commits
  3. 09 Feb, 2021 7 commits
  4. 04 Feb, 2021 9 commits
  5. 03 Feb, 2021 4 commits
  6. 27 Jan, 2021 6 commits
  7. 25 Jan, 2021 6 commits
  8. 22 Jan, 2021 4 commits