Print this page
9736 kmdb tortures via single-step miscellaneous trap
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/kmdb/kaif_start.c
          +++ new/usr/src/cmd/mdb/common/kmdb/kaif_start.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  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 2007 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + * Copyright 2018 Joyent, Inc.
  24   25   */
  25   26  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   27  /*
  29   28   * The main CPU-control loops, used to control masters and slaves.
  30   29   */
  31   30  
  32   31  #include <sys/types.h>
  33   32  
  34   33  #include <kmdb/kaif.h>
  35   34  #include <kmdb/kaif_start.h>
  36   35  #include <kmdb/kmdb_asmutil.h>
  37   36  #include <kmdb/kmdb_dpi_impl.h>
↓ open down ↓ 203 lines elided ↑ open up ↑
 241  240                          break;
 242  241  #endif
 243  242  
 244  243                  } else if (slavecmd == KAIF_SLAVE_CMD_RESUME) {
 245  244                          rv = KAIF_CPU_CMD_RESUME;
 246  245                          break;
 247  246  #if defined(__sparc)
 248  247                  } else if (slavecmd == KAIF_SLAVE_CMD_ACK) {
 249  248                          cpusave->krs_cpu_acked = 1;
 250  249                  } else if (cpusave->krs_cpu_acked &&
 251      -                        slavecmd == KAIF_SLAVE_CMD_SPIN) {
      250 +                    slavecmd == KAIF_SLAVE_CMD_SPIN) {
 252  251                          cpusave->krs_cpu_acked = 0;
 253  252  #endif
 254  253                  }
 255  254  
 256  255                  kmdb_kdi_slave_wait();
 257  256          }
 258  257  
 259  258  #if defined(__sparc)
 260  259          interrupts_off();
 261  260  #endif
↓ open down ↓ 23 lines elided ↑ open up ↑
 285  284  
 286  285          kaif_lock_exit(&kaif_master_lock);
 287  286  }
 288  287  
 289  288  int
 290  289  kaif_main_loop(kaif_cpusave_t *cpusave)
 291  290  {
 292  291          int cmd;
 293  292  
 294  293          if (kaif_master_cpuid == KAIF_MASTER_CPUID_UNSET) {
      294 +
      295 +                /*
      296 +                 * Special case: Unload requested before first debugger entry.
      297 +                 * Don't stop the world, as there's nothing to clean up that
      298 +                 * can't be handled by the running kernel.
      299 +                 */
 295  300                  if (!kmdb_dpi_resume_requested &&
 296  301                      kmdb_kdi_get_unload_request()) {
 297      -                        /*
 298      -                         * Special case: Unload requested before first debugger
 299      -                         * entry.  Don't stop the world, as there's nothing to
 300      -                         * clean up that can't be handled by the running kernel.
 301      -                         */
 302  302                          cpusave->krs_cpu_state = KAIF_CPU_STATE_NONE;
 303  303                          return (KAIF_CPU_CMD_RESUME);
      304 +                }
      305 +
      306 +                /*
      307 +                 * We're a slave with no master, so just resume.  This can
      308 +                 * happen if, prior to this, two CPUs both raced through
      309 +                 * kdi_cmnint() - for example, a breakpoint on a frequently
      310 +                 * called function.  The loser will be redirected to the slave
      311 +                 * loop; note that the event itself is lost at this point.
      312 +                 *
      313 +                 * The winner will then cross-call that slave, but it won't
      314 +                 * actually be received until the slave returns to the kernel
      315 +                 * and enables interrupts.  We'll then come back in via
      316 +                 * kdi_slave_entry() and hit this path.
      317 +                 */
      318 +                if (cpusave->krs_cpu_state == KAIF_CPU_STATE_SLAVE) {
      319 +                        cpusave->krs_cpu_state = KAIF_CPU_STATE_NONE;
      320 +                        return (KAIF_CPU_CMD_RESUME);
 304  321                  }
 305  322  
 306  323                  kaif_select_master(cpusave);
 307  324  
 308  325  #ifdef __sparc
 309  326                  if (kaif_master_cpuid == cpusave->krs_cpu_id) {
 310  327                          /*
 311  328                           * Everyone has arrived, so we can disarm the post-PROM
 312  329                           * entry point.
 313  330                           */
↓ open down ↓ 150 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX