Mercurial > illumos > illumos-gate
changeset 9613:26c5867ec56a
PSARC 2009/222 Add zone support to uprintf() and vuprintf()
6676374 If Solaris Kills a process, the user needs to know why
author | Abhinandan Ekande <Abhinandan.Ekande@Sun.COM> |
---|---|
date | Tue, 12 May 2009 02:21:55 -0700 |
parents | cbb9ab387d66 |
children | 45a627bdff50 |
files | usr/src/uts/common/os/fm.c usr/src/uts/common/os/printf.c usr/src/uts/i86pc/os/trap.c usr/src/uts/sun4/os/trap.c usr/src/uts/sun4u/os/mach_trap.c usr/src/uts/sun4v/os/mach_trap.c |
diffstat | 6 files changed, 76 insertions(+), 103 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/os/fm.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/common/os/fm.c Tue May 12 02:21:55 2009 -0700 @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1257,3 +1257,10 @@ fm_payload_set(payload, FM_EREPORT_PAYLOAD_NAME_STACK, DATA_TYPE_STRING_ARRAY, depth, stkpp, NULL); } + +void +print_msg_hwerr(ctid_t ct_id, proc_t *p) +{ + uprintf("Killed process %d (%s) in contract id %d " + "due to hardware error\n", p->p_pid, p->p_user.u_comm, ct_id); +}
--- a/usr/src/uts/common/os/printf.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/common/os/printf.c Tue May 12 02:21:55 2009 -0700 @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/param.h> #include <sys/types.h> #include <sys/sysmacros.h> @@ -213,8 +211,19 @@ void vuprintf(const char *fmt, va_list adx) { + va_list adxcp; + va_copy(adxcp, adx); + + /* Message the user tty, if any, and the global zone syslog */ cprintf(fmt, adx, SL_CONSOLE | SL_LOGONLY | SL_USER | SL_NOTE, "", "", caller(), 0, 0, 0, GLOBAL_ZONEID); + + /* Now message the local zone syslog */ + if (!INGLOBALZONE(curproc)) + cprintf(fmt, adxcp, SL_CONSOLE | SL_LOGONLY | SL_NOTE, + "", "", caller(), 0, 0, 0, getzoneid()); + + va_end(adxcp); } /*PRINTFLIKE1*/ @@ -224,8 +233,9 @@ va_list adx; va_start(adx, fmt); - cprintf(fmt, adx, SL_CONSOLE | SL_LOGONLY | SL_USER | SL_NOTE, - "", "", caller(), 0, 0, 0, GLOBAL_ZONEID); + + vuprintf(fmt, adx); + va_end(adx); }
--- a/usr/src/uts/i86pc/os/trap.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/i86pc/os/trap.c Tue May 12 02:21:55 2009 -0700 @@ -1354,8 +1354,11 @@ case T_AST + USER: /* profiling, resched, h/w error pseudo trap */ if (lwp->lwp_pcb.pcb_flags & ASYNC_HWERR) { proc_t *p = ttoproc(curthread); + extern void print_msg_hwerr(ctid_t ct_id, proc_t *p); lwp->lwp_pcb.pcb_flags &= ~ASYNC_HWERR; + print_msg_hwerr(p->p_ct_process->conp_contract.ct_id, + p); contract_process_hwerr(p->p_ct_process, p); siginfo.si_signo = SIGKILL; siginfo.si_code = SI_NOINFO;
--- a/usr/src/uts/sun4/os/trap.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/sun4/os/trap.c Tue May 12 02:21:55 2009 -0700 @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -45,6 +45,7 @@ #include <sys/sun4asi.h> #include <sys/sdt.h> #include <sys/fpras.h> +#include <sys/contract/process_impl.h> #ifdef TRAPTRACE #include <sys/traptrace.h> @@ -1886,3 +1887,49 @@ else return (S_READ); } + +/* + * Handle an asynchronous hardware error. + * The policy is currently to send a hardware error contract event to + * the process's process contract and to kill the process. Eventually + * we may want to instead send a special signal whose default + * disposition is to generate the contract event. + */ +void +trap_async_hwerr(void) +{ + k_siginfo_t si; + proc_t *p = ttoproc(curthread); + extern void print_msg_hwerr(ctid_t ct_id, proc_t *p); + + errorq_drain(ue_queue); /* flush pending async error messages */ + + print_msg_hwerr(p->p_ct_process->conp_contract.ct_id, p); + + contract_process_hwerr(p->p_ct_process, p); + + bzero(&si, sizeof (k_siginfo_t)); + si.si_signo = SIGKILL; + si.si_code = SI_NOINFO; + trapsig(&si, 1); +} + +/* + * Handle bus error and bus timeout for a user process by sending SIGBUS + * The type is either ASYNC_BERR or ASYNC_BTO. + */ +void +trap_async_berr_bto(int type, struct regs *rp) +{ + k_siginfo_t si; + + errorq_drain(ue_queue); /* flush pending async error messages */ + bzero(&si, sizeof (k_siginfo_t)); + + si.si_signo = SIGBUS; + si.si_code = (type == ASYNC_BERR ? BUS_OBJERR : BUS_ADRERR); + si.si_addr = (caddr_t)rp->r_pc; /* AFAR unavailable - future RFE */ + si.si_errno = ENXIO; + + trapsig(&si, 1); +}
--- a/usr/src/uts/sun4u/os/mach_trap.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/sun4u/os/mach_trap.c Tue May 12 02:21:55 2009 -0700 @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/trap.h> #include <sys/machtrap.h> #include <sys/machsystm.h> @@ -32,7 +30,6 @@ #include <sys/panic.h> #include <sys/uadmin.h> #include <sys/kobj.h> -#include <sys/contract/process_impl.h> #include <vm/hat_sfmmu.h> #include <sys/reboot.h> @@ -90,50 +87,6 @@ printf("\n"); } - -/* - * Handle an asynchronous hardware error, i.e. an E-$ parity error. - * The policy is currently to send a hardware error contract event to - * the process's process contract and to kill the process. Eventually - * we may want to instead send a special signal whose default - * disposition is to generate the contract event. - */ -void -trap_async_hwerr(void) -{ - k_siginfo_t si; - proc_t *p = ttoproc(curthread); - - errorq_drain(ue_queue); /* flush pending async error messages */ - - contract_process_hwerr(p->p_ct_process, p); - - bzero(&si, sizeof (k_siginfo_t)); - si.si_signo = SIGKILL; - si.si_code = SI_NOINFO; - trapsig(&si, 1); -} - -/* - * Handle bus error and bus timeout for a user process by sending SIGBUS - * The type is either ASYNC_BERR or ASYNC_BTO. - */ -void -trap_async_berr_bto(int type, struct regs *rp) -{ - k_siginfo_t si; - - errorq_drain(ue_queue); /* flush pending async error messages */ - bzero(&si, sizeof (k_siginfo_t)); - - si.si_signo = SIGBUS; - si.si_code = (type == ASYNC_BERR ? BUS_OBJERR : BUS_ADRERR); - si.si_addr = (caddr_t)rp->r_pc; /* AFAR unavailable - future RFE */ - si.si_errno = ENXIO; - - trapsig(&si, 1); -} - #ifdef TRAPWINDOW long trap_window[25]; #endif /* TRAPWINDOW */
--- a/usr/src/uts/sun4v/os/mach_trap.c Mon May 11 23:03:15 2009 -0700 +++ b/usr/src/uts/sun4v/os/mach_trap.c Tue May 12 02:21:55 2009 -0700 @@ -19,12 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/trap.h> #include <sys/machtrap.h> #include <sys/machsystm.h> @@ -32,7 +30,6 @@ #include <sys/panic.h> #include <sys/uadmin.h> #include <sys/kobj.h> -#include <sys/contract/process_impl.h> #include <vm/hat_sfmmu.h> #include <sys/reboot.h> @@ -79,50 +76,6 @@ printf("\n"); } - -/* - * Handle an asynchronous hardware error, i.e. an E-$ parity error. - * The policy is currently to send a hardware error contract event to - * the process's process contract and to kill the process. Eventually - * we may want to instead send a special signal whose default - * disposition is to generate the contract event. - */ -void -trap_async_hwerr(void) -{ - k_siginfo_t si; - proc_t *p = ttoproc(curthread); - - errorq_drain(ue_queue); /* flush pending async error messages */ - - contract_process_hwerr(p->p_ct_process, p); - - bzero(&si, sizeof (k_siginfo_t)); - si.si_signo = SIGKILL; - si.si_code = SI_NOINFO; - trapsig(&si, 1); -} - -/* - * Handle bus error and bus timeout for a user process by sending SIGBUS - * The type is either ASYNC_BERR or ASYNC_BTO. - */ -void -trap_async_berr_bto(int type, struct regs *rp) -{ - k_siginfo_t si; - - errorq_drain(ue_queue); /* flush pending async error messages */ - bzero(&si, sizeof (k_siginfo_t)); - - si.si_signo = SIGBUS; - si.si_code = (type == ASYNC_BERR ? BUS_OBJERR : BUS_ADRERR); - si.si_addr = (caddr_t)rp->r_pc; /* AFAR unavailable - future RFE */ - si.si_errno = ENXIO; - - trapsig(&si, 1); -} - /* * Print out debugging info. */