diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index f7d0afd..baad354 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -243,7 +243,7 @@ trap(struct trapframe *frame) /* * A trap can occur while DTrace executes a probe. Before * executing the probe, DTrace blocks re-scheduling and sets - * a flag in it's per-cpu flags to indicate that it doesn't + * a flag in its per-cpu flags to indicate that it doesn't * want to fault. On returning from the probe, the no-fault * flag is cleared and finally re-scheduling is enabled. * @@ -252,9 +252,18 @@ trap(struct trapframe *frame) * handled the trap and modified the trap frame so that this * function can return normally. */ - if (type == T_DTRACE_RET || type == T_BPTFLT) { + if ((type == T_DTRACE_RET || type == T_BPTFLT) && + ISPL(frame->tf_cs) == SEL_UPL) { struct reg regs; + /* + * Enable interrupts before calling any fasttrap handlers, since + * they may need to write to a userland address. The handler for + * usermode breakpoints enables interrupts as well, so there's + * no harm in doing that here even if we don't match an enabled + * probe. + */ + enable_intr(); fill_frame_regs(frame, ®s); if (type == T_BPTFLT && dtrace_pid_probe_ptr != NULL && diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index 884e0f0..c91a2f9 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -262,7 +262,7 @@ trap(struct trapframe *frame) /* * A trap can occur while DTrace executes a probe. Before * executing the probe, DTrace blocks re-scheduling and sets - * a flag in it's per-cpu flags to indicate that it doesn't + * a flag in its per-cpu flags to indicate that it doesn't * want to fault. On returning from the probe, the no-fault * flag is cleared and finally re-scheduling is enabled. * @@ -271,9 +271,18 @@ trap(struct trapframe *frame) * handled the trap and modified the trap frame so that this * function can return normally. */ - if (type == T_DTRACE_RET || type == T_BPTFLT) { + if ((type == T_DTRACE_RET || type == T_BPTFLT) && + ISPL(frame->tf_cs) == SEL_UPL) { struct reg regs; + /* + * Enable interrupts before calling any fasttrap handlers, since + * they may need to write to a userland address. The handler for + * usermode breakpoints enables interrupts as well, so there's + * no harm in doing that here even if we don't match an enabled + * probe. + */ + enable_intr(); fill_frame_regs(frame, ®s); if (type == T_BPTFLT && dtrace_pid_probe_ptr != NULL &&