Clean up excessive #ifdef'age of NMI trap handling for amd64/i386/xen.

Handle NMI in all Xen kernels.
This commit is contained in:
dyoung 2011-04-03 22:29:25 +00:00
parent 8056bccd98
commit 7b673ebd9e
15 changed files with 120 additions and 112 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.22 2010/12/20 00:25:24 matt Exp $ */
/* $NetBSD: db_interface.c,v 1.23 2011/04/03 22:29:25 dyoung Exp $ */
/*
* Mach Operating System
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.22 2010/12/20 00:25:24 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.23 2011/04/03 22:29:25 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -173,9 +173,11 @@ kdb_trap(int type, int code, db_regs_t *regs)
db_regs_t dbreg;
switch (type) {
case T_NMI: /* NMI */
printf("NMI ... going to debugger\n");
/*FALLTHROUGH*/
case T_BPTFLT: /* breakpoint */
case T_TRCTRAP: /* single_step */
case T_NMI: /* NMI */
case -1: /* keyboard interrupt */
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: kgdb_machdep.c,v 1.7 2010/12/20 00:25:24 matt Exp $ */
/* $NetBSD: kgdb_machdep.c,v 1.8 2011/04/03 22:29:25 dyoung Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.7 2010/12/20 00:25:24 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.8 2011/04/03 22:29:25 dyoung Exp $");
#include "opt_ddb.h"
@ -99,6 +99,13 @@ kgdb_acc(vaddr_t va, size_t len)
return (1);
}
void
kgdb_entry_notice(int type, db_regs_t *regs)
{
if (type == T_NMI)
printf("NMI ... going to debugger\n");
}
/*
* Translate a trap number into a unix compatible signal value.
* (gdb only understands unix signal numbers).

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.65 2010/12/20 00:25:24 matt Exp $ */
/* $NetBSD: trap.c,v 1.66 2011/04/03 22:29:25 dyoung Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2010/12/20 00:25:24 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.66 2011/04/03 22:29:25 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -98,9 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2010/12/20 00:25:24 matt Exp $");
#include <machine/reg.h>
#include <machine/trap.h>
#include <machine/userret.h>
#ifdef DDB
#include <machine/db_machdep.h>
#endif
#include <x86/nmi.h>
@ -108,9 +106,7 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.65 2010/12/20 00:25:24 matt Exp $");
#include "isa.h"
#endif
#ifdef KGDB
#include <sys/kgdb.h>
#endif
#ifdef KDTRACE_HOOKS
#include <sys/dtrace_bsd.h>
@ -283,24 +279,17 @@ trap(struct trapframe *frame)
" %lx cpl %x rsp %lx\n",
type, frame->tf_err, (u_long)frame->tf_rip, frame->tf_cs,
frame->tf_rflags, rcr2(), curcpu()->ci_ilevel, frame->tf_rsp);
#ifdef DDB
if (kdb_trap(type, 0, frame))
return;
#endif
#ifdef KGDB
if (kgdb_trap(type, frame))
return;
else {
/*
* If this is a breakpoint, don't panic
* if we're not connected.
*/
if (type == T_BPTFLT) {
printf("kgdb: ignored %s\n", trap_type[type]);
return;
}
/*
* If this is a breakpoint, don't panic if we're not connected.
*/
if (type == T_BPTFLT && kgdb_disconnected()) {
printf("kgdb: ignored %s\n", trap_type[type]);
return;
}
#endif
panic("trap");
/*NOTREACHED*/
@ -675,32 +664,17 @@ faultcommon:
break;
case T_NMI:
#if !defined(XEN)
if (nmi_dispatch(frame))
return;
#endif /* !defined(XEN) */
#if NISA > 0
#if defined(KGDB) || defined(DDB)
/* NMI can be hooked up to a pushbutton for debugging */
printf ("NMI ... going to debugger\n");
#ifdef KGDB
if (kgdb_trap(type, frame))
return;
#endif
#ifdef DDB
if (kdb_trap(type, 0, frame))
return;
#endif
#endif /* KGDB || DDB */
/* machine/parity/power fail/"kitchen sink" faults */
if (x86_nmi() != 0)
goto we_re_toast;
else
return;
#endif /* NISA > 0 */
; /* avoid a label at end of compound statement */
x86_nmi();
return;
}
if ((type & T_USER) == 0)

