[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] crash.patch
ChangeSet 1.1406, 2005/04/30 09:50:08+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx crash.patch FreeBSD calls domain_crash() on error so that its core is dumped. Signed-off-by: Kip Macy <kmacy@xxxxxxxxxxx> i386-xen/include/hypervisor.h | 18 + kern/kern_shutdown.c | 635 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 653 insertions(+) diff -Nru a/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h b/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h --- a/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h 2005-04-30 05:02:49 -04:00 +++ b/freebsd-5.3-xen-sparse/i386-xen/include/hypervisor.h 2005-04-30 05:02:49 -04:00 @@ -22,6 +22,7 @@ * be MACHINE addresses. */ +static inline void HYPERVISOR_crash(void) __dead2; void MULTICALL_flush_page_update_queue(void); @@ -199,6 +200,23 @@ "S" (srec) : "memory" ); return ret; +} + + +static inline void +HYPERVISOR_crash(void) +{ + int ret; + unsigned long ign1; + __asm__ __volatile__ ( + TRAP_INSTR + : "=a" (ret), "=b" (ign1) + : "0" (__HYPERVISOR_sched_op), + "1" (SCHEDOP_shutdown | (SHUTDOWN_crash << SCHEDOP_reasonshift)) + : "memory" ); + + for (;;) ; /* eliminate noreturn error */ + } static inline long diff -Nru a/freebsd-5.3-xen-sparse/kern/kern_shutdown.c b/freebsd-5.3-xen-sparse/kern/kern_shutdown.c --- /dev/null Wed Dec 31 16:00:00 196900 +++ b/freebsd-5.3-xen-sparse/kern/kern_shutdown.c 2005-04-30 05:02:49 -04:00 @@ -0,0 +1,635 @@ +/*- + * Copyright (c) 1986, 1988, 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)kern_shutdown.c 8.3 (Berkeley) 1/21/94 + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/sys/kern/kern_shutdown.c,v 1.163.2.2 2004/09/10 00:04:17 scottl Exp $"); + +#include "opt_kdb.h" +#include "opt_hw_wdog.h" +#include "opt_mac.h" +#include "opt_panic.h" +#include "opt_show_busybufs.h" +#include "opt_sched.h" + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/bio.h> +#include <sys/buf.h> +#include <sys/conf.h> +#include <sys/cons.h> +#include <sys/eventhandler.h> +#include <sys/kdb.h> +#include <sys/kernel.h> +#include <sys/kthread.h> +#include <sys/mac.h> +#include <sys/malloc.h> +#include <sys/mount.h> +#include <sys/proc.h> +#include <sys/reboot.h> +#include <sys/resourcevar.h> +#include <sys/smp.h> /* smp_active */ +#include <sys/sysctl.h> +#include <sys/sysproto.h> +#include <sys/vnode.h> + +#include <machine/cpu.h> +#include <machine/pcb.h> +#include <machine/smp.h> + +#include <sys/signalvar.h> + +#ifndef PANIC_REBOOT_WAIT_TIME +#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */ +#endif + +/* + * Note that stdarg.h and the ANSI style va_start macro is used for both + * ANSI and traditional C compilers. + */ +#include <machine/stdarg.h> + +#ifdef KDB +#ifdef KDB_UNATTENDED +int debugger_on_panic = 0; +#else +int debugger_on_panic = 1; +#endif +SYSCTL_INT(_debug, OID_AUTO, debugger_on_panic, CTLFLAG_RW, + &debugger_on_panic, 0, "Run debugger on kernel panic"); + +#ifdef KDB_TRACE +int trace_on_panic = 1; +#else +int trace_on_panic = 0; +#endif +SYSCTL_INT(_debug, OID_AUTO, trace_on_panic, CTLFLAG_RW, + &trace_on_panic, 0, "Print stack trace on kernel panic"); +#endif /* KDB */ + +int sync_on_panic = 0; +SYSCTL_INT(_kern, OID_AUTO, sync_on_panic, CTLFLAG_RW, + &sync_on_panic, 0, "Do a sync before rebooting from a panic"); + +SYSCTL_NODE(_kern, OID_AUTO, shutdown, CTLFLAG_RW, 0, "Shutdown environment"); + +#ifdef HW_WDOG +/* + * If there is a hardware watchdog, point this at the function needed to + * hold it off. + * It's needed when the kernel needs to do some lengthy operations. + * e.g. in wd.c when dumping core.. It's most annoying to have + * your precious core-dump only half written because the wdog kicked in. + */ +watchdog_tickle_fn wdog_tickler = NULL; +#endif /* HW_WDOG */ + +/* + * Variable panicstr contains argument to first call to panic; used as flag + * to indicate that the kernel has already called panic. + */ +const char *panicstr; + +int dumping; /* system is dumping */ +static struct dumperinfo dumper; /* our selected dumper */ + +/* Context information for dump-debuggers. */ +static struct pcb dumppcb; /* Registers. */ +static lwpid_t dumptid; /* Thread ID. */ + +static void boot(int) __dead2; +static void poweroff_wait(void *, int); +static void shutdown_halt(void *junk, int howto); +static void shutdown_panic(void *junk, int howto); +static void shutdown_reset(void *junk, int howto); + +/* register various local shutdown events */ +static void +shutdown_conf(void *unused) +{ + + EVENTHANDLER_REGISTER(shutdown_final, poweroff_wait, NULL, + SHUTDOWN_PRI_FIRST); + EVENTHANDLER_REGISTER(shutdown_final, shutdown_halt, NULL, + SHUTDOWN_PRI_LAST + 100); + EVENTHANDLER_REGISTER(shutdown_final, shutdown_panic, NULL, + SHUTDOWN_PRI_LAST + 100); + EVENTHANDLER_REGISTER(shutdown_final, shutdown_reset, NULL, + SHUTDOWN_PRI_LAST + 200); +} + +SYSINIT(shutdown_conf, SI_SUB_INTRINSIC, SI_ORDER_ANY, shutdown_conf, NULL) + +/* + * The system call that results in a reboot + * + * MPSAFE + */ +/* ARGSUSED */ +int +reboot(struct thread *td, struct reboot_args *uap) +{ + int error; + + error = 0; +#ifdef MAC + error = mac_check_system_reboot(td->td_ucred, uap->opt); +#endif + if (error == 0) + error = suser(td); + if (error == 0) { + mtx_lock(&Giant); + boot(uap->opt); + mtx_unlock(&Giant); + } + return (error); +} + +/* + * Called by events that want to shut down.. e.g <CTL><ALT><DEL> on a PC + */ +static int shutdown_howto = 0; + +void +shutdown_nice(int howto) +{ + + shutdown_howto = howto; + + /* Send a signal to init(8) and have it shutdown the world */ + if (initproc != NULL) { + PROC_LOCK(initproc); + psignal(initproc, SIGINT); + PROC_UNLOCK(initproc); + } else { + /* No init(8) running, so simply reboot */ + boot(RB_NOSYNC); + } + return; +} +static int waittime = -1; + +static void +print_uptime(void) +{ + int f; + struct timespec ts; + + getnanouptime(&ts); + printf("Uptime: "); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |