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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/i86pc/os/mlsetup.c
          +++ new/usr/src/uts/i86pc/os/mlsetup.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2012 Gary Mills
  23   23   *
  24   24   * Copyright (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
  25   25   * Copyright (c) 2011 by Delphix. All rights reserved.
  26      - * Copyright 2016 Joyent, Inc.
       26 + * Copyright 2018 Joyent, Inc.
  27   27   */
  28   28  /*
  29   29   * Copyright (c) 2010, Intel Corporation.
  30   30   * All rights reserved.
  31   31   */
  32   32  
  33   33  #include <sys/types.h>
  34   34  #include <sys/sysmacros.h>
  35   35  #include <sys/disp.h>
  36   36  #include <sys/promif.h>
↓ open down ↓ 104 lines elided ↑ open up ↑
 141  141          if (bootprop_getval("cpuid_feature_edx_include", &prop_value) != 0)
 142  142                  cpuid_feature_edx_include = 0;
 143  143          else
 144  144                  cpuid_feature_edx_include = (uint32_t)prop_value;
 145  145  
 146  146          if (bootprop_getval("cpuid_feature_edx_exclude", &prop_value) != 0)
 147  147                  cpuid_feature_edx_exclude = 0;
 148  148          else
 149  149                  cpuid_feature_edx_exclude = (uint32_t)prop_value;
 150  150  
      151 +#if !defined(__xpv)
 151  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 +        /*
 152  173           * Initialize idt0, gdt0, ldt0_default, ktss0 and dftss.
 153  174           */
 154  175          init_desctbls();
 155  176  
 156  177          /*
 157  178           * lgrp_init() and possibly cpuid_pass1() need PCI config
 158  179           * space access
 159  180           */
 160  181  #if defined(__xpv)
 161  182          if (DOMAIN_IS_INITDOMAIN(xen_info))
↓ open down ↓ 360 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX