linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] arch/tile: implement user_regset interface on tilegx
@ 2012-12-15  4:34 Simon Marchi
  2012-12-15  4:34 ` [PATCH 2/3] arch/tile: implement arch_ptrace using user_regset " Simon Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Simon Marchi @ 2012-12-15  4:34 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

This is an implementation of user_regset for the tilegx architecture. It
reuses the basic blocks that were already there.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
I only tested these patches on a 3.0 kernel, as this is what my current
setup allows me. Some testing on more recent versions would be
appreciated, although I don't think the user_regset framework changed
much since then.

Also, I put some ifdefs so that these patches only affect tilegx and not
the older tile architectures, which I don't have access to. Hopefully
someone else can finish the work for those, it's probably not much.

 arch/tile/kernel/ptrace.c |   65 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index b32bc3f..0e68d06 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -19,6 +19,8 @@
 #include <linux/kprobes.h>
 #include <linux/compat.h>
 #include <linux/uaccess.h>
+#include <linux/regset.h>
+#include <linux/elf.h>
 #include <asm/traps.h>
 
 void user_enable_single_step(struct task_struct *child)
@@ -80,6 +82,69 @@ static void putregs(struct task_struct *child, struct pt_regs *uregs)
 	*regs = *uregs;
 }
 
+#ifdef __tilegx__
+
+enum tile_regset {
+	REGSET_GPR,
+};
+
+static int tile_gpr_get(struct task_struct *target,
+			  const struct user_regset *regset,
+			  unsigned int pos, unsigned int count,
+			  void *kbuf, void __user *ubuf)
+{
+	struct pt_regs regs;
+
+	getregs(target, &regs);
+
+	return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs, 0,
+				   sizeof(regs));
+}
+
+static int tile_gpr_set(struct task_struct *target,
+			  const struct user_regset *regset,
+			  unsigned int pos, unsigned int count,
+			  const void *kbuf, const void __user *ubuf)
+{
+	int ret;
+	struct pt_regs regs;
+
+	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0,
+				 sizeof(regs));
+	if (ret)
+		return ret;
+
+	putregs(target, &regs);
+
+	return 0;
+}
+
+static const struct user_regset tile_user_regset[] = {
+	[REGSET_GPR] = {
+		.core_note_type = NT_PRSTATUS,
+		.n = ELF_NGREG,
+		.size = sizeof(elf_greg_t),
+		.align = sizeof(elf_greg_t),
+		.get = tile_gpr_get,
+		.set = tile_gpr_set,
+	},
+};
+
+static const struct user_regset_view tile_user_regset_view = {
+	.name = "tilegx",
+	.e_machine = ELF_ARCH,
+	.ei_osabi = ELF_OSABI,
+	.regsets = tile_user_regset,
+	.n = ARRAY_SIZE(tile_user_regset),
+};
+
+const struct user_regset_view *task_user_regset_view(struct task_struct *task)
+{
+	return &tile_user_regset_view;
+}
+
+#endif /* __tilegx__ */
+
 long arch_ptrace(struct task_struct *child, long request,
 		 unsigned long addr, unsigned long data)
 {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] arch/tile: implement arch_ptrace using user_regset on tilegx
  2012-12-15  4:34 [PATCH 1/3] arch/tile: implement user_regset interface on tilegx Simon Marchi
@ 2012-12-15  4:34 ` Simon Marchi
  2012-12-15  4:34 ` [PATCH 3/3] arch/tile: set CORE_DUMP_USE_REGSET " Simon Marchi
  2012-12-17 17:06 ` [PATCH 1/3] arch/tile: implement user_regset interface " Chris Metcalf
  2 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2012-12-15  4:34 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

This patch changes arch_ptrace on tilegx so that it uses the user_regset
to implement the PTRACE_GETREGS and PTRACE_SETREGS operations.

The ifdefs and the old code can be removed when user_regset support for
the older architectures is there.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
 arch/tile/kernel/ptrace.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index 0e68d06..9435dd1 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -196,18 +196,28 @@ long arch_ptrace(struct task_struct *child, long request,
 		break;
 
 	case PTRACE_GETREGS:  /* Get all registers from the child. */
+#ifdef __tilegx__
+		ret = copy_regset_to_user(child, &tile_user_regset_view, REGSET_GPR,
+					  0, sizeof(struct pt_regs), datap);
+#else /* __tilegx__ */
 		if (copy_to_user(datap, getregs(child, &copyregs),
 				 sizeof(struct pt_regs)) == 0) {
 			ret = 0;
 		}
+#endif /* __tilegx__ */
 		break;
 
 	case PTRACE_SETREGS:  /* Set all registers in the child. */
+#ifdef __tilegx__
+		ret = copy_regset_from_user(child, &tile_user_regset_view, REGSET_GPR,
+					    0, sizeof(struct pt_regs), datap);
+#else /* __tilegx__ */
 		if (copy_from_user(&copyregs, datap,
 				   sizeof(struct pt_regs)) == 0) {
 			putregs(child, &copyregs);
 			ret = 0;
 		}
+#endif /* __tilegx__ */
 		break;
 
 	case PTRACE_GETFPREGS:  /* Get the child FPU state. */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] arch/tile: set CORE_DUMP_USE_REGSET on tilegx
  2012-12-15  4:34 [PATCH 1/3] arch/tile: implement user_regset interface on tilegx Simon Marchi
  2012-12-15  4:34 ` [PATCH 2/3] arch/tile: implement arch_ptrace using user_regset " Simon Marchi
@ 2012-12-15  4:34 ` Simon Marchi
  2012-12-17 17:06 ` [PATCH 1/3] arch/tile: implement user_regset interface " Chris Metcalf
  2 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2012-12-15  4:34 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

Following the previous patch which adds support for user_regset, tilegx
can now use this feature.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
 arch/tile/include/asm/elf.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h
index f8ccf08..7a793c7 100644
--- a/arch/tile/include/asm/elf.h
+++ b/arch/tile/include/asm/elf.h
@@ -169,4 +169,8 @@ do { \
 
 #endif /* CONFIG_COMPAT */
 
+#ifdef __tilegx__
+#define CORE_DUMP_USE_REGSET
+#endif /* __tilegx__ */
+
 #endif /* _ASM_TILE_ELF_H */
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arch/tile: implement user_regset interface on tilegx
  2012-12-15  4:34 [PATCH 1/3] arch/tile: implement user_regset interface on tilegx Simon Marchi
  2012-12-15  4:34 ` [PATCH 2/3] arch/tile: implement arch_ptrace using user_regset " Simon Marchi
  2012-12-15  4:34 ` [PATCH 3/3] arch/tile: set CORE_DUMP_USE_REGSET " Simon Marchi
@ 2012-12-17 17:06 ` Chris Metcalf
  2012-12-17 22:07   ` Simon Marchi
  2 siblings, 1 reply; 7+ messages in thread
From: Chris Metcalf @ 2012-12-17 17:06 UTC (permalink / raw)
  To: Simon Marchi; +Cc: linux-kernel

On 12/14/2012 11:34 PM, Simon Marchi wrote:
> This is an implementation of user_regset for the tilegx architecture. It
> reuses the basic blocks that were already there.

Thanks, Simon!  A couple of comments:

I encourage you to respin this for tilepro as well as tilegx, since it's going to be trivial to make it happen.  Just take away all yours ifdefs, and use #include <arch/chip.h> and CHIP_ARCH_NAME instead of the string "tilegx".  It's worth it just to avoid the ifdefs in the code :-)

I think with this support added, we have all the prerequisites to add "select HAVE_ARCH_TRACEHOOK" under "config TILE" in arch/tile/Kconfig, so we might as well do that too.  That will enable PTRACE_GETREGSET and PTRACE_SETREGSET, as well as /proc/PID/syscall, so why not?

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arch/tile: implement user_regset interface on tilegx
  2012-12-17 17:06 ` [PATCH 1/3] arch/tile: implement user_regset interface " Chris Metcalf
@ 2012-12-17 22:07   ` Simon Marchi
  2012-12-17 22:59     ` Chris Metcalf
  0 siblings, 1 reply; 7+ messages in thread
From: Simon Marchi @ 2012-12-17 22:07 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel

On Mon, Dec 17, 2012 at 12:06 PM, Chris Metcalf <cmetcalf@tilera.com> wrote:
> On 12/14/2012 11:34 PM, Simon Marchi wrote:
>> This is an implementation of user_regset for the tilegx architecture. It
>> reuses the basic blocks that were already there.
>
> Thanks, Simon!  A couple of comments:
>
> I encourage you to respin this for tilepro as well as tilegx, since it's going to be trivial to make it happen.  Just take away all yours ifdefs, and use #include <arch/chip.h> and CHIP_ARCH_NAME instead of the string "tilegx".  It's worth it just to avoid the ifdefs in the code :-)

Ok, I will send a v2 with this soon.

> I think with this support added, we have all the prerequisites to add "select HAVE_ARCH_TRACEHOOK" under "config TILE" in arch/tile/Kconfig, so we might as well do that too.  That will enable PTRACE_GETREGSET and PTRACE_SETREGSET, as well as /proc/PID/syscall, so why not?

This is indeed my objective ;), and it is an intermediate objective to
add support for HAVE_SYSCALL_TRACEPOINTS. If we look at arch/Kconfig,
just above HAVE_ARCH_TRACEHOOK, we still have

