public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Amit S. Kale" <amitkale@emsyssoft.com>
To: Tom Rini <trini@kernel.crashing.org>,
	Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Pavel Machek <pavel@suse.cz>,
	kgdb-bugreport@lists.sourceforge.net
Subject: Re: [KGDB PATCH][4/7] Fix x86_64 hooks
Date: Mon, 1 Mar 2004 18:03:05 +0530	[thread overview]
Message-ID: <200403011803.05687.amitkale@emsyssoft.com> (raw)
In-Reply-To: <20040227214031.GF1052@smtp.west.cox.net>

I guess you haven't tested this on an x86_64 machine. Please checkin. I'll 
test once you do that. If there is something incorrect (unlikely), I'll fix 
it.

-Amit


On Saturday 28 Feb 2004 3:10 am, Tom Rini wrote:
> Hello.  The following is more complicated than it looks.  This makes the
> x86_64 stub add kgdb to the die_chain, and then remove all of the now
> unneeded CHK_DEBUGGER statements, and other whitespace changes.  In the
> end, the x86_64 patch looks like:
>  arch/x86_64/Kconfig            |    4
>  arch/x86_64/kernel/Makefile    |    1
>  arch/x86_64/kernel/entry.S     |   41 +++
>  arch/x86_64/kernel/irq.c       |    2
>  arch/x86_64/kernel/kgdb.c      |  478
> +++++++++++++++++++++++++++++++++++++++++ arch/x86_64/kernel/traps.c     | 
>   3
>  include/asm-x86_64/kgdb.h      |   54 ++++
>  include/asm-x86_64/processor.h |    1
>  8 files changed, 577 insertions(+), 7 deletions(-)
>
> As an aside, I now know how to kill off user_schedule bits on i386/x86_64,
> so with more thought on how to do it cleanly for everyone, the entry.S
> changes can die.
>
> diff -zrupN linux-2.6.3+config+serial/arch/x86_64/kernel/kgdb.c
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/kgdb.c ---
> linux-2.6.3+config+serial/arch/x86_64/kernel/kgdb.c	2004-02-27
> 12:16:13.000000000 -0700 +++
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/kgdb.c	2004-0
>2-27 12:16:14.000000000 -0700 @@ -41,6 +41,7 @@
>  #endif
>  #include <linux/init.h>
>  #include <linux/debugger.h>
> +#include <asm/kdebug.h>
>
>  /* Put the error code here just in case the user cares.  */
>  int gdb_x86_64errcode;
> @@ -443,6 +444,33 @@ struct pt_regs *kgdb_shadow_regs(struct
>  	return NULL;
>  }
>
> +/* Register KGDB with the die_chain so that we hook into all of the right
> + * spots. */
> +static int kgdb_notify(struct notifier_block *self, unsigned long cmd,
> +		void *ptr)
> +{
> +        struct die_args *d = ptr;
> +
> +        if (!kgdb_connected || (cmd == DIE_DEBUG && user_mode(d->regs)))
> +                return NOTIFY_DONE;
> +        if (cmd == DIE_NMI_IPI) {
> +                if (atomic_read(debugger_active))
> +                        return NOTIFY_BAD;
> +        } else if ((*linux_debug_hook)(d->trapnr, d->signr, d->err,
> d->regs)) +                return NOTIFY_BAD; /* skip */
> +
> +        return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block kgdb_notifier = {
> +        .notifier_call = kgdb_notify,
> +};
> +
> +int kgdb_arch_init(void)
> +{
> +	notifier_chain_register(&die_chain, &kgdb_notifier);
> +}
> +
>  struct kgdb_arch arch_kgdb_ops = {
>  	.gdb_bpt_instr = {0xcc},
>  	.flags = KGDB_HW_BREAKPOINT,
> diff -zrupN linux-2.6.3+config+serial/arch/x86_64/kernel/nmi.c
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/nmi.c ---
> linux-2.6.3+config+serial/arch/x86_64/kernel/nmi.c	2004-02-27
> 12:16:13.000000000 -0700 +++
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/nmi.c	2004-02
>-27 12:11:20.000000000 -0700 @@ -24,7 +24,6 @@
>  #include <linux/module.h>
>  #include <linux/sysdev.h>
>  #include <linux/nmi.h>
> -#include <linux/debugger.h>
>
>  #include <asm/smp.h>
>  #include <asm/mtrr.h>
> @@ -318,26 +317,13 @@ void nmi_watchdog_tick (struct pt_regs *
>  		return;
>
>  	sum = read_pda(apic_timer_irqs);
> -	if (atomic_read(&debugger_active)) {
> -
> -		/*
> -		 * The machine is in debugger, hold this cpu if already
> -		 * not held.
> -		 */
> -		debugger_nmihook(cpu, regs);
> -		alert_counter[cpu] = 0;
> -
> -	} else if (last_irq_sums[cpu] == sum) {
> -
> +	if (last_irq_sums[cpu] == sum) {
>  		/*
>  		 * Ayiee, looks like this CPU is stuck ...
>  		 * wait a few IRQs (5 seconds) before doing the oops ...
>  		 */
>  		alert_counter[cpu]++;
>  		if (alert_counter[cpu] == 5*nmi_hz) {
> -
> -			CHK_DEBUGGER(2,SIGSEGV,0,regs,)
> -
>  			if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_BAD)
> { alert_counter[cpu] = 0;
>  				return;
> diff -zrupN linux-2.6.3+config+serial/arch/x86_64/kernel/traps.c
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/traps.c ---
> linux-2.6.3+config+serial/arch/x86_64/kernel/traps.c	2004-02-27
> 12:16:13.000000000 -0700 +++
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/kernel/traps.c	2004-
>02-27 12:16:14.000000000 -0700 @@ -364,7 +364,6 @@ void __die(const char *
> str, struct pt_r
>
>  void die(const char * str, struct pt_regs * regs, long err)
>  {
> -	CHK_DEBUGGER(1,SIGTRAP,err,regs,)
>  	oops_begin();
>  	handle_BUG(regs);
>  	__die(str, regs, err);
> @@ -438,7 +437,6 @@ static void do_trap(int trapnr, int sign
>  #define DO_ERROR(trapnr, signr, str, name) \
>  asmlinkage void do_##name(struct pt_regs * regs, long error_code) \
>  { \
> -	CHK_DEBUGGER(1,SIGTRAP,error_code,regs,return) \
>  	if (notify_die(DIE_TRAP, str, regs, error_code, trapnr, signr) ==
> NOTIFY_BAD) \ return; \
>  	do_trap(trapnr, signr, str, regs, error_code, NULL); \
> @@ -646,7 +644,6 @@ asmlinkage void do_debug(struct pt_regs
>  	force_sig_info(SIGTRAP, &info, tsk);
>  clear_dr7:
>  	asm volatile("movq %0,%%db7"::"r"(0UL));
> -	CHK_DEBUGGER(1,SIGTRAP,error_code,regs,return)
>  	notify_die(DIE_DEBUG, "debug", regs, error_code, 1, SIGTRAP);
>  	return;
>
> diff -zrupN linux-2.6.3+config+serial/arch/x86_64/mm/fault.c
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/mm/fault.c ---
> linux-2.6.3+config+serial/arch/x86_64/mm/fault.c	2004-02-27
> 12:16:13.000000000 -0700 +++
> linux-2.6.3+config+serial+sysrq+arch_hooks/arch/x86_64/mm/fault.c	2004-02-2
>7 12:10:49.000000000 -0700 @@ -23,7 +23,6 @@
>  #include <linux/vt_kern.h>		/* For unblank_screen() */
>  #include <linux/compiler.h>
>  #include <linux/module.h>
> -#include <linux/debugger.h>
>
>  #include <asm/system.h>
>  #include <asm/uaccess.h>
> @@ -408,7 +407,6 @@ no_context:
>
>   	if (is_prefetch(regs, address))
>   		return;
> -	CHK_DEBUGGER(14, SIGSEGV,error_code, regs,)
>
>  	if (is_errata93(regs, address))
>  		return;
> diff -zrupN linux-2.6.3+config+serial/include/asm-x86_64/calling.h
> linux-2.6.3+config+serial+sysrq+arch_hooks/include/asm-x86_64/calling.h ---
> linux-2.6.3+config+serial/include/asm-x86_64/calling.h	2004-02-27
> 12:16:13.000000000 -0700 +++
> linux-2.6.3+config+serial+sysrq+arch_hooks/include/asm-x86_64/calling.h	200
>4-02-27 12:12:03.000000000 -0700 @@ -12,7 +12,7 @@
>  #define RBX 40
>  /* arguments: interrupts/non tracing syscalls only save upto here*/
>  #define R11 48
> -#define R10 56
> +#define R10 56
>  #define R9 64
>  #define R8 72
>  #define RAX 80


  parent reply	other threads:[~2004-03-01 12:33 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-27 21:23 [KGDB PATCH][1/7] Add / use kernel/Kconfig.kgdb Tom Rini
2004-02-27 21:25 ` [KGDB PATCH][2/7] Serial updates, take 2 Tom Rini
2004-02-27 21:32   ` [KGDB PATCH][3/7] SysRq-G Tom Rini
2004-02-27 21:40     ` [KGDB PATCH][4/7] Fix x86_64 hooks Tom Rini
2004-02-27 21:46       ` [KGDB PATCH][5/7] Fix ppc32 hooks Tom Rini
2004-02-27 21:52         ` [KGDB PATCH][6/7] KGDBOE fixes Tom Rini
2004-02-27 21:54           ` [KGDB PATCH][7/7] Move debugger_entry() Tom Rini
2004-02-27 22:53             ` [Kgdb-bugreport] " George Anzinger
2004-02-27 23:08               ` Tom Rini
2004-03-01 10:08             ` Amit S. Kale
2004-03-03  1:08               ` George Anzinger
2004-03-03  5:45                 ` Amit S. Kale
2004-03-11 21:24                   ` George Anzinger
2004-03-11 22:27                     ` Tom Rini
2004-03-11 22:49                       ` George Anzinger
2004-03-11 22:58                         ` Tom Rini
2004-03-12  4:42                     ` Amit S. Kale
2004-03-12 15:11                       ` Tom Rini
2004-03-01 10:42           ` [KGDB PATCH][6/7] KGDBOE fixes Amit S. Kale
2004-03-01 12:31         ` [KGDB PATCH][5/7] Fix ppc32 hooks Amit S. Kale
2004-03-01 12:33       ` Amit S. Kale [this message]
2004-02-27 22:49     ` [Kgdb-bugreport] [KGDB PATCH][3/7] SysRq-G George Anzinger
2004-03-01 10:05       ` Amit S. Kale
2004-02-27 22:44   ` [Kgdb-bugreport] [KGDB PATCH][2/7] Serial updates, take 2 George Anzinger
2004-02-27 23:11     ` Tom Rini
2004-02-27 23:53       ` George Anzinger
2004-03-01 15:28         ` Tom Rini
2004-03-02 11:36           ` Amit S. Kale
2004-03-02 15:04             ` Tom Rini
2004-02-27 22:30 ` [Kgdb-bugreport] [KGDB PATCH][1/7] Add / use kernel/Kconfig.kgdb George Anzinger
2004-02-27 22:39   ` Tom Rini
2004-02-27 23:50   ` Pavel Machek
2004-02-28  1:08     ` George Anzinger
2004-03-01  9:24       ` Amit S. Kale
2004-03-02 21:38         ` George Anzinger
2004-03-03  5:30           ` Amit S. Kale
2004-03-04  0:15             ` George Anzinger
2004-03-01  9:28 ` Amit S. Kale
2004-03-02 11:39 ` Amit S. Kale
2004-03-02 15:05   ` Tom Rini
2004-03-02 22:23     ` Pavel Machek
2004-03-02 22:34       ` Tom Rini
2004-03-02 22:35         ` Pavel Machek
2004-03-03  7:54           ` Amit S. Kale

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=200403011803.05687.amitkale@emsyssoft.com \
    --to=amitkale@emsyssoft.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=trini@kernel.crashing.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