View File

@ -1,4 +1,4 @@
# $NetBSD: files.amd64,v 1.69 2010/07/08 11:24:59 rmind Exp $
# $NetBSD: files.amd64,v 1.70 2011/04/03 22:29:26 dyoung Exp $
#
# new style config file for amd64 architecture
#
@ -111,6 +111,9 @@ file arch/x86/isa/rtc.c isa
# TSC timecounter support
file arch/x86/x86/tsc.c
# Stubs for x86 routines not included in the system
file arch/x86/x86/x86_stub.c
# attribute used to represent the "keyboard controller"
# XXX should be a real device
define pckbcport { [irq = -1], [port = -1] }

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.65 2010/06/09 02:48:52 mrg Exp $ */
/* $NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $ */
/*
* Mach Operating System
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.65 2010/06/09 02:48:52 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.66 2011/04/03 22:29:26 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@ -182,9 +182,11 @@ kdb_trap(int type, int code, db_regs_t *regs)
regs->tf_err &= ~TC_FLAGMASK;
switch (type) {
case T_NMI: /* NMI */
printf("NMI ... going to debugger\n");
/*FALLTHROUGH*/
case T_BPTFLT: /* breakpoint */
case T_TRCTRAP: /* single_step */
case T_NMI: /* NMI */
case -1: /* keyboard interrupt */
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: kgdb_machdep.c,v 1.21 2009/10/18 18:14:00 snj Exp $ */
/* $NetBSD: kgdb_machdep.c,v 1.22 2011/04/03 22:29:26 dyoung Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -56,7 +56,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.21 2009/10/18 18:14:00 snj Exp $");
__KERNEL_RCSID(0, "$NetBSD: kgdb_machdep.c,v 1.22 2011/04/03 22:29:26 dyoung Exp $");
#include "opt_ddb.h"
@ -105,6 +105,13 @@ kgdb_acc(vaddr_t va, size_t len)
return (1);
}
void
kgdb_entry_notice(int type, db_regs_t *regs)
{
if (type == T_NMI)
printf("NMI ... going to debugger\n");
}
/*
* Translate a trap number into a unix compatible signal value.
* (gdb only understands unix signal numbers).

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.260 2010/12/20 00:25:35 matt Exp $ */
/* $NetBSD: trap.c,v 1.261 2011/04/03 22:29:26 dyoung Exp $ */
/*-
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.260 2010/12/20 00:25:35 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.261 2011/04/03 22:29:26 dyoung Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -102,22 +102,16 @@ __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.260 2010/12/20 00:25:35 matt Exp $");
#include <machine/reg.h>
#include <machine/trap.h>
#include <machine/userret.h>
#ifdef DDB
#include <machine/db_machdep.h>
#endif
#include "mca.h"
#if NMCA > 0
#include <machine/mca_machdep.h>
#endif
#include <x86/nmi.h>
#include "isa.h"
#ifdef KGDB
#include <sys/kgdb.h>
#endif
#include "npx.h"
@ -388,24 +382,17 @@ trap(struct trapframe *frame)
check_dr0();
else
trap_print(type, frame);
#ifdef DDB
if (kdb_trap(type, 0, frame))
return;
#endif
#ifdef KGDB
if (kgdb_trap(type, frame))
return;
else {
/*
* If this is a breakpoint, don't panic
* if we're not connected.
*/
if (type == T_BPTFLT) {
printf("kgdb: ignored %s\n", trap_type[type]);
return;
}
/*
* If this is a breakpoint, don't panic if we're not connected.
*/
if (type == T_BPTFLT && kgdb_disconnected()) {
printf("kgdb: ignored %s\n", trap_type[type]);
return;
}
#endif
panic("trap");
/*NOTREACHED*/
@ -806,40 +793,16 @@ faultcommon:
break;
case T_NMI:
#if !defined(XEN)
if (nmi_dispatch(frame))
return;
#if (NISA > 0 || NMCA > 0)
#if defined(KGDB) || defined(DDB)
/* NMI can be hooked up to a pushbutton for debugging */
printf ("NMI ... going to debugger\n");
#ifdef KGDB
if (kgdb_trap(type, frame))
return;
#endif
#ifdef DDB
if (kdb_trap(type, 0, frame))
return;
#endif
#endif /* KGDB || DDB */
/* machine/parity/power fail/"kitchen sink" faults */
#if NMCA > 0
/* mca_nmi() takes care to call x86_nmi() if appropriate */
if (mca_nmi() != 0)
goto we_re_toast;
else
return;
#else /* NISA > 0 */
if (x86_nmi() != 0)
goto we_re_toast;
else
return;
#endif /* NMCA > 0 */
#endif /* (NISA > 0 || NMCA > 0) */
#endif /* !defined(XEN) */
; /* avoid a label at end of compound statement */
mca_nmi();
x86_nmi();
}
if ((type & T_USER) == 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mca_machdep.h,v 1.13 2009/05/04 12:19:29 cegger Exp $ */
/* $NetBSD: mca_machdep.h,v 1.14 2011/04/03 22:29:26 dyoung Exp $ */
/*
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@ extern struct x86_bus_dma_tag mca_bus_dma_tag;
/* set to 1 if MCA bus is detected */
extern int MCA_system;
int mca_nmi(void);
void mca_nmi(void);
/*
* Types provided to machine-independent MCA code.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mca_machdep.c,v 1.39 2010/03/23 21:18:23 dyoung Exp $ */
/* $NetBSD: mca_machdep.c,v 1.40 2011/04/03 22:29:27 dyoung Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mca_machdep.c,v 1.39 2010/03/23 21:18:23 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: mca_machdep.c,v 1.40 2011/04/03 22:29:27 dyoung Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -236,7 +236,7 @@ mca_intr_disestablish(mca_chipset_tag_t mc, void *cookie)
* Handle a NMI.
* return true to panic system, false to ignore.
*/
int
void
mca_nmi(void)
{
/*
@ -272,9 +272,8 @@ mca_nmi(void)
out:
if (!mcanmi) {
/* no CHCK bits asserted, assume ISA NMI */
return (x86_nmi());
} else
return(0);
x86_nmi();
}
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.h,v 1.41 2010/05/02 18:03:31 plunky Exp $ */
/* $NetBSD: intr.h,v 1.42 2011/04/03 22:29:27 dyoung Exp $ */
/*-
* Copyright (c) 1998, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -171,7 +171,7 @@ struct cpu_info;
struct pcibus_attach_args;
void intr_default_setup(void);
int x86_nmi(void);
void x86_nmi(void);
void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *, bool);
void intr_disestablish(struct intrhand *);
void intr_add_pcibus(struct pcibus_attach_args *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.c,v 1.70 2011/01/22 14:01:27 tsutsui Exp $ */
/* $NetBSD: intr.c,v 1.71 2011/04/03 22:29:27 dyoung Exp $ */
/*-
* Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@ -133,7 +133,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.70 2011/01/22 14:01:27 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.71 2011/04/03 22:29:27 dyoung Exp $");
#include "opt_intrdebug.h"
#include "opt_multiprocessor.h"
@ -222,12 +222,11 @@ intr_default_setup(void)
* Handle a NMI, possibly a machine check.
* return true to panic system, false to ignore.
*/
int
void
x86_nmi(void)
{
log(LOG_CRIT, "NMI port 61 %x, port 70 %x\n", inb(0x61), inb(0x70));
return(0);
}
/*

View File

@ -0,0 +1,28 @@
/* $NetBSD: x86_stub.c,v 1.1 2011/04/03 22:29:27 dyoung Exp $ */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x86_stub.c,v 1.1 2011/04/03 22:29:27 dyoung Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kgdb.h>
int x86_nullop(void);
void x86_voidop(void);
void
x86_voidop(void)
{
}
int
x86_nullop(void)
{
return 0;
}
__weak_alias(kdb_trap, x86_nullop);
__weak_alias(kgdb_disconnected, x86_nullop);
__weak_alias(kgdb_trap, x86_nullop);
__weak_alias(mca_nmi, x86_voidop);
__weak_alias(x86_nmi, x86_voidop);

