Print this page
10908 Simplify SMAP relocations with krtld

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/startup.c
          +++ new/usr/src/uts/i86pc/os/startup.c
↓ open down ↓ 689 lines elided ↑ open up ↑
 690  690   * replace the four byte word at the patch point. See uts/intel/ia32/ml/copy.s
 691  691   * for more information on what's going on here.
 692  692   */
 693  693  static void
 694  694  startup_smap(void)
 695  695  {
 696  696          int i;
 697  697          uint32_t inst;
 698  698          uint8_t *instp;
 699  699          char sym[128];
      700 +        struct modctl *modp;
 700  701  
 701  702          extern int _smap_enable_patch_count;
 702  703          extern int _smap_disable_patch_count;
 703  704  
 704  705          if (disable_smap != 0)
 705  706                  remove_x86_feature(x86_featureset, X86FSET_SMAP);
 706  707  
 707  708          if (is_x86_feature(x86_featureset, X86FSET_SMAP) == B_FALSE)
 708  709                  return;
 709  710  
↓ open down ↓ 13 lines elided ↑ open up ↑
 723  724                  int sizep;
 724  725  
 725  726                  VERIFY(snprintf(sym, sizeof (sym), "_smap_disable_patch_%d",
 726  727                      i) < sizeof (sym));
 727  728                  instp = (uint8_t *)(void *)kobj_getelfsym(sym, NULL, &sizep);
 728  729                  VERIFY(instp != 0);
 729  730                  inst = (instp[3] << 24) | (SMAP_STAC_INSTR & 0x00ffffff);
 730  731                  hot_patch_kernel_text((caddr_t)instp, inst, 4);
 731  732          }
 732  733  
 733      -        hot_patch_kernel_text((caddr_t)smap_enable, SMAP_CLAC_INSTR, 4);
 734      -        hot_patch_kernel_text((caddr_t)smap_disable, SMAP_STAC_INSTR, 4);
      734 +        /*
      735 +         * Hotinline calls to smap_enable and smap_disable within
      736 +         * unix module. Hotinlines in other modules are done on
      737 +         * mod_load().
      738 +         */
      739 +        modp = mod_hold_by_name("unix");
      740 +        do_hotinlines(modp->mod_mp);
      741 +        mod_release_mod(modp);
      742 +
 735  743          setcr4(getcr4() | CR4_SMAP);
 736  744          smap_enable();
 737  745  }
 738  746  
 739  747  /*
 740  748   * Our world looks like this at startup time.
 741  749   *
 742  750   * In a 32-bit OS, boot loads the kernel text at 0xfe800000 and kernel data
 743  751   * at 0xfec00000.  On a 64-bit OS, kernel text and data are loaded at
 744  752   * 0xffffffff.fe800000 and 0xffffffff.fec00000 respectively.  Those
↓ open down ↓ 2647 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX