The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.9.x-ovz" and will appear 
at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.9.10
------>
commit 85583522d8aab897c25cecf72cf9c8b61a51ebc9
Author: Thomas Gleixner <t...@linutronix.de>
Date:   Wed Nov 18 13:23:15 2015 +0400

    ms/x86/process: Unify 32bit and 64bit implementations of get_wchan()
    
    The stack layout and the functionality is identical. Use the 64bit
    version for all of x86.
    
    Signed-off-by: Thomas Gleixner <t...@linutronix.de>
    Reviewed-by: Borislav Petkov <b...@alien8.de>
    Reviewed-by: Dmitry Vyukov <dvyu...@google.com>
    Cc: Andrey Ryabinin <ryabinin....@gmail.com>
    Cc: Andy Lutomirski <l...@amacapital.net>
    Cc: Andrey Konovalov <andreyk...@google.com>
    Cc: Kostya Serebryany <k...@google.com>
    Cc: Alexander Potapenko <gli...@google.com>
    Cc: kasan-dev <kasan-...@googlegroups.com>
    Cc: Denys Vlasenko <dvlas...@redhat.com>
    Cc: Andi Kleen <a...@linux.intel.com>
    Cc: Sasha Levin <sasha.le...@oracle.com>
    Cc: Wolfram Gloger <wm...@dent.med.uni-muenchen.de>
    Link: http://lkml.kernel.org/r/20150930083302.779694...@linutronix.de
    Signed-off-by: Thomas Gleixner <t...@linutronix.de>
    (cherry picked from commit 7ba78053aacb89998a052843e3c56983c31d57f0)
    Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
    
    Signed-off-by: Andrey Ryabinin <aryabi...@virtuozzo.com>
---
 arch/x86/kernel/process.c    | 55 +++++++++++++++++++++++++++++++++++++++++++
 arch/x86/kernel/process_32.c | 28 ----------------------
 arch/x86/kernel/process_64.c | 56 --------------------------------------------
 3 files changed, 55 insertions(+), 84 deletions(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 5111a56..ee3666a 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -470,3 +470,58 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
        return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
 }
 
+/*
+ * Called from fs/proc with a reference on @p to find the function
+ * which called into schedule(). This needs to be done carefully
+ * because the task might wake up and we might look at a stack
+ * changing under us.
+ */
+unsigned long get_wchan(struct task_struct *p)
+{
+       unsigned long start, bottom, top, sp, fp, ip;
+       int count = 0;
+
+       if (!p || p == current || p->state == TASK_RUNNING)
+               return 0;
+
+       start = (unsigned long)task_stack_page(p);
+       if (!start)
+               return 0;
+
+       /*
+        * Layout of the stack page:
+        *
+        * ----------- topmax = start + THREAD_SIZE - sizeof(unsigned long)
+        * PADDING
+        * ----------- top = topmax - TOP_OF_KERNEL_STACK_PADDING
+        * stack
+        * ----------- bottom = start + sizeof(thread_info)
+        * thread_info
+        * ----------- start
+        *
+        * The tasks stack pointer points at the location where the
+        * framepointer is stored. The data on the stack is:
+        * ... IP FP ... IP FP
+        *
+        * We need to read FP and IP, so we need to adjust the upper
+        * bound by another unsigned long.
+        */
+       top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
+       top -= 2 * sizeof(unsigned long);
+       bottom = start + sizeof(struct thread_info);
+
+       sp = READ_ONCE(p->thread.sp);
+       if (sp < bottom || sp > top)
+               return 0;
+
+       fp = READ_ONCE(*(unsigned long *)sp);
+       do {
+               if (fp < bottom || fp > top)
+                       return 0;
+               ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long)));
+               if (!in_sched_functions(ip))
+                       return ip;
+               fp = READ_ONCE(*(unsigned long *)fp);
+       } while (count++ < 16 && p->state != TASK_RUNNING);
+       return 0;
+}
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index dd02d27..ca615af 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -313,31 +313,3 @@ __switch_to(struct task_struct *prev_p, struct task_struct 
*next_p)
 
        return prev_p;
 }
-
-#define top_esp                (THREAD_SIZE - sizeof(unsigned long))
-#define top_ebp                (THREAD_SIZE - 2*sizeof(unsigned long))
-
-unsigned long get_wchan(struct task_struct *p)
-{
-       unsigned long bp, sp, ip;
-       unsigned long stack_page;
-       int count = 0;
-       if (!p || p == current || p->state == TASK_RUNNING)
-               return 0;
-       stack_page = (unsigned long)task_stack_page(p);
-       sp = p->thread.sp;
-       if (!stack_page || sp < stack_page || sp > top_esp+stack_page)
-               return 0;
-       /* include/asm-i386/system.h:switch_to() pushes bp last. */
-       bp = *(unsigned long *) sp;
-       do {
-               if (bp < stack_page || bp > top_ebp+stack_page)
-                       return 0;
-               ip = *(unsigned long *) (bp+4);
-               if (!in_sched_functions(ip))
-                       return ip;
-               bp = *(unsigned long *) bp;
-       } while (count++ < 16);
-       return 0;
-}
-
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 6970509..d9a542f 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -422,62 +422,6 @@ void set_personality_ia32(bool x32)
 }
 EXPORT_SYMBOL_GPL(set_personality_ia32);
 
-/*
- * Called from fs/proc with a reference on @p to find the function
- * which called into schedule(). This needs to be done carefully
- * because the task might wake up and we might look at a stack
- * changing under us.
- */
-unsigned long get_wchan(struct task_struct *p)
-{
-       unsigned long start, bottom, top, sp, fp, ip;
-       int count = 0;
-
-       if (!p || p == current || p->state == TASK_RUNNING)
-               return 0;
-
-       start = (unsigned long)task_stack_page(p);
-       if (!start)
-               return 0;
-
-       /*
-        * Layout of the stack page:
-        *
-        * ----------- topmax = start + THREAD_SIZE - sizeof(unsigned long)
-        * PADDING
-        * ----------- top = topmax - TOP_OF_KERNEL_STACK_PADDING
-        * stack
-        * ----------- bottom = start + sizeof(thread_info)
-        * thread_info
-        * ----------- start
-        *
-        * The tasks stack pointer points at the location where the
-        * framepointer is stored. The data on the stack is:
-        * ... IP FP ... IP FP
-        *
-        * We need to read FP and IP, so we need to adjust the upper
-        * bound by another unsigned long.
-        */
-       top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
-       top -= 2 * sizeof(unsigned long);
-       bottom = start + sizeof(struct thread_info);
-
-       sp = READ_ONCE(p->thread.sp);
-       if (sp < bottom || sp > top)
-               return 0;
-
-       fp = READ_ONCE(*(unsigned long *)sp);
-       do {
-               if (fp < bottom || fp > top)
-                       return 0;
-               ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long)));
-               if (!in_sched_functions(ip))
-                       return ip;
-               fp = READ_ONCE(*(unsigned long *)fp);
-       } while (count++ < 16 && p->state != TASK_RUNNING);
-       return 0;
-}
-
 long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
 {
        int ret = 0;
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to