svn commit: r315011 - in stable/11/sys/cddl/dev/dtrace: amd64 i386
Mark Johnston
markj at FreeBSD.org
Fri Mar 10 18:51:49 UTC 2017
Author: markj
Date: Fri Mar 10 18:51:47 2017
New Revision: 315011
URL: https://svnweb.freebsd.org/changeset/base/315011
Log:
MFC r313841, r313850:
Prevent CPU migration when checking the DTrace nofault flag on x86.
Modified:
stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
==============================================================================
--- stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Fri Mar 10 17:37:55 2017 (r315010)
+++ stable/11/sys/cddl/dev/dtrace/amd64/dtrace_subr.c Fri Mar 10 18:51:47 2017 (r315011)
@@ -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 void dtrace_getnanotime(struct timespec *tsp);
@@ -384,6 +386,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
@@ -393,7 +397,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/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c
==============================================================================
--- stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c Fri Mar 10 17:37:55 2017 (r315010)
+++ stable/11/sys/cddl/dev/dtrace/i386/dtrace_subr.c Fri Mar 10 18:51:47 2017 (r315011)
@@ -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;
@@ -386,6 +388,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
@@ -395,7 +399,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.
More information about the svn-src-stable
mailing list