4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Public interface to routines implemented by CPU modules
31 #include <sys/types.h>
32 #include <sys/atomic.h>
33 #include <sys/x86_archext.h>
34 #include <sys/cpu_module_impl.h>
35 #include <sys/cpu_module_ms.h>
36 #include <sys/fm/util.h>
37 #include <sys/reboot.h>
38 #include <sys/modctl.h>
39 #include <sys/param.h>
40 #include <sys/cmn_err.h>
41 #include <sys/systm.h>
42 #include <sys/fm/protocol.h>
44 #include <sys/ontrap.h>
46 #include <sys/privregs.h>
47 #include <sys/machsystm.h>
50 * Set to force cmi_init to fail.
55 * Set to avoid MCA initialization.
57 int cmi_no_mca_init
= 0;
60 * If cleared for debugging we will not attempt to load a model-specific
61 * cpu module but will load the generic cpu module instead.
63 int cmi_force_generic
= 0;
66 * If cleared for debugging, we will suppress panicking on fatal hardware
67 * errors. This should *only* be used for debugging; it use can and will
68 * cause data corruption if actual hardware errors are detected by the system.
70 int cmi_panic_on_uncorrectable_error
= 1;
74 * Set to indicate whether we are able to enable cmci interrupt.
76 int cmi_enable_cmci
= 0;
80 * Subdirectory (relative to the module search path) in which we will
81 * look for cpu modules.
83 #define CPUMOD_SUBDIR "cpu"
86 * CPU modules have a filenames such as "cpu.AuthenticAMD.15" and
87 * "cpu.generic" - the "cpu" prefix is specified by the following.
89 #define CPUMOD_PREFIX "cpu"
92 * Structure used to keep track of cpu modules we have loaded and their ops
97 const cmi_ops_t
*cmi_ops
;
98 struct modctl
*cmi_modp
;
102 static cmi_t
*cmi_list
;
103 static const cmi_mc_ops_t
*cmi_mc_global_ops
;
104 static void *cmi_mc_global_data
;
105 static kmutex_t cmi_load_lock
;
108 * Functions we need from cmi_hw.c that are not part of the cpu_module.h
111 extern cmi_hdl_t
cmi_hdl_create(enum cmi_hdl_class
, uint_t
, uint_t
, uint_t
);
112 extern void cmi_hdl_destroy(cmi_hdl_t ophdl
);
113 extern void cmi_hdl_setcmi(cmi_hdl_t
, void *, void *);
114 extern void *cmi_hdl_getcmi(cmi_hdl_t
);
115 extern void cmi_hdl_setmc(cmi_hdl_t
, const struct cmi_mc_ops
*, void *);
116 extern void cmi_hdl_inj_begin(cmi_hdl_t
);
117 extern void cmi_hdl_inj_end(cmi_hdl_t
);
118 extern void cmi_read_smbios(cmi_hdl_t
);
120 #define HDL2CMI(hdl) cmi_hdl_getcmi(hdl)
122 #define CMI_OPS(cmi) (cmi)->cmi_ops
123 #define CMI_OP_PRESENT(cmi, op) ((cmi) && CMI_OPS(cmi)->op != NULL)
125 #define CMI_MATCH_VENDOR 0 /* Just match on vendor */
126 #define CMI_MATCH_FAMILY 1 /* Match down to family */
127 #define CMI_MATCH_MODEL 2 /* Match down to model */
128 #define CMI_MATCH_STEPPING 3 /* Match down to stepping */
133 ASSERT(MUTEX_HELD(&cmi_load_lock
));
135 cmi
->cmi_prev
= NULL
;
136 cmi
->cmi_next
= cmi_list
;
137 if (cmi_list
!= NULL
)
138 cmi_list
->cmi_prev
= cmi
;
143 cmi_unlink(cmi_t
*cmi
)
145 ASSERT(MUTEX_HELD(&cmi_load_lock
));
146 ASSERT(cmi
->cmi_refcnt
== 0);
148 if (cmi
->cmi_prev
!= NULL
)
149 cmi
->cmi_prev
= cmi
->cmi_next
;
151 if (cmi
->cmi_next
!= NULL
)
152 cmi
->cmi_next
->cmi_prev
= cmi
->cmi_prev
;
155 cmi_list
= cmi
->cmi_next
;
159 * Hold the module in memory. We call to CPU modules without using the
160 * stubs mechanism, so these modules must be manually held in memory.
161 * The mod_ref acts as if another loaded module has a dependency on us.
166 ASSERT(MUTEX_HELD(&cmi_load_lock
));
168 mutex_enter(&mod_lock
);
169 cmi
->cmi_modp
->mod_ref
++;
170 mutex_exit(&mod_lock
);
177 ASSERT(MUTEX_HELD(&cmi_load_lock
));
179 mutex_enter(&mod_lock
);
180 cmi
->cmi_modp
->mod_ref
--;
181 mutex_exit(&mod_lock
);
183 if (--cmi
->cmi_refcnt
== 0) {
185 kmem_free(cmi
, sizeof (cmi_t
));
190 cmi_getops(modctl_t
*modp
)
194 if ((ops
= (cmi_ops_t
*)modlookup_by_modctl(modp
, "_cmi_ops")) ==
196 cmn_err(CE_WARN
, "cpu module '%s' is invalid: no _cmi_ops "
197 "found", modp
->mod_modname
);
201 if (ops
->cmi_init
== NULL
) {
202 cmn_err(CE_WARN
, "cpu module '%s' is invalid: no cmi_init "
203 "entry point", modp
->mod_modname
);
211 cmi_load_modctl(modctl_t
*modp
)
216 cmi_api_ver_t apiver
;
218 ASSERT(MUTEX_HELD(&cmi_load_lock
));
220 for (cmi
= cmi_list
; cmi
!= NULL
; cmi
= cmi
->cmi_next
) {
221 if (cmi
->cmi_modp
== modp
)
225 if ((ver
= modlookup_by_modctl(modp
, "_cmi_api_version")) == NULL
) {
227 * Apparently a cpu module before versioning was introduced -
228 * we call this version 0.
230 apiver
= CMI_API_VERSION_0
;
232 apiver
= *((cmi_api_ver_t
*)ver
);
233 if (!CMI_API_VERSION_CHKMAGIC(apiver
)) {
234 cmn_err(CE_WARN
, "cpu module '%s' is invalid: "
235 "_cmi_api_version 0x%x has bad magic",
236 modp
->mod_modname
, apiver
);
241 if (apiver
!= CMI_API_VERSION
) {
242 cmn_err(CE_WARN
, "cpu module '%s' has API version %d, "
243 "kernel requires API version %d", modp
->mod_modname
,
244 CMI_API_VERSION_TOPRINT(apiver
),
245 CMI_API_VERSION_TOPRINT(CMI_API_VERSION
));
249 if ((ops
= cmi_getops(modp
)) == NULL
)
252 cmi
= kmem_zalloc(sizeof (*cmi
), KM_SLEEP
);
254 cmi
->cmi_modp
= modp
;
262 cmi_cpu_match(cmi_hdl_t hdl1
, cmi_hdl_t hdl2
, int match
)
264 if (match
>= CMI_MATCH_VENDOR
&&
265 cmi_hdl_vendor(hdl1
) != cmi_hdl_vendor(hdl2
))
268 if (match
>= CMI_MATCH_FAMILY
&&
269 cmi_hdl_family(hdl1
) != cmi_hdl_family(hdl2
))
272 if (match
>= CMI_MATCH_MODEL
&&
273 cmi_hdl_model(hdl1
) != cmi_hdl_model(hdl2
))
276 if (match
>= CMI_MATCH_STEPPING
&&
277 cmi_hdl_stepping(hdl1
) != cmi_hdl_stepping(hdl2
))
284 cmi_search_list_cb(cmi_hdl_t whdl
, void *arg1
, void *arg2
, void *arg3
)
286 cmi_hdl_t thdl
= (cmi_hdl_t
)arg1
;
287 int match
= *((int *)arg2
);
288 cmi_hdl_t
*rsltp
= (cmi_hdl_t
*)arg3
;
290 if (cmi_cpu_match(thdl
, whdl
, match
)) {
291 cmi_hdl_hold(whdl
); /* short-term hold */
293 return (CMI_HDL_WALK_DONE
);
295 return (CMI_HDL_WALK_NEXT
);
300 cmi_search_list(cmi_hdl_t hdl
, int match
)
302 cmi_hdl_t dhdl
= NULL
;
305 ASSERT(MUTEX_HELD(&cmi_load_lock
));
307 cmi_hdl_walk(cmi_search_list_cb
, (void *)hdl
, (void *)&match
, &dhdl
);
310 cmi_hdl_rele(dhdl
); /* held in cmi_search_list_cb */
317 cmi_load_module(cmi_hdl_t hdl
, int match
, int *chosenp
)
324 ASSERT(MUTEX_HELD(&cmi_load_lock
));
325 ASSERT(match
== CMI_MATCH_STEPPING
|| match
== CMI_MATCH_MODEL
||
326 match
== CMI_MATCH_FAMILY
|| match
== CMI_MATCH_VENDOR
);
329 * Have we already loaded a module for a cpu with the same
330 * vendor/family/model/stepping?
332 if ((cmi
= cmi_search_list(hdl
, match
)) != NULL
) {
337 s
[0] = cmi_hdl_family(hdl
);
338 s
[1] = cmi_hdl_model(hdl
);
339 s
[2] = cmi_hdl_stepping(hdl
);
340 modid
= modload_qualified(CPUMOD_SUBDIR
, CPUMOD_PREFIX
,
341 cmi_hdl_vendorstr(hdl
), ".", s
, match
, chosenp
);
346 modp
= mod_hold_by_id(modid
);
347 cmi
= cmi_load_modctl(modp
);
350 mod_release_mod(modp
);
356 * Try to load a cpu module with specific support for this chip type.
359 cmi_load_specific(cmi_hdl_t hdl
, void **datap
)
365 ASSERT(MUTEX_HELD(&cmi_load_lock
));
367 for (i
= CMI_MATCH_STEPPING
; i
>= CMI_MATCH_VENDOR
; i
--) {
370 if ((cmi
= cmi_load_module(hdl
, i
, &suffixlevel
)) == NULL
)
374 * A module has loaded and has a _cmi_ops structure, and the
375 * module has been held for this instance. Call its cmi_init
376 * entry point - we expect success (0) or ENOTSUP.
378 if ((err
= cmi
->cmi_ops
->cmi_init(hdl
, datap
)) == 0) {
379 if (boothowto
& RB_VERBOSE
) {
380 printf("initialized cpu module '%s' on "
381 "chip %d core %d strand %d\n",
382 cmi
->cmi_modp
->mod_modname
,
383 cmi_hdl_chipid(hdl
), cmi_hdl_coreid(hdl
),
384 cmi_hdl_strandid(hdl
));
387 } else if (err
!= ENOTSUP
) {
388 cmn_err(CE_WARN
, "failed to init cpu module '%s' on "
389 "chip %d core %d strand %d: err=%d\n",
390 cmi
->cmi_modp
->mod_modname
,
391 cmi_hdl_chipid(hdl
), cmi_hdl_coreid(hdl
),
392 cmi_hdl_strandid(hdl
), err
);
396 * The module failed or declined to init, so release
397 * it and update i to be equal to the number
398 * of suffices actually used in the last module path.
408 * Load the generic IA32 MCA cpu module, which may still supplement
409 * itself with model-specific support through cpu model-specific modules.
412 cmi_load_generic(cmi_hdl_t hdl
, void **datap
)
419 ASSERT(MUTEX_HELD(&cmi_load_lock
));
421 if ((modid
= modload(CPUMOD_SUBDIR
, CPUMOD_PREFIX
".generic")) == -1)
424 modp
= mod_hold_by_id(modid
);
425 cmi
= cmi_load_modctl(modp
);
428 mod_release_mod(modp
);
433 if ((err
= cmi
->cmi_ops
->cmi_init(hdl
, datap
)) != 0) {
435 cmn_err(CE_WARN
, CPUMOD_PREFIX
".generic failed to "
436 "init: err=%d", err
);
445 cmi_init(enum cmi_hdl_class
class, uint_t chipid
, uint_t coreid
,
457 mutex_enter(&cmi_load_lock
);
459 if ((hdl
= cmi_hdl_create(class, chipid
, coreid
, strandid
)) == NULL
) {
460 mutex_exit(&cmi_load_lock
);
461 cmn_err(CE_WARN
, "There will be no MCA support on chip %d "
462 "core %d strand %d (cmi_hdl_create returned NULL)\n",
463 chipid
, coreid
, strandid
);
467 if (!cmi_force_generic
)
468 cmi
= cmi_load_specific(hdl
, &data
);
470 if (cmi
== NULL
&& (cmi
= cmi_load_generic(hdl
, &data
)) == NULL
) {
471 cmn_err(CE_WARN
, "There will be no MCA support on chip %d "
472 "core %d strand %d\n", chipid
, coreid
, strandid
);
474 mutex_exit(&cmi_load_lock
);
478 cmi_hdl_setcmi(hdl
, cmi
, data
);
482 cmi_read_smbios(hdl
);
484 mutex_exit(&cmi_load_lock
);
490 * cmi_fini is called on DR deconfigure of a cpu resource.
491 * It should not be called at simple offline of a cpu.
494 cmi_fini(cmi_hdl_t hdl
)
496 cmi_t
*cmi
= HDL2CMI(hdl
);
498 if (cms_present(hdl
))
501 if (CMI_OP_PRESENT(cmi
, cmi_fini
))
502 CMI_OPS(cmi
)->cmi_fini(hdl
);
504 cmi_hdl_destroy(hdl
);
508 * cmi_post_startup is called from post_startup for the boot cpu only (no
509 * other cpus are started yet).
512 cmi_post_startup(void)
517 if (cmi_no_mca_init
!= 0 ||
518 (hdl
= cmi_hdl_any()) == NULL
) /* short-term hold */
523 if (CMI_OP_PRESENT(cmi
, cmi_post_startup
))
524 CMI_OPS(cmi
)->cmi_post_startup(hdl
);
530 * Called just once from start_other_cpus when all processors are started.
531 * This will not be called for each cpu, so the registered op must not
532 * assume it is called as such. We are not necessarily executing on
536 cmi_post_mpstartup(void)
541 if (cmi_no_mca_init
!= 0 ||
542 (hdl
= cmi_hdl_any()) == NULL
) /* short-term hold */
547 if (CMI_OP_PRESENT(cmi
, cmi_post_mpstartup
))
548 CMI_OPS(cmi
)->cmi_post_mpstartup(hdl
);
554 cmi_faulted_enter(cmi_hdl_t hdl
)
556 cmi_t
*cmi
= HDL2CMI(hdl
);
558 if (cmi_no_mca_init
!= 0)
561 if (CMI_OP_PRESENT(cmi
, cmi_faulted_enter
))
562 CMI_OPS(cmi
)->cmi_faulted_enter(hdl
);
566 cmi_faulted_exit(cmi_hdl_t hdl
)
568 cmi_t
*cmi
= HDL2CMI(hdl
);
570 if (cmi_no_mca_init
!= 0)
573 if (CMI_OP_PRESENT(cmi
, cmi_faulted_exit
))
574 CMI_OPS(cmi
)->cmi_faulted_exit(hdl
);
578 cmi_mca_init(cmi_hdl_t hdl
)
582 if (cmi_no_mca_init
!= 0)
587 if (CMI_OP_PRESENT(cmi
, cmi_mca_init
))
588 CMI_OPS(cmi
)->cmi_mca_init(hdl
);
591 #define CMI_RESPONSE_PANIC 0x0 /* panic must have value 0 */
592 #define CMI_RESPONSE_NONE 0x1
593 #define CMI_RESPONSE_CKILL 0x2
594 #define CMI_RESPONSE_REBOOT 0x3 /* not implemented */
595 #define CMI_RESPONSE_ONTRAP_PROT 0x4
596 #define CMI_RESPONSE_LOFAULT_PROT 0x5
599 * Return 0 if we will panic in response to this machine check, otherwise
600 * non-zero. If the caller is cmi_mca_trap in this file then the nonzero
601 * return values are to be interpreted from CMI_RESPONSE_* above.
603 * This function must just return what will be done without actually
604 * doing anything; this includes not changing the regs.
607 cmi_mce_response(struct regs
*rp
, uint64_t disp
)
609 int panicrsp
= cmi_panic_on_uncorrectable_error
? CMI_RESPONSE_PANIC
:
613 ASSERT(rp
!= NULL
); /* don't call for polling, only on #MC */
616 * If no bits are set in the disposition then there is nothing to
617 * worry about and we do not need to trampoline to ontrap or
621 return (CMI_RESPONSE_NONE
);
624 * Unconstrained errors cannot be forgiven, even by ontrap or
625 * lofault protection. The data is not poisoned and may not
626 * even belong to the trapped context - eg a writeback of
627 * data that is found to be bad.
629 if (disp
& CMI_ERRDISP_UC_UNCONSTRAINED
)
633 * ontrap OT_DATA_EC and lofault protection forgive any disposition
634 * other than unconstrained, even those normally forced fatal.
636 if ((otp
= curthread
->t_ontrap
) != NULL
&& otp
->ot_prot
& OT_DATA_EC
)
637 return (CMI_RESPONSE_ONTRAP_PROT
);
638 else if (curthread
->t_lofault
)
639 return (CMI_RESPONSE_LOFAULT_PROT
);
642 * Forced-fatal errors are terminal even in user mode.
644 if (disp
& CMI_ERRDISP_FORCEFATAL
)
648 * If the trapped context is corrupt or we have no instruction pointer
649 * to resume at (and aren't trampolining to a fault handler)
650 * then in the kernel case we must panic and in usermode we
651 * kill the affected contract.
653 if (disp
& (CMI_ERRDISP_CURCTXBAD
| CMI_ERRDISP_RIPV_INVALID
))
654 return (USERMODE(rp
->r_cs
) ? CMI_RESPONSE_CKILL
: panicrsp
);
657 * Anything else is harmless
659 return (CMI_RESPONSE_NONE
);
662 int cma_mca_trap_panic_suppressed
= 0;
667 if (cmi_panic_on_uncorrectable_error
) {
668 fm_panic("Unrecoverable Machine-Check Exception");
670 cmn_err(CE_WARN
, "suppressing panic from fatal #mc");
671 cma_mca_trap_panic_suppressed
++;
676 int cma_mca_trap_contract_kills
= 0;
677 int cma_mca_trap_ontrap_forgiven
= 0;
678 int cma_mca_trap_lofault_forgiven
= 0;
681 * Native #MC handler - we branch to here from mcetrap
685 cmi_mca_trap(struct regs
*rp
)
688 cmi_hdl_t hdl
= NULL
;
693 if (cmi_no_mca_init
!= 0)
697 * This function can call cmn_err, and the cpu module cmi_mca_trap
698 * entry point may also elect to call cmn_err (e.g., if it can't
699 * log the error onto an errorq, say very early in boot).
700 * We need to let cprintf know that we must not block.
704 if ((hdl
= cmi_hdl_lookup(CMI_HDL_NATIVE
, cmi_ntv_hwchipid(CPU
),
705 cmi_ntv_hwcoreid(CPU
), cmi_ntv_hwstrandid(CPU
))) == NULL
||
706 (cmi
= HDL2CMI(hdl
)) == NULL
||
707 !CMI_OP_PRESENT(cmi
, cmi_mca_trap
)) {
709 cmn_err(CE_WARN
, "#MC exception on cpuid %d: %s",
711 hdl
? "handle lookup ok but no #MC handler found" :
712 "handle lookup failed");
721 disp
= CMI_OPS(cmi
)->cmi_mca_trap(hdl
, rp
);
723 switch (cmi_mce_response(rp
, disp
)) {
725 cmn_err(CE_WARN
, "Invalid response from cmi_mce_response");
728 case CMI_RESPONSE_PANIC
:
732 case CMI_RESPONSE_NONE
:
735 case CMI_RESPONSE_CKILL
:
736 ttolwp(curthread
)->lwp_pcb
.pcb_flags
|= ASYNC_HWERR
;
738 cma_mca_trap_contract_kills
++;
741 case CMI_RESPONSE_ONTRAP_PROT
: {
742 on_trap_data_t
*otp
= curthread
->t_ontrap
;
743 otp
->ot_trap
= OT_DATA_EC
;
744 rp
->r_pc
= otp
->ot_trampoline
;
745 cma_mca_trap_ontrap_forgiven
++;
749 case CMI_RESPONSE_LOFAULT_PROT
:
751 rp
->r_pc
= curthread
->t_lofault
;
752 cma_mca_trap_lofault_forgiven
++;
762 cmi_hdl_poke(cmi_hdl_t hdl
)
764 cmi_t
*cmi
= HDL2CMI(hdl
);
766 if (!CMI_OP_PRESENT(cmi
, cmi_hdl_poke
))
769 CMI_OPS(cmi
)->cmi_hdl_poke(hdl
);
776 cmi_hdl_t hdl
= NULL
;
779 if (cmi_no_mca_init
!= 0)
782 if ((hdl
= cmi_hdl_lookup(CMI_HDL_NATIVE
, cmi_ntv_hwchipid(CPU
),
783 cmi_ntv_hwcoreid(CPU
), cmi_ntv_hwstrandid(CPU
))) == NULL
||
784 (cmi
= HDL2CMI(hdl
)) == NULL
||
785 !CMI_OP_PRESENT(cmi
, cmi_cmci_trap
)) {
787 cmn_err(CE_WARN
, "CMCI interrupt on cpuid %d: %s",
789 hdl
? "handle lookup ok but no CMCI handler found" :
790 "handle lookup failed");
798 CMI_OPS(cmi
)->cmi_cmci_trap(hdl
);
805 cmi_mc_register(cmi_hdl_t hdl
, const cmi_mc_ops_t
*mcops
, void *mcdata
)
807 if (!cmi_no_mca_init
)
808 cmi_hdl_setmc(hdl
, mcops
, mcdata
);
812 cmi_mc_register_global(const cmi_mc_ops_t
*mcops
, void *mcdata
)
814 if (!cmi_no_mca_init
) {
815 if (cmi_mc_global_ops
!= NULL
|| cmi_mc_global_data
!= NULL
||
816 mcops
== NULL
|| mcops
->cmi_mc_patounum
== NULL
||
817 mcops
->cmi_mc_unumtopa
== NULL
) {
818 return (CMIERR_UNKNOWN
);
820 cmi_mc_global_data
= mcdata
;
821 cmi_mc_global_ops
= mcops
;
823 return (CMI_SUCCESS
);
827 cmi_mc_sw_memscrub_disable(void)
833 cmi_mc_patounum(uint64_t pa
, uint8_t valid_hi
, uint8_t valid_lo
, uint32_t synd
,
834 int syndtype
, mc_unum_t
*up
)
836 const struct cmi_mc_ops
*mcops
;
841 return (CMIERR_MC_ABSENT
);
843 if (cmi_mc_global_ops
!= NULL
) {
844 if (cmi_mc_global_ops
->cmi_mc_patounum
== NULL
)
845 return (CMIERR_MC_NOTSUP
);
846 return (cmi_mc_global_ops
->cmi_mc_patounum(cmi_mc_global_data
,
847 pa
, valid_hi
, valid_lo
, synd
, syndtype
, up
));
850 if ((hdl
= cmi_hdl_any()) == NULL
) /* short-term hold */
851 return (CMIERR_MC_ABSENT
);
853 if ((mcops
= cmi_hdl_getmcops(hdl
)) == NULL
||
854 mcops
->cmi_mc_patounum
== NULL
) {
856 return (CMIERR_MC_NOTSUP
);
859 rv
= mcops
->cmi_mc_patounum(cmi_hdl_getmcdata(hdl
), pa
, valid_hi
,
860 valid_lo
, synd
, syndtype
, up
);
868 cmi_mc_unumtopa(mc_unum_t
*up
, nvlist_t
*nvl
, uint64_t *pap
)
870 const struct cmi_mc_ops
*mcops
;
875 if (up
!= NULL
&& nvl
!= NULL
)
876 return (CMIERR_API
); /* convert from just one form */
879 return (CMIERR_MC_ABSENT
);
881 if (cmi_mc_global_ops
!= NULL
) {
882 if (cmi_mc_global_ops
->cmi_mc_unumtopa
== NULL
)
883 return (CMIERR_MC_NOTSUP
);
884 return (cmi_mc_global_ops
->cmi_mc_unumtopa(cmi_mc_global_data
,
888 if ((hdl
= cmi_hdl_any()) == NULL
) /* short-term hold */
889 return (CMIERR_MC_ABSENT
);
891 if ((mcops
= cmi_hdl_getmcops(hdl
)) == NULL
||
892 mcops
->cmi_mc_unumtopa
== NULL
) {
895 if (nvl
!= NULL
&& nvlist_lookup_nvlist(nvl
,
896 FM_FMRI_HC_SPECIFIC
, &hcsp
) == 0 &&
897 (nvlist_lookup_uint64(hcsp
,
898 "asru-" FM_FMRI_HC_SPECIFIC_PHYSADDR
, pap
) == 0 ||
899 nvlist_lookup_uint64(hcsp
, FM_FMRI_HC_SPECIFIC_PHYSADDR
,
901 return (CMIERR_MC_PARTIALUNUMTOPA
);
903 return (mcops
&& mcops
->cmi_mc_unumtopa
== NULL
?
904 CMIERR_MC_NOTSUP
: CMIERR_MC_ABSENT
);
908 rv
= mcops
->cmi_mc_unumtopa(cmi_hdl_getmcdata(hdl
), up
, nvl
, pap
);
916 cmi_mc_logout(cmi_hdl_t hdl
, boolean_t ismc
, boolean_t sync
)
918 const struct cmi_mc_ops
*mcops
;
923 if (cmi_mc_global_ops
!= NULL
)
924 mcops
= cmi_mc_global_ops
;
926 mcops
= cmi_hdl_getmcops(hdl
);
928 if (mcops
!= NULL
&& mcops
->cmi_mc_logout
!= NULL
)
929 mcops
->cmi_mc_logout(hdl
, ismc
, sync
);
933 cmi_hdl_msrinject(cmi_hdl_t hdl
, cmi_mca_regs_t
*regs
, uint_t nregs
,
936 cmi_t
*cmi
= cmi_hdl_getcmi(hdl
);
939 if (!CMI_OP_PRESENT(cmi
, cmi_msrinject
))
940 return (CMIERR_NOTSUP
);
942 cmi_hdl_inj_begin(hdl
);
943 rc
= CMI_OPS(cmi
)->cmi_msrinject(hdl
, regs
, nregs
, force
);
944 cmi_hdl_inj_end(hdl
);
950 cmi_panic_on_ue(void)
952 return (cmi_panic_on_uncorrectable_error
? B_TRUE
: B_FALSE
);
956 cmi_panic_callback(void)
961 if (cmi_no_mca_init
|| (hdl
= cmi_hdl_any()) == NULL
)
964 cmi
= cmi_hdl_getcmi(hdl
);
965 if (CMI_OP_PRESENT(cmi
, cmi_panic_callback
))
966 CMI_OPS(cmi
)->cmi_panic_callback();