error.c revision c4b034952d3374cdd114e12b3990493b1b45dc32
0N/A/*
1879N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License (the "License").
0N/A * You may not use this file except in compliance with the License.
0N/A *
0N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A * or http://www.opensolaris.org/os/licensing.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information: Portions Copyright [yyyy] [name of copyright owner]
0N/A *
1472N/A * CDDL HEADER END
1472N/A */
1472N/A/*
0N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
0N/A * Use is subject to license terms.
0N/A */
1879N/A
1879N/A#pragma ident "%Z%%M% %I% %E% SMI"
1879N/A
1879N/A#include <sys/types.h>
1879N/A#include <sys/machsystm.h>
1879N/A#include <sys/cpuvar.h>
1879N/A#include <sys/async.h>
1879N/A#include <sys/ontrap.h>
1879N/A#include <sys/ddifm.h>
1879N/A#include <sys/hypervisor_api.h>
1879N/A#include <sys/errorq.h>
1879N/A#include <sys/promif.h>
1879N/A#include <sys/prom_plat.h>
0N/A#include <sys/x_call.h>
0N/A#include <sys/error.h>
0N/A#include <sys/fm/util.h>
0N/A#include <sys/ivintr.h>
0N/A
0N/A#define MAX_CE_FLTS 10
0N/A#define MAX_ASYNC_FLTS 6
0N/A
0N/Aerrorq_t *ue_queue; /* queue of uncorrectable errors */
0N/Aerrorq_t *ce_queue; /* queue of correctable errors */
0N/A
0N/A/*
0N/A * Being used by memory test driver.
0N/A * ce_verbose_memory - covers CEs in DIMMs
0N/A * ce_verbose_other - covers "others" (ecache, IO, etc.)
0N/A *
0N/A * If the value is 0, nothing is logged.
0N/A * If the value is 1, the error is logged to the log file, but not console.
0N/A * If the value is 2, the error is logged to the log file and console.
0N/A */
0N/Aint ce_verbose_memory = 1;
0N/Aint ce_verbose_other = 1;
0N/A
0N/Aint ce_show_data = 0;
0N/Aint ce_debug = 0;
0N/Aint ue_debug = 0;
0N/Aint reset_debug = 0;
0N/A
0N/A/*
0N/A * Tunables for controlling the handling of asynchronous faults (AFTs). Setting
0N/A * these to non-default values on a non-DEBUG kernel is NOT supported.
0N/A */
0N/Aint aft_verbose = 0; /* log AFT messages > 1 to log only */
0N/Aint aft_panic = 0; /* panic (not reboot) on fatal usermode AFLT */
0N/Aint aft_testfatal = 0; /* force all AFTs to panic immediately */
0N/A
0N/A/*
0N/A * Used for vbsc hostshutdown (power-off buton)
0N/A */
0N/Aint err_shutdown_triggered = 0; /* only once */
0N/Auint_t err_shutdown_inum = 0; /* used to pull the trigger */
0N/A
0N/A/*
0N/A * Defined in bus_func.c but initialised in error_init
0N/A */
0N/Aextern kmutex_t bfd_lock;
0N/A
0N/Astatic uint32_t rq_overflow_count = 0; /* counter for rq overflow */
0N/A
0N/Astatic void cpu_queue_one_event(errh_async_flt_t *);
0N/Astatic uint32_t count_entries_on_queue(uint64_t, uint64_t, uint32_t);
0N/Astatic void errh_page_retire(errh_async_flt_t *, uchar_t);
0N/Astatic int errh_error_protected(struct regs *, struct async_flt *, int *);
0N/Astatic void errh_rq_full(struct async_flt *);
0N/Astatic void ue_drain(void *, struct async_flt *, errorq_elem_t *);
0N/Astatic void ce_drain(void *, struct async_flt *, errorq_elem_t *);
0N/A
0N/A/*ARGSUSED*/
0N/Avoid
0N/Aprocess_resumable_error(struct regs *rp, uint32_t head_offset,
0N/A uint32_t tail_offset)
0N/A{
0N/A struct machcpu *mcpup;
0N/A struct async_flt *aflt;
0N/A errh_async_flt_t errh_flt;
0N/A errh_er_t *head_va;
0N/A
0N/A mcpup = &(CPU->cpu_m);
0N/A
0N/A while (head_offset != tail_offset) {
0N/A /* kernel buffer starts right after the resumable queue */
0N/A head_va = (errh_er_t *)(mcpup->cpu_rq_va + head_offset +
0N/A CPU_RQ_SIZE);
0N/A /* Copy the error report to local buffer */
0N/A bzero(&errh_flt, sizeof (errh_async_flt_t));
0N/A bcopy((char *)head_va, &(errh_flt.errh_er),
0N/A sizeof (errh_er_t));
0N/A
0N/A /* Increment the queue head */
0N/A head_offset += Q_ENTRY_SIZE;
0N/A /* Wrap around */
0N/A head_offset &= (CPU_RQ_SIZE - 1);
0N/A
0N/A /* set error handle to zero so it can hold new error report */
0N/A head_va->ehdl = 0;
0N/A
0N/A switch (errh_flt.errh_er.desc) {
0N/A case ERRH_DESC_UCOR_RE:
0N/A break;
0N/A
0N/A case ERRH_DESC_WARN_RE:
0N/A /*
0N/A * Power-off requested, but handle it one time only.
0N/A */
0N/A if (!err_shutdown_triggered) {
0N/A setsoftint(err_shutdown_inum);
0N/A ++err_shutdown_triggered;
0N/A }
0N/A continue;
0N/A
0N/A default:
0N/A cmn_err(CE_WARN, "Error Descriptor 0x%llx "
0N/A " invalid in resumable error handler",
0N/A (long long) errh_flt.errh_er.desc);
0N/A continue;
0N/A }
0N/A
0N/A aflt = (struct async_flt *)&(errh_flt.cmn_asyncflt);
0N/A aflt->flt_id = gethrtime();
1601N/A aflt->flt_bus_id = getprocessorid();
1601N/A aflt->flt_class = CPU_FAULT;
1601N/A aflt->flt_prot = AFLT_PROT_NONE;
0N/A aflt->flt_priv = (((errh_flt.errh_er.attr & ERRH_MODE_MASK)
0N/A >> ERRH_MODE_SHIFT) == ERRH_MODE_PRIV);
0N/A
0N/A if (errh_flt.errh_er.attr & ERRH_ATTR_CPU)
0N/A /* If it is an error on other cpu */
0N/A aflt->flt_panic = 1;
0N/A else
0N/A aflt->flt_panic = 0;
0N/A
0N/A /*
0N/A * Handle resumable queue full case.
0N/A */
0N/A if (errh_flt.errh_er.attr & ERRH_ATTR_RQF) {
0N/A (void) errh_rq_full(aflt);
0N/A }
0N/A
0N/A /*
0N/A * Queue the error on ce or ue queue depend on flt_panic.
0N/A * Even if flt_panic is set, the code still keep processing
0N/A * the rest element on rq until the panic starts.
0N/A */
0N/A (void) cpu_queue_one_event(&errh_flt);
0N/A
0N/A /*
0N/A * Panic here if aflt->flt_panic has been set.
0N/A * Enqueued errors will be logged as part of the panic flow.
0N/A */
0N/A if (aflt->flt_panic) {
0N/A fm_panic("Unrecoverable error on another CPU");
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid
0N/Aprocess_nonresumable_error(struct regs *rp, uint64_t flags,
0N/A uint32_t head_offset, uint32_t tail_offset)
0N/A{
0N/A struct machcpu *mcpup;
0N/A struct async_flt *aflt;
1808N/A errh_async_flt_t errh_flt;
1808N/A errh_er_t *head_va;
0N/A int trampolined = 0;
1808N/A int expected = DDI_FM_ERR_UNEXPECTED;
1808N/A uint64_t exec_mode;
0N/A uint8_t u_spill_fill;
1145N/A
1145N/A mcpup = &(CPU->cpu_m);
1145N/A
1145N/A while (head_offset != tail_offset) {
1145N/A /* kernel buffer starts right after the nonresumable queue */
1145N/A head_va = (errh_er_t *)(mcpup->cpu_nrq_va + head_offset +
0N/A CPU_NRQ_SIZE);
0N/A
0N/A /* Copy the error report to local buffer */
0N/A bzero(&errh_flt, sizeof (errh_async_flt_t));
0N/A
0N/A bcopy((char *)head_va, &(errh_flt.errh_er),
0N/A sizeof (errh_er_t));
0N/A
0N/A /* Increment the queue head */
0N/A head_offset += Q_ENTRY_SIZE;
0N/A /* Wrap around */
0N/A head_offset &= (CPU_NRQ_SIZE - 1);
0N/A
0N/A /* set error handle to zero so it can hold new error report */
0N/A head_va->ehdl = 0;
0N/A
0N/A aflt = (struct async_flt *)&(errh_flt.cmn_asyncflt);
0N/A
0N/A trampolined = 0;
0N/A
0N/A if (errh_flt.errh_er.attr & ERRH_ATTR_PIO)
0N/A aflt->flt_class = BUS_FAULT;
0N/A else
0N/A aflt->flt_class = CPU_FAULT;
0N/A
0N/A aflt->flt_id = gethrtime();
0N/A aflt->flt_bus_id = getprocessorid();
0N/A aflt->flt_pc = (caddr_t)rp->r_pc;
0N/A exec_mode = (errh_flt.errh_er.attr & ERRH_MODE_MASK)
0N/A >> ERRH_MODE_SHIFT;
0N/A aflt->flt_priv = (exec_mode == ERRH_MODE_PRIV ||
0N/A exec_mode == ERRH_MODE_UNKNOWN);
0N/A aflt->flt_prot = AFLT_PROT_NONE;
0N/A aflt->flt_tl = (uchar_t)(flags & ERRH_TL_MASK);
0N/A aflt->flt_panic = ((aflt->flt_tl != 0) ||
0N/A (aft_testfatal != 0));
0N/A
0N/A /*
0N/A * For the first error packet on the queue, check if it
0N/A * happened in user fill/spill trap.
0N/A */
0N/A if (flags & ERRH_U_SPILL_FILL) {
0N/A u_spill_fill = 1;
0N/A /* clear the user fill/spill flag in flags */
0N/A flags = (uint64_t)aflt->flt_tl;
0N/A } else
0N/A u_spill_fill = 0;
0N/A
0N/A switch (errh_flt.errh_er.desc) {
0N/A case ERRH_DESC_PR_NRE:
0N/A if (u_spill_fill) {
0N/A aflt->flt_panic = 0;
0N/A break;
0N/A }
0N/A /*
0N/A * Fall through, precise fault also need to check
0N/A * to see if it was protected.
0N/A */
0N/A /*FALLTHRU*/
0N/A
0N/A case ERRH_DESC_DEF_NRE:
0N/A /*
0N/A * If the trap occurred in privileged mode at TL=0,
0N/A * we need to check to see if we were executing
0N/A * in kernel under on_trap() or t_lofault
0N/A * protection. If so, and if it was a PIO or MEM
0N/A * error, then modify the saved registers so that
0N/A * we return from the trap to the appropriate
0N/A * trampoline routine.
0N/A */
0N/A if (aflt->flt_priv == 1 && aflt->flt_tl == 0 &&
0N/A ((errh_flt.errh_er.attr & ERRH_ATTR_PIO) ||
0N/A (errh_flt.errh_er.attr & ERRH_ATTR_MEM))) {
0N/A trampolined =
0N/A errh_error_protected(rp, aflt, &expected);
0N/A }
0N/A
0N/A if (!aflt->flt_priv || aflt->flt_prot ==
0N/A AFLT_PROT_COPY) {
0N/A aflt->flt_panic |= aft_panic;
0N/A } else if (!trampolined &&
0N/A (aflt->flt_class != BUS_FAULT)) {
0N/A aflt->flt_panic = 1;
0N/A }
0N/A
0N/A /*
0N/A * If PIO error, we need to query the bus nexus
0N/A * for fatal errors.
0N/A */
0N/A if (aflt->flt_class == BUS_FAULT) {
0N/A aflt->flt_addr = errh_flt.errh_er.ra;
0N/A errh_cpu_run_bus_error_handlers(aflt,
0N/A expected);
0N/A }
0N/A
0N/A break;
0N/A
0N/A default:
0N/A cmn_err(CE_WARN, "Panic - Error Descriptor 0x%llx "
0N/A " invalid in non-resumable error handler",
0N/A (long long) errh_flt.errh_er.desc);
0N/A aflt->flt_panic = 1;
0N/A break;
0N/A }
0N/A
0N/A /*
0N/A * Queue the error report for further processing. If
0N/A * flt_panic is set, code still process other errors
0N/A * in the queue until the panic routine stops the
0N/A * kernel.
0N/A */
0N/A (void) cpu_queue_one_event(&errh_flt);
0N/A
0N/A /*
113N/A * Panic here if aflt->flt_panic has been set.
0N/A * Enqueued errors will be logged as part of the panic flow.
0N/A */
0N/A if (aflt->flt_panic) {
0N/A fm_panic("Unrecoverable hardware error");
0N/A }
0N/A
0N/A /*
0N/A * Call page_retire() to handle memory errors.
0N/A */
0N/A if (errh_flt.errh_er.attr & ERRH_ATTR_MEM)
0N/A errh_page_retire(&errh_flt, PR_UE);
0N/A
0N/A /*
0N/A * If we queued an error and the it was in user mode, or
0N/A * protected by t_lofault, or user_spill_fill is set, we
0N/A * set AST flag so the queue will be drained before
0N/A * returning to user mode.
0N/A */
0N/A if (!aflt->flt_priv || aflt->flt_prot == AFLT_PROT_COPY ||
0N/A u_spill_fill) {
0N/A int pcb_flag = 0;
0N/A
0N/A if (aflt->flt_class == CPU_FAULT)
0N/A pcb_flag |= ASYNC_HWERR;
0N/A else if (aflt->flt_class == BUS_FAULT)
0N/A pcb_flag |= ASYNC_BERR;
0N/A
0N/A ttolwp(curthread)->lwp_pcb.pcb_flags |= pcb_flag;
0N/A aston(curthread);
0N/A }
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * For PIO errors, this routine calls nexus driver's error
0N/A * callback routines. If the callback routine returns fatal, and
0N/A * we are in kernel or unknow mode without any error protection,
0N/A * we need to turn on the panic flag.
0N/A */
0N/Avoid
0N/Aerrh_cpu_run_bus_error_handlers(struct async_flt *aflt, int expected)
0N/A{
0N/A int status;
0N/A ddi_fm_error_t de;
0N/A
0N/A bzero(&de, sizeof (ddi_fm_error_t));
0N/A
0N/A de.fme_version = DDI_FME_VERSION;
0N/A de.fme_ena = fm_ena_generate(aflt->flt_id, FM_ENA_FMT1);
0N/A de.fme_flag = expected;
0N/A de.fme_bus_specific = (void *)aflt->flt_addr;
0N/A status = ndi_fm_handler_dispatch(ddi_root_node(), NULL, &de);
0N/A
0N/A /*
1808N/A * If error is protected, it will jump to proper routine
1808N/A * to handle the handle; if it is in user level, we just
1808N/A * kill the user process; if the driver thinks the error is
1808N/A * not fatal, we can drive on. If none of above are true,
1808N/A * we panic
1808N/A */
1808N/A if ((aflt->flt_prot == AFLT_PROT_NONE) && (aflt->flt_priv == 1) &&
1808N/A (status == DDI_FM_FATAL))
1808N/A aflt->flt_panic = 1;
1808N/A}
0N/A
0N/A/*
0N/A * This routine checks to see if we are under any error protection when
0N/A * the error happens. If we are under error protection, we unwind to
0N/A * the protection and indicate fault.
0N/A */
0N/Astatic int
0N/Aerrh_error_protected(struct regs *rp, struct async_flt *aflt, int *expected)
0N/A{
0N/A int trampolined = 0;
0N/A ddi_acc_hdl_t *hp;
0N/A
0N/A if (curthread->t_ontrap != NULL) {
0N/A on_trap_data_t *otp = curthread->t_ontrap;
0N/A
0N/A if (otp->ot_prot & OT_DATA_EC) {
0N/A aflt->flt_prot = AFLT_PROT_EC;
0N/A otp->ot_trap |= OT_DATA_EC;
0N/A rp->r_pc = otp->ot_trampoline;
0N/A rp->r_npc = rp->r_pc +4;
0N/A trampolined = 1;
0N/A }
0N/A
0N/A if (otp->ot_prot & OT_DATA_ACCESS) {
0N/A aflt->flt_prot = AFLT_PROT_ACCESS;
0N/A otp->ot_trap |= OT_DATA_ACCESS;
263N/A rp->r_pc = otp->ot_trampoline;
263N/A rp->r_npc = rp->r_pc + 4;
263N/A trampolined = 1;
0N/A /*
0N/A * for peek and caut_gets
0N/A * errors are expected
0N/A */
0N/A hp = (ddi_acc_hdl_t *)otp->ot_handle;
0N/A if (!hp)
0N/A *expected = DDI_FM_ERR_PEEK;
0N/A else if (hp->ah_acc.devacc_attr_access ==
0N/A DDI_CAUTIOUS_ACC)
0N/A *expected = DDI_FM_ERR_EXPECTED;
0N/A }
0N/A } else if (curthread->t_lofault) {
0N/A aflt->flt_prot = AFLT_PROT_COPY;
0N/A rp->r_g1 = EFAULT;
0N/A rp->r_pc = curthread->t_lofault;
0N/A rp->r_npc = rp->r_pc + 4;
0N/A trampolined = 1;
0N/A }
0N/A
0N/A return (trampolined);
0N/A}
0N/A
0N/A/*
0N/A * Queue one event.
0N/A */
0N/Astatic void
0N/Acpu_queue_one_event(errh_async_flt_t *errh_fltp)
0N/A{
0N/A struct async_flt *aflt = (struct async_flt *)errh_fltp;
0N/A errorq_t *eqp;
0N/A
0N/A if (aflt->flt_panic)
0N/A eqp = ue_queue;
0N/A else
0N/A eqp = ce_queue;
0N/A
0N/A errorq_dispatch(eqp, errh_fltp, sizeof (errh_async_flt_t),
0N/A aflt->flt_panic);
0N/A}
0N/A
0N/A/*
0N/A * The cpu_async_log_err() function is called by the ce/ue_drain() function to
0N/A * handle logging for CPU events that are dequeued. As such, it can be invoked
0N/A * from softint context, from AST processing in the trap() flow, or from the
0N/A * panic flow. We decode the CPU-specific data, and log appropriate messages.
0N/A */
0N/Avoid
0N/Acpu_async_log_err(void *flt)
0N/A{
0N/A errh_async_flt_t *errh_fltp = (errh_async_flt_t *)flt;
0N/A errh_er_t *errh_erp = (errh_er_t *)&errh_fltp->errh_er;
0N/A
0N/A switch (errh_erp->desc) {
0N/A case ERRH_DESC_UCOR_RE:
0N/A if (errh_erp->attr & ERRH_ATTR_MEM) {
0N/A /*
0N/A * Turn on the PR_UE flag. The page will be
0N/A * scrubbed when it is freed.
0N/A */
0N/A errh_page_retire(errh_fltp, PR_UE);
0N/A }
0N/A
0N/A break;
0N/A
0N/A case ERRH_DESC_PR_NRE:
0N/A case ERRH_DESC_DEF_NRE:
0N/A if (errh_erp->attr & ERRH_ATTR_MEM) {
0N/A /*
0N/A * For non-resumable memory error, retire
0N/A * the page here.
0N/A */
0N/A errh_page_retire(errh_fltp, PR_UE);
0N/A
0N/A /*
0N/A * If we are going to panic, scrub the page first
0N/A */
0N/A if (errh_fltp->cmn_asyncflt.flt_panic)
0N/A mem_scrub(errh_fltp->errh_er.ra,
0N/A errh_fltp->errh_er.sz);
0N/A }
0N/A break;
0N/A
0N/A default:
0N/A break;
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Called from ce_drain().
0N/A */
0N/Avoid
0N/Acpu_ce_log_err(struct async_flt *aflt)
0N/A{
0N/A switch (aflt->flt_class) {
0N/A case CPU_FAULT:
0N/A cpu_async_log_err(aflt);
0N/A break;
0N/A
0N/A case BUS_FAULT:
0N/A cpu_async_log_err(aflt);
263N/A break;
263N/A
263N/A default:
263N/A break;
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Called from ue_drain().
0N/A */
0N/Avoid
0N/Acpu_ue_log_err(struct async_flt *aflt)
0N/A{
0N/A switch (aflt->flt_class) {
0N/A case CPU_FAULT:
0N/A cpu_async_log_err(aflt);
0N/A break;
0N/A
0N/A case BUS_FAULT:
0N/A cpu_async_log_err(aflt);
0N/A break;
0N/A
0N/A default:
0N/A break;
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Turn on flag on the error memory region.
0N/A */
0N/Astatic void
0N/Aerrh_page_retire(errh_async_flt_t *errh_fltp, uchar_t flag)
0N/A{
0N/A uint64_t flt_real_addr_start = errh_fltp->errh_er.ra;
0N/A uint64_t flt_real_addr_end = flt_real_addr_start +
0N/A errh_fltp->errh_er.sz - 1;
0N/A int64_t current_addr;
0N/A
0N/A if (errh_fltp->errh_er.sz == 0)
517N/A return;
517N/A
517N/A for (current_addr = flt_real_addr_start;
517N/A current_addr < flt_real_addr_end; current_addr += MMU_PAGESIZE) {
517N/A (void) page_retire(current_addr, flag);
0N/A }
0N/A}
0N/A
0N/Avoid
0N/Amem_scrub(uint64_t paddr, uint64_t len)
0N/A{
0N/A uint64_t pa, length, scrubbed_len;
0N/A
0N/A pa = paddr;
0N/A length = len;
0N/A scrubbed_len = 0;
0N/A
0N/A while (length > 0) {
0N/A if (hv_mem_scrub(pa, length, &scrubbed_len) != H_EOK)
0N/A break;
0N/A
0N/A pa += scrubbed_len;
0N/A length -= scrubbed_len;
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Call hypervisor to flush the memory region. The memory region
0N/A * must be within the same page frame.
0N/A */
0N/Avoid
0N/Amem_sync(caddr_t va, size_t len)
0N/A{
0N/A uint64_t pa, length, flushed;
0N/A
0N/A pa = va_to_pa((caddr_t)va);
0N/A
0N/A if (pa == (uint64_t)-1)
0N/A return;
0N/A
0N/A ASSERT((pa >> MMU_PAGESHIFT) == ((pa + len - 1) >> MMU_PAGESHIFT));
0N/A
0N/A length = len;
0N/A flushed = 0;
0N/A
0N/A while (length > 0) {
0N/A if (hv_mem_sync(pa, length, &flushed) != H_EOK)
0N/A break;
0N/A
0N/A pa += flushed;
0N/A length -= flushed;
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * If resumable queue is full, we need to check if any cpu is in
0N/A * error state. If not, we drive on. If yes, we need to panic. The
0N/A * hypervisor call hv_cpu_state() is being used for checking the
0N/A * cpu state.
0N/A */
0N/Astatic void
0N/Aerrh_rq_full(struct async_flt *afltp)
0N/A{
0N/A processorid_t who;
0N/A uint64_t cpu_state;
0N/A uint64_t retval;
0N/A
0N/A for (who = 0; who < NCPU; who++)
0N/A if (CPU_IN_SET(cpu_ready_set, who)) {
0N/A retval = hv_cpu_state(who, &cpu_state);
0N/A if (retval != H_EOK || cpu_state == CPU_STATE_ERROR) {
0N/A afltp->flt_panic = 1;
0N/A break;
0N/A }
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Return processor specific async error structure
0N/A * size used.
0N/A */
0N/Aint
0N/Acpu_aflt_size(void)
0N/A{
0N/A return (sizeof (errh_async_flt_t));
0N/A}
0N/A
0N/A#define SZ_TO_ETRS_SHIFT 6
0N/A
0N/A/*
0N/A * Message print out when resumable queue is overflown
0N/A */
0N/A/*ARGSUSED*/
271N/Avoid
271N/Arq_overflow(struct regs *rp, uint64_t head_offset,
271N/A uint64_t tail_offset)
271N/A{
271N/A rq_overflow_count++;
0N/A}
0N/A
0N/A/*
0N/A * Handler to process a fatal error. This routine can be called from a
0N/A * softint, called from trap()'s AST handling, or called from the panic flow.
271N/A */
271N/A/*ARGSUSED*/
271N/Astatic void
271N/Aue_drain(void *ignored, struct async_flt *aflt, errorq_elem_t *eqep)
271N/A{
0N/A cpu_ue_log_err(aflt);
0N/A}
0N/A
0N/A/*
0N/A * Handler to process a correctable error. This routine can be called from a
0N/A * softint. We just call the CPU module's logging routine.
0N/A */
0N/A/*ARGSUSED*/
0N/Astatic void
0N/Ace_drain(void *ignored, struct async_flt *aflt, errorq_elem_t *eqep)
0N/A{
0N/A cpu_ce_log_err(aflt);
0N/A}
0N/A
0N/A/*
0N/A * Handler to process vbsc hostshutdown (power-off button).
0N/A */
0N/Astatic int
0N/Aerr_shutdown_softintr()
0N/A{
271N/A cmn_err(CE_WARN, "Power-off requested, system will now shutdown.");
0N/A do_shutdown();
271N/A
0N/A /*
0N/A * just in case do_shutdown() fails
0N/A */
0N/A (void) timeout((void(*)(void *))power_down, NULL, 100 * hz);
271N/A return (DDI_INTR_CLAIMED);
0N/A}
0N/A
0N/A/*
0N/A * Allocate error queue sizes based on max_ncpus. max_ncpus is set just
0N/A * after ncpunode has been determined. ncpus is set in start_other_cpus
0N/A * which is called after error_init() but may change dynamically.
0N/A */
0N/Avoid
0N/Aerror_init(void)
0N/A{
0N/A char tmp_name[MAXSYSNAME];
0N/A pnode_t node;
0N/A size_t size = cpu_aflt_size();
0N/A
0N/A /*
0N/A * Initialize the correctable and uncorrectable error queues.
0N/A */
0N/A ue_queue = errorq_create("ue_queue", (errorq_func_t)ue_drain, NULL,
0N/A MAX_ASYNC_FLTS * (max_ncpus + 1), size, PIL_2, ERRORQ_VITAL);
0N/A
0N/A ce_queue = errorq_create("ce_queue", (errorq_func_t)ce_drain, NULL,
0N/A MAX_CE_FLTS * (max_ncpus + 1), size, PIL_1, 0);
0N/A
0N/A if (ue_queue == NULL || ce_queue == NULL)
0N/A panic("failed to create required system error queue");
0N/A
0N/A /*
0N/A * Setup interrupt handler for power-off button.
0N/A */
0N/A err_shutdown_inum = add_softintr(PIL_9,
0N/A (softintrfunc)err_shutdown_softintr, NULL);
0N/A
0N/A /*
0N/A * Initialize the busfunc list mutex. This must be a PIL_15 spin lock
0N/A * because we will need to acquire it from cpu_async_error().
0N/A */
0N/A mutex_init(&bfd_lock, NULL, MUTEX_SPIN, (void *)PIL_15);
0N/A
0N/A node = prom_rootnode();
0N/A if ((node == OBP_NONODE) || (node == OBP_BADNODE)) {
0N/A cmn_err(CE_CONT, "error_init: node 0x%x\n", (uint_t)node);
0N/A return;
0N/A }
0N/A
0N/A if (((size = prom_getproplen(node, "reset-reason")) != -1) &&
0N/A (size <= MAXSYSNAME) &&
0N/A (prom_getprop(node, "reset-reason", tmp_name) != -1)) {
0N/A if (reset_debug) {
0N/A cmn_err(CE_CONT, "System booting after %s\n", tmp_name);
0N/A } else if (strncmp(tmp_name, "FATAL", 5) == 0) {
0N/A cmn_err(CE_CONT,
0N/A "System booting after fatal error %s\n", tmp_name);
0N/A }
0N/A }
0N/A}
0N/A
0N/A/*
0N/A * Nonresumable queue is full, panic here
0N/A */
0N/A/*ARGSUSED*/
0N/Avoid
0N/Anrq_overflow(struct regs *rp)
0N/A{
0N/A fm_panic("Nonresumable queue full");
0N/A}
0N/A