Print this page
9210 remove KMDB branch debugging support
9211 ::crregs could do with cr2/cr3 support
9209 ::ttrace should be able to filter by thread
Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>

@@ -19,14 +19,14 @@
  * CDDL HEADER END
  */
 /*
  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright 2018 Joyent, Inc.
  */
 
-#pragma ident   "%Z%%M% %I%     %E% SMI"
-
 /*
  * The debugger/"PROM" interface layer
  *
  * It makes more sense on SPARC. In reality, these interfaces deal with three
  * things: setting break/watchpoints, stepping, and interfacing with the KDI to

@@ -601,42 +601,10 @@
                     (oldfl & KREG_EFLAGS_IF_MASK)));
                 return (0);
         }
 }
 
-/*
- * The target has already configured the chip for branch step, leaving us to
- * actually make the machine go.  Due to a number of issues involving
- * the potential alteration of system state via instructions like sti, cli,
- * pushfl, and popfl, we're going to treat this like a normal system resume.
- * All CPUs will be released, on the kernel's IDT.  Our primary concern is
- * the alteration/storage of our TF'd EFLAGS via pushfl and popfl.  There's no
- * real workaround - we don't have opcode breakpoints - so the best we can do is
- * to ensure that the world won't end if someone does bad things to EFLAGS.
- *
- * Two things can happen:
- *  1. EFLAGS.TF may be cleared, either maliciously or via a popfl from saved
- *     state.  The CPU will continue execution beyond the branch, and will not
- *     reenter the debugger unless brought/sent in by other means.
- *  2. Someone may pushlf the TF'd EFLAGS, and may stash a copy of it somewhere.
- *     When the saved version is popfl'd back into place, the debugger will be
- *     re-entered on a single-step trap.
- */
-static void
-kaif_step_branch(void)
-{
-        kreg_t fl;
-
-        (void) kmdb_dpi_get_register(FLAGS_REG_NAME, &fl);
-        (void) kmdb_dpi_set_register(FLAGS_REG_NAME,
-            (fl | (1 << KREG_EFLAGS_TF_SHIFT)));
-
-        kmdb_dpi_resume_master();
-
-        (void) kmdb_dpi_set_register(FLAGS_REG_NAME, fl);
-}
-
 /*ARGSUSED*/
 static uintptr_t
 kaif_call(uintptr_t funcva, uint_t argc, const uintptr_t argv[])
 {
         return (kaif_invoke(funcva, argc, argv));

@@ -722,51 +690,10 @@
         ASSERT(kaif_modchg_cb != NULL);
 
         kaif_modchg_cb = NULL;
 }
 
-static void
-kaif_msr_add(const kdi_msr_t *msrs)
-{
-        kdi_msr_t *save;
-        size_t nr_msrs = 0;
-        size_t i;
-
-        while (msrs[nr_msrs].msr_num != 0)
-                nr_msrs++;
-        /* we want to copy the terminating kdi_msr_t too */
-        nr_msrs++;
-
-        save = mdb_zalloc(sizeof (kdi_msr_t) * nr_msrs * kaif_ncpusave,
-            UM_SLEEP);
-
-        for (i = 0; i < kaif_ncpusave; i++)
-                bcopy(msrs, &save[nr_msrs * i], sizeof (kdi_msr_t) * nr_msrs);
-
-        kmdb_kdi_set_debug_msrs(save);
-}
-
-static uint64_t
-kaif_msr_get(int cpuid, uint_t num)
-{
-        kdi_cpusave_t *save;
-        kdi_msr_t *msr;
-        int i;
-
-        if ((save = kaif_cpuid2save(cpuid)) == NULL)
-                return (-1); /* errno is set for us */
-
-        msr = save->krs_msr;
-
-        for (i = 0; msr[i].msr_num != 0; i++) {
-                if (msr[i].msr_num == num && (msr[i].msr_type & KDI_MSR_READ))
-                        return (msr[i].kdi_msr_val);
-        }
-
-        return (0);
-}
-
 void
 kaif_trap_set_debugger(void)
 {
         kmdb_kdi_idt_switch(NULL);
 }

@@ -882,11 +809,8 @@
         kaif_wapt_release,
         kaif_wapt_arm,
         kaif_wapt_disarm,
         kaif_wapt_match,
         kaif_step,
-        kaif_step_branch,
         kaif_call,
         kaif_dump_crumbs,
-        kaif_msr_add,
-        kaif_msr_get,
 };