Print this page
8956 Implement KPTI
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>


   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 (c) 2012 Gary Mills
  23  *
  24  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2011 by Delphix. All rights reserved.
  26  * Copyright 2016 Joyent, Inc.
  27  */
  28 /*
  29  * Copyright (c) 2010, Intel Corporation.
  30  * All rights reserved.
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/disp.h>
  36 #include <sys/promif.h>
  37 #include <sys/clock.h>
  38 #include <sys/cpuvar.h>
  39 #include <sys/stack.h>
  40 #include <vm/as.h>
  41 #include <vm/hat.h>
  42 #include <sys/reboot.h>
  43 #include <sys/avintr.h>
  44 #include <sys/vtrace.h>
  45 #include <sys/proc.h>
  46 #include <sys/thread.h>


 131         if (bootprop_getval("cpuid_feature_ecx_include", &prop_value) != 0)
 132                 cpuid_feature_ecx_include = 0;
 133         else
 134                 cpuid_feature_ecx_include = (uint32_t)prop_value;
 135 
 136         if (bootprop_getval("cpuid_feature_ecx_exclude", &prop_value) != 0)
 137                 cpuid_feature_ecx_exclude = 0;
 138         else
 139                 cpuid_feature_ecx_exclude = (uint32_t)prop_value;
 140 
 141         if (bootprop_getval("cpuid_feature_edx_include", &prop_value) != 0)
 142                 cpuid_feature_edx_include = 0;
 143         else
 144                 cpuid_feature_edx_include = (uint32_t)prop_value;
 145 
 146         if (bootprop_getval("cpuid_feature_edx_exclude", &prop_value) != 0)
 147                 cpuid_feature_edx_exclude = 0;
 148         else
 149                 cpuid_feature_edx_exclude = (uint32_t)prop_value;
 150 

 151         /*




















 152          * Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
 153          */
 154         init_desctbls();
 155 
 156         /*
 157          * lgrp_init() and possibly cpuid_pass1() need PCI config
 158          * space access
 159          */
 160 #if defined(__xpv)
 161         if (DOMAIN_IS_INITDOMAIN(xen_info))
 162                 pci_cfgspace_init();
 163 #else
 164         pci_cfgspace_init();
 165         /*
 166          * Initialize the platform type from CPU 0 to ensure that
 167          * determine_platform() is only ever called once.
 168          */
 169         determine_platform();
 170 #endif
 171 




   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 (c) 2012 Gary Mills
  23  *
  24  * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25  * Copyright (c) 2011 by Delphix. All rights reserved.
  26  * Copyright 2018 Joyent, Inc.
  27  */
  28 /*
  29  * Copyright (c) 2010, Intel Corporation.
  30  * All rights reserved.
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/disp.h>
  36 #include <sys/promif.h>
  37 #include <sys/clock.h>
  38 #include <sys/cpuvar.h>
  39 #include <sys/stack.h>
  40 #include <vm/as.h>
  41 #include <vm/hat.h>
  42 #include <sys/reboot.h>
  43 #include <sys/avintr.h>
  44 #include <sys/vtrace.h>
  45 #include <sys/proc.h>
  46 #include <sys/thread.h>


 131         if (bootprop_getval("cpuid_feature_ecx_include", &prop_value) != 0)
 132                 cpuid_feature_ecx_include = 0;
 133         else
 134                 cpuid_feature_ecx_include = (uint32_t)prop_value;
 135 
 136         if (bootprop_getval("cpuid_feature_ecx_exclude", &prop_value) != 0)
 137                 cpuid_feature_ecx_exclude = 0;
 138         else
 139                 cpuid_feature_ecx_exclude = (uint32_t)prop_value;
 140 
 141         if (bootprop_getval("cpuid_feature_edx_include", &prop_value) != 0)
 142                 cpuid_feature_edx_include = 0;
 143         else
 144                 cpuid_feature_edx_include = (uint32_t)prop_value;
 145 
 146         if (bootprop_getval("cpuid_feature_edx_exclude", &prop_value) != 0)
 147                 cpuid_feature_edx_exclude = 0;
 148         else
 149                 cpuid_feature_edx_exclude = (uint32_t)prop_value;
 150 
 151 #if !defined(__xpv)
 152         /*
 153          * Check to see if KPTI has been explicitly enabled or disabled.
 154          * We have to check this before init_desctbls().
 155          */
 156         if (bootprop_getval("kpti", &prop_value) == 0) {
 157                 kpti_enable = (uint64_t)(prop_value == 1);
 158                 prom_printf("unix: forcing kpti to %s due to boot argument\n",
 159                     (kpti_enable == 1) ? "ON" : "OFF");
 160         } else {
 161                 kpti_enable = 1;
 162         }
 163 
 164         if (bootprop_getval("pcid", &prop_value) == 0 && prop_value == 0) {
 165                 prom_printf("unix: forcing pcid to OFF due to boot argument\n");
 166                 x86_use_pcid = 0;
 167         } else if (kpti_enable != 1) {
 168                 x86_use_pcid = 0;
 169         }
 170 #endif
 171 
 172         /*
 173          * Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
 174          */
 175         init_desctbls();
 176 
 177         /*
 178          * lgrp_init() and possibly cpuid_pass1() need PCI config
 179          * space access
 180          */
 181 #if defined(__xpv)
 182         if (DOMAIN_IS_INITDOMAIN(xen_info))
 183                 pci_cfgspace_init();
 184 #else
 185         pci_cfgspace_init();
 186         /*
 187          * Initialize the platform type from CPU 0 to ensure that
 188          * determine_platform() is only ever called once.
 189          */
 190         determine_platform();
 191 #endif
 192