View File

@ -1,4 +1,4 @@
# $NetBSD: files.xen,v 1.113 2011/02/24 10:56:03 jruoho Exp $
# $NetBSD: files.xen,v 1.114 2011/04/03 22:29:27 dyoung Exp $
# NetBSD: files.x86,v 1.10 2003/10/08 17:30:00 bouyer Exp
# NetBSD: files.i386,v 1.254 2004/03/25 23:32:10 jmc Exp
@ -255,6 +255,9 @@ file arch/x86/x86/mpacpi.c acpi
file arch/x86/x86/acpi_machdep.c acpi
file arch/x86/x86/i8259.c
# Stubs for x86 routines not included in the system
file arch/x86/x86/x86_stub.c
# MP configuration using Intel SMP specification 1.4
file arch/x86/x86/mpbios.c mpbios
@ -265,6 +268,7 @@ file arch/x86/pci/pci_bus_fixup.c pci_bus_fixup
file arch/x86/pci/pci_addr_fixup.c pci_addr_fixup
file arch/x86/x86/apic.c ioapic
file arch/x86/x86/nmi.c
device ioapic
attach ioapic at ioapicbus

View File

@ -1,4 +1,4 @@
/* $NetBSD: kgdb_stub.c,v 1.23 2009/01/11 10:20:53 cegger Exp $ */
/* $NetBSD: kgdb_stub.c,v 1.24 2011/04/03 22:29:28 dyoung Exp $ */
/*
* Copyright (c) 1990, 1993
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.23 2009/01/11 10:20:53 cegger Exp $");
__KERNEL_RCSID(0, "$NetBSD: kgdb_stub.c,v 1.24 2011/04/03 22:29:28 dyoung Exp $");
#include "opt_kgdb.h"
@ -94,6 +94,16 @@ static kgdb_reg_t gdb_regs[KGDB_NUMREGS];
*/
void (*db_trap_callback)(int);
void kgdb_voidop(void);
__weak_alias(kgdb_entry_notice, kgdb_voidop);
void
kgdb_voidop(void)
{
return;
}
/*
* This little routine exists simply so that bcopy() can be debugged.
*/
@ -321,6 +331,8 @@ kgdb_trap(int type, db_regs_t *regs)
size_t len;
u_char *p;
kgdb_entry_notice(type, regs);
if (kgdb_dev == NODEV || kgdb_getc == NULL) {
/* not debugging */
return (0);
@ -527,3 +539,9 @@ kgdb_trap(int type, db_regs_t *regs)
kgdb_recover = 0;
return (1);
}
int
kgdb_disconnected(void)
{
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kgdb.h,v 1.11 2009/01/11 10:20:53 cegger Exp $ */
/* $NetBSD: kgdb.h,v 1.12 2011/04/03 22:29:28 dyoung Exp $ */
/*
* Copyright (c) 1992, 1993
@ -89,12 +89,14 @@ void kgdb_attach(int (*)(void *), void (*)(void *, int), void *);
void kgdb_connect(int);
void kgdb_panic(void);
int kgdb_trap(int, db_regs_t *);
int kgdb_disconnected(void);
/*
* Machine dependent functions needed by kgdb_stub.c
*/
int kgdb_signal(int);
int kgdb_acc(vaddr_t, size_t);
void kgdb_entry_notice(int, db_regs_t *);
void kgdb_getregs(db_regs_t *, kgdb_reg_t *);
void kgdb_setregs(db_regs_t *, kgdb_reg_t *);