Date: Fri, 10 Mar 2017 18:52:37 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r315012 - in stable/10/sys/cddl/dev/dtrace: amd64 i386 Message-ID: <201703101852.v2AIqbF9090903@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Fri Mar 10 18:52:37 2017 New Revision: 315012 URL: https://svnweb.freebsd.org/changeset/base/315012 Log: MFC r313841, r313850: Prevent CPU migration when checking the DTrace nofault flag on x86. Modified: stable/10/sys/cddl/dev/dtrace/amd64/dtrace_subr.c stable/10/sys/cddl/dev/dtrace/i386/dtrace_subr.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cddl/dev/dtrace/amd64/dtrace_subr.c ============================================================================== --- stable/10/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Fri Mar 10 18:51:47 2017 (r315011) +++ stable/10/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Fri Mar 10 18:52:37 2017 (r315012) @@ -41,7 +41,9 @@ #include <sys/dtrace_impl.h> #include <sys/dtrace_bsd.h> #include <machine/clock.h> +#include <machine/cpufunc.h> #include <machine/frame.h> +#include <machine/psl.h> #include <vm/pmap.h> extern uintptr_t dtrace_in_probe_addr; @@ -466,6 +468,8 @@ dtrace_gethrestime(void) int dtrace_trap(struct trapframe *frame, u_int type) { + uint16_t nofault; + /* * A trap can occur while DTrace executes a probe. Before * executing the probe, DTrace blocks re-scheduling and sets @@ -476,7 +480,12 @@ dtrace_trap(struct trapframe *frame, u_i * Check if DTrace has enabled 'no-fault' mode: * */ - if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { + sched_pin(); + nofault = cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT; + sched_unpin(); + if (nofault) { + KASSERT((read_rflags() & PSL_I) == 0, ("interrupts enabled")); + /* * There are only a couple of trap types that are expected. * All the rest will be handled in the usual way. Modified: stable/10/sys/cddl/dev/dtrace/i386/dtrace_subr.c ============================================================================== --- stable/10/sys/cddl/dev/dtrace/i386/dtrace_subr.c Fri Mar 10 18:51:47 2017 (r315011) +++ stable/10/sys/cddl/dev/dtrace/i386/dtrace_subr.c Fri Mar 10 18:52:37 2017 (r315012) @@ -42,7 +42,9 @@ #include <sys/dtrace_impl.h> #include <sys/dtrace_bsd.h> #include <machine/clock.h> +#include <machine/cpufunc.h> #include <machine/frame.h> +#include <machine/psl.h> #include <vm/pmap.h> extern uintptr_t kernelbase; @@ -475,6 +477,8 @@ dtrace_gethrestime(void) int dtrace_trap(struct trapframe *frame, u_int type) { + uint16_t nofault; + /* * A trap can occur while DTrace executes a probe. Before * executing the probe, DTrace blocks re-scheduling and sets @@ -485,7 +489,12 @@ dtrace_trap(struct trapframe *frame, u_i * Check if DTrace has enabled 'no-fault' mode: * */ - if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { + sched_pin(); + nofault = cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT; + sched_unpin(); + if (nofault) { + KASSERT((read_eflags() & PSL_I) == 0, ("interrupts enabled")); + /* * There are only a couple of trap types that are expected. * All the rest will be handled in the usual way.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703101852.v2AIqbF9090903>