Bug #647 » vkhalt-HEAD.patch
share/man/man7/vkernel.7 10 Jun 2007 23:09:02 -0000 | ||
---|---|---|
.Xr tap 4
|
||
device.
|
||
.Sh SIGNALS
|
||
The virtual kernel enables all terminal signals while in
|
||
.Xr ddb 4
|
||
mode but only enables
|
||
The virtual kernel only enables SIGQUIT and SIGTERM while operating in
|
||
regular console mode. Sending
|
||
.Ql \&^\e
|
||
.Pq Dv SIGQUIT
|
||
while operating as a console which causes the virtual kernel to enter its
|
||
internal
|
||
to the virtual kernel causes the virtual kernel to enter its internal
|
||
.Xr ddb 4
|
||
debugger.
|
||
debugger and re-enable all other terminal signals. Sending SIGTERM to the
|
||
virtual kernel triggers a clean shutdown by passing a SIGUSR2 to the
|
||
virtual kernel's
|
||
.Xr init 8
|
||
process.
|
||
.Sh DEBUGGING
|
||
It is possible to directly gdb the virtual kernel's process.
|
||
It is recommended that you do a
|
sys/platform/vkernel/i386/cpu_regs.c 10 Jun 2007 22:43:22 -0000 | ||
---|---|---|
if (cpu_idle_hlt && !lwkt_runnable() &&
|
||
(td->td_flags & TDF_IDLE_NOHLT) == 0) {
|
||
splz();
|
||
if (mdcpu->gd_shutdown)
|
||
exc_shutdown();
|
||
signalmailbox(NULL);
|
||
if (!lwkt_runnable()) {
|
||
sigpause(0);
|
||
... | ... | |
} else {
|
||
td->td_flags &= ~TDF_IDLE_NOHLT;
|
||
splz();
|
||
if (mdcpu->gd_shutdown)
|
||
exc_shutdown();
|
||
signalmailbox(NULL);
|
||
#ifdef SMP
|
||
/*__asm __volatile("sti; pause");*/
|
sys/platform/vkernel/i386/exception.c 10 Jun 2007 22:49:31 -0000 | ||
---|---|---|
#include <sys/types.h>
|
||
#include <sys/systm.h>
|
||
#include <sys/kernel.h>
|
||
#include <sys/reboot.h>
|
||
#include <ddb/ddb.h>
|
||
#include <sys/thread2.h>
|
||
... | ... | |
int _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
|
||
static void exc_segfault(int signo, siginfo_t *info, void *ctx);
|
||
void exc_shutdown( void );
|
||
#ifdef DDB
|
||
static void exc_debugger(int signo, siginfo_t *info, void *ctx);
|
||
#endif
|
||
... | ... | |
sigemptyset(&sa.sa_mask);
|
||
sigaction(SIGSEGV, &sa, NULL);
|
||
sigaction(SIGTRAP, &sa, NULL);
|
||
#ifdef DDB
|
||
sa.sa_sigaction = exc_debugger;
|
||
sigaction(SIGQUIT, &sa, NULL);
|
||
#endif
|
||
bzero(&sa, sizeof(sa));
|
||
sigemptyset(&sa.sa_mask);
|
||
sa.sa_flags |= SA_MAILBOX | SA_NODEFER;
|
||
sa.sa_mailbox = &mdcpu->gd_shutdown;
|
||
sigaction(SIGTERM, &sa, NULL);
|
||
}
|
||
/*
|
||
... | ... | |
splz();
|
||
}
|
||
/*
|
||
* This function handles external signals for shutdown.
|
||
*
|
||
* Currently, when a vkernel recieves a SIGTERM, either the VKERNEL init(8)
|
||
* is signaled with SIGUSR2, or simply shuts down, preventing filesystem
|
||
* checks from being needed upon reboot.
|
||
*/
|
||
void
|
||
exc_shutdown( void )
|
||
{
|
||
mdcpu->gd_shutdown = 0;
|
||
kprintf("Caught SIGTERM from host system. Shutting down...\n");
|
||
if (initproc != NULL) {
|
||
ksignal(initproc, SIGUSR2);
|
||
}
|
||
else {
|
||
reboot(RB_POWEROFF);
|
||
}
|
||
}
|
||
#ifdef DDB
|
||
static void
|
sys/platform/vkernel/i386/trap.c 10 Jun 2007 22:43:41 -0000 | ||
---|---|---|
* user_trap() when we break out of it (usually due to a signal).
|
||
*/
|
||
for (;;) {
|
||
/*
|
||
* Handle shutdown requests before attempting anything
|
||
*/
|
||
if (mdcpu->gd_shutdown)
|
||
exc_shutdown();
|
||
/*
|
||
* Tell the real kernel whether it is ok to use the FP
|
||
* unit or not.
|
sys/platform/vkernel/include/globaldata.h 10 Jun 2007 21:10:26 -0000 | ||
---|---|---|
int gd_spending; /* software interrupt pending */
|
||
int gd_sdelayed; /* delayed software ints */
|
||
int gd_currentldt;
|
||
int gd_mailbox; /* signal delivery mailbox */
|
||
int gd_mailbox; /* I/O signal delivery mailbox */
|
||
int gd_shutdown; /* Shutdown signal delivery mailbox */
|
||
u_int unused001;
|
||
u_int gd_other_cpus;
|
||
u_int gd_ss_eflags;
|