linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ptrace: unify FDPIC implementations
@ 2010-02-11  9:36 Mike Frysinger
  2010-02-11 20:24 ` Roland McGrath
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mike Frysinger @ 2010-02-11  9:36 UTC (permalink / raw)
  To: Roland McGrath, Oleg Nesterov, David Howells, Paul Mundt
  Cc: uclinux-dist-devel, linux-kernel, linux-sh

The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
their arch handlers (since they were probably copied & pasted).  Since
these ptrace interfaces are an arch independent aspect of the FDPIC code,
unify them in the common ptrace code so new FDPIC ports don't need to copy
and paste this fundamental stuff yet again.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 arch/blackfin/kernel/ptrace.c |   33 ++++++++-------------------------
 arch/frv/kernel/ptrace.c      |   20 --------------------
 arch/sh/kernel/ptrace_32.c    |   23 -----------------------
 kernel/ptrace.c               |   20 ++++++++++++++++++++
 4 files changed, 28 insertions(+), 68 deletions(-)

diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index 65567dc..0ae2f1e 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -261,11 +261,15 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			} else if (addr == (sizeof(struct pt_regs) + 8)) {
 				/* PT_DATA_ADDR */
 				tmp = child->mm->start_data;
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+#ifdef CONFIG_BINFMT_ELF_FDPIC	/* backwards compat */
 			} else if (addr == (sizeof(struct pt_regs) + 12)) {
-				goto case_PTRACE_GETFDPIC_EXEC;
+				request = PTRACE_GETFDPIC;
+				addr = PTRACE_GETFDPIC_EXEC;
+				goto case_default;
 			} else if (addr == (sizeof(struct pt_regs) + 16)) {
-				goto case_PTRACE_GETFDPIC_INTERP;
+				request = PTRACE_GETFDPIC;
+				addr = PTRACE_GETFDPIC_INTERP;
+				goto case_default;
 #endif
 			} else {
 				tmp = get_reg(child, addr);
@@ -274,28 +278,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			break;
 		}
 
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-	case PTRACE_GETFDPIC: {
-		unsigned long tmp = 0;
-
-		switch (addr) {
-		case_PTRACE_GETFDPIC_EXEC:
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case_PTRACE_GETFDPIC_INTERP:
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = put_user(tmp, datap);
-		break;
-	}
-#endif
-
 		/* when I and D space are separate, this will have to be fixed. */
 	case PTRACE_POKEDATA:
 		pr_debug("ptrace: PTRACE_PEEKDATA\n");
@@ -409,6 +391,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 		ret = 0;
 		break;
 
+	case_default:
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c
index 60eeed3..fac0289 100644
--- a/arch/frv/kernel/ptrace.c
+++ b/arch/frv/kernel/ptrace.c
@@ -344,26 +344,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 					     0, sizeof(child->thread.user->f),
 					     (const void __user *)data);
 
-	case PTRACE_GETFDPIC:
-		tmp = 0;
-		switch (addr) {
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = 0;
-		if (put_user(tmp, (unsigned long *) data)) {
-			ret = -EFAULT;
-			break;
-		}
-		break;
-
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 9be35f3..ab8123b 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -405,29 +405,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 					     0, sizeof(struct pt_dspregs),
 					     (const void __user *)data);
 #endif
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-	case PTRACE_GETFDPIC: {
-		unsigned long tmp = 0;
-
-		switch (addr) {
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = 0;
-		if (put_user(tmp, datap)) {
-			ret = -EFAULT;
-			break;
-		}
-		break;
-	}
-#endif
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 23bd09c..60fe465 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -554,6 +554,26 @@ int ptrace_request(struct task_struct *child, long request,
 		ret = ptrace_detach(child, data);
 		break;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	case PTRACE_GETFDPIC: {
+		unsigned long tmp = 0;
+
+		switch (addr) {
+		case PTRACE_GETFDPIC_EXEC:
+			tmp = child->mm->context.exec_fdpic_loadmap;
+			break;
+		case PTRACE_GETFDPIC_INTERP:
+			tmp = child->mm->context.interp_fdpic_loadmap;
+			break;
+		default:
+			break;
+		}
+
+		ret = put_user(tmp, (unsigned long __user *) data);
+		break;
+	}
+#endif
+
 #ifdef PTRACE_SINGLESTEP
 	case PTRACE_SINGLESTEP:
 #endif
-- 
1.6.6.1


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

* Re: [PATCH] ptrace: unify FDPIC implementations
  2010-02-11  9:36 [PATCH] ptrace: unify FDPIC implementations Mike Frysinger
@ 2010-02-11 20:24 ` Roland McGrath
  2010-02-11 21:07 ` David Howells
  2010-02-11 23:26 ` Paul Mundt
  2 siblings, 0 replies; 7+ messages in thread
From: Roland McGrath @ 2010-02-11 20:24 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Oleg Nesterov, David Howells, Paul Mundt, uclinux-dist-devel,
	linux-kernel, linux-sh

Acked-by: Roland McGrath <roland@redhat.com>

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

* Re: [PATCH] ptrace: unify FDPIC implementations
  2010-02-11  9:36 [PATCH] ptrace: unify FDPIC implementations Mike Frysinger
  2010-02-11 20:24 ` Roland McGrath
@ 2010-02-11 21:07 ` David Howells
  2010-02-11 23:26 ` Paul Mundt
  2 siblings, 0 replies; 7+ messages in thread
From: David Howells @ 2010-02-11 21:07 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: dhowells, Roland McGrath, Oleg Nesterov, Paul Mundt,
	uclinux-dist-devel, linux-kernel, linux-sh

Mike Frysinger <vapier@gentoo.org> wrote:

> The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
> their arch handlers (since they were probably copied & pasted).  Since
> these ptrace interfaces are an arch independent aspect of the FDPIC code,
> unify them in the common ptrace code so new FDPIC ports don't need to copy
> and paste this fundamental stuff yet again.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Acked-by: David Howells <dhowells@redhat.com>

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

* Re: [PATCH] ptrace: unify FDPIC implementations
  2010-02-11  9:36 [PATCH] ptrace: unify FDPIC implementations Mike Frysinger
  2010-02-11 20:24 ` Roland McGrath
  2010-02-11 21:07 ` David Howells
@ 2010-02-11 23:26 ` Paul Mundt
  2 siblings, 0 replies; 7+ messages in thread
From: Paul Mundt @ 2010-02-11 23:26 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Roland McGrath, Oleg Nesterov, David Howells, uclinux-dist-devel,
	linux-kernel, linux-sh

On Thu, Feb 11, 2010 at 04:36:00AM -0500, Mike Frysinger wrote:
> The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
> their arch handlers (since they were probably copied & pasted).  Since
> these ptrace interfaces are an arch independent aspect of the FDPIC code,
> unify them in the common ptrace code so new FDPIC ports don't need to copy
> and paste this fundamental stuff yet again.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Acked-by: Paul Mundt  <lethal@linux-sh.org>

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

* [PATCH] ptrace: unify FDPIC implementations
@ 2010-02-16  0:30 Mike Frysinger
  2010-02-16  1:10 ` Paul Mundt
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2010-02-16  0:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-kernel, Roland McGrath, David Howells, Paul Mundt,
	Oleg Nesterov, uclinux-dist-devel, linux-sh

The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
their arch handlers (since they were probably copied & pasted).  Since
these ptrace interfaces are an arch independent aspect of the FDPIC code,
unify them in the common ptrace code so new FDPIC ports don't need to copy
and paste this fundamental stuff yet again.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Roland McGrath <roland@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
---
Andrew: could you pick this up ?  everyone concerned has acked it ...

 arch/blackfin/kernel/ptrace.c |   33 ++++++++-------------------------
 arch/frv/kernel/ptrace.c      |   20 --------------------
 arch/sh/kernel/ptrace_32.c    |   23 -----------------------
 kernel/ptrace.c               |   20 ++++++++++++++++++++
 4 files changed, 28 insertions(+), 68 deletions(-)

diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index 65567dc..0ae2f1e 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -261,11 +261,15 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			} else if (addr == (sizeof(struct pt_regs) + 8)) {
 				/* PT_DATA_ADDR */
 				tmp = child->mm->start_data;
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+#ifdef CONFIG_BINFMT_ELF_FDPIC	/* backwards compat */
 			} else if (addr == (sizeof(struct pt_regs) + 12)) {
-				goto case_PTRACE_GETFDPIC_EXEC;
+				request = PTRACE_GETFDPIC;
+				addr = PTRACE_GETFDPIC_EXEC;
+				goto case_default;
 			} else if (addr == (sizeof(struct pt_regs) + 16)) {
-				goto case_PTRACE_GETFDPIC_INTERP;
+				request = PTRACE_GETFDPIC;
+				addr = PTRACE_GETFDPIC_INTERP;
+				goto case_default;
 #endif
 			} else {
 				tmp = get_reg(child, addr);
@@ -274,28 +278,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 			break;
 		}
 
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-	case PTRACE_GETFDPIC: {
-		unsigned long tmp = 0;
-
-		switch (addr) {
-		case_PTRACE_GETFDPIC_EXEC:
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case_PTRACE_GETFDPIC_INTERP:
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = put_user(tmp, datap);
-		break;
-	}
-#endif
-
 		/* when I and D space are separate, this will have to be fixed. */
 	case PTRACE_POKEDATA:
 		pr_debug("ptrace: PTRACE_PEEKDATA\n");
@@ -409,6 +391,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 		ret = 0;
 		break;
 
+	case_default:
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/arch/frv/kernel/ptrace.c b/arch/frv/kernel/ptrace.c
index 60eeed3..fac0289 100644
--- a/arch/frv/kernel/ptrace.c
+++ b/arch/frv/kernel/ptrace.c
@@ -344,26 +344,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 					     0, sizeof(child->thread.user->f),
 					     (const void __user *)data);
 
-	case PTRACE_GETFDPIC:
-		tmp = 0;
-		switch (addr) {
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = 0;
-		if (put_user(tmp, (unsigned long *) data)) {
-			ret = -EFAULT;
-			break;
-		}
-		break;
-
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 9be35f3..ab8123b 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -405,29 +405,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 					     0, sizeof(struct pt_dspregs),
 					     (const void __user *)data);
 #endif
-#ifdef CONFIG_BINFMT_ELF_FDPIC
-	case PTRACE_GETFDPIC: {
-		unsigned long tmp = 0;
-
-		switch (addr) {
-		case PTRACE_GETFDPIC_EXEC:
-			tmp = child->mm->context.exec_fdpic_loadmap;
-			break;
-		case PTRACE_GETFDPIC_INTERP:
-			tmp = child->mm->context.interp_fdpic_loadmap;
-			break;
-		default:
-			break;
-		}
-
-		ret = 0;
-		if (put_user(tmp, datap)) {
-			ret = -EFAULT;
-			break;
-		}
-		break;
-	}
-#endif
 	default:
 		ret = ptrace_request(child, request, addr, data);
 		break;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 23bd09c..60fe465 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -554,6 +554,26 @@ int ptrace_request(struct task_struct *child, long request,
 		ret = ptrace_detach(child, data);
 		break;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	case PTRACE_GETFDPIC: {
+		unsigned long tmp = 0;
+
+		switch (addr) {
+		case PTRACE_GETFDPIC_EXEC:
+			tmp = child->mm->context.exec_fdpic_loadmap;
+			break;
+		case PTRACE_GETFDPIC_INTERP:
+			tmp = child->mm->context.interp_fdpic_loadmap;
+			break;
+		default:
+			break;
+		}
+
+		ret = put_user(tmp, (unsigned long __user *) data);
+		break;
+	}
+#endif
+
 #ifdef PTRACE_SINGLESTEP
 	case PTRACE_SINGLESTEP:
 #endif
-- 
1.7.0


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

* Re: [PATCH] ptrace: unify FDPIC implementations
  2010-02-16  0:30 Mike Frysinger
@ 2010-02-16  1:10 ` Paul Mundt
  2010-02-16  8:12   ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Mundt @ 2010-02-16  1:10 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: Andrew Morton, linux-kernel, Roland McGrath, David Howells,
	Oleg Nesterov, uclinux-dist-devel, linux-sh

On Mon, Feb 15, 2010 at 07:30:29PM -0500, Mike Frysinger wrote:
> The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
> their arch handlers (since they were probably copied & pasted).  Since
> these ptrace interfaces are an arch independent aspect of the FDPIC code,
> unify them in the common ptrace code so new FDPIC ports don't need to copy
> and paste this fundamental stuff yet again.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> Acked-by: Roland McGrath <roland@redhat.com>
> Acked-by: David Howells <dhowells@redhat.com>
> Acked-by: Paul Mundt <lethal@linux-sh.org>

Just to follow up on this, this code obviously expects consistent entries
in mm_context_t. Presently include/asm-generic/mmu.h is aimed at nommu,
so it would probably be worthwhile stubbing in the FDPIC loadmap entries
there to make things easier for future ports.

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

* Re: [PATCH] ptrace: unify FDPIC implementations
  2010-02-16  1:10 ` Paul Mundt
@ 2010-02-16  8:12   ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2010-02-16  8:12 UTC (permalink / raw)
  To: Paul Mundt
  Cc: Andrew Morton, linux-kernel, Roland McGrath, David Howells,
	Oleg Nesterov, uclinux-dist-devel, linux-sh

On Mon, Feb 15, 2010 at 20:10, Paul Mundt wrote:
> On Mon, Feb 15, 2010 at 07:30:29PM -0500, Mike Frysinger wrote:
>> The Blackfin/FRV/SuperH guys all have the same exact FDPIC ptrace code in
>> their arch handlers (since they were probably copied & pasted).  Since
>> these ptrace interfaces are an arch independent aspect of the FDPIC code,
>> unify them in the common ptrace code so new FDPIC ports don't need to copy
>> and paste this fundamental stuff yet again.
>>
>> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>> Acked-by: Roland McGrath <roland@redhat.com>
>> Acked-by: David Howells <dhowells@redhat.com>
>> Acked-by: Paul Mundt <lethal@linux-sh.org>
>
> Just to follow up on this, this code obviously expects consistent entries
> in mm_context_t. Presently include/asm-generic/mmu.h is aimed at nommu,
> so it would probably be worthwhile stubbing in the FDPIC loadmap entries
> there to make things easier for future ports.

probably be a good idea.  for FDPIC in general, the header also needs
"stack_start".
-mike

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

end of thread, other threads:[~2010-02-16  8:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11  9:36 [PATCH] ptrace: unify FDPIC implementations Mike Frysinger
2010-02-11 20:24 ` Roland McGrath
2010-02-11 21:07 ` David Howells
2010-02-11 23:26 ` Paul Mundt
  -- strict thread matches above, loose matches on Subject: below --
2010-02-16  0:30 Mike Frysinger
2010-02-16  1:10 ` Paul Mundt
2010-02-16  8:12   ` Mike Frysinger

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).