From: Chen Zhongjin <chenzhongjin@huawei.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linux-arch@vger.kernel.org>
Cc: <linux@armlinux.org.uk>, <arnd@arndb.de>,
<linus.walleij@linaro.org>, <ardb@kernel.org>,
<rmk+kernel@armlinux.org.uk>, <rostedt@goodmis.org>,
<nick.hawkins@hpe.com>, <john@phrozen.org>, <mhiramat@kernel.org>
Subject: Re: [PATCH] x86/unwind/orc: Add 'unwind_debug' cmdline option
Date: Mon, 15 Aug 2022 19:04:52 +0800 [thread overview]
Message-ID: <1b8cfda9-8a33-91af-dee1-a0586a11adf1@huawei.com> (raw)
In-Reply-To: <20220815105808.17385-2-chenzhongjin@huawei.com>
I accidentally attached this with my patch.
Please ignore this one.
Thanks,
Chen
On 2022/8/15 18:58, Chen Zhongjin wrote:
> From: Josh Poimboeuf <jpoimboe@redhat.com>
>
> Sometimes the one-line ORC unwinder warnings aren't very helpful. Add a
> new 'unwind_debug' cmdline option which will dump the full stack
> contents of the current task when an error condition is encountered.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> Reviewed-by: Miroslav Benes <mbenes@suse.cz>
> ---
> .../admin-guide/kernel-parameters.txt | 6 +++
> arch/x86/kernel/unwind_orc.c | 46 +++++++++++++++++++
> 2 files changed, 52 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index cc3ea8febc62..85d48f6052fd 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6317,6 +6317,12 @@
> unknown_nmi_panic
> [X86] Cause panic on unknown NMI.
>
> + unwind_debug [X86-64]
> + Enable unwinder debug output. This can be
> + useful for debugging certain unwinder error
> + conditions, including corrupt stacks and
> + bad/missing unwinder metadata.
> +
> usbcore.authorized_default=
> [USB] Default USB device authorization:
> (default -1 = authorized except for wireless USB,
> diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c
> index 38185aedf7d1..c539ca39e9f4 100644
> --- a/arch/x86/kernel/unwind_orc.c
> +++ b/arch/x86/kernel/unwind_orc.c
> @@ -13,8 +13,13 @@
>
> #define orc_warn_current(args...) \
> ({ \
> + static bool dumped_before;
> if (state->task == current && !state->error) \
> orc_warn(args); \
> + if (unwind_debug && !dumped_before) \
> + unwind_dump(state); \
> + dumped_before = true; \
> + } \
> })
>
> extern int __start_orc_unwind_ip[];
> @@ -23,8 +28,49 @@ extern struct orc_entry __start_orc_unwind[];
> extern struct orc_entry __stop_orc_unwind[];
>
> static bool orc_init __ro_after_init;
> +static bool unwind_debug __ro_after_init;
> static unsigned int lookup_num_blocks __ro_after_init;
>
> +static int __init unwind_debug_cmdline(char *str)
> +{
> + unwind_debug = true;
> +
> + return 0;
> +}
> +early_param("unwind_debug", unwind_debug_cmdline);
> +
> +static void unwind_dump(struct unwind_state *state)
> +{
> + static bool dumped_before;
> + unsigned long word, *sp;
> + struct stack_info stack_info = {0};
> + unsigned long visit_mask = 0;
> +
> + if (dumped_before)
> + return;
> +
> + dumped_before = true;
> +
> + printk_deferred("unwind stack type:%d next_sp:%p mask:0x%lx graph_idx:%d\n",
> + state->stack_info.type, state->stack_info.next_sp,
> + state->stack_mask, state->graph_idx);
> +
> + for (sp = __builtin_frame_address(0); sp;
> + sp = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
> + if (get_stack_info(sp, state->task, &stack_info, &visit_mask))
> + break;
> +
> + for (; sp < stack_info.end; sp++) {
> +
> + word = READ_ONCE_NOCHECK(*sp);
> +
> + printk_deferred("%0*lx: %0*lx (%pB)\n", BITS_PER_LONG/4,
> + (unsigned long)sp, BITS_PER_LONG/4,
> + word, (void *)word);
> + }
> + }
> +}
> +
> static inline unsigned long orc_ip(const int *ip)
> {
> return (unsigned long)ip + *ip;
next prev parent reply other threads:[~2022-08-15 11:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 10:58 [RESEND PATCH] ARM: Recover kretprobes return address for EABI stack unwinder Chen Zhongjin
2022-08-15 10:58 ` [PATCH] x86/unwind/orc: Add 'unwind_debug' cmdline option Chen Zhongjin
2022-08-15 11:04 ` Chen Zhongjin [this message]
2022-08-15 19:41 ` kernel test robot
2022-08-15 23:44 ` kernel test robot
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=1b8cfda9-8a33-91af-dee1-a0586a11adf1@huawei.com \
--to=chenzhongjin@huawei.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=john@phrozen.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mhiramat@kernel.org \
--cc=nick.hawkins@hpe.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=rostedt@goodmis.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