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

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

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
v2 included change for all tile architectures (not just tilegx)
v3 changed #include <uapi/arch/chip.h> to <arch/chip.h>

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

diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index b32bc3f..882e381 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -19,7 +19,10 @@
 #include <linux/kprobes.h>
 #include <linux/compat.h>
 #include <linux/uaccess.h>
+#include <linux/regset.h>
+#include <linux/elf.h>
 #include <asm/traps.h>
+#include <arch/chip.h>
 
 void user_enable_single_step(struct task_struct *child)
 {
@@ -80,6 +83,65 @@ static void putregs(struct task_struct *child, struct pt_regs *uregs)
 	*regs = *uregs;
 }
 
+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 = CHIP_ARCH_NAME,
+	.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;
+}
+
 long arch_ptrace(struct task_struct *child, long request,
 		 unsigned long addr, unsigned long data)
 {
-- 
1.7.1


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

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

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

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

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


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

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

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

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

diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h
index f8ccf08..2b43fa0 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 */
-- 
1.7.1


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

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

On 12/17/2012 8:08 PM, Simon Marchi wrote:
> This is a basic implementation of user_regset for the tile
> architecture. It reuses the basic blocks that were already there.
>
> Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>

Thanks, I'll take this into the tile tree for this merge window.

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


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-18  1:08 [PATCH v3 1/3] arch/tile: implement user_regset interface on tile Simon Marchi
2012-12-18  1:08 ` [PATCH v3 2/3] arch/tile: implement arch_ptrace using user_regset " Simon Marchi
2012-12-18  1:08 ` [PATCH v3 3/3] arch/tile: set CORE_DUMP_USE_REGSET " Simon Marchi
2012-12-18  1:19 ` [PATCH v3 1/3] arch/tile: implement user_regset interface " Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox