xref: /illumos-gate/usr/src/uts/intel/ml/modstubs.S (revision 0e8f244e5530e0810ce630dfbb4ad550fc7fae04)
1/*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2019 Joyent, Inc.
25 * Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
26 * Copyright 2022 Garrett D'Amore <garrett@damore.org>
27 * Copyright 2023 Oxide Computer Company
28 * Copyright 2023 MNX Cloud, Inc.
29 */
30
31#include <sys/asm_linkage.h>
32
33#include "assym.h"
34
35/*
36 * !!!!!!!! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! !!!!!!!!
37 *
38 *	For functions which are either STUBs or WSTUBs the actual function
39 *	need to be called using 'call' instruction because of preamble and
40 *	postamble (i.e mod_hold_stub and mod_release_stub) around the
41 *	function call. Due to this we need to copy arguments for the
42 *	real function. On Intel we can't tell how many arguments are there
43 *	on the stack so we have to either copy everything between esp and
44 *	ebp or copy only a fixed number (MAXNARG - defined here) for
45 *	all the stub functions. Currently we are using MAXNARG (it is a kludge
46 *	but worth it?!).
47 *
48 *	NOTE: Use NO_UNLOAD_STUBs if the module is NOT unloadable once it is
49 *	      loaded.
50 */
51#define	MAXNARG	10
52
53/*
54 * WARNING: there is no check for forgetting to write END_MODULE,
55 * and if you do, the kernel will most likely crash.  Be careful
56 *
57 * This file assumes that all of the contributions to the data segment
58 * will be contiguous in the output file, even though they are separated
59 * by pieces of text.  This is safe for all assemblers I know of now...
60 */
61
62/*
63 * This file contains the stubs routines for modules which can be autoloaded.
64 */
65
66/*
67 * See the 'struct mod_modinfo' definition to see what this declaration
68 * is trying to achieve here.
69 */
70#define	MODULE(module,namespace)	\
71	.data;				\
72module##_modname:			\
73	.ascii #namespace;		\
74	.ascii "/";			\
75	.asciz #module;			\
76	SET_SIZE(module##_modname);	\
77	.align	CPTRSIZE;		\
78	.globl	module##_modinfo;	\
79	.type	module##_modinfo, @object;	\
80module##_modinfo:			\
81	.quad	module##_modname;	\
82	.quad	0	/* storage for modctl pointer */
83
84	/* then mod_stub_info structures follow until a mods_func_adr is 0 */
85
86/* this puts a 0 where the next mods_func_adr would be */
87#define	END_MODULE(module)		\
88	.data;				\
89	.align	CPTRSIZE;		\
90	.quad 0;			\
91	SET_SIZE(module##_modinfo)
92
93/*
94 * The data section in the stub_common macro is the
95 * mod_stub_info structure for the stub function
96 */
97
98#define STUB_COMMON(module, fcnname, install_fcn, retfcn, weak)		\
99	ENTRY(fcnname);							\
100	leaq	fcnname##_info(%rip), %rax;				\
101	cmpl	$0, MODS_FLAG(%rax);			/* weak? */	\
102	je	stubs_common_code;			/* not weak */	\
103	testb	$MODS_INSTALLED, MODS_FLAG(%rax);	/* installed? */ \
104	jne	stubs_common_code;		/* yes, do the mod_hold */ \
105	movq	MODS_RETFCN(%rax), %rax;	/* no, load retfcn */	\
106	INDIRECT_JMP_REG(rax);			/* no, jump to retfcn */ \
107	SET_SIZE(fcnname);						\
108	.data;								\
109	.align	 CPTRSIZE;						\
110	.type	fcnname##_info, @object;				\
111fcnname##_info:							\
112	.quad	install_fcn;		/* 0 */				\
113	.quad	module##_modinfo;	/* 0x8 */			\
114	.quad	fcnname;		/* 0x10 */			\
115	.quad	retfcn;			/* 0x18 */			\
116	.long	weak;			/* 0x20 */			\
117	SET_SIZE(fcnname##_info)
118
119#define STUB_NO_UNLOADABLE(module, fcnname, install_fcn, retfcn, weak)	\
120	ENTRY(fcnname);							\
121	leaq	fcnname##_info(%rip), %rax;				\
122	testb	$MODS_INSTALLED, MODS_FLAG(%rax); /* installed? */	\
123	je	5f;			/* no */			\
124	movq	MODS_INSTFCN(%rax), %rax; /* yes, load install_fcn */	\
125	INDIRECT_JMP_REG(rax);		/* yes, jump to install_fcn */	\
1265:	testb	$MODS_WEAK, MODS_FLAG(%rax);	/* weak? */		\
127	je	stubs_common_code;	/* no, do mod load */		\
128	movq	MODS_RETFCN(%rax), %rax; /* yes, load retfcn */		\
129	INDIRECT_JMP_REG(rax);		/* yes, jump to retfcn */	\
130	SET_SIZE(fcnname);						\
131	.data;								\
132	.align	CPTRSIZE;						\
133	.type	fcnname##_info, @object;				\
134fcnname##_info:							\
135	.quad	install_fcn;		/* 0 */				\
136	.quad	module##_modinfo;	/* 0x8 */			\
137	.quad	fcnname;		/* 0x10 */			\
138	.quad	retfcn;			/* 0x18 */			\
139	.long   weak;			/* 0x20 */			\
140	SET_SIZE(fcnname##_info)
141
142/*
143 * We branch here with the fcnname_info pointer in %rax
144 */
145	ENTRY_NP(stubs_common_code)
146	.globl	mod_hold_stub
147	.globl	mod_release_stub
148	pushq	%rbp
149	movq	%rsp, %rbp
150	subq	$0x10, %rsp
151	movq	%r15, (%rsp)		/* (caller saved) */
152	movq	%rax, %r15		/* stash the fcnname_info pointer */
153	/*
154	 * save incoming register arguments
155	 */
156	pushq	%rdi
157	pushq	%rsi
158	pushq	%rdx
159	pushq	%rcx
160	pushq	%r8
161	pushq	%r9
162	/* (next 4 args, if any, are already on the stack above %rbp) */
163	movq	%r15, %rdi
164	call	mod_hold_stub		/* mod_hold_stub(mod_stub_info *) */
165	cmpl	$-1, %eax		/* error? */
166	jne	.L1
167	movq	0x18(%r15), %rax
168	INDIRECT_CALL_REG(rax)
169	addq	$0x30, %rsp
170	jmp	.L2
171.L1:
172	/*
173	 * copy MAXNARG == 10 incoming arguments
174	 */
175	popq	%r9
176	popq	%r8
177	popq	%rcx
178	popq	%rdx
179	popq	%rsi
180	popq	%rdi
181	/*
182	 * stack:
183	 *	arg9		0x38(%rsp)
184	 *	arg8		0x30(%rsp)
185	 *	arg7		0x28(%rsp)
186	 *	arg6		0x20(%rsp)
187	 *	saved %rip	0x18(%rsp)
188	 *	saved %rbp	0x10(%rsp)
189	 *	<pad>		0x8(%rsp)
190	 *	saved %r15	0x0(%rsp)
191	 */
192	movl	$MAXNARG - 6 + 3, %r11d
193	pushq	(%rsp, %r11, 8)
194	pushq	(%rsp, %r11, 8)
195	pushq	(%rsp, %r11, 8)
196	pushq	(%rsp, %r11, 8)
197	movq	(%r15), %rax
198	INDIRECT_CALL_REG(rax)		/* call the stub fn(arg, ..) */
199	addq	$0x20, %rsp		/* pop off last 4 args */
200	pushq	%rax			/* save any return values */
201	pushq	%rdx
202	movq	%r15, %rdi
203	call	mod_release_stub	/* release hold on module */
204	popq	%rdx			/* restore return values */
205	popq	%rax
206.L2:
207	popq	%r15
208	leave
209	ret
210	SET_SIZE(stubs_common_code)
211
212#define STUB(module, fcnname, retfcn)	\
213    STUB_COMMON(module, fcnname, mod_hold_stub, retfcn, 0)
214
215/*
216 * "weak stub", don't load on account of this call
217 */
218#define WSTUB(module, fcnname, retfcn)	\
219    STUB_COMMON(module, fcnname, retfcn, retfcn, MODS_WEAK)
220
221/*
222 * "non-unloadable stub", don't bother 'holding' module if it's already loaded
223 * since the module cannot be unloaded.
224 *
225 * User *MUST* guarantee the module is not unloadable (no _fini routine).
226 */
227#define NO_UNLOAD_STUB(module, fcnname, retfcn) \
228    STUB_NO_UNLOADABLE(module, fcnname,  retfcn, retfcn, MODS_NOUNLOAD)
229
230/*
231 * "weak stub" for non-unloadable module, don't load on account of this call
232 */
233#define NO_UNLOAD_WSTUB(module, fcnname, retfcn) \
234    STUB_NO_UNLOADABLE(module, fcnname, retfcn, retfcn, MODS_NOUNLOAD|MODS_WEAK)
235
236/*
237 * this is just a marker for the beginning area of text that contains stubs
238 */
239	ENTRY_NP(stubs_base)
240	nop
241
242/*
243 * WARNING WARNING WARNING!!!!!!
244 *
245 * On the MODULE macro you MUST NOT use any spaces!!! They are
246 * significant to the preprocessor.  With ansi c there is a way around this
247 * but for some reason (yet to be investigated) ansi didn't work for other
248 * reasons!
249 *
250 * When zero is used as the return function, the system will call
251 * panic if the stub can't be resolved.
252 */
253
254/*
255 * Stubs for devfs. A non-unloadable module.
256 */
257
258#ifndef	DEVFS_MODULE
259	MODULE(devfs,fs);
260	NO_UNLOAD_STUB(devfs, devfs_clean,		nomod_minus_one);
261	NO_UNLOAD_STUB(devfs, devfs_lookupname,		nomod_minus_one);
262	NO_UNLOAD_STUB(devfs, devfs_walk,		nomod_minus_one);
263	NO_UNLOAD_STUB(devfs, devfs_devpolicy,		nomod_minus_one);
264	NO_UNLOAD_STUB(devfs, devfs_reset_perm,		nomod_minus_one);
265	NO_UNLOAD_STUB(devfs, devfs_remdrv_cleanup,	nomod_minus_one);
266	END_MODULE(devfs);
267#endif
268
269#ifndef	DEV_MODULE
270	MODULE(dev,fs);
271	NO_UNLOAD_STUB(dev, sdev_modctl_readdir,	nomod_minus_one);
272	NO_UNLOAD_STUB(dev, sdev_modctl_readdir_free,	nomod_minus_one);
273	NO_UNLOAD_STUB(dev, devname_filename_register,	nomod_minus_one);
274	NO_UNLOAD_STUB(dev, sdev_modctl_devexists,	nomod_minus_one);
275	NO_UNLOAD_STUB(dev, devname_profile_update,	nomod_minus_one);
276	NO_UNLOAD_STUB(dev, sdev_devstate_change,	nomod_minus_one);
277	NO_UNLOAD_STUB(dev, devvt_getvnodeops,		nomod_minus_one);
278	NO_UNLOAD_STUB(dev, devpts_getvnodeops,		nomod_zero);
279	END_MODULE(dev);
280#endif
281
282/*
283 * Stubs for specfs. A non-unloadable module.
284 */
285
286#ifndef SPEC_MODULE
287	MODULE(specfs,fs);
288	NO_UNLOAD_STUB(specfs, common_specvp,		nomod_zero);
289	NO_UNLOAD_STUB(specfs, makectty,		nomod_zero);
290	NO_UNLOAD_STUB(specfs, makespecvp,		nomod_zero);
291	NO_UNLOAD_STUB(specfs, smark,			nomod_zero);
292	NO_UNLOAD_STUB(specfs, spec_segmap,		nomod_einval);
293	NO_UNLOAD_STUB(specfs, specfind,		nomod_zero);
294	NO_UNLOAD_STUB(specfs, specvp,			nomod_zero);
295	NO_UNLOAD_STUB(specfs, devi_stillreferenced,	nomod_zero);
296	NO_UNLOAD_STUB(specfs, spec_getvnodeops,	nomod_zero);
297	NO_UNLOAD_STUB(specfs, spec_char_map,		nomod_zero);
298	NO_UNLOAD_STUB(specfs, specvp_devfs,		nomod_zero);
299	NO_UNLOAD_STUB(specfs, spec_assoc_vp_with_devi,	nomod_void);
300	NO_UNLOAD_STUB(specfs, spec_hold_devi_by_vp,	nomod_zero);
301	NO_UNLOAD_STUB(specfs, spec_snode_walk,		nomod_void);
302	NO_UNLOAD_STUB(specfs, spec_devi_open_count,	nomod_minus_one);
303	NO_UNLOAD_STUB(specfs, spec_is_clone,		nomod_zero);
304	NO_UNLOAD_STUB(specfs, spec_is_selfclone,	nomod_zero);
305	NO_UNLOAD_STUB(specfs, spec_fence_snode,	nomod_minus_one);
306	NO_UNLOAD_STUB(specfs, spec_unfence_snode,	nomod_minus_one);
307	END_MODULE(specfs);
308#endif
309
310
311/*
312 * Stubs for sockfs. A non-unloadable module.
313 */
314#ifndef SOCK_MODULE
315	MODULE(sockfs,fs);
316	NO_UNLOAD_STUB(sockfs, so_socket,	nomod_zero);
317	NO_UNLOAD_STUB(sockfs, so_socketpair,	nomod_zero);
318	NO_UNLOAD_STUB(sockfs, bind,		nomod_zero);
319	NO_UNLOAD_STUB(sockfs, listen,		nomod_zero);
320	NO_UNLOAD_STUB(sockfs, accept,		nomod_zero);
321	NO_UNLOAD_STUB(sockfs, connect,		nomod_zero);
322	NO_UNLOAD_STUB(sockfs, shutdown,	nomod_zero);
323	NO_UNLOAD_STUB(sockfs, recv,		nomod_zero);
324	NO_UNLOAD_STUB(sockfs, recvfrom,	nomod_zero);
325	NO_UNLOAD_STUB(sockfs, recvmsg,		nomod_zero);
326	NO_UNLOAD_STUB(sockfs, send,		nomod_zero);
327	NO_UNLOAD_STUB(sockfs, sendmsg,		nomod_zero);
328	NO_UNLOAD_STUB(sockfs, sendto,		nomod_zero);
329#ifdef _SYSCALL32_IMPL
330	NO_UNLOAD_STUB(sockfs, recv32,		nomod_zero);
331	NO_UNLOAD_STUB(sockfs, recvfrom32,	nomod_zero);
332	NO_UNLOAD_STUB(sockfs, send32,		nomod_zero);
333	NO_UNLOAD_STUB(sockfs, sendto32,	nomod_zero);
334#endif	/* _SYSCALL32_IMPL */
335	NO_UNLOAD_STUB(sockfs, getpeername,	nomod_zero);
336	NO_UNLOAD_STUB(sockfs, getsockname,	nomod_zero);
337	NO_UNLOAD_STUB(sockfs, getsockopt,	nomod_zero);
338	NO_UNLOAD_STUB(sockfs, setsockopt,	nomod_zero);
339	NO_UNLOAD_STUB(sockfs, sockconfig,	nomod_zero);
340	NO_UNLOAD_STUB(sockfs, sock_getmsg,	nomod_zero);
341	NO_UNLOAD_STUB(sockfs, sock_putmsg,	nomod_zero);
342	NO_UNLOAD_STUB(sockfs, sosendfile64,	nomod_zero);
343	NO_UNLOAD_STUB(sockfs, snf_segmap,	nomod_einval);
344	NO_UNLOAD_STUB(sockfs, sock_getfasync,	nomod_zero);
345	NO_UNLOAD_STUB(sockfs, sotpi_sototpi,	nomod_zero);
346	NO_UNLOAD_STUB(sockfs, socket_sendmblk,	nomod_zero);
347	NO_UNLOAD_STUB(sockfs, socket_setsockopt,  nomod_zero);
348	END_MODULE(sockfs);
349#endif
350
351/*
352 * IPsec stubs.
353 */
354
355#ifndef	IPSECAH_MODULE
356	MODULE(ipsecah,drv);
357	WSTUB(ipsecah,	ipsec_construct_inverse_acquire,	nomod_zero);
358	WSTUB(ipsecah,	sadb_acquire,		nomod_zero);
359	WSTUB(ipsecah,	ipsecah_algs_changed,	nomod_zero);
360	WSTUB(ipsecah,	sadb_alg_update,	nomod_zero);
361	WSTUB(ipsecah,	sadb_unlinkassoc,	nomod_zero);
362	WSTUB(ipsecah,	sadb_insertassoc,	nomod_zero);
363	WSTUB(ipsecah,	ipsecah_in_assocfailure,	nomod_zero);
364	WSTUB(ipsecah,	sadb_set_lpkt,		nomod_zero);
365	WSTUB(ipsecah,	ipsecah_icmp_error,	nomod_zero);
366	END_MODULE(ipsecah);
367#endif
368
369#ifndef	IPSECESP_MODULE
370	MODULE(ipsecesp,drv);
371	WSTUB(ipsecesp,	ipsecesp_fill_defs,	nomod_zero);
372	WSTUB(ipsecesp,	ipsecesp_algs_changed,	nomod_zero);
373	WSTUB(ipsecesp, ipsecesp_in_assocfailure,	nomod_zero);
374	WSTUB(ipsecesp, ipsecesp_init_funcs,	nomod_zero);
375	WSTUB(ipsecesp,	ipsecesp_icmp_error,	nomod_zero);
376	WSTUB(ipsecesp,	ipsecesp_send_keepalive,	nomod_zero);
377	END_MODULE(ipsecesp);
378#endif
379
380#ifndef	KEYSOCK_MODULE
381	MODULE(keysock,	drv);
382	WSTUB(keysock,	keysock_spdsock_wput_iocdata,	nomod_void);
383	WSTUB(keysock,	keysock_plumb_ipsec,	nomod_zero);
384	WSTUB(keysock,	keysock_extended_reg,	nomod_zero);
385	WSTUB(keysock,	keysock_next_seq,	nomod_zero);
386	END_MODULE(keysock);
387#endif
388
389#ifndef SPDSOCK_MODULE
390	MODULE(spdsock,drv);
391	WSTUB(spdsock,	spdsock_update_pending_algs,	nomod_zero);
392	END_MODULE(spdsock);
393#endif
394
395/*
396 * Stubs for nfs common code.
397 * XXX nfs_getvnodeops should go away with removal of kludge in vnode.c
398 */
399#ifndef NFS_MODULE
400	MODULE(nfs,fs);
401	WSTUB(nfs,	nfs_getvnodeops,	nomod_zero);
402	WSTUB(nfs,	nfs_perror,		nomod_zero);
403	WSTUB(nfs,	nfs_cmn_err,		nomod_zero);
404	WSTUB(nfs,	clcleanup_zone,		nomod_zero);
405	WSTUB(nfs,	clcleanup4_zone,	nomod_zero);
406	END_MODULE(nfs);
407#endif
408
409
410/*
411 * Stubs for nfs_dlboot (diskless booting).
412 */
413#ifndef NFS_DLBOOT_MODULE
414	MODULE(nfs_dlboot,misc);
415	STUB(nfs_dlboot,	mount_root,	nomod_minus_one);
416	STUB(nfs_dlboot,	dhcpinit,	nomod_minus_one);
417	END_MODULE(nfs_dlboot);
418#endif
419
420/*
421 * Stubs for nfs server-only code.
422 */
423#ifndef NFSSRV_MODULE
424	MODULE(nfssrv,misc);
425	STUB(nfssrv,		exportfs,	nomod_minus_one);
426	STUB(nfssrv,		nfs_getfh,	nomod_minus_one);
427	STUB(nfssrv,		nfsl_flush,	nomod_minus_one);
428	STUB(nfssrv,		rfs4_check_delegated, nomod_zero);
429	STUB(nfssrv,		rfs4_clear_client_state, nomod_zero);
430	STUB(nfssrv,		mountd_args,	nomod_minus_one);
431	NO_UNLOAD_STUB(nfssrv,	rdma_start,	nomod_zero);
432	NO_UNLOAD_STUB(nfssrv,	nfs_svc,	nomod_zero);
433	END_MODULE(nfssrv);
434#endif
435
436/*
437 * Stubs for kernel lock manager.
438 */
439#ifndef KLM_MODULE
440	MODULE(klmmod,misc);
441	NO_UNLOAD_STUB(klmmod, lm_svc,		nomod_zero);
442	NO_UNLOAD_STUB(klmmod, lm_shutdown,	nomod_zero);
443	NO_UNLOAD_STUB(klmmod, lm_unexport,	nomod_zero);
444	NO_UNLOAD_STUB(klmmod, lm_cprresume,	nomod_zero);
445	NO_UNLOAD_STUB(klmmod, lm_cprsuspend,	nomod_zero);
446	NO_UNLOAD_STUB(klmmod, lm_safelock, nomod_zero);
447	NO_UNLOAD_STUB(klmmod, lm_safemap, nomod_zero);
448	NO_UNLOAD_STUB(klmmod, lm_has_sleep, nomod_zero);
449	NO_UNLOAD_STUB(klmmod, lm_free_config, nomod_zero);
450	NO_UNLOAD_STUB(klmmod, lm_vp_active, nomod_zero);
451	NO_UNLOAD_STUB(klmmod, lm_get_sysid, nomod_zero);
452	NO_UNLOAD_STUB(klmmod, lm_rel_sysid, nomod_zero);
453	NO_UNLOAD_STUB(klmmod, lm_alloc_sysidt, nomod_minus_one);
454	NO_UNLOAD_STUB(klmmod, lm_free_sysidt, nomod_zero);
455	NO_UNLOAD_STUB(klmmod, lm_sysidt, nomod_minus_one);
456	END_MODULE(klmmod);
457#endif
458
459#ifndef KLMOPS_MODULE
460	MODULE(klmops,misc);
461	NO_UNLOAD_STUB(klmops, lm_frlock,	nomod_zero);
462	NO_UNLOAD_STUB(klmops, lm4_frlock,	nomod_zero);
463	NO_UNLOAD_STUB(klmops, lm_shrlock,	nomod_zero);
464	NO_UNLOAD_STUB(klmops, lm4_shrlock,	nomod_zero);
465	NO_UNLOAD_STUB(klmops, lm_nlm_dispatch,	nomod_zero);
466	NO_UNLOAD_STUB(klmops, lm_nlm4_dispatch,	nomod_zero);
467	NO_UNLOAD_STUB(klmops, lm_nlm_reclaim,	nomod_zero);
468	NO_UNLOAD_STUB(klmops, lm_nlm4_reclaim,	nomod_zero);
469	NO_UNLOAD_STUB(klmops, lm_register_lock_locally, nomod_zero);
470	END_MODULE(klmops);
471#endif
472
473/*
474 * Stubs for kernel TLI module
475 *   XXX currently we never allow this to unload
476 */
477#ifndef TLI_MODULE
478	MODULE(tlimod,misc);
479	NO_UNLOAD_STUB(tlimod,	t_kopen,		nomod_minus_one);
480	NO_UNLOAD_STUB(tlimod,	t_kunbind,		nomod_zero);
481	NO_UNLOAD_STUB(tlimod,	t_kadvise,		nomod_zero);
482	NO_UNLOAD_STUB(tlimod,	t_krcvudata,		nomod_zero);
483	NO_UNLOAD_STUB(tlimod,	t_ksndudata,		nomod_zero);
484	NO_UNLOAD_STUB(tlimod,	t_kalloc,		nomod_zero);
485	NO_UNLOAD_STUB(tlimod,	t_kbind,		nomod_zero);
486	NO_UNLOAD_STUB(tlimod,	t_kclose,		nomod_zero);
487	NO_UNLOAD_STUB(tlimod,	t_kspoll,		nomod_zero);
488	NO_UNLOAD_STUB(tlimod,	t_kfree,		nomod_zero);
489	NO_UNLOAD_STUB(tlimod,	t_koptmgmt,		nomod_zero);
490	END_MODULE(tlimod);
491#endif
492
493/*
494 * Stubs for kernel RPC module
495 *   XXX currently we never allow this to unload
496 */
497#ifndef RPC_MODULE
498	MODULE(rpcmod,strmod);
499	NO_UNLOAD_STUB(rpcmod,	clnt_tli_kcreate,	nomod_minus_one);
500	NO_UNLOAD_STUB(rpcmod,	svc_tli_kcreate,	nomod_minus_one);
501	NO_UNLOAD_STUB(rpcmod,	bindresvport,		nomod_minus_one);
502	NO_UNLOAD_STUB(rpcmod, rdma_register_mod,	nomod_minus_one);
503	NO_UNLOAD_STUB(rpcmod, rdma_unregister_mod,	nomod_minus_one);
504	NO_UNLOAD_STUB(rpcmod, svc_queuereq,		nomod_minus_one);
505	NO_UNLOAD_STUB(rpcmod, clist_add,		nomod_minus_one);
506	END_MODULE(rpcmod);
507#endif
508
509/*
510 * Stubs for des
511 */
512#ifndef DES_MODULE
513	MODULE(des,misc);
514	STUB(des, cbc_crypt,		nomod_zero);
515	STUB(des, ecb_crypt,		nomod_zero);
516	STUB(des, _des_crypt,		nomod_zero);
517	END_MODULE(des);
518#endif
519
520/*
521 * Stubs for procfs. A non-unloadable module.
522 */
523#ifndef PROC_MODULE
524	MODULE(procfs,fs);
525	NO_UNLOAD_STUB(procfs, prfree,		nomod_zero);
526	NO_UNLOAD_STUB(procfs, prexit,		nomod_zero);
527	NO_UNLOAD_STUB(procfs, prlwpfree,	nomod_zero);
528	NO_UNLOAD_STUB(procfs, prlwpexit,	nomod_zero);
529	NO_UNLOAD_STUB(procfs, prinvalidate,	nomod_zero);
530	NO_UNLOAD_STUB(procfs, prnsegs,		nomod_zero);
531	NO_UNLOAD_STUB(procfs, prgetcred,	nomod_zero);
532	NO_UNLOAD_STUB(procfs, prgetpriv,	nomod_zero);
533	NO_UNLOAD_STUB(procfs, prgetprivsize,	nomod_zero);
534	NO_UNLOAD_STUB(procfs, prgetsecflags,	nomod_zero);
535	NO_UNLOAD_STUB(procfs, prgetstatus,	nomod_zero);
536	NO_UNLOAD_STUB(procfs, prgetlwpstatus,	nomod_zero);
537	NO_UNLOAD_STUB(procfs, prgetpsinfo,	nomod_zero);
538	NO_UNLOAD_STUB(procfs, prgetlwpsinfo,	nomod_zero);
539	NO_UNLOAD_STUB(procfs, oprgetstatus,	nomod_zero);
540	NO_UNLOAD_STUB(procfs, oprgetpsinfo,	nomod_zero);
541#ifdef _SYSCALL32_IMPL
542	NO_UNLOAD_STUB(procfs, prgetstatus32,	nomod_zero);
543	NO_UNLOAD_STUB(procfs, prgetlwpstatus32, nomod_zero);
544	NO_UNLOAD_STUB(procfs, prgetpsinfo32,	nomod_zero);
545	NO_UNLOAD_STUB(procfs, prgetlwpsinfo32,	nomod_zero);
546	NO_UNLOAD_STUB(procfs, oprgetstatus32,	nomod_zero);
547	NO_UNLOAD_STUB(procfs, oprgetpsinfo32,	nomod_zero);
548	NO_UNLOAD_STUB(procfs, psinfo_kto32,	nomod_zero);
549	NO_UNLOAD_STUB(procfs, lwpsinfo_kto32,	nomod_zero);
550#endif	/* _SYSCALL32_IMPL */
551	NO_UNLOAD_STUB(procfs, prnotify,	nomod_zero);
552	NO_UNLOAD_STUB(procfs, prexecstart,	nomod_zero);
553	NO_UNLOAD_STUB(procfs, prexecend,	nomod_zero);
554	NO_UNLOAD_STUB(procfs, prrelvm,		nomod_zero);
555	NO_UNLOAD_STUB(procfs, prbarrier,	nomod_zero);
556	NO_UNLOAD_STUB(procfs, estimate_msacct,	nomod_zero);
557	NO_UNLOAD_STUB(procfs, pr_getprot,	nomod_zero);
558	NO_UNLOAD_STUB(procfs, pr_getprot_done,	nomod_zero);
559	NO_UNLOAD_STUB(procfs, pr_getsegsize,	nomod_zero);
560	NO_UNLOAD_STUB(procfs, pr_isobject,	nomod_zero);
561	NO_UNLOAD_STUB(procfs, pr_isself,	nomod_zero);
562	NO_UNLOAD_STUB(procfs, pr_allstopped,	nomod_zero);
563	NO_UNLOAD_STUB(procfs, pr_free_watched_pages, nomod_zero);
564	END_MODULE(procfs);
565#endif
566
567/*
568 * Stubs for fifofs
569 */
570#ifndef FIFO_MODULE
571	MODULE(fifofs,fs);
572	NO_UNLOAD_STUB(fifofs, fifovp,		nomod_zero);
573	NO_UNLOAD_STUB(fifofs, fifo_getinfo,	nomod_zero);
574	NO_UNLOAD_STUB(fifofs, fifo_vfastoff,	nomod_zero);
575	END_MODULE(fifofs);
576#endif
577
578/*
579 * Stubs for ufs
580 *
581 * This is needed to support the old quotactl system call.
582 * When the old sysent stuff goes away, this will need to be revisited.
583 */
584#ifndef UFS_MODULE
585	MODULE(ufs,fs);
586	STUB(ufs, quotactl, nomod_minus_one);
587	END_MODULE(ufs);
588#endif
589
590/*
591 * Stubs for zfs
592 */
593#ifndef ZFS_MODULE
594	MODULE(zfs,fs);
595	STUB(zfs, dsl_prop_get, nomod_minus_one);
596	STUB(zfs, spa_boot_init, nomod_minus_one);
597	STUB(zfs, zfs_prop_to_name, nomod_zero);
598	END_MODULE(zfs);
599#endif
600
601/*
602 * Stubs for dcfs
603 */
604#ifndef DCFS_MODULE
605	MODULE(dcfs,fs);
606	STUB(dcfs, decompvp, 0);
607	END_MODULE(dcfs);
608#endif
609
610/*
611 * Stubs for namefs
612 */
613#ifndef NAMEFS_MODULE
614	MODULE(namefs,fs);
615	STUB(namefs, nm_unmountall,	0);
616	END_MODULE(namefs);
617#endif
618
619/*
620 * Stubs for sysdc
621 */
622#ifndef SDC_MODULE
623	MODULE(SDC,sched);
624	NO_UNLOAD_STUB(SDC, sysdc_thread_enter,		nomod_zero);
625	END_MODULE(SDC);
626#endif
627
628/*
629 * Stubs for ts_dptbl
630 */
631#ifndef TS_DPTBL_MODULE
632	MODULE(TS_DPTBL,sched);
633	STUB(TS_DPTBL, ts_getdptbl,		0);
634	STUB(TS_DPTBL, ts_getkmdpris,		0);
635	STUB(TS_DPTBL, ts_getmaxumdpri,	0);
636	END_MODULE(TS_DPTBL);
637#endif
638
639/*
640 * Stubs for rt_dptbl
641 */
642#ifndef RT_DPTBL_MODULE
643	MODULE(RT_DPTBL,sched);
644	STUB(RT_DPTBL, rt_getdptbl,		0);
645	END_MODULE(RT_DPTBL);
646#endif
647
648/*
649 * Stubs for ia_dptbl
650 */
651#ifndef IA_DPTBL_MODULE
652	MODULE(IA_DPTBL,sched);
653	STUB(IA_DPTBL, ia_getdptbl,		nomod_zero);
654	STUB(IA_DPTBL, ia_getkmdpris,		nomod_zero);
655	STUB(IA_DPTBL, ia_getmaxumdpri,	nomod_zero);
656	END_MODULE(IA_DPTBL);
657#endif
658
659/*
660 * Stubs for FSS scheduler
661 */
662#ifndef FSS_MODULE
663	MODULE(FSS,sched);
664	WSTUB(FSS, fss_allocbuf,		nomod_zero);
665	WSTUB(FSS, fss_freebuf,			nomod_zero);
666	WSTUB(FSS, fss_changeproj,		nomod_zero);
667	WSTUB(FSS, fss_changepset,		nomod_zero);
668	END_MODULE(FSS);
669#endif
670
671/*
672 * Stubs for fx_dptbl
673 */
674#ifndef FX_DPTBL_MODULE
675	MODULE(FX_DPTBL,sched);
676	STUB(FX_DPTBL, fx_getdptbl,		0);
677	STUB(FX_DPTBL, fx_getmaxumdpri,		0);
678	END_MODULE(FX_DPTBL);
679#endif
680
681/*
682 * Stubs for bootdev
683 */
684#ifndef BOOTDEV_MODULE
685	MODULE(bootdev,misc);
686	STUB(bootdev, i_promname_to_devname, 0);
687	STUB(bootdev, i_convert_boot_device_name, 0);
688	END_MODULE(bootdev);
689#endif
690
691/*
692 * stubs for strplumb...
693 */
694#ifndef STRPLUMB_MODULE
695	MODULE(strplumb,misc);
696	STUB(strplumb, strplumb,     0);
697	STUB(strplumb, strplumb_load, 0);
698	STUB(strplumb, strplumb_get_netdev_path, 0);
699	END_MODULE(strplumb);
700#endif
701
702/*
703 * Stubs for console configuration module
704 */
705#ifndef CONSCONFIG_MODULE
706	MODULE(consconfig,misc);
707	STUB(consconfig, consconfig,	0);
708	STUB(consconfig, consconfig_get_usb_kb_path,	0);
709	STUB(consconfig, consconfig_get_usb_ms_path,	0);
710	STUB(consconfig, consconfig_get_plat_fbpath,	0);
711	STUB(consconfig, consconfig_console_is_ready,	0);
712	END_MODULE(consconfig);
713#endif
714
715/*
716 * Stubs for accounting.
717 */
718#ifndef SYSACCT_MODULE
719	MODULE(sysacct,sys);
720	NO_UNLOAD_WSTUB(sysacct, acct,			nomod_zero);
721	NO_UNLOAD_WSTUB(sysacct, acct_fs_in_use,	nomod_zero);
722	END_MODULE(sysacct);
723#endif
724
725/*
726 * Stubs for semaphore routines. sem.c
727 */
728#ifndef SEMSYS_MODULE
729	MODULE(semsys,sys);
730	NO_UNLOAD_WSTUB(semsys, semexit,		nomod_zero);
731	END_MODULE(semsys);
732#endif
733
734/*
735 * Stubs for shmem routines. shm.c
736 */
737#ifndef SHMSYS_MODULE
738	MODULE(shmsys,sys);
739	NO_UNLOAD_WSTUB(shmsys, shmexit,		nomod_zero);
740	NO_UNLOAD_WSTUB(shmsys, shmfork,		nomod_zero);
741	NO_UNLOAD_WSTUB(shmsys, shmgetid,		nomod_minus_one);
742	END_MODULE(shmsys);
743#endif
744
745/*
746 * Stubs for doors
747 */
748#ifndef DOOR_MODULE
749	MODULE(doorfs,sys);
750	NO_UNLOAD_WSTUB(doorfs, door_slam,		nomod_zero);
751	NO_UNLOAD_WSTUB(doorfs, door_exit,		nomod_zero);
752	NO_UNLOAD_WSTUB(doorfs, door_revoke_all,	nomod_zero);
753	NO_UNLOAD_WSTUB(doorfs, door_fork,		nomod_zero);
754	NO_UNLOAD_STUB(doorfs, door_upcall,		nomod_einval);
755	NO_UNLOAD_STUB(doorfs, door_ki_create,		nomod_einval);
756	NO_UNLOAD_STUB(doorfs, door_ki_open,		nomod_einval);
757	NO_UNLOAD_STUB(doorfs, door_ki_lookup,		nomod_zero);
758	NO_UNLOAD_WSTUB(doorfs, door_ki_upcall,		nomod_einval);
759	NO_UNLOAD_WSTUB(doorfs, door_ki_upcall_limited,	nomod_einval);
760	NO_UNLOAD_WSTUB(doorfs, door_ki_hold,		nomod_zero);
761	NO_UNLOAD_WSTUB(doorfs, door_ki_rele,		nomod_zero);
762	NO_UNLOAD_WSTUB(doorfs, door_ki_info,		nomod_einval);
763	END_MODULE(doorfs);
764#endif
765
766/*
767 * Stubs for MD5
768 */
769#ifndef MD5_MODULE
770	MODULE(md5,misc);
771	WSTUB(md5, MD5Init,		nomod_zero);
772	WSTUB(md5, MD5Update,		nomod_zero);
773	WSTUB(md5, MD5Final,		nomod_zero);
774	END_MODULE(md5);
775#endif
776
777/*
778 * Stubs for idmap
779 */
780#ifndef IDMAP_MODULE
781	MODULE(idmap,misc);
782	STUB(idmap, kidmap_batch_getgidbysid,	nomod_zero);
783	STUB(idmap, kidmap_batch_getpidbysid,	nomod_zero);
784	STUB(idmap, kidmap_batch_getsidbygid,	nomod_zero);
785	STUB(idmap, kidmap_batch_getsidbyuid,	nomod_zero);
786	STUB(idmap, kidmap_batch_getuidbysid,	nomod_zero);
787	STUB(idmap, kidmap_get_create,		nomod_zero);
788	STUB(idmap, kidmap_get_destroy,		nomod_zero);
789	STUB(idmap, kidmap_get_mappings,	nomod_zero);
790	STUB(idmap, kidmap_getgidbysid,		nomod_zero);
791	STUB(idmap, kidmap_getpidbysid,		nomod_zero);
792	STUB(idmap, kidmap_getsidbygid,		nomod_zero);
793	STUB(idmap, kidmap_getsidbyuid,		nomod_zero);
794	STUB(idmap, kidmap_getuidbysid,		nomod_zero);
795	STUB(idmap, idmap_get_door,		nomod_einval);
796	STUB(idmap, idmap_unreg_dh,		nomod_einval);
797	STUB(idmap, idmap_reg_dh,		nomod_einval);
798	STUB(idmap, idmap_purge_cache,		nomod_einval);
799	END_MODULE(idmap);
800#endif
801
802/*
803 * Stubs for auditing.
804 */
805#ifndef C2AUDIT_MODULE
806	MODULE(c2audit,sys);
807	NO_UNLOAD_STUB(c2audit, audit_init_module,	nomod_zero);
808	NO_UNLOAD_STUB(c2audit, audit_start,		nomod_zero);
809	NO_UNLOAD_STUB(c2audit, audit_finish,		nomod_zero);
810	NO_UNLOAD_STUB(c2audit, audit,			nomod_zero);
811	NO_UNLOAD_STUB(c2audit, auditdoor,		nomod_zero);
812	NO_UNLOAD_STUB(c2audit, audit_closef,		nomod_zero);
813	NO_UNLOAD_STUB(c2audit, audit_core_start,	nomod_zero);
814	NO_UNLOAD_STUB(c2audit, audit_core_finish,	nomod_zero);
815	NO_UNLOAD_STUB(c2audit, audit_strputmsg,	nomod_zero);
816	NO_UNLOAD_STUB(c2audit, audit_savepath,		nomod_zero);
817	NO_UNLOAD_STUB(c2audit, audit_anchorpath,	nomod_zero);
818	NO_UNLOAD_STUB(c2audit, audit_exit,		nomod_zero);
819	NO_UNLOAD_STUB(c2audit, audit_exec,		nomod_zero);
820	NO_UNLOAD_STUB(c2audit, audit_symlink,		nomod_zero);
821	NO_UNLOAD_STUB(c2audit, audit_symlink_create,	nomod_zero);
822	NO_UNLOAD_STUB(c2audit, audit_vncreate_start,	nomod_zero);
823	NO_UNLOAD_STUB(c2audit, audit_vncreate_finish,	nomod_zero);
824	NO_UNLOAD_STUB(c2audit, audit_enterprom,	nomod_zero);
825	NO_UNLOAD_STUB(c2audit, audit_exitprom,		nomod_zero);
826	NO_UNLOAD_STUB(c2audit, audit_chdirec,		nomod_zero);
827	NO_UNLOAD_STUB(c2audit, audit_setf,		nomod_zero);
828	NO_UNLOAD_STUB(c2audit, audit_sock,		nomod_zero);
829	NO_UNLOAD_STUB(c2audit, audit_strgetmsg,	nomod_zero);
830	NO_UNLOAD_STUB(c2audit, audit_ipc,		nomod_zero);
831	NO_UNLOAD_STUB(c2audit, audit_ipcget,		nomod_zero);
832	NO_UNLOAD_STUB(c2audit, audit_fdsend,		nomod_zero);
833	NO_UNLOAD_STUB(c2audit, audit_fdrecv,		nomod_zero);
834	NO_UNLOAD_STUB(c2audit, audit_priv,		nomod_zero);
835	NO_UNLOAD_STUB(c2audit, audit_setppriv,		nomod_zero);
836	NO_UNLOAD_STUB(c2audit, audit_psecflags,	nomod_zero);
837	NO_UNLOAD_STUB(c2audit, audit_devpolicy,	nomod_zero);
838	NO_UNLOAD_STUB(c2audit, audit_setfsat_path,	nomod_zero);
839	NO_UNLOAD_STUB(c2audit, audit_cryptoadm,	nomod_zero);
840	NO_UNLOAD_STUB(c2audit, audit_pf_policy,	nomod_zero);
841	NO_UNLOAD_STUB(c2audit, au_doormsg,		nomod_zero);
842	NO_UNLOAD_STUB(c2audit, au_uwrite,		nomod_zero);
843	NO_UNLOAD_STUB(c2audit, au_to_arg32,		nomod_zero);
844	NO_UNLOAD_STUB(c2audit, au_free_rec,		nomod_zero);
845	END_MODULE(c2audit);
846#endif
847
848/*
849 * Stubs for kernel rpc security service module
850 */
851#ifndef RPCSEC_MODULE
852	MODULE(rpcsec,misc);
853	NO_UNLOAD_STUB(rpcsec, sec_clnt_revoke,		nomod_zero);
854	NO_UNLOAD_STUB(rpcsec, authkern_create,		nomod_zero);
855	NO_UNLOAD_STUB(rpcsec, sec_svc_msg,		nomod_zero);
856	NO_UNLOAD_STUB(rpcsec, sec_svc_control,		nomod_zero);
857	END_MODULE(rpcsec);
858#endif
859
860/*
861 * Stubs for rpc RPCSEC_GSS security service module
862 */
863#ifndef RPCSEC_GSS_MODULE
864	MODULE(rpcsec_gss,misc);
865	NO_UNLOAD_STUB(rpcsec_gss, __svcrpcsec_gss,		nomod_zero);
866	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_getcred,		nomod_zero);
867	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_set_callback,	nomod_zero);
868	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_secget,		nomod_zero);
869	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_secfree,		nomod_zero);
870	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_seccreate,		nomod_zero);
871	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_set_defaults,	nomod_zero);
872	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_revauth,		nomod_zero);
873	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_secpurge,		nomod_zero);
874	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_cleanup,		nomod_zero);
875	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_get_versions,	nomod_zero);
876	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_max_data_length,	nomod_zero);
877	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_svc_max_data_length,	nomod_zero);
878	NO_UNLOAD_STUB(rpcsec_gss, rpc_gss_get_service_type,	nomod_zero);
879	END_MODULE(rpcsec_gss);
880#endif
881
882/*
883 * Stubs for PCI configurator module (misc/pcicfg).
884 */
885#ifndef PCICFG_MODULE
886	MODULE(pcicfg,misc);
887	STUB(pcicfg, pcicfg_configure, 0);
888	STUB(pcicfg, pcicfg_unconfigure, 0);
889	END_MODULE(pcicfg);
890#endif
891
892/*
893 * Stubs for pcieb nexus driver.
894 */
895#ifndef PCIEB_MODULE
896	MODULE(pcieb,drv);
897	STUB(pcieb, pcieb_intel_error_workaround, 0);
898	END_MODULE(pcieb);
899#endif
900
901#ifndef IWSCN_MODULE
902	MODULE(iwscn,drv);
903	STUB(iwscn, srpop, 0);
904	END_MODULE(iwscn);
905#endif
906
907/*
908 * Stubs for checkpoint-resume module
909 */
910#ifndef CPR_MODULE
911        MODULE(cpr,misc);
912        STUB(cpr, cpr, 0);
913        END_MODULE(cpr);
914#endif
915
916/*
917 * Stubs for i86hvm bootstraping
918 */
919#ifndef HVM_BOOTSTRAP
920	MODULE(hvm_bootstrap,misc);
921	NO_UNLOAD_STUB(hvm_bootstrap, hvmboot_rootconf, nomod_zero);
922	END_MODULE(hvm_bootstrap);
923#endif
924
925/*
926 * Clustering: stubs for bootstrapping.
927 */
928#ifndef CL_BOOTSTRAP
929	MODULE(cl_bootstrap,misc);
930	NO_UNLOAD_WSTUB(cl_bootstrap, clboot_modload, nomod_minus_one);
931	NO_UNLOAD_WSTUB(cl_bootstrap, clboot_loadrootmodules, nomod_zero);
932	NO_UNLOAD_WSTUB(cl_bootstrap, clboot_rootconf, nomod_zero);
933	NO_UNLOAD_WSTUB(cl_bootstrap, clboot_mountroot, nomod_zero);
934	NO_UNLOAD_WSTUB(cl_bootstrap, clconf_init, nomod_zero);
935	NO_UNLOAD_WSTUB(cl_bootstrap, clconf_get_nodeid, nomod_zero);
936	NO_UNLOAD_WSTUB(cl_bootstrap, clconf_maximum_nodeid, nomod_zero);
937	NO_UNLOAD_WSTUB(cl_bootstrap, cluster, nomod_zero);
938	END_MODULE(cl_bootstrap);
939#endif
940
941/*
942 * Clustering: stubs for cluster infrastructure.
943 */
944#ifndef CL_COMM_MODULE
945	MODULE(cl_comm,misc);
946	NO_UNLOAD_STUB(cl_comm, cladmin, nomod_minus_one);
947	END_MODULE(cl_comm);
948#endif
949
950/*
951 * Clustering: stubs for global file system operations.
952 */
953#ifndef PXFS_MODULE
954	MODULE(pxfs,fs);
955	NO_UNLOAD_WSTUB(pxfs, clpxfs_aio_read, nomod_zero);
956	NO_UNLOAD_WSTUB(pxfs, clpxfs_aio_write, nomod_zero);
957	NO_UNLOAD_WSTUB(pxfs, cl_flk_state_transition_notify, nomod_zero);
958	END_MODULE(pxfs);
959#endif
960
961/*
962 * Stubs for kernel cryptographic framework module (misc/kcf).
963 */
964#ifndef KCF_MODULE
965	MODULE(kcf,misc);
966	NO_UNLOAD_STUB(kcf, crypto_mech2id, nomod_minus_one);
967	NO_UNLOAD_STUB(kcf, crypto_register_provider, nomod_minus_one);
968	NO_UNLOAD_STUB(kcf, crypto_unregister_provider, nomod_minus_one);
969	NO_UNLOAD_STUB(kcf, crypto_provider_notification, nomod_minus_one);
970	NO_UNLOAD_STUB(kcf, crypto_op_notification, nomod_minus_one);
971	NO_UNLOAD_STUB(kcf, crypto_kmflag, nomod_minus_one);
972	NO_UNLOAD_STUB(kcf, crypto_digest, nomod_minus_one);
973	NO_UNLOAD_STUB(kcf, crypto_digest_prov, nomod_minus_one);
974	NO_UNLOAD_STUB(kcf, crypto_digest_init, nomod_minus_one);
975	NO_UNLOAD_STUB(kcf, crypto_digest_init_prov, nomod_minus_one);
976	NO_UNLOAD_STUB(kcf, crypto_digest_update, nomod_minus_one);
977	NO_UNLOAD_STUB(kcf, crypto_digest_final, nomod_minus_one);
978	NO_UNLOAD_STUB(kcf, crypto_digest_key_prov, nomod_minus_one);
979	NO_UNLOAD_STUB(kcf, crypto_encrypt, nomod_minus_one);
980	NO_UNLOAD_STUB(kcf, crypto_encrypt_prov, nomod_minus_one);
981	NO_UNLOAD_STUB(kcf, crypto_encrypt_init, nomod_minus_one);
982	NO_UNLOAD_STUB(kcf, crypto_encrypt_init_prov, nomod_minus_one);
983	NO_UNLOAD_STUB(kcf, crypto_encrypt_update, nomod_minus_one);
984	NO_UNLOAD_STUB(kcf, crypto_encrypt_final, nomod_minus_one);
985	NO_UNLOAD_STUB(kcf, crypto_decrypt, nomod_minus_one);
986	NO_UNLOAD_STUB(kcf, crypto_decrypt_prov, nomod_minus_one);
987	NO_UNLOAD_STUB(kcf, crypto_decrypt_init, nomod_minus_one);
988	NO_UNLOAD_STUB(kcf, crypto_decrypt_init_prov, nomod_minus_one);
989	NO_UNLOAD_STUB(kcf, crypto_decrypt_update, nomod_minus_one);
990	NO_UNLOAD_STUB(kcf, crypto_decrypt_final, nomod_minus_one);
991	NO_UNLOAD_STUB(kcf, crypto_get_all_mech_info, nomod_minus_one);
992	NO_UNLOAD_STUB(kcf, crypto_key_check, nomod_minus_one);
993	NO_UNLOAD_STUB(kcf, crypto_key_check_prov, nomod_minus_one);
994	NO_UNLOAD_STUB(kcf, crypto_key_derive, nomod_minus_one);
995	NO_UNLOAD_STUB(kcf, crypto_key_generate, nomod_minus_one);
996	NO_UNLOAD_STUB(kcf, crypto_key_generate_pair, nomod_minus_one);
997	NO_UNLOAD_STUB(kcf, crypto_key_unwrap, nomod_minus_one);
998	NO_UNLOAD_STUB(kcf, crypto_key_wrap, nomod_minus_one);
999	NO_UNLOAD_STUB(kcf, crypto_mac, nomod_minus_one);
1000	NO_UNLOAD_STUB(kcf, crypto_mac_prov, nomod_minus_one);
1001	NO_UNLOAD_STUB(kcf, crypto_mac_verify, nomod_minus_one);
1002	NO_UNLOAD_STUB(kcf, crypto_mac_verify_prov, nomod_minus_one);
1003	NO_UNLOAD_STUB(kcf, crypto_mac_init, nomod_minus_one);
1004	NO_UNLOAD_STUB(kcf, crypto_mac_init_prov, nomod_minus_one);
1005	NO_UNLOAD_STUB(kcf, crypto_mac_update, nomod_minus_one);
1006	NO_UNLOAD_STUB(kcf, crypto_mac_final, nomod_minus_one);
1007	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt, nomod_minus_one);
1008	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt_prov, nomod_minus_one);
1009	NO_UNLOAD_STUB(kcf, crypto_mac_verify_decrypt, nomod_minus_one);
1010	NO_UNLOAD_STUB(kcf, crypto_mac_verify_decrypt_prov, nomod_minus_one);
1011	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt_init, nomod_minus_one);
1012	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt_init_prov, nomod_minus_one);
1013	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt_update, nomod_minus_one);
1014	NO_UNLOAD_STUB(kcf, crypto_mac_decrypt_final, nomod_minus_one);
1015	NO_UNLOAD_STUB(kcf, crypto_object_copy, nomod_minus_one);
1016	NO_UNLOAD_STUB(kcf, crypto_object_create, nomod_minus_one);
1017	NO_UNLOAD_STUB(kcf, crypto_object_destroy, nomod_minus_one);
1018	NO_UNLOAD_STUB(kcf, crypto_object_find_final, nomod_minus_one);
1019	NO_UNLOAD_STUB(kcf, crypto_object_find_init, nomod_minus_one);
1020	NO_UNLOAD_STUB(kcf, crypto_object_find, nomod_minus_one);
1021	NO_UNLOAD_STUB(kcf, crypto_object_get_attribute_value, nomod_minus_one);
1022	NO_UNLOAD_STUB(kcf, crypto_object_get_size, nomod_minus_one);
1023	NO_UNLOAD_STUB(kcf, crypto_object_set_attribute_value, nomod_minus_one);
1024	NO_UNLOAD_STUB(kcf, crypto_session_close, nomod_minus_one);
1025	NO_UNLOAD_STUB(kcf, crypto_session_login, nomod_minus_one);
1026	NO_UNLOAD_STUB(kcf, crypto_session_logout, nomod_minus_one);
1027	NO_UNLOAD_STUB(kcf, crypto_session_open, nomod_minus_one);
1028	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac, nomod_minus_one);
1029	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac_prov, nomod_minus_one);
1030	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac_init, nomod_minus_one);
1031	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac_init_prov, nomod_minus_one);
1032	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac_update, nomod_minus_one);
1033	NO_UNLOAD_STUB(kcf, crypto_encrypt_mac_final, nomod_minus_one);
1034	NO_UNLOAD_STUB(kcf, crypto_create_ctx_template, nomod_minus_one);
1035	NO_UNLOAD_STUB(kcf, crypto_destroy_ctx_template, nomod_minus_one);
1036	NO_UNLOAD_STUB(kcf, crypto_get_mech_list, nomod_minus_one);
1037	NO_UNLOAD_STUB(kcf, crypto_free_mech_list, nomod_minus_one);
1038	NO_UNLOAD_STUB(kcf, crypto_cancel_req, nomod_minus_one);
1039	NO_UNLOAD_STUB(kcf, crypto_cancel_ctx, nomod_minus_one);
1040	NO_UNLOAD_STUB(kcf, crypto_bufcall_alloc, nomod_minus_one);
1041	NO_UNLOAD_STUB(kcf, crypto_bufcall_free, nomod_minus_one);
1042	NO_UNLOAD_STUB(kcf, crypto_bufcall, nomod_minus_one);
1043	NO_UNLOAD_STUB(kcf, crypto_unbufcall, nomod_minus_one);
1044	NO_UNLOAD_STUB(kcf, crypto_notify_events, nomod_minus_one);
1045	NO_UNLOAD_STUB(kcf, crypto_unnotify_events, nomod_minus_one);
1046	NO_UNLOAD_STUB(kcf, crypto_get_provider, nomod_minus_one);
1047	NO_UNLOAD_STUB(kcf, crypto_get_provinfo, nomod_minus_one);
1048	NO_UNLOAD_STUB(kcf, crypto_release_provider, nomod_minus_one);
1049	NO_UNLOAD_STUB(kcf, crypto_sign, nomod_minus_one);
1050	NO_UNLOAD_STUB(kcf, crypto_sign_prov, nomod_minus_one);
1051	NO_UNLOAD_STUB(kcf, crypto_sign_init, nomod_minus_one);
1052	NO_UNLOAD_STUB(kcf, crypto_sign_init_prov, nomod_minus_one);
1053	NO_UNLOAD_STUB(kcf, crypto_sign_update, nomod_minus_one);
1054	NO_UNLOAD_STUB(kcf, crypto_sign_final, nomod_minus_one);
1055	NO_UNLOAD_STUB(kcf, crypto_sign_recover, nomod_minus_one);
1056	NO_UNLOAD_STUB(kcf, crypto_sign_recover_prov, nomod_minus_one);
1057	NO_UNLOAD_STUB(kcf, crypto_sign_recover_init_prov, nomod_minus_one);
1058	NO_UNLOAD_STUB(kcf, crypto_verify, nomod_minus_one);
1059	NO_UNLOAD_STUB(kcf, crypto_verify_prov, nomod_minus_one);
1060	NO_UNLOAD_STUB(kcf, crypto_verify_init, nomod_minus_one);
1061	NO_UNLOAD_STUB(kcf, crypto_verify_init_prov, nomod_minus_one);
1062	NO_UNLOAD_STUB(kcf, crypto_verify_update, nomod_minus_one);
1063	NO_UNLOAD_STUB(kcf, crypto_verify_final, nomod_minus_one);
1064	NO_UNLOAD_STUB(kcf, crypto_verify_recover, nomod_minus_one);
1065	NO_UNLOAD_STUB(kcf, crypto_verify_recover_prov, nomod_minus_one);
1066	NO_UNLOAD_STUB(kcf, crypto_verify_recover_init_prov, nomod_minus_one);
1067	NO_UNLOAD_STUB(kcf, random_add_entropy, nomod_minus_one);
1068	NO_UNLOAD_STUB(kcf, random_add_pseudo_entropy, nomod_minus_one);
1069	NO_UNLOAD_STUB(kcf, random_get_blocking_bytes, nomod_minus_one);
1070	NO_UNLOAD_STUB(kcf, random_get_bytes, nomod_minus_one);
1071	NO_UNLOAD_STUB(kcf, random_get_pseudo_bytes, nomod_minus_one);
1072	END_MODULE(kcf);
1073#endif
1074
1075/*
1076 * Stubs for sha1. A non-unloadable module.
1077 */
1078#ifndef SHA1_MODULE
1079	MODULE(sha1,crypto);
1080	NO_UNLOAD_STUB(sha1, SHA1Init, nomod_void);
1081	NO_UNLOAD_STUB(sha1, SHA1Update, nomod_void);
1082	NO_UNLOAD_STUB(sha1, SHA1Final, nomod_void);
1083	END_MODULE(sha1);
1084#endif
1085
1086/*
1087 * The following stubs are used by the mac module.
1088 * Since dld already depends on mac, these
1089 * stubs are needed to avoid circular dependencies.
1090 */
1091#ifndef	DLD_MODULE
1092	MODULE(dld,drv);
1093	STUB(dld, dld_init_ops, nomod_void);
1094	STUB(dld, dld_fini_ops, nomod_void);
1095	STUB(dld, dld_devt_to_instance, nomod_minus_one);
1096	STUB(dld, dld_autopush, nomod_minus_one);
1097	STUB(dld, dld_getinfo, nomod_minus_one);
1098	STUB(dld, dld_ioc_register, nomod_einval);
1099	STUB(dld, dld_ioc_unregister, nomod_void);
1100	END_MODULE(dld);
1101#endif
1102
1103/*
1104 * The following stubs are used by the mac module.
1105 * Since dls already depends on mac, these
1106 * stubs are needed to avoid circular dependencies.
1107 */
1108#ifndef DLS_MODULE
1109	MODULE(dls,misc);
1110	STUB(dls, dls_devnet_mac, nomod_zero);
1111	STUB(dls, dls_devnet_hold_tmp, nomod_einval);
1112	STUB(dls, dls_devnet_rele_tmp, nomod_void);
1113	STUB(dls, dls_devnet_hold_link, nomod_einval);
1114	STUB(dls, dls_devnet_rele_link, nomod_void);
1115	STUB(dls, dls_devnet_prop_task_wait, nomod_void);
1116	STUB(dls, dls_mgmt_get_linkid, nomod_einval);
1117	STUB(dls, dls_devnet_macname2linkid, nomod_einval);
1118	STUB(dls, dls_mgmt_get_linkinfo, nomod_einval);
1119        END_MODULE(dls);
1120#endif
1121
1122#ifndef	SOFTMAC_MODULE
1123	MODULE(softmac,drv);
1124	STUB(softmac, softmac_hold_device, nomod_einval);
1125	STUB(softmac, softmac_rele_device, nomod_void);
1126	STUB(softmac, softmac_recreate, nomod_void);
1127	END_MODULE(softmac);
1128#endif
1129
1130#ifndef IPTUN_MODULE
1131	MODULE(iptun,drv);
1132	STUB(iptun, iptun_create, nomod_einval);
1133	STUB(iptun, iptun_delete, nomod_einval);
1134	STUB(iptun, iptun_set_policy, nomod_void) ;
1135	END_MODULE(iptun);
1136#endif
1137
1138/*
1139 * Stubs for dcopy, for Intel IOAT KAPIs
1140 */
1141#ifndef DCOPY_MODULE
1142	MODULE(dcopy,misc);
1143	NO_UNLOAD_STUB(dcopy, dcopy_query, nomod_minus_one);
1144	NO_UNLOAD_STUB(dcopy, dcopy_query_channel, nomod_minus_one);
1145	NO_UNLOAD_STUB(dcopy, dcopy_alloc, nomod_minus_one);
1146	NO_UNLOAD_STUB(dcopy, dcopy_free, nomod_minus_one);
1147	NO_UNLOAD_STUB(dcopy, dcopy_cmd_alloc, nomod_minus_one);
1148	NO_UNLOAD_STUB(dcopy, dcopy_cmd_free, nomod_void);
1149	NO_UNLOAD_STUB(dcopy, dcopy_cmd_post, nomod_minus_one);
1150	NO_UNLOAD_STUB(dcopy, dcopy_cmd_poll, nomod_minus_one);
1151	END_MODULE(dcopy);
1152#endif
1153
1154/*
1155 * Stubs for acpica
1156 */
1157#ifndef ACPICA_MODULE
1158	MODULE(acpica,misc);
1159	NO_UNLOAD_STUB(acpica, AcpiOsReadPort, nomod_minus_one) ;
1160	NO_UNLOAD_STUB(acpica, AcpiOsWritePort, nomod_minus_one) ;
1161	NO_UNLOAD_STUB(acpica, AcpiInstallNotifyHandler, nomod_minus_one) ;
1162	NO_UNLOAD_STUB(acpica, AcpiRemoveNotifyHandler, nomod_minus_one) ;
1163	NO_UNLOAD_STUB(acpica, AcpiEvaluateObject, nomod_minus_one) ;
1164	NO_UNLOAD_STUB(acpica, AcpiEvaluateObjectTyped, nomod_minus_one) ;
1165	NO_UNLOAD_STUB(acpica, AcpiWriteBitRegister, nomod_minus_one) ;
1166	NO_UNLOAD_STUB(acpica, AcpiReadBitRegister, nomod_minus_one) ;
1167	NO_UNLOAD_STUB(acpica, AcpiOsFree, nomod_minus_one) ;
1168	NO_UNLOAD_STUB(acpica, acpica_get_handle_cpu, nomod_minus_one) ;
1169	NO_UNLOAD_STUB(acpica, acpica_get_global_FADT, nomod_minus_one) ;
1170	NO_UNLOAD_STUB(acpica, acpica_write_cpupm_capabilities,
1171	    nomod_minus_one)		       ;
1172	NO_UNLOAD_STUB(acpica, __acpi_wbinvd, nomod_minus_one) ;
1173	NO_UNLOAD_STUB(acpica, acpi_reset_system, nomod_minus_one) ;
1174	END_MODULE(acpica);
1175#endif
1176
1177/*
1178 * Stubs for acpidev
1179 */
1180#ifndef ACPIDEV_MODULE
1181	MODULE(acpidev,misc);
1182	NO_UNLOAD_STUB(acpidev, acpidev_dr_get_cpu_numa_info, nomod_minus_one) ;
1183	NO_UNLOAD_STUB(acpidev, acpidev_dr_free_cpu_numa_info,
1184	    nomod_minus_one) ;
1185	END_MODULE(acpidev);
1186#endif
1187
1188#ifndef IPNET_MODULE
1189	MODULE(ipnet,drv);
1190	STUB(ipnet, ipnet_if_getdev, nomod_zero);
1191	STUB(ipnet, ipnet_walk_if, nomod_zero);
1192	END_MODULE(ipnet);
1193#endif
1194
1195#ifndef IOMMULIB_MODULE
1196	MODULE(iommulib,misc);
1197	STUB(iommulib, iommulib_nex_close, nomod_void);
1198        END_MODULE(iommulib);
1199#endif
1200
1201/*
1202 * Stubs for rootnex nexus driver.
1203 */
1204#ifndef ROOTNEX_MODULE
1205	MODULE(rootnex,drv);
1206	STUB(rootnex, immu_init, 0);
1207	STUB(rootnex, immu_startup, 0);
1208	STUB(rootnex, immu_physmem_update, 0);
1209	END_MODULE(rootnex);
1210#endif
1211
1212/*
1213 * Stubs for kernel socket, for iscsi
1214 */
1215#ifndef KSOCKET_MODULE
1216	MODULE(ksocket, misc);
1217	NO_UNLOAD_STUB(ksocket, ksocket_setsockopt, nomod_minus_one);
1218	NO_UNLOAD_STUB(ksocket, ksocket_getsockopt, nomod_minus_one);
1219	NO_UNLOAD_STUB(ksocket, ksocket_getpeername, nomod_minus_one);
1220	NO_UNLOAD_STUB(ksocket, ksocket_getsockname, nomod_minus_one);
1221	NO_UNLOAD_STUB(ksocket, ksocket_socket, nomod_minus_one);
1222	NO_UNLOAD_STUB(ksocket, ksocket_bind, nomod_minus_one);
1223	NO_UNLOAD_STUB(ksocket, ksocket_listen, nomod_minus_one);
1224	NO_UNLOAD_STUB(ksocket, ksocket_accept, nomod_minus_one);
1225	NO_UNLOAD_STUB(ksocket, ksocket_connect, nomod_minus_one);
1226	NO_UNLOAD_STUB(ksocket, ksocket_recv, nomod_minus_one);
1227	NO_UNLOAD_STUB(ksocket, ksocket_recvfrom, nomod_minus_one);
1228	NO_UNLOAD_STUB(ksocket, ksocket_recvmsg, nomod_minus_one);
1229	NO_UNLOAD_STUB(ksocket, ksocket_send, nomod_minus_one);
1230	NO_UNLOAD_STUB(ksocket, ksocket_sendto, nomod_minus_one);
1231	NO_UNLOAD_STUB(ksocket, ksocket_sendmsg, nomod_minus_one);
1232	NO_UNLOAD_STUB(ksocket, ksocket_ioctl, nomod_minus_one);
1233	NO_UNLOAD_STUB(ksocket, ksocket_setcallbacks, nomod_minus_one);
1234	NO_UNLOAD_STUB(ksocket, ksocket_hold, nomod_minus_one);
1235	NO_UNLOAD_STUB(ksocket, ksocket_rele, nomod_minus_one);
1236	NO_UNLOAD_STUB(ksocket, ksocket_shutdown, nomod_minus_one);
1237	NO_UNLOAD_STUB(ksocket, ksocket_close, nomod_minus_one);
1238	END_MODULE(ksocket);
1239#endif
1240
1241/*
1242 * Stubs for elfexec
1243 */
1244#ifndef ELFEXEC_MODULE
1245	MODULE(elfexec,exec);
1246	STUB(elfexec, elfexec,		nomod_einval);
1247	STUB(elfexec, mapexec_brand,	nomod_einval);
1248	STUB(elfexec, elf32exec,	nomod_einval);
1249	STUB(elfexec, mapexec32_brand,	nomod_einval);
1250	END_MODULE(elfexec);
1251#endif
1252
1253/*
1254 * Stub(s) for APIX module.
1255 */
1256#ifndef APIX_MODULE
1257	MODULE(apix,mach);
1258	WSTUB(apix, apix_loaded, nomod_zero);
1259	END_MODULE(apix);
1260#endif
1261
1262/*
1263 * Stubs for ppt module (bhyve PCI passthrough driver)
1264 */
1265#ifndef PPT_MODULE
1266	MODULE(ppt,drv);
1267	WSTUB(ppt, ppt_unassign_all,		nomod_zero);
1268	WSTUB(ppt, ppt_map_mmio,		nomod_einval);
1269	WSTUB(ppt, ppt_unmap_mmio,		nomod_einval);
1270	WSTUB(ppt, ppt_setup_msi,		nomod_einval);
1271	WSTUB(ppt, ppt_setup_msix,		nomod_einval);
1272	WSTUB(ppt, ppt_disable_msix,		nomod_einval);
1273	WSTUB(ppt, ppt_assigned_devices,	nomod_zero);
1274	WSTUB(ppt, ppt_is_mmio,			nomod_zero);
1275	WSTUB(ppt, ppt_assign_device,		nomod_einval);
1276	WSTUB(ppt, ppt_unassign_device,		nomod_einval);
1277	WSTUB(ppt, ppt_get_limits,		nomod_einval);
1278	END_MODULE(ppt);
1279#endif
1280
1281/*
1282 * this is just a marker for the area of text that contains stubs
1283 */
1284	ENTRY_NP(stubs_end)
1285	nop
1286