Print this page
10908 Simplify SMAP relocations with krtld


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2009, Intel Corporation
  28  * All rights reserved.
  29  */
  30 
  31 /*       Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.        */
  32 /*       Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T              */
  33 /*         All Rights Reserved                                          */
  34 
  35 /*       Copyright (c) 1987, 1988 Microsoft Corporation                 */
  36 /*         All Rights Reserved                                          */
  37 
  38 /*
  39  * Copyright 2016 Joyent, Inc.
  40  */
  41 
  42 #include <sys/errno.h>
  43 #include <sys/asm_linkage.h>
  44 
  45 #if defined(__lint)
  46 #include <sys/types.h>
  47 #include <sys/systm.h>
  48 #else   /* __lint */
  49 #include "assym.h"
  50 #endif  /* __lint */
  51 
  52 #define KCOPY_MIN_SIZE  128     /* Must be >= 16 bytes */
  53 #define XCOPY_MIN_SIZE  128     /* Must be >= 16 bytes */
  54 /*
  55  * Non-temopral access (NTA) alignment requirement
  56  */
  57 #define NTA_ALIGN_SIZE  4       /* Must be at least 4-byte aligned */
  58 #define NTA_ALIGN_MASK  _CONST(NTA_ALIGN_SIZE-1)
  59 #define COUNT_ALIGN_SIZE        16      /* Must be at least 16-byte aligned */


3120         .string "copyin: kaddr argument below kernelbase"
3121 .xcopyin_panic_msg:
3122         .string "xcopyin: kaddr argument below kernelbase"
3123 .copyout_panic_msg:
3124         .string "copyout: kaddr argument below kernelbase"
3125 .xcopyout_panic_msg:
3126         .string "xcopyout: kaddr argument below kernelbase"
3127 .copystr_panic_msg:
3128         .string "copystr: arguments in user space"
3129 .copyinstr_panic_msg:
3130         .string "copyinstr: kaddr argument not in kernel address space"
3131 .copyoutstr_panic_msg:
3132         .string "copyoutstr: kaddr argument not in kernel address space"
3133 .cpyin_ne_pmsg:
3134         .string "copyin_noerr: argument not in kernel address space"
3135 .cpyout_ne_pmsg:
3136         .string "copyout_noerr: argument not in kernel address space"
3137 #endif
3138 
3139 #endif  /* __lint */
3140 
3141 /*
3142  * These functions are used for SMAP, supervisor mode access protection. They
3143  * are hotpatched to become real instructions when the system starts up which is
3144  * done in mlsetup() as a part of enabling the other CR4 related features.
3145  *
3146  * Generally speaking, smap_disable() is a stac instruction and smap_enable is a
3147  * clac instruction. It's safe to call these any number of times, and in fact,
3148  * out of paranoia, the kernel will likely call it at several points.
3149  */
3150 
3151 #if defined(__lint)
3152 
3153 void
3154 smap_enable(void)
3155 {}
3156 
3157 void
3158 smap_disable(void)
3159 {}
3160 
3161 #else
3162 
3163 #if defined (__amd64) || defined(__i386)
3164         ENTRY(smap_disable)
3165         nop
3166         nop
3167         nop
3168         ret
3169         SET_SIZE(smap_disable)
3170 
3171         ENTRY(smap_enable)
3172         nop
3173         nop
3174         nop
3175         ret
3176         SET_SIZE(smap_enable)
3177 
3178 #endif /* __amd64 || __i386 */
3179 
3180 #endif /* __lint */
3181 
3182 #ifndef __lint
3183 
3184 .data
3185 .align  4
3186 .globl  _smap_enable_patch_count
3187 .type   _smap_enable_patch_count,@object
3188 .size   _smap_enable_patch_count, 4
3189 _smap_enable_patch_count:
3190         .long   SMAP_ENABLE_COUNT
3191 
3192 .globl  _smap_disable_patch_count
3193 .type   _smap_disable_patch_count,@object
3194 .size   _smap_disable_patch_count, 4
3195 _smap_disable_patch_count:
3196         .long SMAP_DISABLE_COUNT
3197 
3198 #endif /* __lint */


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2009, Intel Corporation
  28  * All rights reserved.
  29  */
  30 
  31 /*       Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.        */
  32 /*       Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T              */
  33 /*         All Rights Reserved                                          */
  34 
  35 /*       Copyright (c) 1987, 1988 Microsoft Corporation                 */
  36 /*         All Rights Reserved                                          */
  37 
  38 /*
  39  * Copyright (c) 2017 Joyent, Inc.
  40  */
  41 
  42 #include <sys/errno.h>
  43 #include <sys/asm_linkage.h>
  44 
  45 #if defined(__lint)
  46 #include <sys/types.h>
  47 #include <sys/systm.h>
  48 #else   /* __lint */
  49 #include "assym.h"
  50 #endif  /* __lint */
  51 
  52 #define KCOPY_MIN_SIZE  128     /* Must be >= 16 bytes */
  53 #define XCOPY_MIN_SIZE  128     /* Must be >= 16 bytes */
  54 /*
  55  * Non-temopral access (NTA) alignment requirement
  56  */
  57 #define NTA_ALIGN_SIZE  4       /* Must be at least 4-byte aligned */
  58 #define NTA_ALIGN_MASK  _CONST(NTA_ALIGN_SIZE-1)
  59 #define COUNT_ALIGN_SIZE        16      /* Must be at least 16-byte aligned */


3120         .string "copyin: kaddr argument below kernelbase"
3121 .xcopyin_panic_msg:
3122         .string "xcopyin: kaddr argument below kernelbase"
3123 .copyout_panic_msg:
3124         .string "copyout: kaddr argument below kernelbase"
3125 .xcopyout_panic_msg:
3126         .string "xcopyout: kaddr argument below kernelbase"
3127 .copystr_panic_msg:
3128         .string "copystr: arguments in user space"
3129 .copyinstr_panic_msg:
3130         .string "copyinstr: kaddr argument not in kernel address space"
3131 .copyoutstr_panic_msg:
3132         .string "copyoutstr: kaddr argument not in kernel address space"
3133 .cpyin_ne_pmsg:
3134         .string "copyin_noerr: argument not in kernel address space"
3135 .cpyout_ne_pmsg:
3136         .string "copyout_noerr: argument not in kernel address space"
3137 #endif
3138 
3139 #endif  /* __lint */









































3140 
3141 #ifndef __lint
3142 
3143 .data
3144 .align  4
3145 .globl  _smap_enable_patch_count
3146 .type   _smap_enable_patch_count,@object
3147 .size   _smap_enable_patch_count, 4
3148 _smap_enable_patch_count:
3149         .long   SMAP_ENABLE_COUNT
3150 
3151 .globl  _smap_disable_patch_count
3152 .type   _smap_disable_patch_count,@object
3153 .size   _smap_disable_patch_count, 4
3154 _smap_disable_patch_count:
3155         .long SMAP_DISABLE_COUNT
3156 
3157 #endif /* __lint */