TIF_SYSCALL_TRACE       calls tracehook_report_syscall_{entry,exit}
TIF_NOTIFY_RESUME       calls tracehook_notify_resume()
signal delivery         calls tracehook_signal_handler()

that we need to implement.

> --
> Chris Metcalf, Tilera Corp.
> http://www.tilera.com
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arch/tile: implement user_regset interface on tilegx
  2012-12-17 22:07   ` Simon Marchi
@ 2012-12-17 22:59     ` Chris Metcalf
  2012-12-18  1:05       ` Simon Marchi
  0 siblings, 1 reply; 7+ messages in thread
From: Chris Metcalf @ 2012-12-17 22:59 UTC (permalink / raw)
  To: Simon Marchi; +Cc: linux-kernel

On 12/17/2012 5:07 PM, Simon Marchi wrote:
>> I think with this support added, we have all the prerequisites to add "select HAVE_ARCH_TRACEHOOK" under "config TILE" in arch/tile/Kconfig, so we might as well do that too.  That will enable PTRACE_GETREGSET and PTRACE_SETREGSET, as well as /proc/PID/syscall, so why not?
> This is indeed my objective ;), and it is an intermediate objective to
> add support for HAVE_SYSCALL_TRACEPOINTS. If we look at arch/Kconfig,
> just above HAVE_ARCH_TRACEHOOK, we still have
>
> TIF_SYSCALL_TRACE       calls tracehook_report_syscall_{entry,exit}
> TIF_NOTIFY_RESUME       calls tracehook_notify_resume()
> signal delivery         calls tracehook_signal_handler()

I believe we do properly support TIF_SYSCALL_TRACE; see arch/tile/kernel/intvec_64.S.  Likewise TIF_NOTIFY_RESUME; see do_work_pending() in arch/tile/kernel/process.c.  And signal delivery seems to be handled in a platform-independent way now; see kernel/signal.c.

My only comment on the revised patch is that I believe you should #include <arch/chip.h>, not <uapi/arch/chip.h>.  Source code (.c files) doesn't seem to use the <uapi/> prefix.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] arch/tile: implement user_regset interface on tilegx
  2012-12-17 22:59     ` Chris Metcalf
@ 2012-12-18  1:05       ` Simon Marchi
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Marchi @ 2012-12-18  1:05 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: linux-kernel

On Mon, Dec 17, 2012 at 5:59 PM, Chris Metcalf <cmetcalf@tilera.com> wrote:
> On 12/17/2012 5:07 PM, Simon Marchi wrote:
>>> I think with this support added, we have all the prerequisites to add "select HAVE_ARCH_TRACEHOOK" under "config TILE" in arch/tile/Kconfig, so we might as well do that too.  That will enable PTRACE_GETREGSET and PTRACE_SETREGSET, as well as /proc/PID/syscall, so why not?
>> This is indeed my objective ;), and it is an intermediate objective to
>> add support for HAVE_SYSCALL_TRACEPOINTS. If we look at arch/Kconfig,
>> just above HAVE_ARCH_TRACEHOOK, we still have
>>
>> TIF_SYSCALL_TRACE       calls tracehook_report_syscall_{entry,exit}
>> TIF_NOTIFY_RESUME       calls tracehook_notify_resume()
>> signal delivery         calls tracehook_signal_handler()
>
> I believe we do properly support TIF_SYSCALL_TRACE; see arch/tile/kernel/intvec_64.S.  Likewise TIF_NOTIFY_RESUME; see do_work_pending() in arch/tile/kernel/process.c.  And signal delivery seems to be handled in a platform-independent way now; see kernel/signal.c.

TIF_SYSCALL_TRACE is handled, but it doesn't call
tracehook_report_syscall_{entry,exit} as specified. The two others
seem handled like you said.

> My only comment on the revised patch is that I believe you should #include <arch/chip.h>, not <uapi/arch/chip.h>.  Source code (.c files) doesn't seem to use the <uapi/> prefix.

Oh, I didn't know the include path contained arch/tile/include/uapi
directly. Fixing it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-18  1:06 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-15  4:34 [PATCH 1/3] arch/tile: implement user_regset interface on tilegx Simon Marchi
2012-12-15  4:34 ` [PATCH 2/3] arch/tile: implement arch_ptrace using user_regset " Simon Marchi
2012-12-15  4:34 ` [PATCH 3/3] arch/tile: set CORE_DUMP_USE_REGSET " Simon Marchi
2012-12-17 17:06 ` [PATCH 1/3] arch/tile: implement user_regset interface " Chris Metcalf
2012-12-17 22:07   ` Simon Marchi
2012-12-17 22:59     ` Chris Metcalf
2012-12-18  1:05       ` Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).