Re: [PATCH v3 26/29] nios2: ptrace support
On Tue, Sep 16, 2014 at 5:43 PM, Tobias Klauser wrote: > > This could be simplified to: > > long arch_ptrace(struct task_struct *child, long request, unsigned long addr, > unsigned long data) > { > return ptrace_request(child, request, addr, data); > } Okay, will change this. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v3 26/29] nios2: ptrace support
On 2014-09-08 at 11:22:37 +0200, Ley Foon Tan wrote: > Add ptrace support for nios2. > > Signed-off-by: Ley Foon Tan > --- > arch/nios2/include/asm/ptrace.h | 33 +++ > arch/nios2/include/uapi/asm/ptrace.h | 120 > arch/nios2/kernel/ptrace.c | 176 > +++ > 3 files changed, 329 insertions(+) > create mode 100644 arch/nios2/include/asm/ptrace.h > create mode 100644 arch/nios2/include/uapi/asm/ptrace.h > create mode 100644 arch/nios2/kernel/ptrace.c [...] > diff --git a/arch/nios2/kernel/ptrace.c b/arch/nios2/kernel/ptrace.c > new file mode 100644 > index 000..bcbf748 > --- /dev/null > +++ b/arch/nios2/kernel/ptrace.c [...] > +long arch_ptrace(struct task_struct *child, long request, unsigned long addr, > + unsigned long data) > +{ > + int ret = -EIO; > + > + pr_debug("REQ=%ld: ADDR =0x%lx, DATA=0x%lx)\n", request, addr, data); > + > + switch (request) { > + default: > + ret = ptrace_request(child, request, addr, data); > + break; > + } > + > + return ret; > +} This could be simplified to: long arch_ptrace(struct task_struct *child, long request, unsigned long addr, unsigned long data) { return ptrace_request(child, request, addr, data); } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v3 26/29] nios2: ptrace support
Add ptrace support for nios2. Signed-off-by: Ley Foon Tan --- arch/nios2/include/asm/ptrace.h | 33 +++ arch/nios2/include/uapi/asm/ptrace.h | 120 arch/nios2/kernel/ptrace.c | 176 +++ 3 files changed, 329 insertions(+) create mode 100644 arch/nios2/include/asm/ptrace.h create mode 100644 arch/nios2/include/uapi/asm/ptrace.h create mode 100644 arch/nios2/kernel/ptrace.c diff --git a/arch/nios2/include/asm/ptrace.h b/arch/nios2/include/asm/ptrace.h new file mode 100644 index 000..20fb1cf --- /dev/null +++ b/arch/nios2/include/asm/ptrace.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2013 Altera Corporation + * Copyright (C) 2010 Tobias Klauser + * Copyright (C) 2004 Microtronix Datacom Ltd + * + * based on m68k asm/processor.h + * + * 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. + */ + +#ifndef _ASM_NIOS2_PTRACE_H +#define _ASM_NIOS2_PTRACE_H + +#include + +#ifndef __ASSEMBLY__ +#define user_mode(regs)(((regs)->estatus & ESTATUS_EU)) + +#define instruction_pointer(regs) ((regs)->ra) +#define profile_pc(regs) instruction_pointer(regs) +#define user_stack_pointer(regs) ((regs)->sp) +extern void show_regs(struct pt_regs *); + +#define current_pt_regs() \ + ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\ + - 1) + +int do_syscall_trace_enter(void); +void do_syscall_trace_exit(void); +#endif /* __ASSEMBLY__ */ +#endif /* _ASM_NIOS2_PTRACE_H */ diff --git a/arch/nios2/include/uapi/asm/ptrace.h b/arch/nios2/include/uapi/asm/ptrace.h new file mode 100644 index 000..e83a7c9 --- /dev/null +++ b/arch/nios2/include/uapi/asm/ptrace.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2010 Tobias Klauser + * Copyright (C) 2004 Microtronix Datacom Ltd + * + * based on m68k asm/processor.h + * + * 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. + */ + +#ifndef _UAPI_ASM_NIOS2_PTRACE_H +#define _UAPI_ASM_NIOS2_PTRACE_H + +#ifndef __ASSEMBLY__ + +/* + * Register numbers used by 'ptrace' system call interface. + */ + +/* GP registers */ +#define PTR_R0 0 +#define PTR_R1 1 +#define PTR_R2 2 +#define PTR_R3 3 +#define PTR_R4 4 +#define PTR_R5 5 +#define PTR_R6 6 +#define PTR_R7 7 +#define PTR_R8 8 +#define PTR_R9 9 +#define PTR_R1010 +#define PTR_R1111 +#define PTR_R1212 +#define PTR_R1313 +#define PTR_R1414 +#define PTR_R1515 +#define PTR_R1616 +#define PTR_R1717 +#define PTR_R1818 +#define PTR_R1919 +#define PTR_R2020 +#define PTR_R2121 +#define PTR_R2222 +#define PTR_R2323 +#define PTR_R2424 +#define PTR_R2525 +#define PTR_GP 26 +#define PTR_SP 27 +#define PTR_FP 28 +#define PTR_EA 29 +#define PTR_BA 30 +#define PTR_RA 31 +/* Control registers */ +#define PTR_PC 32 +#define PTR_STATUS 33 +#define PTR_ESTATUS34 +#define PTR_BSTATUS35 +#define PTR_IENABLE36 +#define PTR_IPENDING 37 +#define PTR_CPUID 38 +#define PTR_CTL6 39 +#define PTR_CTL7 40 +#define PTR_PTEADDR41 +#define PTR_TLBACC 42 +#define PTR_TLBMISC43 + +#define NUM_PTRACE_REG (PTR_TLBMISC + 1) + +/* this struct defines the way the registers are stored on the + stack during a system call. + + There is a fake_regs in setup.c that has to match pt_regs.*/ + +struct pt_regs { + unsigned long r8; /* r8-r15 Caller-saved GP registers */ + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r1; /* Assembler temporary */ + unsigned long r2; /* Retval LS 32bits */ + unsigned long r3; /* Retval MS 32bits */ + unsigned long r4; /* r4-r7 Register arguments */ + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long orig_r2; /* Copy of r2 ?? */ + unsigned long ra; /* Return address */ + unsigned long fp; /* Frame pointer */ + unsigned long sp; /* Stack pointer */ + unsigned long gp; /* Global pointer */ + unsigned long estatus; + unsigned long ea; /* Exception return address (pc) */ + unsigned long orig_r7; +}; + +/* + * This i