From cb67e161bc947ab467657dda38168c2b2266f5bc Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Wed, 12 Dec 2012 17:24:39 -0500 Subject: arch/tile: provide PT_FLAGS_COMPAT value in pt_regs This flag is set for ptrace GETREGS or PEEKUSER for processes that are COMPAT, i.e. 32-bit. This allows things like strace to easily discover what personality to use, for example. Acked-by: Oleg Nesterov Signed-off-by: Chris Metcalf --- arch/tile/include/uapi/asm/ptrace.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'arch/tile/include') diff --git a/arch/tile/include/uapi/asm/ptrace.h b/arch/tile/include/uapi/asm/ptrace.h index c717d0fec72e..0d2208803b29 100644 --- a/arch/tile/include/uapi/asm/ptrace.h +++ b/arch/tile/include/uapi/asm/ptrace.h @@ -84,5 +84,11 @@ struct pt_regs { #define PTRACE_O_TRACEMIGRATE 0x00010000 #define PTRACE_EVENT_MIGRATE 16 +/* + * Flag bits in pt_regs.flags that are part of the ptrace API. + * We start our numbering higher up to avoid confusion with the + * non-ABI kernel-internal values that use the low 16 bits. + */ +#define PT_FLAGS_COMPAT 0x10000 /* process is an -m32 compat process */ #endif /* _UAPI_ASM_TILE_PTRACE_H */ -- cgit v1.2.3 From 395e095ed92b1ccfe74c90fee4cc637cff468ea7 Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Thu, 13 Dec 2012 11:34:45 -0500 Subject: arch/tile: clean up tile-specific PTRACE_SETOPTIONS Use the newer idioms for setting PTRACE_O_xxx and PT_TRACE_xxx flags. Only set/clear tile-specific flags if the generic routine returns success, since otherwise we want to avoid setting any flags at all. Atomically update the ptrace flags with the new values. Eliminate the PT_TRACE_MASK_TILE bitmask and just shift PTRACE_O_MASK_TILE. Add a BUILD_BUG_ON to avoid overlapping with generic bits. Acked-by: Oleg Nesterov Signed-off-by: Chris Metcalf --- arch/tile/include/asm/ptrace.h | 3 +-- arch/tile/include/uapi/asm/ptrace.h | 2 +- arch/tile/kernel/ptrace.c | 10 +++++++--- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'arch/tile/include') diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h index 1a4fd9ab0ee1..5ce052e16b7b 100644 --- a/arch/tile/include/asm/ptrace.h +++ b/arch/tile/include/asm/ptrace.h @@ -24,8 +24,7 @@ typedef unsigned long pt_reg_t; #include #define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE) -#define PT_TRACE_MIGRATE 0x00080000 -#define PT_TRACE_MASK_TILE (PT_TRACE_MIGRATE) +#define PT_TRACE_MIGRATE PT_EVENT_FLAG(PTRACE_EVENT_MIGRATE) /* Flag bits in pt_regs.flags */ #define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */ diff --git a/arch/tile/include/uapi/asm/ptrace.h b/arch/tile/include/uapi/asm/ptrace.h index 0d2208803b29..7757e1985fb6 100644 --- a/arch/tile/include/uapi/asm/ptrace.h +++ b/arch/tile/include/uapi/asm/ptrace.h @@ -81,8 +81,8 @@ struct pt_regs { #define PTRACE_SETFPREGS 15 /* Support TILE-specific ptrace options, with events starting at 16. */ -#define PTRACE_O_TRACEMIGRATE 0x00010000 #define PTRACE_EVENT_MIGRATE 16 +#define PTRACE_O_TRACEMIGRATE (1 << PTRACE_EVENT_MIGRATE) /* * Flag bits in pt_regs.flags that are part of the ptrace API. diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c index 64ba102c5964..b32bc3f9d631 100644 --- a/arch/tile/kernel/ptrace.c +++ b/arch/tile/kernel/ptrace.c @@ -151,12 +151,16 @@ long arch_ptrace(struct task_struct *child, long request, case PTRACE_SETOPTIONS: /* Support TILE-specific ptrace options. */ - child->ptrace &= ~PT_TRACE_MASK_TILE; + BUILD_BUG_ON(PTRACE_O_MASK_TILE & PTRACE_O_MASK); tmp = data & PTRACE_O_MASK_TILE; data &= ~PTRACE_O_MASK_TILE; ret = ptrace_request(child, request, addr, data); - if (tmp & PTRACE_O_TRACEMIGRATE) - child->ptrace |= PT_TRACE_MIGRATE; + if (ret == 0) { + unsigned int flags = child->ptrace; + flags &= ~(PTRACE_O_MASK_TILE << PT_OPT_FLAG_SHIFT); + flags |= (tmp << PT_OPT_FLAG_SHIFT); + child->ptrace = flags; + } break; default: -- cgit v1.2.3 From e6cdebdf5aeccb5cbcf81e5e2764ad28a80f3185 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 17 Dec 2012 20:08:11 -0500 Subject: arch/tile: set CORE_DUMP_USE_REGSET on tile Following the previous patch which adds support for user_regset, tile can now use this feature. Signed-off-by: Simon Marchi Signed-off-by: Chris Metcalf --- arch/tile/include/asm/elf.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/tile/include') diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h index f8ccf08f6934..2b43fa0fb37b 100644 --- a/arch/tile/include/asm/elf.h +++ b/arch/tile/include/asm/elf.h @@ -169,4 +169,6 @@ do { \ #endif /* CONFIG_COMPAT */ +#define CORE_DUMP_USE_REGSET + #endif /* _ASM_TILE_ELF_H */ -- cgit v1.2.3