Project

General

Profile

Bug #647 » vkhalt-HEAD.patch

c.turner, 06/10/2007 11:46 PM

View differences:

share/man/man7/vkernel.7 10 Jun 2007 23:09:02 -0000
202 202
.Xr tap 4
203 203
device.
204 204
.Sh SIGNALS
205
The virtual kernel enables all terminal signals while in
206
.Xr ddb 4
207
mode but only enables
205
The virtual kernel only enables SIGQUIT and SIGTERM while operating in 
206
regular console mode. Sending 
208 207
.Ql \&^\e
209 208
.Pq Dv SIGQUIT
210
while operating as a console which causes the virtual kernel to enter its
211
internal
209
to the virtual kernel causes the virtual kernel to enter its internal
212 210
.Xr ddb 4
213
debugger.
211
debugger and re-enable all other terminal signals. Sending SIGTERM to the 
212
virtual kernel triggers a clean shutdown by passing a SIGUSR2 to the 
213
virtual kernel's 
214
.Xr init 8
215
process.
214 216
.Sh DEBUGGING
215 217
It is possible to directly gdb the virtual kernel's process.
216 218
It is recommended that you do a
sys/platform/vkernel/i386/cpu_regs.c 10 Jun 2007 22:43:22 -0000
700 700
		if (cpu_idle_hlt && !lwkt_runnable() &&
701 701
		    (td->td_flags & TDF_IDLE_NOHLT) == 0) {
702 702
			splz();
703
	                if (mdcpu->gd_shutdown)
704
				exc_shutdown();
703 705
			signalmailbox(NULL);
704 706
			if (!lwkt_runnable()) {
705 707
				sigpause(0);
......
713 715
		} else {
714 716
			td->td_flags &= ~TDF_IDLE_NOHLT;
715 717
			splz();
718
	                if (mdcpu->gd_shutdown)
719
				exc_shutdown();
716 720
			signalmailbox(NULL);
717 721
#ifdef SMP
718 722
			/*__asm __volatile("sti; pause");*/
sys/platform/vkernel/i386/exception.c 10 Jun 2007 22:49:31 -0000
39 39
#include <sys/types.h>
40 40
#include <sys/systm.h>
41 41
#include <sys/kernel.h>
42
#include <sys/reboot.h>
42 43
#include <ddb/ddb.h>
43 44

  
44 45
#include <sys/thread2.h>
......
52 53
int _udatasel = LSEL(LUDATA_SEL, SEL_UPL);
53 54

  
54 55
static void exc_segfault(int signo, siginfo_t *info, void *ctx);
56
void exc_shutdown( void );
55 57
#ifdef DDB
56 58
static void exc_debugger(int signo, siginfo_t *info, void *ctx);
57 59
#endif
......
67 69
	sigemptyset(&sa.sa_mask);
68 70
	sigaction(SIGSEGV, &sa, NULL);
69 71
	sigaction(SIGTRAP, &sa, NULL);
72

  
70 73
#ifdef DDB
71 74
	sa.sa_sigaction = exc_debugger;
72 75
	sigaction(SIGQUIT, &sa, NULL);
73 76
#endif
77

  
78
	bzero(&sa, sizeof(sa));
79
	sigemptyset(&sa.sa_mask);
80
	sa.sa_flags |= SA_MAILBOX | SA_NODEFER;
81
	sa.sa_mailbox = &mdcpu->gd_shutdown;
82
	sigaction(SIGTERM, &sa, NULL);
74 83
}
75 84

  
76 85
/*
......
95 104
	splz();
96 105
}
97 106

  
107
/*
108
 * This function handles external signals for shutdown. 
109
 *
110
 * Currently, when a vkernel recieves a SIGTERM, either the VKERNEL init(8) 
111
 * is signaled with SIGUSR2, or simply shuts down, preventing filesystem
112
 * checks from being needed upon reboot.
113
 */ 
114
void
115
exc_shutdown( void )
116
{
117
	mdcpu->gd_shutdown = 0;
118
	kprintf("Caught SIGTERM from host system. Shutting down...\n");
119
	if (initproc != NULL) {
120
		ksignal(initproc, SIGUSR2);
121
	}
122
	else {
123
		reboot(RB_POWEROFF);
124
	}	
125
}
126

  
98 127
#ifdef DDB
99 128

  
100 129
static void
sys/platform/vkernel/i386/trap.c 10 Jun 2007 22:43:41 -0000
1422 1422
	 * user_trap() when we break out of it (usually due to a signal).
1423 1423
	 */
1424 1424
	for (;;) {
1425

  
1426
		/*
1427
		 * Handle shutdown requests before attempting anything
1428
		 */ 
1429
		if (mdcpu->gd_shutdown)
1430
			exc_shutdown();
1431

  
1425 1432
		/*
1426 1433
		 * Tell the real kernel whether it is ok to use the FP
1427 1434
		 * unit or not.
sys/platform/vkernel/include/globaldata.h 10 Jun 2007 21:10:26 -0000
83 83
	int		gd_spending;	/* software interrupt pending */
84 84
	int		gd_sdelayed;	/* delayed software ints */
85 85
	int		gd_currentldt;
86
	int		gd_mailbox;	/* signal delivery mailbox */
86
	int		gd_mailbox;	/* I/O signal delivery mailbox */
87
	int		gd_shutdown;    /* Shutdown signal delivery mailbox */
87 88
	u_int		unused001;
88 89
	u_int		gd_other_cpus;
89 90
	u_int		gd_ss_eflags;
(2-2/4)