From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751508AbdALKOx (ORCPT ); Thu, 12 Jan 2017 05:14:53 -0500 Received: from terminus.zytor.com ([198.137.202.10]:39310 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbdALKO3 (ORCPT ); Thu, 12 Jan 2017 05:14:29 -0500 Date: Thu, 12 Jan 2017 02:05:10 -0800 From: tip-bot for Josh Poimboeuf Message-ID: Cc: jpoimboe@redhat.com, torvalds@linux-foundation.org, tglx@linutronix.de, dvyukov@google.com, luto@kernel.org, mingo@kernel.org, mbenes@suse.cz, linux-kernel@vger.kernel.org, hpa@zytor.com, bp@alien8.de, luto@amacapital.net, dvlasenk@redhat.com, davej@codemonkey.org.uk, peterz@infradead.org, brgerst@gmail.com Reply-To: torvalds@linux-foundation.org, jpoimboe@redhat.com, tglx@linutronix.de, luto@kernel.org, dvyukov@google.com, mingo@kernel.org, mbenes@suse.cz, linux-kernel@vger.kernel.org, luto@amacapital.net, bp@alien8.de, hpa@zytor.com, davej@codemonkey.org.uk, dvlasenk@redhat.com, brgerst@gmail.com, peterz@infradead.org In-Reply-To: <598e9f7505ed0aba86e8b9590aa528c6c7ae8dcd.1483978430.git.jpoimboe@redhat.com> References: <598e9f7505ed0aba86e8b9590aa528c6c7ae8dcd.1483978430.git.jpoimboe@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/unwind: Include __schedule() in stack traces Git-Commit-ID: 2c96b2fe9c57b4267c3f0a680d82d7cc52e1c447 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 2c96b2fe9c57b4267c3f0a680d82d7cc52e1c447 Gitweb: http://git.kernel.org/tip/2c96b2fe9c57b4267c3f0a680d82d7cc52e1c447 Author: Josh Poimboeuf AuthorDate: Mon, 9 Jan 2017 12:00:24 -0600 Committer: Ingo Molnar CommitDate: Thu, 12 Jan 2017 09:28:28 +0100 x86/unwind: Include __schedule() in stack traces In the following commit: 0100301bfdf5 ("sched/x86: Rewrite the switch_to() code") ... the layout of the 'inactive_task_frame' struct was designed to have a frame pointer header embedded in it, so that the unwinder could use the 'bp' and 'ret_addr' fields to report __schedule() on the stack (or ret_from_fork() for newly forked tasks which haven't actually run yet). Finish the job by changing get_frame_pointer() to return a pointer to inactive_task_frame's 'bp' field rather than 'bp' itself. This allows the unwinder to start one frame higher on the stack, so that it properly reports __schedule(). Reported-by: Miroslav Benes Signed-off-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Jones Cc: Denys Vlasenko Cc: Dmitry Vyukov Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/598e9f7505ed0aba86e8b9590aa528c6c7ae8dcd.1483978430.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/stacktrace.h | 5 +---- arch/x86/include/asm/switch_to.h | 10 +++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h index 20ce3db..2e41c50 100644 --- a/arch/x86/include/asm/stacktrace.h +++ b/arch/x86/include/asm/stacktrace.h @@ -52,16 +52,13 @@ static inline bool on_stack(struct stack_info *info, void *addr, size_t len) static inline unsigned long * get_frame_pointer(struct task_struct *task, struct pt_regs *regs) { - struct inactive_task_frame *frame; - if (regs) return (unsigned long *)regs->bp; if (task == current) return __builtin_frame_address(0); - frame = (struct inactive_task_frame *)task->thread.sp; - return (unsigned long *)READ_ONCE_NOCHECK(frame->bp); + return &((struct inactive_task_frame *)task->thread.sp)->bp; } #else static inline unsigned long * diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h index 5cb436a..fcc5cd3 100644 --- a/arch/x86/include/asm/switch_to.h +++ b/arch/x86/include/asm/switch_to.h @@ -36,7 +36,10 @@ static inline void prepare_switch_to(struct task_struct *prev, asmlinkage void ret_from_fork(void); -/* data that is pointed to by thread.sp */ +/* + * This is the structure pointed to by thread.sp for an inactive task. The + * order of the fields must match the code in __switch_to_asm(). + */ struct inactive_task_frame { #ifdef CONFIG_X86_64 unsigned long r15; @@ -48,6 +51,11 @@ struct inactive_task_frame { unsigned long di; #endif unsigned long bx; + + /* + * These two fields must be together. They form a stack frame header, + * needed by get_frame_pointer(). + */ unsigned long bp; unsigned long ret_addr; };