All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fengguang Wu <fengguang.wu@intel.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [x86] Kernel panic - not syncing: Fatal exception in interrupt
Date: Mon, 22 Jul 2013 00:21:13 +0800	[thread overview]
Message-ID: <20130721162113.GA5014@localhost> (raw)
In-Reply-To: <alpine.LNX.2.00.1307211004100.31632@pobox.suse.cz>

Hi Jiri,

> Fengguang, as I am not able to reproduce this bug locally, could you do me 
> a favor and test whether the patch below works the problem around, just 
> for the sake of testing the hypothesis?

Sure. I just created a branch with this patch on top of the first bad
commit, and queued the branch for boot tests.

Thanks,
Fengguang

> From: Jiri Kosina <jkosina@suse.cz>
> Subject: [PATCH] x86: call out into int3 handler directly instead of using notifier
> 
> ---
>  arch/x86/include/asm/alternative.h |    2 ++
>  arch/x86/kernel/alternative.c      |   22 +++++++++++++++++++++-
>  arch/x86/kernel/traps.c            |    4 ++++
>  3 files changed, 27 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
> index 3abf8dd..c22a41d 100644
> --- a/arch/x86/include/asm/alternative.h
> +++ b/arch/x86/include/asm/alternative.h
> @@ -5,6 +5,7 @@
>  #include <linux/stddef.h>
>  #include <linux/stringify.h>
>  #include <asm/asm.h>
> +#include <asm/ptrace.h>
>  
>  /*
>   * Alternative inline assembly for SMP.
> @@ -232,6 +233,7 @@ struct text_poke_param {
>  	size_t len;
>  };
>  
> +extern int poke_bp_int3_handler(struct pt_regs *regs);
>  extern void *text_poke(void *addr, const void *opcode, size_t len);
>  extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler);
>  extern void *text_poke_smp(void *addr, const void *opcode, size_t len);
> diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
> index 0ab4936..e1088f2 100644
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -605,6 +605,24 @@ static void do_sync_core(void *info)
>  static bool bp_patching_in_progress;
>  static void *bp_int3_handler, *bp_int3_addr;
>  
> +int poke_bp_int3_handler(struct pt_regs *regs)
> +{
> +	/* bp_patching_in_progress */
> +	smp_rmb();
> +
> +	if (likely(!bp_patching_in_progress))
> +		return 0;
> +
> +	if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
> +		return 0;
> +
> +	/* set up the specified breakpoint handler */
> +	regs->ip = (unsigned long) bp_int3_handler;
> +
> +	return 1;
> +
> +}
> +
>  static int int3_notify(struct notifier_block *self, unsigned long val, void *data)
>  {
>  	struct die_args *args = data;
> @@ -689,6 +707,7 @@ void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
>  	return addr;
>  }
>  
> +#if 0
>  /* this one needs to run before anything else handles it as a
>   * regular exception */
>  static struct notifier_block int3_nb = {
> @@ -700,8 +719,9 @@ static int __init int3_init(void)
>  {
>  	return register_die_notifier(&int3_nb);
>  }
> -
>  arch_initcall(int3_init);
> +#endif
> +
>  /*
>   * Cross-modifying kernel text with stop_machine().
>   * This code originally comes from immediate value.
> diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> index 772e2a8..e464764 100644
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -58,6 +58,7 @@
>  #include <asm/mce.h>
>  #include <asm/fixmap.h>
>  #include <asm/mach_traps.h>
> +#include <asm/alternative.h>
>  
>  #ifdef CONFIG_X86_64
>  #include <asm/x86_init.h>
> @@ -324,6 +325,9 @@ dotraplinkage void __kprobes notrace do_int3(struct pt_regs *regs, long error_co
>  	    ftrace_int3_handler(regs))
>  		return;
>  #endif
> +	if (poke_bp_int3_handler(regs))
> +		return;
> +
>  	prev_state = exception_enter();
>  #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
>  	if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
> 
> -- 
> Jiri Kosina
> SUSE Labs

  reply	other threads:[~2013-07-21 16:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-20 13:12 [x86] Kernel panic - not syncing: Fatal exception in interrupt Fengguang Wu
2013-07-21  0:23 ` H. Peter Anvin
2013-07-21  8:30   ` Jiri Kosina
2013-07-21 16:21     ` Fengguang Wu [this message]
2013-07-21 17:21     ` H. Peter Anvin
2013-07-22 11:18       ` Jiri Kosina
2013-07-22  1:07     ` Fengguang Wu
2013-07-22 11:14 ` [PATCH -tip/x86/jumplabel] x86: call out into int3 handler directly instead of using notifier Jiri Kosina
2013-07-22 11:24   ` Masami Hiramatsu
2013-07-22 20:53   ` H. Peter Anvin
2013-07-22 21:00     ` Jiri Kosina
2013-07-23  1:24       ` Masami Hiramatsu
2013-07-23  7:45         ` Ingo Molnar
2013-07-23  8:09           ` Jiri Kosina
2013-07-24  3:55             ` [tip:perf/core] kprobes/x86: Call out into INT3 " tip-bot for Jiri Kosina
2013-07-24 14:33               ` H. Peter Anvin
2013-07-29  9:06                 ` Jiri Kosina
2013-07-29  9:14                   ` H. Peter Anvin
2013-07-29  9:18                     ` Jiri Kosina
2013-07-29  9:23                       ` H. Peter Anvin

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=20130721162113.GA5014@localhost \
    --to=fengguang.wu@intel.com \
    --cc=hpa@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.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 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.