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 <oleg@redhat.com>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
This commit is contained in:
Chris Metcalf 2012-12-13 11:34:45 -05:00
Родитель cb67e161bc
Коммит 395e095ed9
3 изменённых файлов: 9 добавлений и 6 удалений

Просмотреть файл

@ -24,8 +24,7 @@ typedef unsigned long pt_reg_t;
#include <uapi/asm/ptrace.h> #include <uapi/asm/ptrace.h>
#define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE) #define PTRACE_O_MASK_TILE (PTRACE_O_TRACEMIGRATE)
#define PT_TRACE_MIGRATE 0x00080000 #define PT_TRACE_MIGRATE PT_EVENT_FLAG(PTRACE_EVENT_MIGRATE)
#define PT_TRACE_MASK_TILE (PT_TRACE_MIGRATE)
/* Flag bits in pt_regs.flags */ /* Flag bits in pt_regs.flags */
#define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */ #define PT_FLAGS_DISABLE_IRQ 1 /* on return to kernel, disable irqs */

Просмотреть файл

@ -81,8 +81,8 @@ struct pt_regs {
#define PTRACE_SETFPREGS 15 #define PTRACE_SETFPREGS 15
/* Support TILE-specific ptrace options, with events starting at 16. */ /* Support TILE-specific ptrace options, with events starting at 16. */
#define PTRACE_O_TRACEMIGRATE 0x00010000
#define PTRACE_EVENT_MIGRATE 16 #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. * Flag bits in pt_regs.flags that are part of the ptrace API.

Просмотреть файл

@ -151,12 +151,16 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_SETOPTIONS: case PTRACE_SETOPTIONS:
/* Support TILE-specific ptrace options. */ /* 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; tmp = data & PTRACE_O_MASK_TILE;
data &= ~PTRACE_O_MASK_TILE; data &= ~PTRACE_O_MASK_TILE;
ret = ptrace_request(child, request, addr, data); ret = ptrace_request(child, request, addr, data);
if (tmp & PTRACE_O_TRACEMIGRATE) if (ret == 0) {
child->ptrace |= PT_TRACE_MIGRATE; unsigned int flags = child->ptrace;
flags &= ~(PTRACE_O_MASK_TILE << PT_OPT_FLAG_SHIFT);
flags |= (tmp << PT_OPT_FLAG_SHIFT);
child->ptrace = flags;
}
break; break;
default: default: