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

@@ -695,10 +695,11 @@
 {
         int i;
         uint32_t inst;
         uint8_t *instp;
         char sym[128];
+        struct modctl *modp;
 
         extern int _smap_enable_patch_count;
         extern int _smap_disable_patch_count;
 
         if (disable_smap != 0)

@@ -728,12 +729,19 @@
                 VERIFY(instp != 0);
                 inst = (instp[3] << 24) | (SMAP_STAC_INSTR & 0x00ffffff);
                 hot_patch_kernel_text((caddr_t)instp, inst, 4);
         }
 
-        hot_patch_kernel_text((caddr_t)smap_enable, SMAP_CLAC_INSTR, 4);
-        hot_patch_kernel_text((caddr_t)smap_disable, SMAP_STAC_INSTR, 4);
+        /*
+         * Hotinline calls to smap_enable and smap_disable within
+         * unix module. Hotinlines in other modules are done on
+         * mod_load().
+         */
+        modp = mod_hold_by_name("unix");
+        do_hotinlines(modp->mod_mp);
+        mod_release_mod(modp);
+
         setcr4(getcr4() | CR4_SMAP);
         smap_enable();
 }
 
 /*