Print this page
11859 need swapgs mitigation
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@fingolfin.org>


   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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 




  26 /
  27 / In-line functions for amd64 kernels.
  28 /
  29 
  30 /
  31 / return current thread pointer
  32 /
  33 / NOTE: the "0x18" should be replaced by the computed value of the
  34 /       offset of "cpu_thread" from the beginning of the struct cpu.
  35 /       Including "assym.h" does not work, however, since that stuff
  36 /       is PSM-specific and is only visible to the 'unix' build anyway.
  37 /       Same with current cpu pointer, where "0xc" should be replaced
  38 /       by the computed value of the offset of "cpu_self".
  39 /       Ugh -- what a disaster.
  40 /
  41         .inline threadp,0
  42         movq    %gs:0x18, %rax
  43         .end
  44 
  45 /


 172 
 173 /*
 174  * inlines for update_sregs().
 175  */
 176         .inline __set_ds, 0
 177         movw    %di, %ds
 178         .end
 179 
 180         .inline __set_es, 0
 181         movw    %di, %es
 182         .end
 183 
 184         .inline __set_fs, 0
 185         movw    %di, %fs
 186         .end
 187 
 188         .inline __set_gs, 0
 189         movw    %di, %gs
 190         .end
 191 
 192         /*
 193          * OPTERON_ERRATUM_88 requires mfence
 194          */
 195         .inline __swapgs, 0
 196         mfence
 197         swapgs
 198         .end
 199 
 200 /*
 201  * prefetch 64 bytes
 202  */
 203 
 204         .inline prefetch_read_many,8
 205         prefetcht0      (%rdi)
 206         prefetcht0      32(%rdi)
 207         .end
 208 
 209         .inline prefetch_read_once,8
 210         prefetchnta     (%rdi)
 211         prefetchnta     32(%rdi)
 212         .end
 213 
 214         .inline prefetch_write_many,8
 215         prefetcht0      (%rdi)
 216         prefetcht0      32(%rdi)
 217         .end
 218 
 219         .inline prefetch_write_once,8


   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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright 2019 Joyent, Inc.
  28  */
  29 
  30 /
  31 / In-line functions for amd64 kernels.
  32 /
  33 
  34 /
  35 / return current thread pointer
  36 /
  37 / NOTE: the "0x18" should be replaced by the computed value of the
  38 /       offset of "cpu_thread" from the beginning of the struct cpu.
  39 /       Including "assym.h" does not work, however, since that stuff
  40 /       is PSM-specific and is only visible to the 'unix' build anyway.
  41 /       Same with current cpu pointer, where "0xc" should be replaced
  42 /       by the computed value of the offset of "cpu_self".
  43 /       Ugh -- what a disaster.
  44 /
  45         .inline threadp,0
  46         movq    %gs:0x18, %rax
  47         .end
  48 
  49 /


 176 
 177 /*
 178  * inlines for update_sregs().
 179  */
 180         .inline __set_ds, 0
 181         movw    %di, %ds
 182         .end
 183 
 184         .inline __set_es, 0
 185         movw    %di, %es
 186         .end
 187 
 188         .inline __set_fs, 0
 189         movw    %di, %fs
 190         .end
 191 
 192         .inline __set_gs, 0
 193         movw    %di, %gs
 194         .end
 195 








 196 /*
 197  * prefetch 64 bytes
 198  */
 199 
 200         .inline prefetch_read_many,8
 201         prefetcht0      (%rdi)
 202         prefetcht0      32(%rdi)
 203         .end
 204 
 205         .inline prefetch_read_once,8
 206         prefetchnta     (%rdi)
 207         prefetchnta     32(%rdi)
 208         .end
 209 
 210         .inline prefetch_write_many,8
 211         prefetcht0      (%rdi)
 212         prefetcht0      32(%rdi)
 213         .end
 214 
 215         .inline prefetch_write_once,8