All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix X86_64 procfs provide stack information for threads
@ 2009-11-02 10:47 Stefani Seibold
  2009-11-03  5:58 ` Américo Wang
  2009-11-03  9:06 ` Alexey Dobriyan
  0 siblings, 2 replies; 5+ messages in thread
From: Stefani Seibold @ 2009-11-02 10:47 UTC (permalink / raw)
  To: linux-kernel, Andrew Morton; +Cc: Alexey Dobriyan

This patch fix two issues in the procfs stack information on X86_64
linux. 

The 32 bit loader compat_do_execve did not store stack start (this was
figured out by alexey).

The stack information on a X64_64 kernel always show 0 kbyte stack
usage, because of a miss implemented KSTK_ESP macro which always return
-1. The new implementation returns now the right value. 

The patch is against 2.6.32-rc5-git5.

Andrew would you so kind to apply this patch?

Greetings,
Stefani

Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
 arch/x86/include/asm/processor.h |    9 ++++++++-
 arch/x86/kernel/process_64.c     |    8 ++++++++
 fs/compat.c                      |    2 ++
 3 files changed, 18 insertions(+), 1 deletion(-)

--- linux-2.6.32-rc5/fs/compat.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/fs/compat.c	2009-11-02 09:00:52.871909633 +0100
@@ -1532,6 +1532,8 @@
 	if (retval < 0)
 		goto out;
 
+	current->stack_start = current->mm->start_stack;
+
 	/* execve succeeded */
 	current->fs->in_exec = 0;
 	current->in_execve = 0;
--- linux-2.6.32-rc5/arch/x86/include/asm/processor.h	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h	2009-11-02 10:39:47.177909657 +0100
@@ -29,6 +29,7 @@
 #include <linux/threads.h>
 #include <linux/math64.h>
 #include <linux/init.h>
+//#include <linux/sched.h>
 
 /*
  * Default implementation of macro that returns current
@@ -1000,7 +1001,13 @@
 #define thread_saved_pc(t)	(*(unsigned long *)((t)->thread.sp - 8))
 
 #define task_pt_regs(tsk)	((struct pt_regs *)(tsk)->thread.sp0 - 1)
-#define KSTK_ESP(tsk)		-1 /* sorry. doesn't work for syscall. */
+
+#ifdef CONFIG_IA32_EMULATION
+extern unsigned long KSTK_ESP(struct task_struct *task);
+#else
+#define KSTK_ESP(task)		((task)->thread.usersp)
+#endif
+
 #endif /* CONFIG_X86_64 */
 
 extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
--- linux-2.6.32-rc5/arch/x86/kernel/process_64.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c	2009-11-02 10:48:23.614936810 +0100
@@ -664,3 +669,11 @@
 	return do_arch_prctl(current, code, addr);
 }
 
+#ifdef CONFIG_IA32_EMULATION
+unsigned long KSTK_ESP(struct task_struct *task)
+{
+	return (test_tsk_thread_flag(task, TIF_IA32)) ? \
+			(task_pt_regs(task)->sp) : \
+			((task)->thread.usersp);
+}
+#endif



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

* Re: [PATCH] fix X86_64 procfs provide stack information for threads
  2009-11-02 10:47 [PATCH] fix X86_64 procfs provide stack information for threads Stefani Seibold
