Print this page
9059 Simplify SMAP relocations with krtld
Portions contributed by: John Levon <john.levon@joyent.com>


   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) 1990, 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 /*
  27  * modctl system call for loadable module support.
  28  */
  29 
  30 #include <sys/param.h>
  31 #include <sys/user.h>
  32 #include <sys/systm.h>
  33 #include <sys/exec.h>
  34 #include <sys/file.h>
  35 #include <sys/stat.h>
  36 #include <sys/conf.h>
  37 #include <sys/time.h>
  38 #include <sys/reboot.h>
  39 #include <sys/fs/ufs_fsdir.h>
  40 #include <sys/kmem.h>
  41 #include <sys/sysconf.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/ddi.h>


3456                 }
3457 
3458                 /*
3459                  * DCS: bootstrapping code. If the driver is loaded
3460                  * before root mount, it is assumed that the driver
3461                  * may be used before mounting root. In order to
3462                  * access mappings of global to local minor no.'s
3463                  * during installation/open of the driver, we load
3464                  * them into memory here while the BOP_interfaces
3465                  * are still up.
3466                  */
3467                 if ((cluster_bootflags & CLUSTER_BOOTED) && !modrootloaded) {
3468                         retval = clboot_modload(mp);
3469                 }
3470 
3471                 kmem_free(modinfop, sizeof (struct modinfo));
3472                 (void) mod_sysctl(SYS_SET_MVAR, (void *)mp);
3473                 retval = install_stubs_by_name(mp, mp->mod_modname);
3474 
3475                 /*





3476                  * Now that the module is loaded, we need to give DTrace
3477                  * a chance to notify its providers.  This is done via
3478                  * the dtrace_modload function pointer.
3479                  */
3480                 if (strcmp(mp->mod_modname, "dtrace") != 0) {
3481                         struct modctl *dmp = mod_hold_by_name("dtrace");
3482 
3483                         if (dmp != NULL && dtrace_modload != NULL)
3484                                 (*dtrace_modload)(mp);
3485 
3486                         mod_release_mod(dmp);
3487                 }
3488 
3489         } else {
3490                 /*
3491                  * If load failed then we need to release any requisites
3492                  * that we had established.
3493                  */
3494                 ASSERT(retval);
3495                 mod_release_requisites(mp);




   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) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2017 Joyent, Inc.
  25  */
  26 
  27 /*
  28  * modctl system call for loadable module support.
  29  */
  30 
  31 #include <sys/param.h>
  32 #include <sys/user.h>
  33 #include <sys/systm.h>
  34 #include <sys/exec.h>
  35 #include <sys/file.h>
  36 #include <sys/stat.h>
  37 #include <sys/conf.h>
  38 #include <sys/time.h>
  39 #include <sys/reboot.h>
  40 #include <sys/fs/ufs_fsdir.h>
  41 #include <sys/kmem.h>
  42 #include <sys/sysconf.h>
  43 #include <sys/cmn_err.h>
  44 #include <sys/ddi.h>


3457                 }
3458 
3459                 /*
3460                  * DCS: bootstrapping code. If the driver is loaded
3461                  * before root mount, it is assumed that the driver
3462                  * may be used before mounting root. In order to
3463                  * access mappings of global to local minor no.'s
3464                  * during installation/open of the driver, we load
3465                  * them into memory here while the BOP_interfaces
3466                  * are still up.
3467                  */
3468                 if ((cluster_bootflags & CLUSTER_BOOTED) && !modrootloaded) {
3469                         retval = clboot_modload(mp);
3470                 }
3471 
3472                 kmem_free(modinfop, sizeof (struct modinfo));
3473                 (void) mod_sysctl(SYS_SET_MVAR, (void *)mp);
3474                 retval = install_stubs_by_name(mp, mp->mod_modname);
3475 
3476                 /*
3477                  * Perform hotinlines before module is started.
3478                  */
3479                 do_hotinlines(mp->mod_mp);
3480 
3481                 /*
3482                  * Now that the module is loaded, we need to give DTrace
3483                  * a chance to notify its providers.  This is done via
3484                  * the dtrace_modload function pointer.
3485                  */
3486                 if (strcmp(mp->mod_modname, "dtrace") != 0) {
3487                         struct modctl *dmp = mod_hold_by_name("dtrace");
3488 
3489                         if (dmp != NULL && dtrace_modload != NULL)
3490                                 (*dtrace_modload)(mp);
3491 
3492                         mod_release_mod(dmp);
3493                 }
3494 
3495         } else {
3496                 /*
3497                  * If load failed then we need to release any requisites
3498                  * that we had established.
3499                  */
3500                 ASSERT(retval);
3501                 mod_release_requisites(mp);