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 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/param.h>
31 #include <sys/sysmacros.h>
32 #include <sys/cmn_err.h>
33 #include <sys/systm.h>
34 #include <sys/modctl.h>
39 * PSARC 2004/405 made hat_getkpfnum(9F) obsolete. As part of the
40 * obsolecense, the original documented behavior will begin to be
41 * enforced in the future; namely, hat_getkpfnum(9F) may _only_
42 * be called with device-mapped memory virtual addresses. Since
43 * changing hat_getkpfnum(9F) to return PFN_INVALID on kernel memory
44 * would break a lot of modules without any warning, we've implemented
45 * the following mechanism as a stop-gap. In a future release, this
46 * can all be ripped out and hat_getkpfnum(9F) changed to return
47 * PFN_INVALID if it isn't called with a device-mapped memory address.
49 * We keep track of each module that has used hat_getkpfnum(9F)
50 * incorrectly. This allows us to avoid flooding the console/logs
51 * with too many warnings about a bad module that has already been
54 * On amd64 hat_getkpfnum() is never supported.
59 #define HAT_STACK_MAXDEPTH 15
64 pc_t bc_callstack
[HAT_STACK_MAXDEPTH
];
65 struct badcall_node
*bc_linkage
;
68 static struct badcall_node
*bad_getkpfnum_callers
;
71 * Common VM HAT routines.
75 printwarn(struct badcall_node
*bc
)
81 cmn_err(CE_WARN
, "Module %s is using the obsolete hat_getkpfnum(9F)",
83 cmn_err(CE_CONT
, "interface in a way that will not be supported in\n");
84 cmn_err(CE_CONT
, "a future release of Solaris. Please contact the\n");
85 cmn_err(CE_CONT
, "vendor that supplied the module for assistance,\n");
86 cmn_err(CE_CONT
, "or consult the Writing Device Drivers guide,\n");
87 cmn_err(CE_CONT
, "available from http://www.sun.com for migration\n");
88 cmn_err(CE_CONT
, "advice.\n");
89 cmn_err(CE_CONT
, "---\n");
90 cmn_err(CE_CONT
, "Callstack of bad caller:\n");
92 for (sf
= 0; sf
< bc
->bc_stackdepth
; sf
++) {
93 ksym
= kobj_getsymname(bc
->bc_callstack
[sf
], &off
);
94 cmn_err(CE_CONT
, "\t%s+%lx\n", ksym
? ksym
: "?", off
);
100 hat_getkpfnum_badcall(void *caller
)
102 struct badcall_node bcs
;
103 char *modname
= mod_containing_pc((caddr_t
)caller
);
104 struct badcall_node
*bc
;
108 * This is a hack until the ifb and jfb framebuffer drivers
109 * are fixed. Right now they use hat_getkpfnum() in a way that
110 * is really safe but will be incorrectly flagged as being
113 if (strcmp(modname
, "ifb") == 0 || strcmp(modname
, "jfb") == 0)
115 #elif defined(__i386)
117 * This is a hack until these ethernet drivers can be fixed
118 * or EOL'd. hat_getkpfnum() will continue to work correctly
119 * until this list can be removed.
121 if (strcmp(modname
, "dnet") == 0 || strcmp(modname
, "pcn") == 0 ||
122 strcmp(modname
, "adp") == 0)
124 #endif /* __sparc / __i386 */
126 for (bc
= bad_getkpfnum_callers
; bc
!= NULL
; bc
= bc
->bc_linkage
)
127 if (strcmp(bc
->bc_modname
, modname
) == 0)
131 * We haven't seen this caller before, so create a log of
132 * the callstack and module name, and emit a warning to the
135 bc
= kmem_zalloc(sizeof (struct badcall_node
), KM_NOSLEEP
);
137 bc
->bc_linkage
= bad_getkpfnum_callers
;
138 bc
->bc_modname
= modname
;
139 bad_getkpfnum_callers
= bc
;
142 bc
->bc_modname
= modname
;
145 bc
->bc_stackdepth
= getpcstack(bc
->bc_callstack
, HAT_STACK_MAXDEPTH
);