public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Safonov <dima@arista.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Dmitry Safonov <dima@arista.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Ingo Molnar <mingo@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH-4.19-stable 2/2] x86/stackframe, x86/ftrace: Add pt_regs frame annotations
Date: Mon, 10 Feb 2020 14:05:43 +0000	[thread overview]
Message-ID: <20200210140543.79641-3-dima@arista.com> (raw)
In-Reply-To: <20200210140543.79641-1-dima@arista.com>

From: Peter Zijlstra <peterz@infradead.org>

[ Upstream commit ea1ed38dba64b64a245ab8ca1406269d17b99485 ]

When CONFIG_FRAME_POINTER, we should mark pt_regs frames.

Fixes user-visible warning for unwinder (i.e, ftrace's stack tracer):
> WARNING: kernel stack frame pointer at 00000000bceb5183 in Coronavirus:3282 has bad value           (null)
>  unwind stack type:0 next_sp:          (null) mask:0x2 graph_idx:0
>  000000009630aa47: ffffc9000126fdb0 (0xffffc9000126fdb0)
>  0000000020360f53: ffffffff81038e33 (__save_stack_trace+0xcb/0xee)
>  00000000675081f2: 0000000000000000 ...
>  0000000043198fe7: ffffc9000126c000 (0xffffc9000126c000)
>  0000000008a46231: ffffc90001270000 (0xffffc90001270000)
[..]

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
[4.19 backport; added user-visible changelog]
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 arch/x86/kernel/ftrace_32.S | 3 +++
 arch/x86/kernel/ftrace_64.S | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/arch/x86/kernel/ftrace_32.S b/arch/x86/kernel/ftrace_32.S
index 4c8440de3355..83f18e829ac7 100644
--- a/arch/x86/kernel/ftrace_32.S
+++ b/arch/x86/kernel/ftrace_32.S
@@ -9,6 +9,7 @@
 #include <asm/export.h>
 #include <asm/ftrace.h>
 #include <asm/nospec-branch.h>
+#include <asm/frame.h>
 
 #ifdef CC_USING_FENTRY
 # define function_hook	__fentry__
@@ -131,6 +132,8 @@ ENTRY(ftrace_regs_caller)
 	pushl	%ecx
 	pushl	%ebx
 
+	ENCODE_FRAME_POINTER
+
 	movl	12*4(%esp), %eax		/* Load ip (1st parameter) */
 	subl	$MCOUNT_INSN_SIZE, %eax		/* Adjust ip */
 #ifdef CC_USING_FENTRY
diff --git a/arch/x86/kernel/ftrace_64.S b/arch/x86/kernel/ftrace_64.S
index 75f2b36b41a6..24b9abf718e8 100644
--- a/arch/x86/kernel/ftrace_64.S
+++ b/arch/x86/kernel/ftrace_64.S
@@ -9,6 +9,7 @@
 #include <asm/export.h>
 #include <asm/nospec-branch.h>
 #include <asm/unwind_hints.h>
+#include <asm/frame.h>
 
 	.code64
 	.section .entry.text, "ax"
@@ -222,6 +223,8 @@ GLOBAL(ftrace_regs_caller_op_ptr)
 	leaq MCOUNT_REG_SIZE+8*2(%rsp), %rcx
 	movq %rcx, RSP(%rsp)
 
+	ENCODE_FRAME_POINTER
+
 	/* regs go into 4th parameter */
 	leaq (%rsp), %rcx
 
-- 
2.25.0


  parent reply	other threads:[~2020-02-10 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 14:05 [PATCH-4.19-stable 0/2] Backport ENCODE_FRAME_POINTER hint Dmitry Safonov
2020-02-10 14:05 ` [PATCH-4.19-stable 1/2] x86/stackframe: Move ENCODE_FRAME_POINTER to asm/frame.h Dmitry Safonov
2020-02-10 14:05 ` Dmitry Safonov [this message]
2020-02-13 15:01 ` [PATCH-4.19-stable 0/2] Backport ENCODE_FRAME_POINTER hint Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200210140543.79641-3-dima@arista.com \
    --to=dima@arista.com \
    --cc=0x7f454c46@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox