Rename the KDB_STOP_NMI kernel option to STOP_NMI and make it apply to all
IPI_STOP IPIs. - Change the i386 and amd64 MD IPI code to send an NMI if STOP_NMI is enabled if an attempt is made to send an IPI_STOP IPI. If the kernel option is enabled, there is also a sysctl to change the behavior at runtime (debug.stop_cpus_with_nmi which defaults to enabled). This includes removing stop_cpus_nmi() and making ipi_nmi_selected() a private function for i386 and amd64. - Fix ipi_all(), ipi_all_but_self(), and ipi_self() on i386 and amd64 to properly handle bitmapped IPIs as well as IPI_STOP IPIs when STOP_NMI is enabled. - Fix ipi_nmi_handler() to execute the restart function on the first CPU that is restarted making use of atomic_readandclear() rather than assuming that the BSP is always included in the set of restarted CPUs. Also, the NMI handler didn't clear the function pointer meaning that subsequent stop and restarts could execute the function again. - Define a new macro HAVE_STOPPEDPCBS on i386 and amd64 to control the use of stoppedpcbs[] and always enable it for i386 and amd64 instead of being dependent on KDB_STOP_NMI. It works fine in both the NMI and non-NMI cases.
This commit is contained in:
parent
301268b8ca
commit
58553b9925
@ -28,7 +28,6 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_cpu.h"
|
#include "opt_cpu.h"
|
||||||
#include "opt_kdb.h"
|
|
||||||
#include "opt_kstack_pages.h"
|
#include "opt_kstack_pages.h"
|
||||||
#include "opt_mp_watchdog.h"
|
#include "opt_mp_watchdog.h"
|
||||||
#include "opt_sched.h"
|
#include "opt_sched.h"
|
||||||
@ -113,10 +112,30 @@ volatile int smp_tlb_wait;
|
|||||||
|
|
||||||
extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
|
extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
|
||||||
|
|
||||||
|
#ifdef STOP_NMI
|
||||||
|
volatile cpumask_t ipi_nmi_pending;
|
||||||
|
|
||||||
|
static void ipi_nmi_selected(u_int32_t cpus);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local data and functions.
|
* Local data and functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef STOP_NMI
|
||||||
|
/*
|
||||||
|
* Provide an alternate method of stopping other CPUs. If another CPU has
|
||||||
|
* disabled interrupts the conventional STOP IPI will be blocked. This
|
||||||
|
* NMI-based stop should get through in that case.
|
||||||
|
*/
|
||||||
|
static int stop_cpus_with_nmi = 1;
|
||||||
|
SYSCTL_INT(_debug, OID_AUTO, stop_cpus_with_nmi, CTLTYPE_INT | CTLFLAG_RW,
|
||||||
|
&stop_cpus_with_nmi, 0, "");
|
||||||
|
TUNABLE_INT("debug.stop_cpus_with_nmi", &stop_cpus_with_nmi);
|
||||||
|
#else
|
||||||
|
#define stop_cpus_with_nmi 0
|
||||||
|
#endif
|
||||||
|
|
||||||
static u_int logical_cpus;
|
static u_int logical_cpus;
|
||||||
|
|
||||||
/* used to hold the AP's until we are ready to release them */
|
/* used to hold the AP's until we are ready to release them */
|
||||||
@ -199,11 +218,6 @@ mp_topology(void)
|
|||||||
smp_topology = &mp_top;
|
smp_topology = &mp_top;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
volatile cpumask_t ipi_nmi_pending;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Calculate usable address in base memory for AP trampoline code.
|
* Calculate usable address in base memory for AP trampoline code.
|
||||||
*/
|
*/
|
||||||
@ -944,6 +958,12 @@ ipi_selected(u_int32_t cpus, u_int ipi)
|
|||||||
ipi = IPI_BITMAP_VECTOR;
|
ipi = IPI_BITMAP_VECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef STOP_NMI
|
||||||
|
if (ipi == IPI_STOP && stop_cpus_with_nmi) {
|
||||||
|
ipi_nmi_selected(cpus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi);
|
CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi);
|
||||||
while ((cpu = ffs(cpus)) != 0) {
|
while ((cpu = ffs(cpus)) != 0) {
|
||||||
cpu--;
|
cpu--;
|
||||||
@ -974,6 +994,10 @@ void
|
|||||||
ipi_all(u_int ipi)
|
ipi_all(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(all_cpus, ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_ALL);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_ALL);
|
||||||
}
|
}
|
||||||
@ -985,6 +1009,10 @@ void
|
|||||||
ipi_all_but_self(u_int ipi)
|
ipi_all_but_self(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(PCPU_GET(other_cpus), ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
|
||||||
}
|
}
|
||||||
@ -996,11 +1024,15 @@ void
|
|||||||
ipi_self(u_int ipi)
|
ipi_self(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(PCPU_GET(cpumask), ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_SELF);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
/*
|
/*
|
||||||
* send NMI IPI to selected CPUs
|
* send NMI IPI to selected CPUs
|
||||||
*/
|
*/
|
||||||
@ -1040,8 +1072,9 @@ ipi_nmi_handler()
|
|||||||
{
|
{
|
||||||
int cpu = PCPU_GET(cpuid);
|
int cpu = PCPU_GET(cpuid);
|
||||||
int cpumask = PCPU_GET(cpumask);
|
int cpumask = PCPU_GET(cpumask);
|
||||||
|
void (*restartfunc)(void);
|
||||||
|
|
||||||
if (!(atomic_load_acq_int(&ipi_nmi_pending) & cpumask))
|
if (!(ipi_nmi_pending & cpumask))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
atomic_clear_int(&ipi_nmi_pending, cpumask);
|
atomic_clear_int(&ipi_nmi_pending, cpumask);
|
||||||
@ -1052,19 +1085,21 @@ ipi_nmi_handler()
|
|||||||
atomic_set_int(&stopped_cpus, cpumask);
|
atomic_set_int(&stopped_cpus, cpumask);
|
||||||
|
|
||||||
/* Wait for restart */
|
/* Wait for restart */
|
||||||
while (!(atomic_load_acq_int(&started_cpus) & cpumask))
|
while (!(started_cpus & cpumask))
|
||||||
ia32_pause();
|
ia32_pause();
|
||||||
|
|
||||||
atomic_clear_int(&started_cpus, cpumask);
|
atomic_clear_int(&started_cpus, cpumask);
|
||||||
atomic_clear_int(&stopped_cpus, cpumask);
|
atomic_clear_int(&stopped_cpus, cpumask);
|
||||||
|
|
||||||
if (cpu == 0 && cpustop_restartfunc != NULL)
|
restartfunc = (void (*)(void))atomic_readandclear_long(
|
||||||
cpustop_restartfunc();
|
(u_long *)&cpustop_restartfunc);
|
||||||
|
if (restartfunc != NULL)
|
||||||
|
restartfunc();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* KDB_STOP_NMI */
|
#endif /* STOP_NMI */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is called once the rest of the system is up and running and we're
|
* This is called once the rest of the system is up and running and we're
|
||||||
|
@ -167,13 +167,13 @@ trap(frame)
|
|||||||
PCPU_LAZY_INC(cnt.v_trap);
|
PCPU_LAZY_INC(cnt.v_trap);
|
||||||
type = frame.tf_trapno;
|
type = frame.tf_trapno;
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
/* Handler for NMI IPIs used for debugging */
|
/* Handler for NMI IPIs used for stopping CPUs. */
|
||||||
if (type == T_NMI) {
|
if (type == T_NMI) {
|
||||||
if (ipi_nmi_handler() == 0)
|
if (ipi_nmi_handler() == 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif /* KDB_STOP_NMI */
|
#endif /* STOP_NMI */
|
||||||
|
|
||||||
#ifdef KDB
|
#ifdef KDB
|
||||||
if (kdb_active) {
|
if (kdb_active) {
|
||||||
|
@ -39,7 +39,7 @@ options MP_WATCHDOG
|
|||||||
#
|
#
|
||||||
# Debugging options.
|
# Debugging options.
|
||||||
#
|
#
|
||||||
options KDB_STOP_NMI # Stop CPUS using NMI instead of IPI
|
options STOP_NMI # Stop CPUS using NMI instead of IPI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,9 +63,8 @@ void smp_masked_invlpg_range(u_int mask, vm_offset_t startva,
|
|||||||
void smp_invltlb(void);
|
void smp_invltlb(void);
|
||||||
void smp_masked_invltlb(u_int mask);
|
void smp_masked_invltlb(u_int mask);
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
int ipi_nmi_handler(void);
|
int ipi_nmi_handler(void);
|
||||||
void ipi_nmi_selected(u_int32_t cpus);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !LOCORE */
|
#endif /* !LOCORE */
|
||||||
|
@ -57,4 +57,4 @@ PSM_DEBUG opt_psm.h
|
|||||||
DEV_ATPIC opt_atpic.h
|
DEV_ATPIC opt_atpic.h
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
KDB_STOP_NMI opt_kdb.h
|
STOP_NMI opt_cpu.h
|
||||||
|
@ -161,5 +161,5 @@ DEV_NPX opt_npx.h
|
|||||||
ASR_COMPAT opt_asr.h
|
ASR_COMPAT opt_asr.h
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
KDB_STOP_NMI opt_kdb.h
|
STOP_NMI opt_cpu.h
|
||||||
NPX_DEBUG opt_npx.h
|
NPX_DEBUG opt_npx.h
|
||||||
|
@ -103,5 +103,5 @@ DEV_MECIA opt_mecia.h
|
|||||||
DEV_NPX opt_npx.h
|
DEV_NPX opt_npx.h
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
KDB_STOP_NMI opt_kdb.h
|
STOP_NMI opt_cpu.h
|
||||||
NPX_DEBUG opt_npx.h
|
NPX_DEBUG opt_npx.h
|
||||||
|
@ -56,7 +56,7 @@ options MP_WATCHDOG
|
|||||||
|
|
||||||
# Debugging options.
|
# Debugging options.
|
||||||
#
|
#
|
||||||
options KDB_STOP_NMI # Stop CPUS using NMI instead of IPI
|
options STOP_NMI # Stop CPUS using NMI instead of IPI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include "opt_apic.h"
|
#include "opt_apic.h"
|
||||||
#include "opt_cpu.h"
|
#include "opt_cpu.h"
|
||||||
#include "opt_kdb.h"
|
|
||||||
#include "opt_kstack_pages.h"
|
#include "opt_kstack_pages.h"
|
||||||
#include "opt_mp_watchdog.h"
|
#include "opt_mp_watchdog.h"
|
||||||
#include "opt_sched.h"
|
#include "opt_sched.h"
|
||||||
@ -177,8 +176,10 @@ vm_offset_t smp_tlb_addr1;
|
|||||||
vm_offset_t smp_tlb_addr2;
|
vm_offset_t smp_tlb_addr2;
|
||||||
volatile int smp_tlb_wait;
|
volatile int smp_tlb_wait;
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
volatile cpumask_t ipi_nmi_pending;
|
volatile cpumask_t ipi_nmi_pending;
|
||||||
|
|
||||||
|
static void ipi_nmi_selected(u_int32_t cpus);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef COUNT_IPIS
|
#ifdef COUNT_IPIS
|
||||||
@ -198,6 +199,20 @@ u_long *ipi_lazypmap_counts[MAXCPU];
|
|||||||
* Local data and functions.
|
* Local data and functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef STOP_NMI
|
||||||
|
/*
|
||||||
|
* Provide an alternate method of stopping other CPUs. If another CPU has
|
||||||
|
* disabled interrupts the conventional STOP IPI will be blocked. This
|
||||||
|
* NMI-based stop should get through in that case.
|
||||||
|
*/
|
||||||
|
static int stop_cpus_with_nmi = 1;
|
||||||
|
SYSCTL_INT(_debug, OID_AUTO, stop_cpus_with_nmi, CTLTYPE_INT | CTLFLAG_RW,
|
||||||
|
&stop_cpus_with_nmi, 0, "");
|
||||||
|
TUNABLE_INT("debug.stop_cpus_with_nmi", &stop_cpus_with_nmi);
|
||||||
|
#else
|
||||||
|
#define stop_cpus_with_nmi 0
|
||||||
|
#endif
|
||||||
|
|
||||||
static u_int logical_cpus;
|
static u_int logical_cpus;
|
||||||
|
|
||||||
/* used to hold the AP's until we are ready to release them */
|
/* used to hold the AP's until we are ready to release them */
|
||||||
@ -1182,6 +1197,12 @@ ipi_selected(u_int32_t cpus, u_int ipi)
|
|||||||
ipi = IPI_BITMAP_VECTOR;
|
ipi = IPI_BITMAP_VECTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef STOP_NMI
|
||||||
|
if (ipi == IPI_STOP && stop_cpus_with_nmi) {
|
||||||
|
ipi_nmi_selected(cpus);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi);
|
CTR3(KTR_SMP, "%s: cpus: %x ipi: %x", __func__, cpus, ipi);
|
||||||
while ((cpu = ffs(cpus)) != 0) {
|
while ((cpu = ffs(cpus)) != 0) {
|
||||||
cpu--;
|
cpu--;
|
||||||
@ -1212,6 +1233,10 @@ void
|
|||||||
ipi_all(u_int ipi)
|
ipi_all(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(all_cpus, ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_ALL);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_ALL);
|
||||||
}
|
}
|
||||||
@ -1223,6 +1248,10 @@ void
|
|||||||
ipi_all_but_self(u_int ipi)
|
ipi_all_but_self(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(PCPU_GET(other_cpus), ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_OTHERS);
|
||||||
}
|
}
|
||||||
@ -1234,11 +1263,15 @@ void
|
|||||||
ipi_self(u_int ipi)
|
ipi_self(u_int ipi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (IPI_IS_BITMAPED(ipi) || (ipi == IPI_STOP && stop_cpus_with_nmi)) {
|
||||||
|
ipi_selected(PCPU_GET(cpumask), ipi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
|
||||||
lapic_ipi_vectored(ipi, APIC_IPI_DEST_SELF);
|
lapic_ipi_vectored(ipi, APIC_IPI_DEST_SELF);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
/*
|
/*
|
||||||
* send NMI IPI to selected CPUs
|
* send NMI IPI to selected CPUs
|
||||||
*/
|
*/
|
||||||
@ -1273,14 +1306,14 @@ ipi_nmi_selected(u_int32_t cpus)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ipi_nmi_handler()
|
ipi_nmi_handler()
|
||||||
{
|
{
|
||||||
int cpu = PCPU_GET(cpuid);
|
int cpu = PCPU_GET(cpuid);
|
||||||
int cpumask = PCPU_GET(cpumask);
|
int cpumask = PCPU_GET(cpumask);
|
||||||
|
void (*restartfunc)(void);
|
||||||
|
|
||||||
if (!(atomic_load_acq_int(&ipi_nmi_pending) & cpumask))
|
if (!(ipi_nmi_pending & cpumask))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
atomic_clear_int(&ipi_nmi_pending, cpumask);
|
atomic_clear_int(&ipi_nmi_pending, cpumask);
|
||||||
@ -1291,19 +1324,21 @@ ipi_nmi_handler()
|
|||||||
atomic_set_int(&stopped_cpus, cpumask);
|
atomic_set_int(&stopped_cpus, cpumask);
|
||||||
|
|
||||||
/* Wait for restart */
|
/* Wait for restart */
|
||||||
while (!(atomic_load_acq_int(&started_cpus) & cpumask))
|
while (!(started_cpus & cpumask))
|
||||||
ia32_pause();
|
ia32_pause();
|
||||||
|
|
||||||
atomic_clear_int(&started_cpus, cpumask);
|
atomic_clear_int(&started_cpus, cpumask);
|
||||||
atomic_clear_int(&stopped_cpus, cpumask);
|
atomic_clear_int(&stopped_cpus, cpumask);
|
||||||
|
|
||||||
if (cpu == 0 && cpustop_restartfunc != NULL)
|
restartfunc = (void (*)(void))atomic_readandclear_int(
|
||||||
cpustop_restartfunc();
|
(u_int *)&cpustop_restartfunc);
|
||||||
|
if (restartfunc != NULL)
|
||||||
|
restartfunc();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* KDB_STOP_NMI */
|
#endif /* STOP_NMI */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is called once the rest of the system is up and running and we're
|
* This is called once the rest of the system is up and running and we're
|
||||||
|
@ -185,13 +185,13 @@ trap(frame)
|
|||||||
PCPU_LAZY_INC(cnt.v_trap);
|
PCPU_LAZY_INC(cnt.v_trap);
|
||||||
type = frame.tf_trapno;
|
type = frame.tf_trapno;
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
/* Handler for NMI IPIs used for debugging */
|
/* Handler for NMI IPIs used for stopping CPUs. */
|
||||||
if (type == T_NMI) {
|
if (type == T_NMI) {
|
||||||
if (ipi_nmi_handler() == 0)
|
if (ipi_nmi_handler() == 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
#endif /* KDB_STOP_NMI */
|
#endif /* STOP_NMI */
|
||||||
|
|
||||||
#ifdef KDB
|
#ifdef KDB
|
||||||
if (kdb_active) {
|
if (kdb_active) {
|
||||||
|
@ -79,9 +79,8 @@ void smp_masked_invlpg_range(u_int mask, vm_offset_t startva,
|
|||||||
void smp_invltlb(void);
|
void smp_invltlb(void);
|
||||||
void smp_masked_invltlb(u_int mask);
|
void smp_masked_invltlb(u_int mask);
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef STOP_NMI
|
||||||
int ipi_nmi_handler(void);
|
int ipi_nmi_handler(void);
|
||||||
void ipi_nmi_selected(u_int32_t cpus);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !LOCORE */
|
#endif /* !LOCORE */
|
||||||
|
@ -42,16 +42,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/kdb.h>
|
#include <machine/kdb.h>
|
||||||
#include <machine/pcb.h>
|
#include <machine/pcb.h>
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
#ifdef SMP
|
||||||
|
#if defined (__i386__) || defined(__amd64__)
|
||||||
|
#define HAVE_STOPPEDPCBS
|
||||||
#include <machine/smp.h>
|
#include <machine/smp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* KDB_STOP_NMI requires SMP to pick up the right dependencies
|
|
||||||
* (And isn't useful on UP anyway)
|
|
||||||
*/
|
|
||||||
#if defined(KDB_STOP_NMI) && !defined(SMP)
|
|
||||||
#error "options KDB_STOP_NMI" requires "options SMP"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int kdb_active = 0;
|
int kdb_active = 0;
|
||||||
@ -91,19 +86,6 @@ static int kdb_stop_cpus = 1;
|
|||||||
SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW,
|
SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW,
|
||||||
&kdb_stop_cpus, 0, "");
|
&kdb_stop_cpus, 0, "");
|
||||||
TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus);
|
TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus);
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
/*
|
|
||||||
* Provide an alternate method of stopping other CPUs. If another CPU has
|
|
||||||
* disabled interrupts the conventional STOP IPI will be blocked. This
|
|
||||||
* NMI-based stop should get through in that case.
|
|
||||||
*/
|
|
||||||
static int kdb_stop_cpus_with_nmi = 1;
|
|
||||||
SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus_with_nmi, CTLTYPE_INT | CTLFLAG_RW,
|
|
||||||
&kdb_stop_cpus_with_nmi, 0, "");
|
|
||||||
TUNABLE_INT("debug.kdb.stop_cpus_with_nmi", &kdb_stop_cpus_with_nmi);
|
|
||||||
#endif /* KDB_STOP_NMI */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -335,26 +317,24 @@ kdb_reenter(void)
|
|||||||
|
|
||||||
struct pcb *
|
struct pcb *
|
||||||
kdb_thr_ctx(struct thread *thr)
|
kdb_thr_ctx(struct thread *thr)
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_STOPPEDPCBS
|
||||||
struct pcpu *pc;
|
struct pcpu *pc;
|
||||||
u_int cpuid;
|
u_int cpuid;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (thr == curthread)
|
if (thr == curthread)
|
||||||
return (&kdb_pcb);
|
return (&kdb_pcb);
|
||||||
|
|
||||||
|
#ifdef HAVE_STOPPEDPCBS
|
||||||
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
|
SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
|
||||||
cpuid = pc->pc_cpuid;
|
cpuid = pc->pc_cpuid;
|
||||||
if (pc->pc_curthread == thr && (atomic_load_acq_int(&stopped_cpus) & (1 << cpuid)))
|
if (pc->pc_curthread == thr && (stopped_cpus & (1 << cpuid)))
|
||||||
return (&stoppcbs[cpuid]);
|
return (&stoppcbs[cpuid]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return (thr->td_pcb);
|
return (thr->td_pcb);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
{
|
|
||||||
return ((thr == curthread) ? &kdb_pcb : thr->td_pcb);
|
|
||||||
}
|
|
||||||
#endif /* KDB_STOP_NMI */
|
|
||||||
|
|
||||||
struct thread *
|
struct thread *
|
||||||
kdb_thr_first(void)
|
kdb_thr_first(void)
|
||||||
@ -451,14 +431,7 @@ kdb_trap(int type, int code, struct trapframe *tf)
|
|||||||
|
|
||||||
#ifdef SMP
|
#ifdef SMP
|
||||||
if ((did_stop_cpus = kdb_stop_cpus) != 0)
|
if ((did_stop_cpus = kdb_stop_cpus) != 0)
|
||||||
{
|
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
if(kdb_stop_cpus_with_nmi)
|
|
||||||
stop_cpus_nmi(PCPU_GET(other_cpus));
|
|
||||||
else
|
|
||||||
#endif /* KDB_STOP_NMI */
|
|
||||||
stop_cpus(PCPU_GET(other_cpus));
|
stop_cpus(PCPU_GET(other_cpus));
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kdb_frame = tf;
|
kdb_frame = tf;
|
||||||
|
@ -35,8 +35,6 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include "opt_kdb.h"
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
@ -256,36 +254,6 @@ stop_cpus(cpumask_t map)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
int
|
|
||||||
stop_cpus_nmi(cpumask_t map)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!smp_started)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
CTR1(KTR_SMP, "stop_cpus(%x)", map);
|
|
||||||
|
|
||||||
/* send the stop IPI to all CPUs in map */
|
|
||||||
ipi_nmi_selected(map);
|
|
||||||
|
|
||||||
i = 0;
|
|
||||||
while ((atomic_load_acq_int(&stopped_cpus) & map) != map) {
|
|
||||||
/* spin */
|
|
||||||
i++;
|
|
||||||
#ifdef DIAGNOSTIC
|
|
||||||
if (i == 100000) {
|
|
||||||
printf("timeout stopping cpus\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif /* KDB_STOP_NMI */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called by a CPU to restart stopped CPUs.
|
* Called by a CPU to restart stopped CPUs.
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,7 @@ options MP_WATCHDOG
|
|||||||
|
|
||||||
# Debugging options.
|
# Debugging options.
|
||||||
#
|
#
|
||||||
options KDB_STOP_NMI # Stop CPUS using NMI instead of IPI
|
options STOP_NMI # Stop CPUS using NMI instead of IPI
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,9 +102,6 @@ int stop_cpus(cpumask_t);
|
|||||||
void smp_rendezvous_action(void);
|
void smp_rendezvous_action(void);
|
||||||
extern struct mtx smp_ipi_mtx;
|
extern struct mtx smp_ipi_mtx;
|
||||||
|
|
||||||
#ifdef KDB_STOP_NMI
|
|
||||||
int stop_cpus_nmi(cpumask_t);
|
|
||||||
#endif
|
|
||||||
#endif /* SMP */
|
#endif /* SMP */
|
||||||
void smp_rendezvous(void (*)(void *),
|
void smp_rendezvous(void (*)(void *),
|
||||||
void (*)(void *),
|
void (*)(void *),
|
||||||
|
Loading…
Reference in New Issue
Block a user