@ 2009-11-03  5:58 ` Américo Wang
  2009-11-03  7:26   ` Stefani Seibold
  2009-11-03  9:06 ` Alexey Dobriyan
  1 sibling, 1 reply; 5+ messages in thread
From: Américo Wang @ 2009-11-03  5:58 UTC (permalink / raw)
  To: Stefani Seibold; +Cc: linux-kernel, Andrew Morton, Alexey Dobriyan

On Mon, Nov 02, 2009 at 11:47:09AM +0100, Stefani Seibold wrote:
>This patch fix two issues in the procfs stack information on X86_64
>linux. 
>
>The 32 bit loader compat_do_execve did not store stack start (this was
>figured out by alexey).
>
>The stack information on a X64_64 kernel always show 0 kbyte stack
>usage, because of a miss implemented KSTK_ESP macro which always return
>-1. The new implementation returns now the right value. 
>
>The patch is against 2.6.32-rc5-git5.
>
>Andrew would you so kind to apply this patch?
>
>Greetings,
>Stefani
>
>Signed-off-by: Stefani Seibold <stefani@seibold.net>
>---
> arch/x86/include/asm/processor.h |    9 ++++++++-
> arch/x86/kernel/process_64.c     |    8 ++++++++
> fs/compat.c                      |    2 ++
> 3 files changed, 18 insertions(+), 1 deletion(-)
>
>--- linux-2.6.32-rc5/fs/compat.c	2009-10-16 02:41:50.000000000 +0200
>+++ linux-2.6.32-rc5.new/fs/compat.c	2009-11-02 09:00:52.871909633 +0100
>@@ -1532,6 +1532,8 @@
> 	if (retval < 0)
> 		goto out;
> 
>+	current->stack_start = current->mm->start_stack;
>+
> 	/* execve succeeded */
> 	current->fs->in_exec = 0;
> 	current->in_execve = 0;
>--- linux-2.6.32-rc5/arch/x86/include/asm/processor.h	2009-10-16 02:41:50.000000000 +0200
>+++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h	2009-11-02 10:39:47.177909657 +0100
>@@ -29,6 +29,7 @@
> #include <linux/threads.h>
> #include <linux/math64.h>
> #include <linux/init.h>
>+//#include <linux/sched.h>

Hey, what is this? :)

Except this, this patch looks fine for me:

Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>

> 
> /*
>  * Default implementation of macro that returns current
>@@ -1000,7 +1001,13 @@
> #define thread_saved_pc(t)	(*(unsigned long *)((t)->thread.sp - 8))
> 
> #define task_pt_regs(tsk)	((struct pt_regs *)(tsk)->thread.sp0 - 1)
>-#define KSTK_ESP(tsk)		-1 /* sorry. doesn't work for syscall. */
>+
>+#ifdef CONFIG_IA32_EMULATION
>+extern unsigned long KSTK_ESP(struct task_struct *task);
>+#else
>+#define KSTK_ESP(task)		((task)->thread.usersp)
>+#endif
>+
> #endif /* CONFIG_X86_64 */
> 
> extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
>--- linux-2.6.32-rc5/arch/x86/kernel/process_64.c	2009-10-16 02:41:50.000000000 +0200
>+++ linux-2.6.32-rc5.new/arch/x86/kernel/process_64.c	2009-11-02 10:48:23.614936810 +0100
>@@ -664,3 +669,11 @@
> 	return do_arch_prctl(current, code, addr);
> }
> 
>+#ifdef CONFIG_IA32_EMULATION
>+unsigned long KSTK_ESP(struct task_struct *task)
>+{
>+	return (test_tsk_thread_flag(task, TIF_IA32)) ? \
>+			(task_pt_regs(task)->sp) : \
>+			((task)->thread.usersp);
>+}
>+#endif
>
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>Please read the FAQ at  http://www.tux.org/lkml/

-- 
Live like a child, think like the god.
 

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

* Re: [PATCH] fix X86_64 procfs provide stack information for threads
  2009-11-03  5:58 ` Américo Wang
@ 2009-11-03  7:26   ` Stefani Seibold
  0 siblings, 0 replies; 5+ messages in thread
From: Stefani Seibold @ 2009-11-03  7:26 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel, Andrew Morton

Am Dienstag, den 03.11.2009, 13:58 +0800 schrieb Américo Wang:
> On Mon, Nov 02, 2009 at 11:47:09AM +0100, Stefani Seibold wrote:
> >--- linux-2.6.32-rc5/arch/x86/include/asm/processor.h	2009-10-16 02:41:50.000000000 +0200
> >+++ linux-2.6.32-rc5.new/arch/x86/include/asm/processor.h	2009-11-02 10:39:47.177909657 +0100
> >@@ -29,6 +29,7 @@
> > #include <linux/threads.h>
> > #include <linux/math64.h>
> > #include <linux/init.h>
> >+//#include <linux/sched.h>
> 
> Hey, what is this? :)
> 
Garbage :-( I will resend the patch without!

> Except this, this patch looks fine for me:
> 
> Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>



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

* Re: [PATCH] fix X86_64 procfs provide stack information for threads
  2009-11-02 10:47 [PATCH] fix X86_64 procfs provide stack information for threads Stefani Seibold
  2009-11-03  5:58 ` Américo Wang
@ 2009-11-03  9:06 ` Alexey Dobriyan
  2009-11-03  9:09   ` Stefani Seibold
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Dobriyan @ 2009-11-03  9:06 UTC (permalink / raw)
  To: Stefani Seibold; +Cc: linux-kernel, Andrew Morton

On Mon, Nov 02, 2009 at 11:47:09AM +0100, Stefani Seibold wrote:
> The 32 bit loader compat_do_execve did not store stack start (this was
> figured out by alexey).

yeah, but let's not mix it since these are two different issues
and KSTK_ESP should go through Ingo.

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

* Re: [PATCH] fix X86_64 procfs provide stack information for threads
  2009-11-03  9:06 ` Alexey Dobriyan
@ 2009-11-03  9:09   ` Stefani Seibold
  0 siblings, 0 replies; 5+ messages in thread
From: Stefani Seibold @ 2009-11-03  9:09 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, Andrew Morton

Am Dienstag, den 03.11.2009, 12:06 +0300 schrieb Alexey Dobriyan:
> On Mon, Nov 02, 2009 at 11:47:09AM +0100, Stefani Seibold wrote:
> > The 32 bit loader compat_do_execve did not store stack start (this was
> > figured out by alexey).
> 
> yeah, but let's not mix it since these are two different issues
> and KSTK_ESP should go through Ingo.

Ingo has contacted me... He has some complains about the #ifdef, so i
remove it. I will put you on the list.



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

end of thread, other threads:[~2009-11-03  9:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-02 10:47 [PATCH] fix X86_64 procfs provide stack information for threads Stefani Seibold
2009-11-03  5:58 ` Américo Wang
2009-11-03  7:26   ` Stefani Seibold
2009-11-03  9:06 ` Alexey Dobriyan
2009-11-03  9:09   ` Stefani Seibold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.