From: Oleg Nesterov <oleg@redhat.com>
To: Chris Metcalf <cmetcalf@tilera.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] arch/tile: clean up tile-specific PTRACE_SETOPTIONS
Date: Fri, 14 Dec 2012 18:26:56 +0100 [thread overview]
Message-ID: <20121214172656.GA21152@redhat.com> (raw)
In-Reply-To: <201212131643.qBDGh4L3018088@farm-0013.internal.tilera.com>
On 12/13, Chris Metcalf wrote:
>
> 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.
>
> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
> ---
> 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(-)
>
> diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h
> index 1a4fd9a..5ce052e 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 <uapi/asm/ptrace.h>
>
> #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 0d22088..7757e19 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 64ba102..b32bc3f 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:
> --
> 1.7.10.3
>
next prev parent reply other threads:[~2012-12-14 17:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-12 22:24 [PATCH] arch/tile: provide PT_FLAGS_COMPAT value in pt_regs Chris Metcalf
2012-12-12 23:43 ` Oleg Nesterov
2012-12-13 14:58 ` Chris Metcalf
2012-12-13 15:49 ` Oleg Nesterov
2012-12-13 16:15 ` Chris Metcalf
2012-12-13 16:27 ` Oleg Nesterov
2012-12-13 16:34 ` [PATCH] arch/tile: clean up tile-specific PTRACE_SETOPTIONS Chris Metcalf
2012-12-14 17:26 ` Oleg Nesterov [this message]
2012-12-13 16:41 ` [PATCH] arch/tile: provide PT_FLAGS_COMPAT value in pt_regs Chris Metcalf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121214172656.GA21152@redhat.com \
--to=oleg@redhat.com \
--cc=cmetcalf@tilera.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox