Print this page
10597 would like a way to set NMI behavior at boot
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>

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 2018 Joyent, Inc.
       26 + * Copyright 2019, 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 ↓ 17 lines elided ↑ open up ↑
  54   54  #include <sys/x86_archext.h>
  55   55  #include <sys/privregs.h>
  56   56  #include <sys/machsystm.h>
  57   57  #include <sys/ontrap.h>
  58   58  #include <sys/bootconf.h>
  59   59  #include <sys/boot_console.h>
  60   60  #include <sys/kdi_machimpl.h>
  61   61  #include <sys/archsystm.h>
  62   62  #include <sys/promif.h>
  63   63  #include <sys/pci_cfgspace.h>
       64 +#include <sys/apic.h>
       65 +#include <sys/apic_common.h>
  64   66  #include <sys/bootvfs.h>
  65   67  #include <sys/tsc.h>
  66   68  #ifdef __xpv
  67   69  #include <sys/hypervisor.h>
  68   70  #else
  69   71  #include <sys/xpv_support.h>
  70   72  #endif
  71   73  
  72   74  /*
  73   75   * some globals for patching the result of cpuid
  74   76   * to solve problems w/ creative cpu vendors
  75   77   */
  76   78  
  77   79  extern uint32_t cpuid_feature_ecx_include;
  78   80  extern uint32_t cpuid_feature_ecx_exclude;
  79   81  extern uint32_t cpuid_feature_edx_include;
  80   82  extern uint32_t cpuid_feature_edx_exclude;
  81   83  
       84 +nmi_action_t nmi_action = NMI_ACTION_UNSET;
       85 +
  82   86  /*
  83   87   * Set console mode
  84   88   */
  85   89  static void
  86   90  set_console_mode(uint8_t val)
  87   91  {
  88   92          struct bop_regs rp = {0};
  89   93  
  90   94          rp.eax.byte.ah = 0x0;
  91   95          rp.eax.byte.al = val;
↓ open down ↓ 4 lines elided ↑ open up ↑
  96  100  
  97  101  
  98  102  /*
  99  103   * Setup routine called right before main(). Interposing this function
 100  104   * before main() allows us to call it in a machine-independent fashion.
 101  105   */
 102  106  void
 103  107  mlsetup(struct regs *rp)
 104  108  {
 105  109          u_longlong_t prop_value;
      110 +        char prop_str[BP_MAX_STRLEN];
 106  111          extern struct classfuncs sys_classfuncs;
 107  112          extern disp_t cpu0_disp;
 108  113          extern char t0stack[];
 109  114          extern int post_fastreboot;
 110  115          extern uint64_t plat_dr_options;
 111  116  
 112  117          ASSERT_STACK_ALIGNED();
 113  118  
 114  119          /*
 115  120           * initialize cpu_self
↓ open down ↓ 26 lines elided ↑ open up ↑
 142  147                  cpuid_feature_edx_include = 0;
 143  148          else
 144  149                  cpuid_feature_edx_include = (uint32_t)prop_value;
 145  150  
 146  151          if (bootprop_getval("cpuid_feature_edx_exclude", &prop_value) != 0)
 147  152                  cpuid_feature_edx_exclude = 0;
 148  153          else
 149  154                  cpuid_feature_edx_exclude = (uint32_t)prop_value;
 150  155  
 151  156  #if !defined(__xpv)
      157 +        if (bootprop_getstr("nmi", prop_str, sizeof (prop_str)) == 0) {
      158 +                if (strcmp(prop_str, "ignore") == 0) {
      159 +                        nmi_action = NMI_ACTION_IGNORE;
      160 +                } else if (strcmp(prop_str, "panic") == 0) {
      161 +                        nmi_action = NMI_ACTION_PANIC;
      162 +                } else if (strcmp(prop_str, "kmdb") == 0) {
      163 +                        nmi_action = NMI_ACTION_KMDB;
      164 +                } else {
      165 +                        prom_printf("unix: ignoring unknown nmi=%s\n",
      166 +                            prop_str);
      167 +                }
      168 +        }
      169 +
 152  170          /*
 153  171           * Check to see if KPTI has been explicitly enabled or disabled.
 154  172           * We have to check this before init_desctbls().
 155  173           */
 156  174          if (bootprop_getval("kpti", &prop_value) == 0) {
 157  175                  kpti_enable = (uint64_t)(prop_value == 1);
 158  176                  prom_printf("unix: forcing kpti to %s due to boot argument\n",
 159  177                      (kpti_enable == 1) ? "ON" : "OFF");
 160  178          } else {
 161  179                  kpti_enable = 1;
↓ open down ↓ 377 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX