[patch] enable interrupts before calling fasttrap handlers

Mark Johnston markj at freebsd.org
Mon Feb 24 03:08:43 UTC 2014


Hello,

The patch here fixes a problem I've run into while doing some work on
fasttrap:

http://people.freebsd.org/~markj/patches/breakpoint_intr_enable.diff

Specifically, we currently call fasttrap_pid_probe() with interrupts
disabled because FreeBSD handles breakpoints through an interrupt gate
and doesn't enable interrupts before calling trap(). The patch changes
trap() on i386 and amd64 to enable interrupts after hitting a breakpoint
if the trap came from usermode. fasttrap should only handle traps from
user mode anyway, and the user mode handler for breakpoints already
enables interrupts immediately, so the change shouldn't have any effect
for breakpoints unrelated to DTrace.

The problem with leaving interrupts disabled is that some pid provider
probes require DTrace to modify userland memory in fasttrap_pid_probe(),
i.e. by calling proc_rwmem() or copyout(). It turns out that this can
cause nasty deadlocks if another thread attempts a TLB shootdown with the
same pmap as that of the traced process. There are probably other issues
as well, but this is the one that I've run into.

Would anyone be able to review and/or test this diff?

Thanks,
-Mark


More information about the freebsd-dtrace mailing list