--- old/usr/src/cmd/mdb/common/modules/genunix/findstack.c	2015-05-08 18:10:20.962600448 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack.c	2015-05-08 18:10:20.969562835 -0400
@@ -874,9 +874,6 @@
 		if (sep->se_failed != 0) {
 			char *reason;
 			switch (sep->se_failed) {
-			case FSI_FAIL_NOTINMEMORY:
-				reason = "thread not in memory";
-				break;
 			case FSI_FAIL_THREADCORRUPT:
 				reason = "thread structure stack info corrupt";
 				break;
--- old/usr/src/cmd/mdb/common/modules/genunix/findstack.h	2015-05-08 18:10:21.178683936 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack.h	2015-05-08 18:10:21.185501272 -0400
@@ -47,9 +47,8 @@
 } findstack_info_t;
 
 #define	FSI_FAIL_BADTHREAD	1
-#define	FSI_FAIL_NOTINMEMORY	2
-#define	FSI_FAIL_THREADCORRUPT	3
-#define	FSI_FAIL_STACKNOTFOUND	4
+#define	FSI_FAIL_THREADCORRUPT	2
+#define	FSI_FAIL_STACKNOTFOUND	3
 
 typedef struct stacks_module {
 	char		sm_name[MAXPATHLEN]; /* name of module */
--- old/usr/src/cmd/mdb/common/modules/genunix/findstack_subr.c	2015-05-08 18:10:21.372085503 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/findstack_subr.c	2015-05-08 18:10:21.379029918 -0400
@@ -163,13 +163,6 @@
 	fsip->fsi_tstate = thr.t_state;
 	fsip->fsi_panic = !!(thr.t_flag & T_PANIC);
 
-	if ((thr.t_schedflag & TS_LOAD) == 0) {
-		if (print_warnings)
-			mdb_warn("thread %p isn't in memory\n", addr);
-		fsip->fsi_failed = FSI_FAIL_NOTINMEMORY;
-		return (DCMD_ERR);
-	}
-
 	if (thr.t_stk < thr.t_stkbase) {
 		if (print_warnings)
 			mdb_warn(
--- old/usr/src/cmd/mdb/common/modules/genunix/kmem.c	2015-05-08 18:10:21.578104684 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/kmem.c	2015-05-08 18:10:21.585167869 -0400
@@ -4322,14 +4322,6 @@
 		return (WALK_NEXT);
 
 	/*
-	 * Warn about swapped out threads, but drive on anyway
-	 */
-	if (!(t->t_schedflag & TS_LOAD)) {
-		mdb_warn("thread %p's stack swapped out\n", addr);
-		return (WALK_NEXT);
-	}
-
-	/*
 	 * Search the thread's stack for the given pointer.  Note that it would
 	 * be more efficient to follow ::kgrep's lead and read in page-sized
 	 * chunks, but this routine is already fast and simple.
--- old/usr/src/cmd/mdb/common/modules/genunix/leaky_subr.c	2015-05-08 18:10:21.889429175 -0400
+++ new/usr/src/cmd/mdb/common/modules/genunix/leaky_subr.c	2015-05-08 18:10:21.896323335 -0400
@@ -24,8 +24,6 @@
  * Use is subject to license terms.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 #include <mdb/mdb_param.h>
 #include <mdb/mdb_modapi.h>
 
@@ -278,22 +276,13 @@
 	return (WALK_NEXT);
 }
 
+/*ARGSUSED*/
 static int
 leaky_thread(uintptr_t addr, const kthread_t *t, unsigned long *pagesize)
 {
 	uintptr_t size, base = (uintptr_t)t->t_stkbase;
 	uintptr_t stk = (uintptr_t)t->t_stk;
 
-	/*
-	 * If this thread isn't in memory, we can't look at its stack.  This
-	 * may result in false positives, so we print a warning.
-	 */
-	if (!(t->t_schedflag & TS_LOAD)) {
-		mdb_printf("findleaks: thread %p's stack swapped out; "
-		    "false positives possible\n", addr);
-		return (WALK_NEXT);
-	}
-
 	if (t->t_state != TS_FREE)
 		leaky_grep(base, stk - base);
 
--- old/usr/src/pkg/manifests/system-kernel-platform.mf	2015-05-08 18:10:22.108281548 -0400
+++ new/usr/src/pkg/manifests/system-kernel-platform.mf	2015-05-08 18:10:22.115137367 -0400
@@ -1081,8 +1081,6 @@
     mode=0755
 $(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/vis group=sys \
     mode=0755
-$(sparc_ONLY)file path=platform/sun4u/kernel/misc/$(ARCH64)/zuluvm group=sys \
-    mode=0755
 $(sparc_ONLY)file path=platform/sun4u/kernel/strmod/$(ARCH64)/kb group=sys \
     mode=0755
 $(sparc_ONLY)file path=platform/sun4u/kernel/tod/$(ARCH64)/todblade group=sys \
--- old/usr/src/uts/common/Makefile.files	2015-05-08 18:10:22.342401959 -0400
+++ new/usr/src/uts/common/Makefile.files	2015-05-08 18:10:22.349367802 -0400
@@ -401,7 +401,6 @@
 		xdr.o		\
 		xdr_array.o	\
 		xdr_refer.o	\
-		xhat.o		\
 		zone.o
 
 #
--- old/usr/src/uts/common/cpr/cpr_dump.c	2015-05-08 18:10:22.593436320 -0400
+++ new/usr/src/uts/common/cpr/cpr_dump.c	2015-05-08 18:10:22.600367660 -0400
@@ -662,7 +662,7 @@
  * Count pages within each kernel segment; call cpr_sparse_seg_check()
  * to find out whether a sparsely filled segment needs special
  * treatment (e.g. kvseg).
- * Todo: A "SEGOP_CPR" like SEGOP_DUMP should be introduced, the cpr
+ * Todo: A "segop_cpr" like segop_dump should be introduced, the cpr
  *       module shouldn't need to know segment details like if it is
  *       sparsely filled or not (makes kseg_table obsolete).
  */
--- old/usr/src/uts/common/disp/disp.c	2015-05-08 18:10:22.817839468 -0400
+++ new/usr/src/uts/common/disp/disp.c	2015-05-08 18:10:22.824673392 -0400
@@ -96,9 +96,7 @@
 #define	KPQPRI	-1 		/* pri where cpu affinity is dropped for kpq */
 pri_t	kpqpri = KPQPRI; 	/* can be set in /etc/system */
 disp_t	cpu0_disp;		/* boot CPU's dispatch queue */
-disp_lock_t	swapped_lock;	/* lock swapped threads and swap queue */
 int	nswapped;		/* total number of swapped threads */
-void	disp_swapped_enq(kthread_t *tp);
 static void	disp_swapped_setrun(kthread_t *tp);
 static void	cpu_resched(cpu_t *cp, pri_t tpri);
 
@@ -776,7 +774,6 @@
 	tp = dq->dq_first;
 
 	ASSERT(tp != NULL);
-	ASSERT(tp->t_schedflag & TS_LOAD);	/* thread must be swapped in */
 
 	DTRACE_SCHED2(dequeue, kthread_t *, tp, disp_t *, dp);
 
@@ -815,12 +812,6 @@
 		tp->t_link = NULL;
 	}
 
-	/*
-	 * Set TS_DONT_SWAP flag to prevent another processor from swapping
-	 * out this thread before we have a chance to run it.
-	 * While running, it is protected against swapping by t_lock.
-	 */
-	tp->t_schedflag |= TS_DONT_SWAP;
 	cpup->cpu_dispthread = tp;		/* protected by spl only */
 	cpup->cpu_dispatch_pri = pri;
 	ASSERT(pri == DISP_PRIO(tp));
@@ -1191,15 +1182,6 @@
 	ASSERT((tp->t_schedflag & TS_ALLSTART) == 0);
 	ASSERT(!thread_on_queue(tp));	/* make sure tp isn't on a runq */
 
-	/*
-	 * If thread is "swapped" or on the swap queue don't
-	 * queue it, but wake sched.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD) {
-		disp_swapped_setrun(tp);
-		return;
-	}
-
 	self = (tp == curthread);
 
 	if (tp->t_bound_cpu || tp->t_weakbound_cpu)
@@ -1380,15 +1362,6 @@
 	ASSERT((tp->t_schedflag & TS_ALLSTART) == 0);
 	ASSERT(!thread_on_queue(tp));	/* make sure tp isn't on a runq */
 
-	/*
-	 * If thread is "swapped" or on the swap queue don't
-	 * queue it, but wake sched.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD) {
-		disp_swapped_setrun(tp);
-		return;
-	}
-
 	if (tp->t_bound_cpu || tp->t_weakbound_cpu)
 		bound = 1;
 	else
@@ -1617,13 +1590,6 @@
 	if (tp->t_state != TS_RUN)
 		return (0);
 
-	/*
-	 * The thread is "swapped" or is on the swap queue and
-	 * hence no longer on the run queue, so return true.
-	 */
-	if ((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD)
-		return (1);
-
 	tpri = DISP_PRIO(tp);
 	dp = tp->t_disp_queue;
 	ASSERT(tpri < dp->disp_npri);
@@ -1677,110 +1643,6 @@
 	return (1);
 }
 
-
-/*
- * dq_sruninc and dq_srundec are public functions for
- * incrementing/decrementing the sruncnts when a thread on
- * a dispatcher queue is made schedulable/unschedulable by
- * resetting the TS_LOAD flag.
- *
- * The caller MUST have the thread lock and therefore the dispatcher
- * queue lock so that the operation which changes
- * the flag, the operation that checks the status of the thread to
- * determine if it's on a disp queue AND the call to this function
- * are one atomic operation with respect to interrupts.
- */
-
-/*
- * Called by sched AFTER TS_LOAD flag is set on a swapped, runnable thread.
- */
-void
-dq_sruninc(kthread_t *t)
-{
-	ASSERT(t->t_state == TS_RUN);
-	ASSERT(t->t_schedflag & TS_LOAD);
-
-	THREAD_TRANSITION(t);
-	setfrontdq(t);
-}
-
-/*
- * See comment on calling conventions above.
- * Called by sched BEFORE TS_LOAD flag is cleared on a runnable thread.
- */
-void
-dq_srundec(kthread_t *t)
-{
-	ASSERT(t->t_schedflag & TS_LOAD);
-
-	(void) dispdeq(t);
-	disp_swapped_enq(t);
-}
-
-/*
- * Change the dispatcher lock of thread to the "swapped_lock"
- * and return with thread lock still held.
- *
- * Called with thread_lock held, in transition state, and at high spl.
- */
-void
-disp_swapped_enq(kthread_t *tp)
-{
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT(tp->t_schedflag & TS_LOAD);
-
-	switch (tp->t_state) {
-	case TS_RUN:
-		disp_lock_enter_high(&swapped_lock);
-		THREAD_SWAP(tp, &swapped_lock);	/* set TS_RUN state and lock */
-		break;
-	case TS_ONPROC:
-		disp_lock_enter_high(&swapped_lock);
-		THREAD_TRANSITION(tp);
-		wake_sched_sec = 1;		/* tell clock to wake sched */
-		THREAD_SWAP(tp, &swapped_lock);	/* set TS_RUN state and lock */
-		break;
-	default:
-		panic("disp_swapped: tp: %p bad t_state", (void *)tp);
-	}
-}
-
-/*
- * This routine is called by setbackdq/setfrontdq if the thread is
- * not loaded or loaded and on the swap queue.
- *
- * Thread state TS_SLEEP implies that a swapped thread
- * has been woken up and needs to be swapped in by the swapper.
- *
- * Thread state TS_RUN, it implies that the priority of a swapped
- * thread is being increased by scheduling class (e.g. ts_update).
- */
-static void
-disp_swapped_setrun(kthread_t *tp)
-{
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT((tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ)) != TS_LOAD);
-
-	switch (tp->t_state) {
-	case TS_SLEEP:
-		disp_lock_enter_high(&swapped_lock);
-		/*
-		 * Wakeup sched immediately (i.e., next tick) if the
-		 * thread priority is above maxclsyspri.
-		 */
-		if (DISP_PRIO(tp) > maxclsyspri)
-			wake_sched = 1;
-		else
-			wake_sched_sec = 1;
-		THREAD_RUN(tp, &swapped_lock); /* set TS_RUN state and lock */
-		break;
-	case TS_RUN:				/* called from ts_update */
-		break;
-	default:
-		panic("disp_swapped_setrun: tp: %p bad t_state", (void *)tp);
-	}
-}
-
 /*
  *	Make a thread give up its processor.  Find the processor on
  *	which this thread is executing, and have that processor
@@ -2154,11 +2016,10 @@
 
 	/*
 	 * Don't do anything if the thread is not bound, or
-	 * currently not runnable or swapped out.
+	 * currently not runnable.
 	 */
 	if (tp->t_bound_cpu == NULL ||
-	    tp->t_state != TS_RUN ||
-	    tp->t_schedflag & TS_ON_SWAPQ)
+	    tp->t_state != TS_RUN)
 		return;
 
 	tpri = DISP_PRIO(tp);
@@ -2353,8 +2214,6 @@
 	 */
 	dp->disp_steal = 0;
 
-	tp->t_schedflag |= TS_DONT_SWAP;
-
 	/*
 	 * Setup thread to run on the current CPU.
 	 */
--- old/usr/src/uts/common/disp/fss.c	2015-05-08 18:10:23.097527134 -0400
+++ new/usr/src/uts/common/disp/fss.c	2015-05-08 18:10:23.104483685 -0400
@@ -349,8 +349,6 @@
 
 static id_t	fss_cid;
 
-static time_t	fss_minrun = 2;	/* t_pri becomes 59 within 2 secs */
-static time_t	fss_minslp = 2;	/* min time on sleep queue for hardswap */
 static int	fss_quantum = 11;
 
 static void	fss_newpri(fssproc_t *, boolean_t);
@@ -379,8 +377,6 @@
 static void	fss_exit(kthread_t *);
 static void	fss_active(kthread_t *);
 static void	fss_inactive(kthread_t *);
-static pri_t	fss_swapin(kthread_t *, int);
-static pri_t	fss_swapout(kthread_t *, int);
 static void	fss_trapret(kthread_t *);
 static void	fss_preempt(kthread_t *);
 static void	fss_setrun(kthread_t *);
@@ -417,8 +413,6 @@
 	fss_exit,
 	fss_active,
 	fss_inactive,
-	fss_swapin,
-	fss_swapout,
 	fss_trapret,
 	fss_preempt,
 	fss_setrun,
@@ -2140,107 +2134,6 @@
 }
 
 /*
- * fss_swapin() returns -1 if the thread is loaded or is not eligible to be
- * swapped in. Otherwise, it returns the thread's effective priority based
- * on swapout time and size of process (0 <= epri <= 0 SHRT_MAX).
- */
-/*ARGSUSED*/
-static pri_t
-fss_swapin(kthread_t *t, int flags)
-{
-	fssproc_t *fssproc = FSSPROC(t);
-	long epri = -1;
-	proc_t *pp = ttoproc(t);
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		time_t swapout_time;
-
-		swapout_time = (ddi_get_lbolt() - t->t_stime) / hz;
-		if (INHERITED(t) || (fssproc->fss_flags & FSSKPRI)) {
-			epri = (long)DISP_PRIO(t) + swapout_time;
-		} else {
-			/*
-			 * Threads which have been out for a long time,
-			 * have high user mode priority and are associated
-			 * with a small address space are more deserving.
-			 */
-			epri = fssproc->fss_umdpri;
-			ASSERT(epri >= 0 && epri <= fss_maxumdpri);
-			epri += swapout_time - pp->p_swrss / nz(maxpgio)/2;
-		}
-		/*
-		 * Scale epri so that SHRT_MAX / 2 represents zero priority.
-		 */
-		epri += SHRT_MAX / 2;
-		if (epri < 0)
-			epri = 0;
-		else if (epri > SHRT_MAX)
-			epri = SHRT_MAX;
-	}
-	return ((pri_t)epri);
-}
-
-/*
- * fss_swapout() returns -1 if the thread isn't loaded or is not eligible to
- * be swapped out. Otherwise, it returns the thread's effective priority
- * based on if the swapper is in softswap or hardswap mode.
- */
-static pri_t
-fss_swapout(kthread_t *t, int flags)
-{
-	fssproc_t *fssproc = FSSPROC(t);
-	long epri = -1;
-	proc_t *pp = ttoproc(t);
-	time_t swapin_time;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (INHERITED(t) ||
-	    (fssproc->fss_flags & FSSKPRI) ||
-	    (t->t_proc_flag & TP_LWPEXIT) ||
-	    (t->t_state & (TS_ZOMB|TS_FREE|TS_STOPPED|TS_ONPROC|TS_WAIT)) ||
-	    !(t->t_schedflag & TS_LOAD) ||
-	    !(SWAP_OK(t)))
-		return (-1);
-
-	ASSERT(t->t_state & (TS_SLEEP | TS_RUN));
-
-	swapin_time = (ddi_get_lbolt() - t->t_stime) / hz;
-
-	if (flags == SOFTSWAP) {
-		if (t->t_state == TS_SLEEP && swapin_time > maxslp) {
-			epri = 0;
-		} else {
-			return ((pri_t)epri);
-		}
-	} else {
-		pri_t pri;
-
-		if ((t->t_state == TS_SLEEP && swapin_time > fss_minslp) ||
-		    (t->t_state == TS_RUN && swapin_time > fss_minrun)) {
-			pri = fss_maxumdpri;
-			epri = swapin_time -
-			    (rm_asrss(pp->p_as) / nz(maxpgio)/2) - (long)pri;
-		} else {
-			return ((pri_t)epri);
-		}
-	}
-
-	/*
-	 * Scale epri so that SHRT_MAX / 2 represents zero priority.
-	 */
-	epri += SHRT_MAX / 2;
-	if (epri < 0)
-		epri = 0;
-	else if (epri > SHRT_MAX)
-		epri = SHRT_MAX;
-
-	return ((pri_t)epri);
-}
-
-/*
  * If thread is currently at a kernel mode priority (has slept) and is
  * returning to the userland we assign it the appropriate user mode priority
  * and time quantum here.  If we're lowering the thread's priority below that
@@ -2271,16 +2164,6 @@
 		if (DISP_MUST_SURRENDER(t))
 			cpu_surrender(t);
 	}
-
-	/*
-	 * Swapout lwp if the swapper is waiting for this thread to reach
-	 * a safe point.
-	 */
-	if (t->t_schedflag & TS_SWAPENQ) {
-		thread_unlock(t);
-		swapout_lwp(ttolwp(t));
-		thread_lock(t);
-	}
 }
 
 /*
@@ -2325,14 +2208,6 @@
 	}
 
 	/*
-	 * If preempted in user-land mark the thread as swappable because it
-	 * cannot be holding any kernel locks.
-	 */
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-	if (lwp != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
-
-	/*
 	 * Check to see if we're doing "preemption control" here.  If
 	 * we are, and if the user has requested that this thread not
 	 * be preempted, and if preemptions haven't been put off for
@@ -2356,7 +2231,6 @@
 					fssproc->fss_flags |= FSSRESTORE;
 				}
 				THREAD_CHANGE_PRI(t, fss_maxumdpri);
-				t->t_schedflag |= TS_DONT_SWAP;
 			}
 			schedctl_set_yield(t, 1);
 			setfrontdq(t);
@@ -2462,20 +2336,17 @@
 		if (DISP_MUST_SURRENDER(curthread))
 			cpu_surrender(t);
 	}
-	t->t_stime = ddi_get_lbolt();	/* time stamp for the swapper */
 }
 
 /*
  * A tick interrupt has ocurrend on a running thread. Check to see if our
- * time slice has expired.  We must also clear the TS_DONT_SWAP flag in
- * t_schedflag if the thread is eligible to be swapped out.
+ * time slice has expired.
  */
 static void
 fss_tick(kthread_t *t)
 {
 	fssproc_t *fssproc;
 	fssproj_t *fssproj;
-	klwp_t *lwp;
 	boolean_t call_cpu_surrender = B_FALSE;
 	boolean_t cpucaps_enforce = B_FALSE;
 
@@ -2547,10 +2418,6 @@
 			 * accomplishes this.
 			 */
 			if (thread_change_pri(t, new_pri, 0)) {
-				if ((t->t_schedflag & TS_LOAD) &&
-				    (lwp = t->t_lwp) &&
-				    lwp->lwp_state == LWP_USER)
-					t->t_schedflag &= ~TS_DONT_SWAP;
 				fssproc->fss_timeleft = fss_quantum;
 			} else {
 				call_cpu_surrender = B_TRUE;
@@ -2614,7 +2481,6 @@
 
 	fss_active(t);
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	fssproc = FSSPROC(t);
 	fssproc->fss_flags &= ~FSSBACKQ;
 
--- old/usr/src/uts/common/disp/fx.c	2015-05-08 18:10:23.385132523 -0400
+++ new/usr/src/uts/common/disp/fx.c	2015-05-08 18:10:23.392021970 -0400
@@ -181,8 +181,6 @@
 static int	fx_parmsset(kthread_t *, void *, id_t, cred_t *);
 static void	fx_stop(kthread_t *, int, int);
 static void	fx_exit(kthread_t *);
-static pri_t	fx_swapin(kthread_t *, int);
-static pri_t	fx_swapout(kthread_t *, int);
 static void	fx_trapret(kthread_t *);
 static void	fx_preempt(kthread_t *);
 static void	fx_setrun(kthread_t *);
@@ -226,8 +224,6 @@
 	fx_exit,
 	fx_nullsys,	/* active */
 	fx_nullsys,	/* inactive */
-	fx_swapin,
-	fx_swapout,
 	fx_trapret,
 	fx_preempt,
 	fx_setrun,
@@ -1224,49 +1220,6 @@
 	if (FX_HAS_CB(fxpp)) {
 		FX_CB_SLEEP(FX_CALLB(fxpp), fxpp->fx_cookie);
 	}
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
-}
-
-
-/*
- * Return Values:
- *
- *	-1 if the thread is loaded or is not eligible to be swapped in.
- *
- * FX and RT threads are designed so that they don't swapout; however,
- * it is possible that while the thread is swapped out and in another class, it
- * can be changed to FX or RT.  Since these threads should be swapped in
- * as soon as they're runnable, rt_swapin returns SHRT_MAX, and fx_swapin
- * returns SHRT_MAX - 1, so that it gives deference to any swapped out
- * RT threads.
- */
-/* ARGSUSED */
-static pri_t
-fx_swapin(kthread_t *t, int flags)
-{
-	pri_t	tpri = -1;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		tpri = (pri_t)SHRT_MAX - 1;
-	}
-
-	return (tpri);
-}
-
-/*
- * Return Values
- *	-1 if the thread isn't loaded or is not eligible to be swapped out.
- */
-/* ARGSUSED */
-static pri_t
-fx_swapout(kthread_t *t, int flags)
-{
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	return (-1);
-
 }
 
 /* ARGSUSED */
@@ -1396,7 +1349,6 @@
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	if (FX_HAS_CB(fxpp)) {
 		clock_t new_quantum =  (clock_t)fxpp->fx_pquantum;
 		pri_t	newpri = fxpp->fx_pri;
--- old/usr/src/uts/common/disp/rt.c	2015-05-08 18:10:23.632989583 -0400
+++ new/usr/src/uts/common/disp/rt.c	2015-05-08 18:10:23.639793352 -0400
@@ -131,8 +131,6 @@
 static void	rt_setrun(kthread_t *);
 static void	rt_tick(kthread_t *);
 static void	rt_wakeup(kthread_t *);
-static pri_t	rt_swapin(kthread_t *, int);
-static pri_t	rt_swapout(kthread_t *, int);
 static pri_t	rt_globpri(kthread_t *);
 static void	rt_yield(kthread_t *);
 static int	rt_alloc(void **, int);
@@ -170,8 +168,6 @@
 	rt_nullsys,	/* exit */
 	rt_nullsys,	/* active */
 	rt_nullsys,	/* inactive */
-	rt_swapin,
-	rt_swapout,
 	rt_nullsys,	/* trapret */
 	rt_preempt,
 	rt_setrun,
@@ -902,16 +898,9 @@
 rt_preempt(kthread_t *t)
 {
 	rtproc_t *rtpp = (rtproc_t *)(t->t_cldata);
-	klwp_t *lwp;
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	/*
-	 * If the state is user I allow swapping because I know I won't
-	 * be holding any locks.
-	 */
-	if ((lwp = curthread->t_lwp) != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
 	if ((rtpp->rt_flags & RTBACKQ) != 0) {
 		rtpp->rt_timeleft = rtpp->rt_pquantum;
 		rtpp->rt_flags &= ~RTBACKQ;
@@ -944,44 +933,6 @@
 }
 
 /*
- * Returns the priority of the thread, -1 if the thread is loaded or ineligible
- * for swapin.
- *
- * FX and RT threads are designed so that they don't swapout; however, it
- * is possible that while the thread is swapped out and in another class, it
- * can be changed to FX or RT.  Since these threads should be swapped in as
- * soon as they're runnable, rt_swapin returns SHRT_MAX, and fx_swapin
- * returns SHRT_MAX - 1, so that it gives deference to any swapped out RT
- * threads.
- */
-/* ARGSUSED */
-static pri_t
-rt_swapin(kthread_t *t, int flags)
-{
-	pri_t	tpri = -1;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		tpri = (pri_t)SHRT_MAX;
-	}
-
-	return (tpri);
-}
-
-/*
- * Return an effective priority for swapout.
- */
-/* ARGSUSED */
-static pri_t
-rt_swapout(kthread_t *t, int flags)
-{
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	return (-1);
-}
-
-/*
  * Check for time slice expiration (unless thread has infinite time
  * slice).  If time slice has expired arrange for thread to be preempted
  * and placed on back of queue.
--- old/usr/src/uts/common/disp/sysclass.c	2015-05-08 18:10:23.861234761 -0400
+++ new/usr/src/uts/common/disp/sysclass.c	2015-05-08 18:10:23.868050183 -0400
@@ -27,8 +27,6 @@
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* from SVr4.0 1.12 */
-
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/sysmacros.h>
@@ -66,7 +64,6 @@
 static int	sys_doprio(kthread_t *, cred_t *, int, int *);
 static void	sys_forkret(kthread_t *, kthread_t *);
 static void	sys_nullsys();
-static pri_t	sys_swappri(kthread_t *, int);
 static int	sys_alloc(void **, int);
 
 struct classfuncs sys_classfuncs = {
@@ -95,8 +92,6 @@
 		sys_nullsys,	/* exit */
 		sys_nullsys,	/* active */
 		sys_nullsys,	/* inactive */
-		sys_swappri,	/* swapin */
-		sys_swappri,	/* swapout */
 		sys_nullsys,	/* trapret */
 		setfrontdq,	/* preempt */
 		setbackdq,	/* setrun */
@@ -194,15 +189,6 @@
 	mutex_exit(&pp->p_lock);
 }
 
-/* ARGSUSED */
-static pri_t
-sys_swappri(t, flags)
-	kthread_t	*t;
-	int		flags;
-{
-	return (-1);
-}
-
 static int
 sys_nosys()
 {
--- old/usr/src/uts/common/disp/sysdc.c	2015-05-08 18:10:24.061501959 -0400
+++ new/usr/src/uts/common/disp/sysdc.c	2015-05-08 18:10:24.068383415 -0400
@@ -1110,14 +1110,6 @@
 	return (t->t_epri);
 }
 
-/*ARGSUSED*/
-static pri_t
-sysdc_no_swap(kthread_t *t, int flags)
-{
-	/* SDC threads cannot be swapped. */
-	return (-1);
-}
-
 /*
  * Get maximum and minimum priorities enjoyed by SDC threads.
  */
@@ -1202,8 +1194,6 @@
 		sysdc_exit,
 		sysdc_nullsys,	/* active */
 		sysdc_nullsys,	/* inactive */
-		sysdc_no_swap,	/* swapin */
-		sysdc_no_swap,	/* swapout */
 		sysdc_nullsys,	/* trapret */
 		sysdc_preempt,
 		sysdc_setrun,
--- old/usr/src/uts/common/disp/thread.c	2015-05-08 18:10:24.293791087 -0400
+++ new/usr/src/uts/common/disp/thread.c	2015-05-08 18:10:24.300601242 -0400
@@ -429,8 +429,7 @@
 	t->t_clfuncs = &sys_classfuncs.thread;
 	t->t_cid = syscid;
 	t->t_pri = pri;
-	t->t_stime = ddi_get_lbolt();
-	t->t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t->t_schedflag = 0;
 	t->t_bind_cpu = PBIND_NONE;
 	t->t_bindflag = (uchar_t)default_binding_mode;
 	t->t_bind_pset = PS_NONE;
--- old/usr/src/uts/common/disp/ts.c	2015-05-08 18:10:24.546212144 -0400
+++ new/usr/src/uts/common/disp/ts.c	2015-05-08 18:10:24.553050351 -0400
@@ -202,8 +202,6 @@
 static void	ts_preempt(kthread_t *);
 static void	ts_setrun(kthread_t *);
 static void	ts_sleep(kthread_t *);
-static pri_t	ts_swapin(kthread_t *, int);
-static pri_t	ts_swapout(kthread_t *, int);
 static void	ts_tick(kthread_t *);
 static void	ts_trapret(kthread_t *);
 static void	ts_update(void *);
@@ -261,8 +259,6 @@
 	ts_exit,
 	ts_nullsys,	/* active */
 	ts_nullsys,	/* inactive */
-	ts_swapin,
-	ts_swapout,
 	ts_trapret,
 	ts_preempt,
 	ts_setrun,
@@ -306,8 +302,6 @@
 	ts_exit,
 	ts_nullsys,	/* active */
 	ts_nullsys,	/* inactive */
-	ts_swapin,
-	ts_swapout,
 	ts_trapret,
 	ts_preempt,
 	ts_setrun,
@@ -1404,14 +1398,6 @@
 	}
 
 	/*
-	 * If thread got preempted in the user-land then we know
-	 * it isn't holding any locks.  Mark it as swappable.
-	 */
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-	if (lwp != NULL && lwp->lwp_state == LWP_USER)
-		t->t_schedflag &= ~TS_DONT_SWAP;
-
-	/*
 	 * Check to see if we're doing "preemption control" here.  If
 	 * we are, and if the user has requested that this thread not
 	 * be preempted, and if preemptions haven't been put off for
@@ -1435,7 +1421,6 @@
 					tspp->ts_flags |= TSRESTORE;
 				}
 				THREAD_CHANGE_PRI(t, ts_maxumdpri);
-				t->t_schedflag |= TS_DONT_SWAP;
 			}
 			schedctl_set_yield(t, 1);
 			setfrontdq(t);
@@ -1562,138 +1547,10 @@
 		if (DISP_MUST_SURRENDER(curthread))
 			cpu_surrender(curthread);
 	}
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
 	TRACE_2(TR_FAC_DISP, TR_SLEEP,
 	    "sleep:tid %p old pri %d", t, old_pri);
 }
 
-
-/*
- * Return Values:
- *
- *	-1 if the thread is loaded or is not eligible to be swapped in.
- *
- *	effective priority of the specified thread based on swapout time
- *		and size of process (epri >= 0 , epri <= SHRT_MAX).
- */
-/* ARGSUSED */
-static pri_t
-ts_swapin(kthread_t *t, int flags)
-{
-	tsproc_t	*tspp = (tsproc_t *)(t->t_cldata);
-	long		epri = -1;
-	proc_t		*pp = ttoproc(t);
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	/*
-	 * We know that pri_t is a short.
-	 * Be sure not to overrun its range.
-	 */
-	if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
-		time_t swapout_time;
-
-		swapout_time = (ddi_get_lbolt() - t->t_stime) / hz;
-		if (INHERITED(t) || (tspp->ts_flags & (TSKPRI | TSIASET)))
-			epri = (long)DISP_PRIO(t) + swapout_time;
-		else {
-			/*
-			 * Threads which have been out for a long time,
-			 * have high user mode priority and are associated
-			 * with a small address space are more deserving
-			 */
-			epri = ts_dptbl[tspp->ts_umdpri].ts_globpri;
-			ASSERT(epri >= 0 && epri <= ts_maxumdpri);
-			epri += swapout_time - pp->p_swrss / nz(maxpgio)/2;
-		}
-		/*
-		 * Scale epri so SHRT_MAX/2 represents zero priority.
-		 */
-		epri += SHRT_MAX/2;
-		if (epri < 0)
-			epri = 0;
-		else if (epri > SHRT_MAX)
-			epri = SHRT_MAX;
-	}
-	return ((pri_t)epri);
-}
-
-/*
- * Return Values
- *	-1 if the thread isn't loaded or is not eligible to be swapped out.
- *
- *	effective priority of the specified thread based on if the swapper
- *		is in softswap or hardswap mode.
- *
- *		Softswap:  Return a low effective priority for threads
- *			   sleeping for more than maxslp secs.
- *
- *		Hardswap:  Return an effective priority such that threads
- *			   which have been in memory for a while and are
- *			   associated with a small address space are swapped
- *			   in before others.
- *
- *		(epri >= 0 , epri <= SHRT_MAX).
- */
-time_t	ts_minrun = 2;		/* XXX - t_pri becomes 59 within 2 secs */
-time_t	ts_minslp = 2;		/* min time on sleep queue for hardswap */
-
-static pri_t
-ts_swapout(kthread_t *t, int flags)
-{
-	tsproc_t	*tspp = (tsproc_t *)(t->t_cldata);
-	long		epri = -1;
-	proc_t		*pp = ttoproc(t);
-	time_t		swapin_time;
-
-	ASSERT(THREAD_LOCK_HELD(t));
-
-	if (INHERITED(t) || (tspp->ts_flags & (TSKPRI | TSIASET)) ||
-	    (t->t_proc_flag & TP_LWPEXIT) ||
-	    (t->t_state & (TS_ZOMB | TS_FREE | TS_STOPPED |
-	    TS_ONPROC | TS_WAIT)) ||
-	    !(t->t_schedflag & TS_LOAD) || !SWAP_OK(t))
-		return (-1);
-
-	ASSERT(t->t_state & (TS_SLEEP | TS_RUN));
-
-	/*
-	 * We know that pri_t is a short.
-	 * Be sure not to overrun its range.
-	 */
-	swapin_time = (ddi_get_lbolt() - t->t_stime) / hz;
-	if (flags == SOFTSWAP) {
-		if (t->t_state == TS_SLEEP && swapin_time > maxslp) {
-			epri = 0;
-		} else {
-			return ((pri_t)epri);
-		}
-	} else {
-		pri_t pri;
-
-		if ((t->t_state == TS_SLEEP && swapin_time > ts_minslp) ||
-		    (t->t_state == TS_RUN && swapin_time > ts_minrun)) {
-			pri = ts_dptbl[tspp->ts_umdpri].ts_globpri;
-			ASSERT(pri >= 0 && pri <= ts_maxumdpri);
-			epri = swapin_time -
-			    (rm_asrss(pp->p_as) / nz(maxpgio)/2) - (long)pri;
-		} else {
-			return ((pri_t)epri);
-		}
-	}
-
-	/*
-	 * Scale epri so SHRT_MAX/2 represents zero priority.
-	 */
-	epri += SHRT_MAX/2;
-	if (epri < 0)
-		epri = 0;
-	else if (epri > SHRT_MAX)
-		epri = SHRT_MAX;
-
-	return ((pri_t)epri);
-}
-
 /*
  * Check for time slice expiration.  If time slice has expired
  * move thread to priority specified in tsdptbl for time slice expiration
@@ -1703,7 +1560,6 @@
 ts_tick(kthread_t *t)
 {
 	tsproc_t *tspp = (tsproc_t *)(t->t_cldata);
-	klwp_t *lwp;
 	boolean_t call_cpu_surrender = B_FALSE;
 	pri_t	oldpri = t->t_pri;
 
@@ -1758,10 +1614,6 @@
 			 * this.
 			 */
 			if (thread_change_pri(t, new_pri, 0)) {
-				if ((t->t_schedflag & TS_LOAD) &&
-				    (lwp = t->t_lwp) &&
-				    lwp->lwp_state == LWP_USER)
-					t->t_schedflag &= ~TS_DONT_SWAP;
 				tspp->ts_timeleft =
 				    ts_dptbl[tspp->ts_cpupri].ts_quantum;
 			} else {
@@ -1835,16 +1687,6 @@
 			cpu_surrender(t);
 	}
 
-	/*
-	 * Swapout lwp if the swapper is waiting for this thread to
-	 * reach a safe point.
-	 */
-	if ((t->t_schedflag & TS_SWAPENQ) && !(tspp->ts_flags & TSIASET)) {
-		thread_unlock(t);
-		swapout_lwp(ttolwp(t));
-		thread_lock(t);
-	}
-
 	TRACE_2(TR_FAC_DISP, TR_TRAPRET,
 	    "trapret:tid %p old pri %d", t, old_pri);
 }
@@ -1982,8 +1824,6 @@
 
 	ASSERT(THREAD_LOCK_HELD(t));
 
-	t->t_stime = ddi_get_lbolt();		/* time stamp for the swapper */
-
 	if (tspp->ts_flags & TSKPRI) {
 		tspp->ts_flags &= ~TSBACKQ;
 		if (tspp->ts_flags & TSIASET)
--- old/usr/src/uts/common/exec/elf/elf.c	2015-05-08 18:10:24.811108556 -0400
+++ new/usr/src/uts/common/exec/elf/elf.c	2015-05-08 18:10:24.817856650 -0400
@@ -1483,7 +1483,7 @@
 		 * something fishy going on so we ignore this segment.
 		 */
 		if (seg->s_ops != &segvn_ops ||
-		    SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 ||
+		    segop_getvp(seg, seg->s_base, &mvp) != 0 ||
 		    mvp == lastvp || mvp == NULL || mvp->v_type != VREG ||
 		    (segsize = pr_getsegsize(seg, 1)) == 0)
 			continue;
@@ -1885,7 +1885,7 @@
 		caddr_t eaddr = seg->s_base + pr_getsegsize(seg, 0);
 		caddr_t saddr, naddr;
 		void *tmp = NULL;
-		extern struct seg_ops segspt_shmops;
+		extern const struct seg_ops segspt_shmops;
 
 		for (saddr = seg->s_base; saddr < eaddr; saddr = naddr) {
 			uint_t prot;
@@ -1914,7 +1914,7 @@
 			/*
 			 * Figure out which mappings to include in the core.
 			 */
-			type = SEGOP_GETTYPE(seg, saddr);
+			type = segop_gettype(seg, saddr);
 
 			if (saddr == stkbase && size == stksize) {
 				if (!(content & CC_CONTENT_STACK))
@@ -1941,7 +1941,7 @@
 					if (!(content & CC_CONTENT_SHM))
 						goto exclude;
 
-				} else if (SEGOP_GETVP(seg, seg->s_base,
+				} else if (segop_getvp(seg, seg->s_base,
 				    &mvp) != 0 || mvp == NULL ||
 				    mvp->v_type != VREG) {
 					if (!(content & CC_CONTENT_SHANON))
@@ -1952,7 +1952,7 @@
 						goto exclude;
 				}
 
-			} else if (SEGOP_GETVP(seg, seg->s_base, &mvp) != 0 ||
+			} else if (segop_getvp(seg, seg->s_base, &mvp) != 0 ||
 			    mvp == NULL || mvp->v_type != VREG) {
 				if (!(content & CC_CONTENT_ANON))
 					goto exclude;
--- old/usr/src/uts/common/fs/nfs/nfs3_vnops.c	2015-05-08 18:10:25.070282719 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs3_vnops.c	2015-05-08 18:10:25.077344839 -0400
@@ -5575,8 +5575,8 @@
 	/*
 	 * The way that the address space of this process deletes its mapping
 	 * of this file is via the following call chains:
-	 * - as_free()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs3_delmap()
-	 * - as_unmap()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs3_delmap()
+	 * - as_free()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs3_delmap()
+	 * - as_unmap()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs3_delmap()
 	 *
 	 * With the use of address space callbacks we are allowed to drop the
 	 * address space lock, a_lock, while executing the NFS operations that
--- old/usr/src/uts/common/fs/nfs/nfs4_vnops.c	2015-05-08 18:10:25.465221256 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs4_vnops.c	2015-05-08 18:10:25.472687832 -0400
@@ -11057,8 +11057,8 @@
 	/*
 	 * The way that the address space of this process deletes its mapping
 	 * of this file is via the following call chains:
-	 * - as_free()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs4_delmap()
-	 * - as_unmap()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs4_delmap()
+	 * - as_free()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs4_delmap()
+	 * - as_unmap()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs4_delmap()
 	 *
 	 * With the use of address space callbacks we are allowed to drop the
 	 * address space lock, a_lock, while executing the NFS operations that
--- old/usr/src/uts/common/fs/nfs/nfs_srv.c	2015-05-08 18:10:26.131605999 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs_srv.c	2015-05-08 18:10:26.138475200 -0400
@@ -1215,8 +1215,6 @@
 	nrp->ro = ro;
 	nrp->thread = curthread;
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	/*
 	 * Look to see if there is already a cluster started
 	 * for this file.
--- old/usr/src/uts/common/fs/nfs/nfs_vnops.c	2015-05-08 18:10:26.410554697 -0400
+++ new/usr/src/uts/common/fs/nfs/nfs_vnops.c	2015-05-08 18:10:26.417457707 -0400
@@ -4672,8 +4672,8 @@
 	/*
 	 * The way that the address space of this process deletes its mapping
 	 * of this file is via the following call chains:
-	 * - as_free()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs_delmap()
-	 * - as_unmap()->SEGOP_UNMAP()/segvn_unmap()->VOP_DELMAP()/nfs_delmap()
+	 * - as_free()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs_delmap()
+	 * - as_unmap()->segop_unmap()/segvn_unmap()->VOP_DELMAP()/nfs_delmap()
 	 *
 	 * With the use of address space callbacks we are allowed to drop the
 	 * address space lock, a_lock, while executing the NFS operations that
--- old/usr/src/uts/common/fs/proc/prioctl.c	2015-05-08 18:10:26.753238954 -0400
+++ new/usr/src/uts/common/fs/proc/prioctl.c	2015-05-08 18:10:26.760229904 -0400
@@ -3146,7 +3146,7 @@
 		seg = as_segat(as, va);
 		if (seg != NULL &&
 		    seg->s_ops == &segvn_ops &&
-		    SEGOP_GETVP(seg, va, &xvp) == 0 &&
+		    segop_getvp(seg, va, &xvp) == 0 &&
 		    xvp != NULL &&
 		    xvp->v_type == VREG) {
 			VN_HOLD(xvp);
@@ -3551,7 +3551,7 @@
 
 			mp->pr_vaddr = saddr;
 			mp->pr_size = naddr - saddr;
-			mp->pr_off = SEGOP_GETOFFSET(seg, saddr);
+			mp->pr_off = segop_getoffset(seg, saddr);
 			mp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				mp->pr_mflags |= MA_READ;
@@ -3559,7 +3559,7 @@
 				mp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				mp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				mp->pr_mflags |= MA_SHARED;
 			if (seg == brkseg)
 				mp->pr_mflags |= MA_BREAK;
@@ -3611,7 +3611,7 @@
 
 			mp->pr_vaddr = (caddr32_t)(uintptr_t)saddr;
 			mp->pr_size = (size32_t)(naddr - saddr);
-			mp->pr_off = (off32_t)SEGOP_GETOFFSET(seg, saddr);
+			mp->pr_off = (off32_t)segop_getoffset(seg, saddr);
 			mp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				mp->pr_mflags |= MA_READ;
@@ -3619,7 +3619,7 @@
 				mp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				mp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				mp->pr_mflags |= MA_SHARED;
 			if (seg == brkseg)
 				mp->pr_mflags |= MA_BREAK;
@@ -3753,7 +3753,7 @@
 			 * the presence of asychronously flushed pages or
 			 * mapped files whose sizes are changing.
 			 * page_exists() may be called indirectly from
-			 * pr_getprot() by a SEGOP_INCORE() routine.
+			 * pr_getprot() by a segop_incore() routine.
 			 * If this happens we need to make sure we don't
 			 * overrun the buffer whose size we computed based
 			 * on the initial iteration through the segments.
@@ -3779,7 +3779,7 @@
 			php->pr_npage += npage;
 			pmp->pr_vaddr = saddr;
 			pmp->pr_npage = npage;
-			pmp->pr_off = SEGOP_GETOFFSET(seg, saddr);
+			pmp->pr_off = segop_getoffset(seg, saddr);
 			pmp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				pmp->pr_mflags |= MA_READ;
@@ -3787,7 +3787,7 @@
 				pmp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				pmp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				pmp->pr_mflags |= MA_SHARED;
 			pmp->pr_pagesize = PAGESIZE;
 			hat_getstat(as, saddr, len, hatid,
@@ -3860,7 +3860,7 @@
 			 * the presence of asychronously flushed pages or
 			 * mapped files whose sizes are changing.
 			 * page_exists() may be called indirectly from
-			 * pr_getprot() by a SEGOP_INCORE() routine.
+			 * pr_getprot() by a segop_incore() routine.
 			 * If this happens we need to make sure we don't
 			 * overrun the buffer whose size we computed based
 			 * on the initial iteration through the segments.
@@ -3886,7 +3886,7 @@
 			php->pr_npage += npage;
 			pmp->pr_vaddr = (uint32_t)(uintptr_t)saddr;
 			pmp->pr_npage = (uint32_t)npage;
-			pmp->pr_off = (int32_t)SEGOP_GETOFFSET(seg, saddr);
+			pmp->pr_off = (int32_t)segop_getoffset(seg, saddr);
 			pmp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				pmp->pr_mflags |= MA_READ;
@@ -3894,7 +3894,7 @@
 				pmp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				pmp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				pmp->pr_mflags |= MA_SHARED;
 			pmp->pr_pagesize = PAGESIZE;
 			hat_getstat(as, saddr, len, hatid,
--- old/usr/src/uts/common/fs/proc/prsubr.c	2015-05-08 18:10:27.064954828 -0400
+++ new/usr/src/uts/common/fs/proc/prsubr.c	2015-05-08 18:10:27.072025151 -0400
@@ -97,8 +97,8 @@
 
 size_t pagev_lim = 256 * 1024;	/* limit on number of pages in prpagev_t */
 
-extern struct seg_ops segdev_ops;	/* needs a header file */
-extern struct seg_ops segspt_shmops;	/* needs a header file */
+extern const struct seg_ops segdev_ops;	/* needs a header file */
+extern const struct seg_ops segspt_shmops;	/* needs a header file */
 
 static	int	set_watched_page(proc_t *, caddr_t, caddr_t, ulong_t, ulong_t);
 static	void	clear_watched_page(proc_t *, caddr_t, caddr_t, ulong_t);
@@ -1483,7 +1483,7 @@
 		addr += p->p_brksize - 1;
 	seg = as_segat(p->p_as, addr);
 	if (seg != NULL && seg->s_ops == &segvn_ops &&
-	    (SEGOP_GETVP(seg, seg->s_base, &vp) != 0 || vp == NULL))
+	    (segop_getvp(seg, seg->s_base, &vp) != 0 || vp == NULL))
 		return (seg);
 	return (NULL);
 }
@@ -1648,7 +1648,7 @@
 
 			mp->pr_vaddr = (uintptr_t)saddr;
 			mp->pr_size = naddr - saddr;
-			mp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+			mp->pr_offset = segop_getoffset(seg, saddr);
 			mp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				mp->pr_mflags |= MA_READ;
@@ -1656,13 +1656,13 @@
 				mp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				mp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				mp->pr_mflags |= MA_SHARED;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+			if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 				mp->pr_mflags |= MA_NORESERVE;
 			if (seg->s_ops == &segspt_shmops ||
 			    (seg->s_ops == &segvn_ops &&
-			    (SEGOP_GETVP(seg, saddr, &vp) != 0 || vp == NULL)))
+			    (segop_getvp(seg, saddr, &vp) != 0 || vp == NULL)))
 				mp->pr_mflags |= MA_ANON;
 			if (seg == brkseg)
 				mp->pr_mflags |= MA_BREAK;
@@ -1688,7 +1688,7 @@
 			 */
 			vattr.va_mask = AT_FSID|AT_NODEID;
 			if (seg->s_ops == &segvn_ops &&
-			    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+			    segop_getvp(seg, saddr, &vp) == 0 &&
 			    vp != NULL && vp->v_type == VREG &&
 			    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 				if (vp == p->p_exec)
@@ -1759,7 +1759,7 @@
 
 			mp->pr_vaddr = (caddr32_t)(uintptr_t)saddr;
 			mp->pr_size = (size32_t)(naddr - saddr);
-			mp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+			mp->pr_offset = segop_getoffset(seg, saddr);
 			mp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				mp->pr_mflags |= MA_READ;
@@ -1767,13 +1767,13 @@
 				mp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				mp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				mp->pr_mflags |= MA_SHARED;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+			if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 				mp->pr_mflags |= MA_NORESERVE;
 			if (seg->s_ops == &segspt_shmops ||
 			    (seg->s_ops == &segvn_ops &&
-			    (SEGOP_GETVP(seg, saddr, &vp) != 0 || vp == NULL)))
+			    (segop_getvp(seg, saddr, &vp) != 0 || vp == NULL)))
 				mp->pr_mflags |= MA_ANON;
 			if (seg == brkseg)
 				mp->pr_mflags |= MA_BREAK;
@@ -1800,7 +1800,7 @@
 			 */
 			vattr.va_mask = AT_FSID|AT_NODEID;
 			if (seg->s_ops == &segvn_ops &&
-			    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+			    segop_getvp(seg, saddr, &vp) == 0 &&
 			    vp != NULL && vp->v_type == VREG &&
 			    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 				if (vp == p->p_exec)
@@ -1953,7 +1953,7 @@
 			 * the presence of asychronously flushed pages or
 			 * mapped files whose sizes are changing.
 			 * page_exists() may be called indirectly from
-			 * pr_getprot() by a SEGOP_INCORE() routine.
+			 * pr_getprot() by a segop_incore() routine.
 			 * If this happens we need to make sure we don't
 			 * overrun the buffer whose size we computed based
 			 * on the initial iteration through the segments.
@@ -1979,7 +1979,7 @@
 			php->pr_npage += npage;
 			pmp->pr_vaddr = (uintptr_t)saddr;
 			pmp->pr_npage = npage;
-			pmp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+			pmp->pr_offset = segop_getoffset(seg, saddr);
 			pmp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				pmp->pr_mflags |= MA_READ;
@@ -1987,13 +1987,13 @@
 				pmp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				pmp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				pmp->pr_mflags |= MA_SHARED;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+			if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 				pmp->pr_mflags |= MA_NORESERVE;
 			if (seg->s_ops == &segspt_shmops ||
 			    (seg->s_ops == &segvn_ops &&
-			    (SEGOP_GETVP(seg, saddr, &vp) != 0 || vp == NULL)))
+			    (segop_getvp(seg, saddr, &vp) != 0 || vp == NULL)))
 				pmp->pr_mflags |= MA_ANON;
 			if (seg->s_ops == &segspt_shmops)
 				pmp->pr_mflags |= MA_ISM | MA_SHM;
@@ -2003,7 +2003,7 @@
 			 */
 			vattr.va_mask = AT_FSID|AT_NODEID;
 			if (seg->s_ops == &segvn_ops &&
-			    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+			    segop_getvp(seg, saddr, &vp) == 0 &&
 			    vp != NULL && vp->v_type == VREG &&
 			    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 				if (vp == p->p_exec)
@@ -2100,7 +2100,7 @@
 			 * the presence of asychronously flushed pages or
 			 * mapped files whose sizes are changing.
 			 * page_exists() may be called indirectly from
-			 * pr_getprot() by a SEGOP_INCORE() routine.
+			 * pr_getprot() by a segop_incore() routine.
 			 * If this happens we need to make sure we don't
 			 * overrun the buffer whose size we computed based
 			 * on the initial iteration through the segments.
@@ -2126,7 +2126,7 @@
 			php->pr_npage += npage;
 			pmp->pr_vaddr = (caddr32_t)(uintptr_t)saddr;
 			pmp->pr_npage = (size32_t)npage;
-			pmp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+			pmp->pr_offset = segop_getoffset(seg, saddr);
 			pmp->pr_mflags = 0;
 			if (prot & PROT_READ)
 				pmp->pr_mflags |= MA_READ;
@@ -2134,13 +2134,13 @@
 				pmp->pr_mflags |= MA_WRITE;
 			if (prot & PROT_EXEC)
 				pmp->pr_mflags |= MA_EXEC;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+			if (segop_gettype(seg, saddr) & MAP_SHARED)
 				pmp->pr_mflags |= MA_SHARED;
-			if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+			if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 				pmp->pr_mflags |= MA_NORESERVE;
 			if (seg->s_ops == &segspt_shmops ||
 			    (seg->s_ops == &segvn_ops &&
-			    (SEGOP_GETVP(seg, saddr, &vp) != 0 || vp == NULL)))
+			    (segop_getvp(seg, saddr, &vp) != 0 || vp == NULL)))
 				pmp->pr_mflags |= MA_ANON;
 			if (seg->s_ops == &segspt_shmops)
 				pmp->pr_mflags |= MA_ISM | MA_SHM;
@@ -2150,7 +2150,7 @@
 			 */
 			vattr.va_mask = AT_FSID|AT_NODEID;
 			if (seg->s_ops == &segvn_ops &&
-			    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+			    segop_getvp(seg, saddr, &vp) == 0 &&
 			    vp != NULL && vp->v_type == VREG &&
 			    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 				if (vp == p->p_exec)
@@ -3328,7 +3328,7 @@
 			if ((pwp->wp_prot != prot ||
 			    (pwp->wp_flags & WP_NOWATCH)) &&
 			    (seg = as_segat(as, addr)) != NULL) {
-				err = SEGOP_SETPROT(seg, addr, PAGESIZE, prot);
+				err = segop_setprot(seg, addr, PAGESIZE, prot);
 				if (err == IE_RETRY) {
 					ASSERT(retrycnt == 0);
 					retrycnt++;
@@ -3434,7 +3434,7 @@
 		vaddr = pwp->wp_vaddr;
 		if (pwp->wp_oprot == 0 &&
 		    (seg = as_segat(as, vaddr)) != NULL) {
-			SEGOP_GETPROT(seg, vaddr, 0, &prot);
+			segop_getprot(seg, vaddr, 0, &prot);
 			pwp->wp_oprot = (uchar_t)prot;
 			pwp->wp_prot = (uchar_t)prot;
 		}
@@ -3640,7 +3640,7 @@
 		 * INCORE cleverly has different semantics than GETPROT:
 		 * it returns info on pages up to but NOT including addr + len.
 		 */
-		SEGOP_INCORE(seg, addr, len, pagev->pg_incore);
+		segop_incore(seg, addr, len, pagev->pg_incore);
 		pn = pagev->pg_pnbase;
 
 		do {
@@ -3668,7 +3668,7 @@
 	 * first byte of the page just past the end of what we want.
 	 */
 out:
-	SEGOP_GETPROT(seg, saddr, len - 1, pagev->pg_protv);
+	segop_getprot(seg, saddr, len - 1, pagev->pg_protv);
 	return (addr);
 }
 
@@ -3789,12 +3789,12 @@
 
 		vattr.va_mask = AT_SIZE;
 
-		if (SEGOP_GETVP(seg, seg->s_base, &vp) == 0 &&
+		if (segop_getvp(seg, seg->s_base, &vp) == 0 &&
 		    vp != NULL && vp->v_type == VREG &&
 		    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 
 			u_offset_t fsize = vattr.va_size;
-			u_offset_t offset = SEGOP_GETOFFSET(seg, seg->s_base);
+			u_offset_t offset = segop_getoffset(seg, seg->s_base);
 
 			if (fsize < offset)
 				fsize = 0;
@@ -3824,7 +3824,7 @@
 	 * MAP_SHARED nor MAP_PRIVATE.
 	 */
 	if (seg->s_ops == &segdev_ops &&
-	    ((SEGOP_GETTYPE(seg, seg->s_base) &
+	    ((segop_gettype(seg, seg->s_base) &
 	    (MAP_SHARED | MAP_PRIVATE)) == 0))
 		return (0);
 
@@ -4055,7 +4055,7 @@
 
 				mp->pr_vaddr = (uintptr_t)saddr;
 				mp->pr_size = naddr - saddr;
-				mp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+				mp->pr_offset = segop_getoffset(seg, saddr);
 				mp->pr_mflags = 0;
 				if (prot & PROT_READ)
 					mp->pr_mflags |= MA_READ;
@@ -4063,13 +4063,13 @@
 					mp->pr_mflags |= MA_WRITE;
 				if (prot & PROT_EXEC)
 					mp->pr_mflags |= MA_EXEC;
-				if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+				if (segop_gettype(seg, saddr) & MAP_SHARED)
 					mp->pr_mflags |= MA_SHARED;
-				if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+				if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 					mp->pr_mflags |= MA_NORESERVE;
 				if (seg->s_ops == &segspt_shmops ||
 				    (seg->s_ops == &segvn_ops &&
-				    (SEGOP_GETVP(seg, saddr, &vp) != 0 ||
+				    (segop_getvp(seg, saddr, &vp) != 0 ||
 				    vp == NULL)))
 					mp->pr_mflags |= MA_ANON;
 				if (seg == brkseg)
@@ -4092,7 +4092,7 @@
 				mp->pr_dev = PRNODEV;
 				vattr.va_mask = AT_FSID|AT_NODEID;
 				if (seg->s_ops == &segvn_ops &&
-				    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+				    segop_getvp(seg, saddr, &vp) == 0 &&
 				    vp != NULL && vp->v_type == VREG &&
 				    VOP_GETATTR(vp, &vattr, 0, CRED(),
 				    NULL) == 0) {
@@ -4124,7 +4124,7 @@
 				    PAGESHIFT;
 				parr = kmem_zalloc(npages, KM_SLEEP);
 
-				SEGOP_INCORE(seg, saddr, naddr - saddr, parr);
+				segop_incore(seg, saddr, naddr - saddr, parr);
 
 				for (pagenum = 0; pagenum < npages; pagenum++) {
 					if (parr[pagenum] & SEG_PAGE_INCORE)
@@ -4239,7 +4239,7 @@
 
 				mp->pr_vaddr = (caddr32_t)(uintptr_t)saddr;
 				mp->pr_size = (size32_t)(naddr - saddr);
-				mp->pr_offset = SEGOP_GETOFFSET(seg, saddr);
+				mp->pr_offset = segop_getoffset(seg, saddr);
 				mp->pr_mflags = 0;
 				if (prot & PROT_READ)
 					mp->pr_mflags |= MA_READ;
@@ -4247,13 +4247,13 @@
 					mp->pr_mflags |= MA_WRITE;
 				if (prot & PROT_EXEC)
 					mp->pr_mflags |= MA_EXEC;
-				if (SEGOP_GETTYPE(seg, saddr) & MAP_SHARED)
+				if (segop_gettype(seg, saddr) & MAP_SHARED)
 					mp->pr_mflags |= MA_SHARED;
-				if (SEGOP_GETTYPE(seg, saddr) & MAP_NORESERVE)
+				if (segop_gettype(seg, saddr) & MAP_NORESERVE)
 					mp->pr_mflags |= MA_NORESERVE;
 				if (seg->s_ops == &segspt_shmops ||
 				    (seg->s_ops == &segvn_ops &&
-				    (SEGOP_GETVP(seg, saddr, &vp) != 0 ||
+				    (segop_getvp(seg, saddr, &vp) != 0 ||
 				    vp == NULL)))
 					mp->pr_mflags |= MA_ANON;
 				if (seg == brkseg)
@@ -4276,7 +4276,7 @@
 				mp->pr_dev = PRNODEV32;
 				vattr.va_mask = AT_FSID|AT_NODEID;
 				if (seg->s_ops == &segvn_ops &&
-				    SEGOP_GETVP(seg, saddr, &vp) == 0 &&
+				    segop_getvp(seg, saddr, &vp) == 0 &&
 				    vp != NULL && vp->v_type == VREG &&
 				    VOP_GETATTR(vp, &vattr, 0, CRED(),
 				    NULL) == 0) {
@@ -4309,7 +4309,7 @@
 				    PAGESHIFT;
 				parr = kmem_zalloc(npages, KM_SLEEP);
 
-				SEGOP_INCORE(seg, saddr, naddr - saddr, parr);
+				segop_incore(seg, saddr, naddr - saddr, parr);
 
 				for (pagenum = 0; pagenum < npages; pagenum++) {
 					if (parr[pagenum] & SEG_PAGE_INCORE)
--- old/usr/src/uts/common/fs/proc/prvnops.c	2015-05-08 18:10:27.415652476 -0400
+++ new/usr/src/uts/common/fs/proc/prvnops.c	2015-05-08 18:10:27.422610948 -0400
@@ -3708,7 +3708,7 @@
 		 */
 		vattr.va_mask = AT_FSID|AT_NODEID;
 		if (seg->s_ops == &segvn_ops &&
-		    SEGOP_GETVP(seg, seg->s_base, &vp) == 0 &&
+		    segop_getvp(seg, seg->s_base, &vp) == 0 &&
 		    vp != NULL && vp->v_type == VREG &&
 		    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 			char name[64];
@@ -4159,7 +4159,7 @@
 					 */
 					vattr.va_mask = AT_FSID|AT_NODEID;
 					if (seg->s_ops == &segvn_ops &&
-					    SEGOP_GETVP(seg, seg->s_base, &vp)
+					    segop_getvp(seg, seg->s_base, &vp)
 					    == 0 &&
 					    vp != NULL && vp->v_type == VREG &&
 					    VOP_GETATTR(vp, &vattr, 0, CRED(),
@@ -4860,7 +4860,7 @@
 	do {
 		vattr.va_mask = AT_FSID|AT_NODEID;
 		if (seg->s_ops == &segvn_ops &&
-		    SEGOP_GETVP(seg, seg->s_base, &vp) == 0 &&
+		    segop_getvp(seg, seg->s_base, &vp) == 0 &&
 		    vp != NULL && vp->v_type == VREG &&
 		    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 			for (i = 0; i < nentries; i++)
--- old/usr/src/uts/common/io/mem.c	2015-05-08 18:10:27.786605398 -0400
+++ new/usr/src/uts/common/io/mem.c	2015-05-08 18:10:27.793437875 -0400
@@ -290,7 +290,7 @@
 
 	AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 	seg = as_segat(as, va);
-	i = (seg != NULL)? SEGOP_CAPABLE(seg, S_CAPABILITY_NOMINFLT) : 0;
+	i = (seg != NULL)? segop_capable(seg, S_CAPABILITY_NOMINFLT) : 0;
 	AS_LOCK_EXIT(as, &as->a_lock);
 
 	return (i);
--- old/usr/src/uts/common/os/clock.c	2015-05-08 18:10:28.007591920 -0400
+++ new/usr/src/uts/common/os/clock.c	2015-05-08 18:10:28.014710963 -0400
@@ -902,44 +902,6 @@
 			calcloadavg(genloadavg(&cpupart->cp_loadavg),
 			    cpupart->cp_hp_avenrun);
 		} while ((cpupart = cpupart->cp_next) != cp_list_head);
-
-		/*
-		 * Wake up the swapper thread if necessary.
-		 */
-		if (runin ||
-		    (runout && (avefree < desfree || wake_sched_sec))) {
-			t = &t0;
-			thread_lock(t);
-			if (t->t_state == TS_STOPPED) {
-				runin = runout = 0;
-				wake_sched_sec = 0;
-				t->t_whystop = 0;
-				t->t_whatstop = 0;
-				t->t_schedflag &= ~TS_ALLSTART;
-				THREAD_TRANSITION(t);
-				setfrontdq(t);
-			}
-			thread_unlock(t);
-		}
-	}
-
-	/*
-	 * Wake up the swapper if any high priority swapped-out threads
-	 * became runable during the last tick.
-	 */
-	if (wake_sched) {
-		t = &t0;
-		thread_lock(t);
-		if (t->t_state == TS_STOPPED) {
-			runin = runout = 0;
-			wake_sched = 0;
-			t->t_whystop = 0;
-			t->t_whatstop = 0;
-			t->t_schedflag &= ~TS_ALLSTART;
-			THREAD_TRANSITION(t);
-			setfrontdq(t);
-		}
-		thread_unlock(t);
 	}
 }
 
--- old/usr/src/uts/common/os/condvar.c	2015-05-08 18:10:28.276372227 -0400
+++ new/usr/src/uts/common/os/condvar.c	2015-05-08 18:10:28.283330281 -0400
@@ -193,7 +193,6 @@
 		return;
 	ASSERT(!quiesce_active);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	thread_lock(curthread);			/* lock the thread */
 	cv_block((condvar_impl_t *)cvp);
 	thread_unlock_nopreempt(curthread);	/* unlock the waiters field */
@@ -326,7 +325,6 @@
 	}
 	ASSERT(t->t_intr == NULL);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	cancel_pending = schedctl_cancel_pending();
 	lwp->lwp_asleep = 1;
 	lwp->lwp_sysabort = 0;
@@ -554,8 +552,6 @@
 	thread_lock(t);
 	t->t_kpri_req = 0;	/* don't need kernel priority */
 	cv_block_sig(t, (condvar_impl_t *)cvp);
-	/* I can be swapped now */
-	curthread->t_schedflag &= ~TS_DONT_SWAP;
 	thread_unlock_nopreempt(t);
 	mutex_exit(mp);
 	if (ISSIG(t, JUSTLOOKING) || MUSTRETURN(p, t) || cancel_pending)
@@ -564,8 +560,6 @@
 	swtch();
 	signalled = (t->t_schedflag & TS_SIGNALLED);
 	t->t_flag &= ~T_WAKEABLE;
-	/* TS_DONT_SWAP set by disp() */
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 	mutex_enter(mp);
 	if (ISSIG_PENDING(t, lwp, p)) {
 		mutex_exit(mp);
--- old/usr/src/uts/common/os/cpu.c	2015-05-08 18:10:28.492808583 -0400
+++ new/usr/src/uts/common/os/cpu.c	2015-05-08 18:10:28.499679839 -0400
@@ -301,10 +301,6 @@
 	kstat_named_t pgpgin;
 	kstat_named_t pgout;
 	kstat_named_t pgpgout;
-	kstat_named_t swapin;
-	kstat_named_t pgswapin;
-	kstat_named_t swapout;
-	kstat_named_t pgswapout;
 	kstat_named_t zfod;
 	kstat_named_t dfree;
 	kstat_named_t scan;
@@ -333,10 +329,6 @@
 	{ "pgpgin",		KSTAT_DATA_UINT64 },
 	{ "pgout",		KSTAT_DATA_UINT64 },
 	{ "pgpgout",		KSTAT_DATA_UINT64 },
-	{ "swapin",		KSTAT_DATA_UINT64 },
-	{ "pgswapin",		KSTAT_DATA_UINT64 },
-	{ "swapout",		KSTAT_DATA_UINT64 },
-	{ "pgswapout",		KSTAT_DATA_UINT64 },
 	{ "zfod",		KSTAT_DATA_UINT64 },
 	{ "dfree",		KSTAT_DATA_UINT64 },
 	{ "scan",		KSTAT_DATA_UINT64 },
@@ -2682,13 +2674,10 @@
 				(void) dispdeq(tp);
 				setbackdq(tp);
 				/*
-				 * Either on the bound CPU's disp queue now,
-				 * or swapped out or on the swap queue.
+				 * On the bound CPU's disp queue now.
 				 */
 				ASSERT(tp->t_disp_queue == cp->cpu_disp ||
-				    tp->t_weakbound_cpu == ocp ||
-				    (tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ))
-				    != TS_LOAD);
+				    tp->t_weakbound_cpu == ocp);
 			}
 		}
 	}
@@ -3291,10 +3280,6 @@
 	cvskd->pgpgin.value.ui64 = cvs->pgpgin;
 	cvskd->pgout.value.ui64 = cvs->pgout;
 	cvskd->pgpgout.value.ui64 = cvs->pgpgout;
-	cvskd->swapin.value.ui64 = cvs->swapin;
-	cvskd->pgswapin.value.ui64 = cvs->pgswapin;
-	cvskd->swapout.value.ui64 = cvs->swapout;
-	cvskd->pgswapout.value.ui64 = cvs->pgswapout;
 	cvskd->zfod.value.ui64 = cvs->zfod;
 	cvskd->dfree.value.ui64 = cvs->dfree;
 	cvskd->scan.value.ui64 = cvs->scan;
@@ -3421,10 +3406,6 @@
 	cso->cpu_vminfo.pgpgin		= CPU_STATS(cp, vm.pgpgin);
 	cso->cpu_vminfo.pgout		= CPU_STATS(cp, vm.pgout);
 	cso->cpu_vminfo.pgpgout		= CPU_STATS(cp, vm.pgpgout);
-	cso->cpu_vminfo.swapin		= CPU_STATS(cp, vm.swapin);
-	cso->cpu_vminfo.pgswapin	= CPU_STATS(cp, vm.pgswapin);
-	cso->cpu_vminfo.swapout		= CPU_STATS(cp, vm.swapout);
-	cso->cpu_vminfo.pgswapout	= CPU_STATS(cp, vm.pgswapout);
 	cso->cpu_vminfo.zfod		= CPU_STATS(cp, vm.zfod);
 	cso->cpu_vminfo.dfree		= CPU_STATS(cp, vm.dfree);
 	cso->cpu_vminfo.scan		= CPU_STATS(cp, vm.scan);
--- old/usr/src/uts/common/os/dumpsubr.c	2015-05-08 18:10:28.792784411 -0400
+++ new/usr/src/uts/common/os/dumpsubr.c	2015-05-08 18:10:28.799582122 -0400
@@ -660,7 +660,7 @@
 
 /*
  * Dump the <as, va, pfn> information for a given address space.
- * SEGOP_DUMP() will call dump_addpage() for each page in the segment.
+ * segop_dump() will call dump_addpage() for each page in the segment.
  */
 static void
 dump_as(struct as *as)
@@ -673,7 +673,7 @@
 			break;
 		if (seg->s_ops == NULL)
 			continue;
-		SEGOP_DUMP(seg);
+		segop_dump(seg);
 	}
 	AS_LOCK_EXIT(as, &as->a_lock);
 
--- old/usr/src/uts/common/os/exec.c	2015-05-08 18:10:29.023869682 -0400
+++ new/usr/src/uts/common/os/exec.c	2015-05-08 18:10:29.030838518 -0400
@@ -1276,7 +1276,7 @@
 			AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 			seg = as_segat(curproc->p_as, (caddr_t)end);
 			if (seg != NULL)
-				SEGOP_GETPROT(seg, (caddr_t)end, zfoddiff - 1,
+				segop_getprot(seg, (caddr_t)end, zfoddiff - 1,
 				    &zprot);
 			AS_LOCK_EXIT(as, &as->a_lock);
 
--- old/usr/src/uts/common/os/lgrp.c	2015-05-08 18:10:29.278806339 -0400
+++ new/usr/src/uts/common/os/lgrp.c	2015-05-08 18:10:29.285760962 -0400
@@ -3501,24 +3501,7 @@
 lgrp_mem_policy_info_t *
 lgrp_mem_policy_get(struct seg *seg, caddr_t vaddr)
 {
-	lgrp_mem_policy_info_t	*policy_info;
-	extern struct seg_ops	segspt_ops;
-	extern struct seg_ops	segspt_shmops;
-
-	/*
-	 * This is for binary compatibility to protect against third party
-	 * segment drivers which haven't recompiled to allow for
-	 * SEGOP_GETPOLICY()
-	 */
-	if (seg->s_ops != &segvn_ops && seg->s_ops != &segspt_ops &&
-	    seg->s_ops != &segspt_shmops)
-		return (NULL);
-
-	policy_info = NULL;
-	if (seg->s_ops->getpolicy != NULL)
-		policy_info = SEGOP_GETPOLICY(seg, vaddr);
-
-	return (policy_info);
+	return (segop_getpolicy(seg, vaddr));
 }
 
 /*
--- old/usr/src/uts/common/os/mmapobj.c	2015-05-08 18:10:29.597676820 -0400
+++ new/usr/src/uts/common/os/mmapobj.c	2015-05-08 18:10:29.604527925 -0400
@@ -1488,7 +1488,7 @@
 			seg = as_findseg(as, myaddr, 0);
 			MOBJ_STAT_ADD(exec_addr_mapped);
 			if (seg && seg->s_ops == &segdev_ops &&
-			    ((SEGOP_GETTYPE(seg, myaddr) &
+			    ((segop_gettype(seg, myaddr) &
 			    (MAP_SHARED | MAP_PRIVATE)) == 0) &&
 			    myaddr >= seg->s_base &&
 			    myaddr + mylen <=
--- old/usr/src/uts/common/os/panic.c	2015-05-08 18:10:29.863090986 -0400
+++ new/usr/src/uts/common/os/panic.c	2015-05-08 18:10:29.869899833 -0400
@@ -223,7 +223,6 @@
 	(void) setjmp(&t->t_pcb);
 	t->t_flag |= T_PANIC;
 
-	t->t_schedflag |= TS_DONT_SWAP;
 	t->t_bound_cpu = cp;
 	t->t_preempt++;
 
--- old/usr/src/uts/common/os/sched.c	2015-05-08 18:10:30.070380745 -0400
+++ new/usr/src/uts/common/os/sched.c	2015-05-08 18:10:30.077252127 -0400
@@ -54,265 +54,37 @@
 #include <vm/seg_kmem.h>
 #include <sys/callb.h>
 
-/*
- * The swapper sleeps on runout when there is no one to swap in.
- * It sleeps on runin when it could not find space to swap someone
- * in or after swapping someone in.
- */
-char	runout;
-char	runin;
-char	wake_sched;	/* flag tells clock to wake swapper on next tick */
-char	wake_sched_sec;	/* flag tells clock to wake swapper after a second */
-
-/*
- * The swapper swaps processes to reduce memory demand and runs
- * when avefree < desfree.  The swapper resorts to SOFTSWAP when
- * avefree < desfree which results in swapping out all processes
- * sleeping for more than maxslp seconds.  HARDSWAP occurs when the
- * system is on the verge of thrashing and this results in swapping
- * out runnable threads or threads sleeping for less than maxslp secs.
- *
- * The swapper runs through all the active processes in the system
- * and invokes the scheduling class specific swapin/swapout routine
- * for every thread in the process to obtain an effective priority
- * for the process.  A priority of -1 implies that the thread isn't
- * swappable.  This effective priority is used to find the most
- * eligible process to swapout or swapin.
- *
- * NOTE:  Threads which have been swapped are not linked on any
- *	  queue and their dispatcher lock points at the "swapped_lock".
- *
- * Processes containing threads with the TS_DONT_SWAP flag set cannot be
- * swapped out immediately by the swapper.  This is due to the fact that
- * such threads may be holding locks which may be needed by the swapper
- * to push its pages out.  The TS_SWAPENQ flag is set on such threads
- * to prevent them running in user mode.  When such threads reach a
- * safe point (i.e., are not holding any locks - CL_TRAPRET), they
- * queue themseleves onto the swap queue which is processed by the
- * swapper.  This results in reducing memory demand when the system
- * is desparate for memory as the thread can't run in user mode.
- *
- * The swap queue consists of threads, linked via t_link, which are
- * haven't been swapped, are runnable but not on the run queue.  The
- * swap queue is protected by the "swapped_lock".  The dispatcher
- * lock (t_lockp) of all threads on the swap queue points at the
- * "swapped_lock".  Thus, the entire queue and/or threads on the
- * queue can be locked by acquiring "swapped_lock".
- */
-static kthread_t *tswap_queue;
-extern disp_lock_t swapped_lock; /* protects swap queue and threads on it */
-
-int	maxslp = 0;
 pgcnt_t	avefree;	/* 5 sec moving average of free memory */
 pgcnt_t	avefree30;	/* 30 sec moving average of free memory */
 
 /*
- * Minimum size used to decide if sufficient memory is available
- * before a process is swapped in.  This is necessary since in most
- * cases the actual size of a process (p_swrss) being swapped in
- * is usually 2 pages (kernel stack pages).  This is due to the fact
- * almost all user pages of a process are stolen by pageout before
- * the swapper decides to swapout it out.
- */
-int	min_procsize = 12;
-
-static int	swapin(proc_t *);
-static int	swapout(proc_t *, uint_t *, int);
-static void	process_swap_queue();
-
-#ifdef __sparc
-extern void lwp_swapin(kthread_t *);
-#endif /* __sparc */
-
-/*
- * Counters to keep track of the number of swapins or swapouts.
- */
-uint_t tot_swapped_in, tot_swapped_out;
-uint_t softswap, hardswap, swapqswap;
-
-/*
- * Macro to determine if a process is eligble to be swapped.
- */
-#define	not_swappable(p)					\
-	(((p)->p_flag & SSYS) || (p)->p_stat == SIDL ||		\
-	    (p)->p_stat == SZOMB || (p)->p_as == NULL ||	\
-	    (p)->p_as == &kas)
-
-/*
  * Memory scheduler.
  */
 void
 sched()
 {
 	kthread_id_t	t;
-	pri_t		proc_pri;
-	pri_t		thread_pri;
-	pri_t		swapin_pri;
-	int		desperate;
-	pgcnt_t		needs;
-	int		divisor;
-	proc_t		*prp;
-	proc_t		*swapout_prp;
-	proc_t		*swapin_prp;
-	spgcnt_t	avail;
-	int		chosen_pri;
-	time_t		swapout_time;
-	time_t		swapin_proc_time;
 	callb_cpr_t	cprinfo;
 	kmutex_t	swap_cpr_lock;
 
 	mutex_init(&swap_cpr_lock, NULL, MUTEX_DEFAULT, NULL);
 	CALLB_CPR_INIT(&cprinfo, &swap_cpr_lock, callb_generic_cpr, "sched");
-	if (maxslp == 0)
-		maxslp = MAXSLP;
-loop:
-	needs = 0;
-	desperate = 0;
-
-	swapin_pri = v.v_nglobpris;
-	swapin_prp = NULL;
-	chosen_pri = -1;
-
-	process_swap_queue();
-
-	/*
-	 * Set desperate if
-	 * 	1.  At least 2 runnable processes (on average).
-	 *	2.  Short (5 sec) and longer (30 sec) average is less
-	 *	    than minfree and desfree respectively.
-	 *	3.  Pagein + pageout rate is excessive.
-	 */
-	if (avenrun[0] >= 2 * FSCALE &&
-	    (MAX(avefree, avefree30) < desfree) &&
-	    (pginrate + pgoutrate > maxpgio || avefree < minfree)) {
-		TRACE_4(TR_FAC_SCHED, TR_DESPERATE,
-		    "desp:avefree: %d, avefree30: %d, freemem: %d"
-		    " pginrate: %d\n", avefree, avefree30, freemem, pginrate);
-		desperate = 1;
-		goto unload;
-	}
-
-	/*
-	 * Search list of processes to swapin and swapout deadwood.
-	 */
-	swapin_proc_time = 0;
-top:
-	mutex_enter(&pidlock);
-	for (prp = practive; prp != NULL; prp = prp->p_next) {
-		if (not_swappable(prp))
-			continue;
-
-		/*
-		 * Look at processes with at least one swapped lwp.
-		 */
-		if (prp->p_swapcnt) {
-			time_t proc_time;
 
-			/*
-			 * Higher priority processes are good candidates
-			 * to swapin.
-			 */
-			mutex_enter(&prp->p_lock);
-			proc_pri = -1;
-			t = prp->p_tlist;
-			proc_time = 0;
-			do {
-				if (t->t_schedflag & TS_LOAD)
-					continue;
-
-				thread_lock(t);
-				thread_pri = CL_SWAPIN(t, 0);
-				thread_unlock(t);
-
-				if (t->t_stime - proc_time > 0)
-					proc_time = t->t_stime;
-				if (thread_pri > proc_pri)
-					proc_pri = thread_pri;
-			} while ((t = t->t_forw) != prp->p_tlist);
-			mutex_exit(&prp->p_lock);
-
-			if (proc_pri == -1)
-				continue;
-
-			TRACE_3(TR_FAC_SCHED, TR_CHOOSE_SWAPIN,
-			    "prp %p epri %d proc_time %d",
-			    prp, proc_pri, proc_time);
-
-			/*
-			 * Swapin processes with a high effective priority.
-			 */
-			if (swapin_prp == NULL || proc_pri > chosen_pri) {
-				swapin_prp = prp;
-				chosen_pri = proc_pri;
-				swapin_pri = proc_pri;
-				swapin_proc_time = proc_time;
-			}
-		} else {
-			/*
-			 * No need to soft swap if we have sufficient
-			 * memory.
-			 */
-			if (avefree > desfree ||
-			    avefree < desfree && freemem > desfree)
-				continue;
-
-			/*
-			 * Skip processes that are exiting
-			 * or whose address spaces are locked.
-			 */
-			mutex_enter(&prp->p_lock);
-			if ((prp->p_flag & SEXITING) ||
-			    (prp->p_as != NULL && AS_ISPGLCK(prp->p_as))) {
-				mutex_exit(&prp->p_lock);
-				continue;
-			}
-
-			/*
-			 * Softswapping to kick out deadwood.
+	for (;;) {
+		if (avenrun[0] >= 2 * FSCALE &&
+		    (MAX(avefree, avefree30) < desfree) &&
+		    (pginrate + pgoutrate > maxpgio || avefree < minfree)) {
+			/*
+			 * Unload all unloadable modules, free all other memory
+			 * resources we can find, then look for a thread to
+			 * hardswap.
 			 */
-			proc_pri = -1;
-			t = prp->p_tlist;
-			do {
-				if ((t->t_schedflag & (TS_SWAPENQ |
-				    TS_ON_SWAPQ | TS_LOAD)) != TS_LOAD)
-					continue;
-
-				thread_lock(t);
-				thread_pri = CL_SWAPOUT(t, SOFTSWAP);
-				thread_unlock(t);
-				if (thread_pri > proc_pri)
-					proc_pri = thread_pri;
-			} while ((t = t->t_forw) != prp->p_tlist);
-
-			if (proc_pri != -1) {
-				uint_t swrss;
-
-				mutex_exit(&pidlock);
-
-				TRACE_1(TR_FAC_SCHED, TR_SOFTSWAP,
-				    "softswap:prp %p", prp);
-
-				(void) swapout(prp, &swrss, SOFTSWAP);
-				softswap++;
-				prp->p_swrss += swrss;
-				mutex_exit(&prp->p_lock);
-				goto top;
-			}
-			mutex_exit(&prp->p_lock);
+			modreap();
+			segkp_cache_free();
 		}
-	}
-	if (swapin_prp != NULL)
-		mutex_enter(&swapin_prp->p_lock);
-	mutex_exit(&pidlock);
-
-	if (swapin_prp == NULL) {
-		TRACE_3(TR_FAC_SCHED, TR_RUNOUT,
-		"schedrunout:runout nswapped: %d, avefree: %ld freemem: %ld",
-		    nswapped, avefree, freemem);
 
 		t = curthread;
 		thread_lock(t);
-		runout++;
 		t->t_schedflag |= (TS_ALLSTART & ~TS_CSTART);
 		t->t_whystop = PR_SUSPENDED;
 		t->t_whatstop = SUSPEND_NORMAL;
@@ -320,620 +92,10 @@
 		mutex_enter(&swap_cpr_lock);
 		CALLB_CPR_SAFE_BEGIN(&cprinfo);
 		mutex_exit(&swap_cpr_lock);
-		thread_stop(t);		/* change state and drop lock */
+		thread_stop(t);		/* change to stop state and drop lock */
 		swtch();
 		mutex_enter(&swap_cpr_lock);
 		CALLB_CPR_SAFE_END(&cprinfo, &swap_cpr_lock);
 		mutex_exit(&swap_cpr_lock);
-		goto loop;
-	}
-
-	/*
-	 * Decide how deserving this process is to be brought in.
-	 * Needs is an estimate of how much core the process will
-	 * need.  If the process has been out for a while, then we
-	 * will bring it in with 1/2 the core needed, otherwise
-	 * we are conservative.
-	 */
-	divisor = 1;
-	swapout_time = (ddi_get_lbolt() - swapin_proc_time) / hz;
-	if (swapout_time > maxslp / 2)
-		divisor = 2;
-
-	needs = MIN(swapin_prp->p_swrss, lotsfree);
-	needs = MAX(needs, min_procsize);
-	needs = needs / divisor;
-
-	/*
-	 * Use freemem, since we want processes to be swapped
-	 * in quickly.
-	 */
-	avail = freemem - deficit;
-	if (avail > (spgcnt_t)needs) {
-		deficit += needs;
-
-		TRACE_2(TR_FAC_SCHED, TR_SWAPIN_VALUES,
-		    "swapin_values: prp %p needs %lu", swapin_prp, needs);
-
-		if (swapin(swapin_prp)) {
-			mutex_exit(&swapin_prp->p_lock);
-			goto loop;
-		}
-		deficit -= MIN(needs, deficit);
-		mutex_exit(&swapin_prp->p_lock);
-	} else {
-		mutex_exit(&swapin_prp->p_lock);
-		/*
-		 * If deficit is high, too many processes have been
-		 * swapped in so wait a sec before attempting to
-		 * swapin more.
-		 */
-		if (freemem > needs) {
-			TRACE_2(TR_FAC_SCHED, TR_HIGH_DEFICIT,
-			    "deficit: prp %p needs %lu", swapin_prp, needs);
-			goto block;
-		}
-	}
-
-	TRACE_2(TR_FAC_SCHED, TR_UNLOAD,
-	    "unload: prp %p needs %lu", swapin_prp, needs);
-
-unload:
-	/*
-	 * Unload all unloadable modules, free all other memory
-	 * resources we can find, then look for a thread to hardswap.
-	 */
-	modreap();
-	segkp_cache_free();
-
-	swapout_prp = NULL;
-	mutex_enter(&pidlock);
-	for (prp = practive; prp != NULL; prp = prp->p_next) {
-
-		/*
-		 * No need to soft swap if we have sufficient
-		 * memory.
-		 */
-		if (not_swappable(prp))
-			continue;
-
-		if (avefree > minfree ||
-		    avefree < minfree && freemem > desfree) {
-			swapout_prp = NULL;
-			break;
-		}
-
-		/*
-		 * Skip processes that are exiting
-		 * or whose address spaces are locked.
-		 */
-		mutex_enter(&prp->p_lock);
-		if ((prp->p_flag & SEXITING) ||
-		    (prp->p_as != NULL && AS_ISPGLCK(prp->p_as))) {
-			mutex_exit(&prp->p_lock);
-			continue;
-		}
-
-		proc_pri = -1;
-		t = prp->p_tlist;
-		do {
-			if ((t->t_schedflag & (TS_SWAPENQ |
-			    TS_ON_SWAPQ | TS_LOAD)) != TS_LOAD)
-				continue;
-
-			thread_lock(t);
-			thread_pri = CL_SWAPOUT(t, HARDSWAP);
-			thread_unlock(t);
-			if (thread_pri > proc_pri)
-				proc_pri = thread_pri;
-		} while ((t = t->t_forw) != prp->p_tlist);
-
-		mutex_exit(&prp->p_lock);
-		if (proc_pri == -1)
-			continue;
-
-		/*
-		 * Swapout processes sleeping with a lower priority
-		 * than the one currently being swapped in, if any.
-		 */
-		if (swapin_prp == NULL || swapin_pri > proc_pri) {
-			TRACE_2(TR_FAC_SCHED, TR_CHOOSE_SWAPOUT,
-			    "hardswap: prp %p needs %lu", prp, needs);
-
-			if (swapout_prp == NULL || proc_pri < chosen_pri) {
-				swapout_prp = prp;
-				chosen_pri = proc_pri;
-			}
-		}
-	}
-
-	/*
-	 * Acquire the "p_lock" before dropping "pidlock"
-	 * to prevent the proc structure from being freed
-	 * if the process exits before swapout completes.
-	 */
-	if (swapout_prp != NULL)
-		mutex_enter(&swapout_prp->p_lock);
-	mutex_exit(&pidlock);
-
-	if ((prp = swapout_prp) != NULL) {
-		uint_t swrss = 0;
-		int swapped;
-
-		swapped = swapout(prp, &swrss, HARDSWAP);
-		if (swapped) {
-			/*
-			 * If desperate, we want to give the space obtained
-			 * by swapping this process out to processes in core,
-			 * so we give them a chance by increasing deficit.
-			 */
-			prp->p_swrss += swrss;
-			if (desperate)
-				deficit += MIN(prp->p_swrss, lotsfree);
-			hardswap++;
-		}
-		mutex_exit(&swapout_prp->p_lock);
-
-		if (swapped)
-			goto loop;
-	}
-
-	/*
-	 * Delay for 1 second and look again later.
-	 */
-	TRACE_3(TR_FAC_SCHED, TR_RUNIN,
-	    "schedrunin:runin nswapped: %d, avefree: %ld freemem: %ld",
-	    nswapped, avefree, freemem);
-
-block:
-	t = curthread;
-	thread_lock(t);
-	runin++;
-	t->t_schedflag |= (TS_ALLSTART & ~TS_CSTART);
-	t->t_whystop = PR_SUSPENDED;
-	t->t_whatstop = SUSPEND_NORMAL;
-	(void) new_mstate(t, LMS_SLEEP);
-	mutex_enter(&swap_cpr_lock);
-	CALLB_CPR_SAFE_BEGIN(&cprinfo);
-	mutex_exit(&swap_cpr_lock);
-	thread_stop(t);		/* change to stop state and drop lock */
-	swtch();
-	mutex_enter(&swap_cpr_lock);
-	CALLB_CPR_SAFE_END(&cprinfo, &swap_cpr_lock);
-	mutex_exit(&swap_cpr_lock);
-	goto loop;
-}
-
-/*
- * Remove the specified thread from the swap queue.
- */
-static void
-swapdeq(kthread_id_t tp)
-{
-	kthread_id_t *tpp;
-
-	ASSERT(THREAD_LOCK_HELD(tp));
-	ASSERT(tp->t_schedflag & TS_ON_SWAPQ);
-
-	tpp = &tswap_queue;
-	for (;;) {
-		ASSERT(*tpp != NULL);
-		if (*tpp == tp)
-			break;
-		tpp = &(*tpp)->t_link;
-	}
-	*tpp = tp->t_link;
-	tp->t_schedflag &= ~TS_ON_SWAPQ;
-}
-
-/*
- * Swap in lwps.  Returns nonzero on success (i.e., if at least one lwp is
- * swapped in) and 0 on failure.
- */
-static int
-swapin(proc_t *pp)
-{
-	kthread_id_t tp;
-	int err;
-	int num_swapped_in = 0;
-	struct cpu *cpup = CPU;
-	pri_t thread_pri;
-
-	ASSERT(MUTEX_HELD(&pp->p_lock));
-	ASSERT(pp->p_swapcnt);
-
-top:
-	tp = pp->p_tlist;
-	do {
-		/*
-		 * Only swapin eligible lwps (specified by the scheduling
-		 * class) which are unloaded and ready to run.
-		 */
-		thread_lock(tp);
-		thread_pri = CL_SWAPIN(tp, 0);
-		if (thread_pri != -1 && tp->t_state == TS_RUN &&
-		    (tp->t_schedflag & TS_LOAD) == 0) {
-			size_t stack_size;
-			pgcnt_t stack_pages;
-
-			ASSERT((tp->t_schedflag & TS_ON_SWAPQ) == 0);
-
-			thread_unlock(tp);
-			/*
-			 * Now drop the p_lock since the stack needs
-			 * to brought in.
-			 */
-			mutex_exit(&pp->p_lock);
-
-			stack_size = swapsize(tp->t_swap);
-			stack_pages = btopr(stack_size);
-			/* Kernel probe */
-			TNF_PROBE_4(swapin_lwp, "vm swap swapin", /* CSTYLED */,
-			    tnf_pid,		pid,		pp->p_pid,
-			    tnf_lwpid,		lwpid,		tp->t_tid,
-			    tnf_kthread_id,	tid,		tp,
-			    tnf_ulong,		page_count,	stack_pages);
-
-			rw_enter(&kas.a_lock, RW_READER);
-			err = segkp_fault(segkp->s_as->a_hat, segkp,
-			    tp->t_swap, stack_size, F_SOFTLOCK, S_OTHER);
-			rw_exit(&kas.a_lock);
-
-			/*
-			 * Re-acquire the p_lock.
-			 */
-			mutex_enter(&pp->p_lock);
-			if (err) {
-				num_swapped_in = 0;
-				break;
-			} else {
-#ifdef __sparc
-				lwp_swapin(tp);
-#endif /* __sparc */
-				CPU_STATS_ADDQ(cpup, vm, swapin, 1);
-				CPU_STATS_ADDQ(cpup, vm, pgswapin,
-				    stack_pages);
-
-				pp->p_swapcnt--;
-				pp->p_swrss -= stack_pages;
-
-				thread_lock(tp);
-				tp->t_schedflag |= TS_LOAD;
-				dq_sruninc(tp);
-
-				/* set swapin time */
-				tp->t_stime = ddi_get_lbolt();
-				thread_unlock(tp);
-
-				nswapped--;
-				tot_swapped_in++;
-				num_swapped_in++;
-
-				TRACE_2(TR_FAC_SCHED, TR_SWAPIN,
-				    "swapin: pp %p stack_pages %lu",
-				    pp, stack_pages);
-				goto top;
-			}
-		}
-		thread_unlock(tp);
-	} while ((tp = tp->t_forw) != pp->p_tlist);
-	return (num_swapped_in);
-}
-
-/*
- * Swap out lwps.  Returns nonzero on success (i.e., if at least one lwp is
- * swapped out) and 0 on failure.
- */
-static int
-swapout(proc_t *pp, uint_t *swrss, int swapflags)
-{
-	kthread_id_t tp;
-	pgcnt_t ws_pages = 0;
-	int err;
-	int swapped_lwps = 0;
-	struct as *as = pp->p_as;
-	struct cpu *cpup = CPU;
-	pri_t thread_pri;
-
-	ASSERT(MUTEX_HELD(&pp->p_lock));
-
-	if (pp->p_flag & SEXITING)
-		return (0);
-
-top:
-	tp = pp->p_tlist;
-	do {
-		klwp_t *lwp = ttolwp(tp);
-
-		/*
-		 * Swapout eligible lwps (specified by the scheduling
-		 * class) which don't have TS_DONT_SWAP set.  Set the
-		 * "intent to swap" flag (TS_SWAPENQ) on threads
-		 * which have TS_DONT_SWAP set so that they can be
-		 * swapped if and when they reach a safe point.
-		 */
-		thread_lock(tp);
-		thread_pri = CL_SWAPOUT(tp, swapflags);
-		if (thread_pri != -1) {
-			if (tp->t_schedflag & TS_DONT_SWAP) {
-				tp->t_schedflag |= TS_SWAPENQ;
-				tp->t_trapret = 1;
-				aston(tp);
-			} else {
-				pgcnt_t stack_pages;
-				size_t stack_size;
-
-				ASSERT((tp->t_schedflag &
-				    (TS_DONT_SWAP | TS_LOAD)) == TS_LOAD);
-
-				if (lock_try(&tp->t_lock)) {
-					/*
-					 * Remove thread from the swap_queue.
-					 */
-					if (tp->t_schedflag & TS_ON_SWAPQ) {
-						ASSERT(!(tp->t_schedflag &
-						    TS_SWAPENQ));
-						swapdeq(tp);
-					} else if (tp->t_state == TS_RUN)
-						dq_srundec(tp);
-
-					tp->t_schedflag &=
-					    ~(TS_LOAD | TS_SWAPENQ);
-					lock_clear(&tp->t_lock);
-
-					/*
-					 * Set swapout time if the thread isn't
-					 * sleeping.
-					 */
-					if (tp->t_state != TS_SLEEP)
-						tp->t_stime = ddi_get_lbolt();
-					thread_unlock(tp);
-
-					nswapped++;
-					tot_swapped_out++;
-
-					lwp->lwp_ru.nswap++;
-
-					/*
-					 * Now drop the p_lock since the
-					 * stack needs to pushed out.
-					 */
-					mutex_exit(&pp->p_lock);
-
-					stack_size = swapsize(tp->t_swap);
-					stack_pages = btopr(stack_size);
-					ws_pages += stack_pages;
-					/* Kernel probe */
-					TNF_PROBE_4(swapout_lwp,
-					    "vm swap swapout",
-					    /* CSTYLED */,
-					    tnf_pid, pid, pp->p_pid,
-					    tnf_lwpid, lwpid, tp->t_tid,
-					    tnf_kthread_id, tid, tp,
-					    tnf_ulong, page_count,
-					    stack_pages);
-
-					rw_enter(&kas.a_lock, RW_READER);
-					err = segkp_fault(segkp->s_as->a_hat,
-					    segkp, tp->t_swap, stack_size,
-					    F_SOFTUNLOCK, S_WRITE);
-					rw_exit(&kas.a_lock);
-
-					if (err) {
-						cmn_err(CE_PANIC,
-						    "swapout: segkp_fault "
-						    "failed err: %d", err);
-					}
-					CPU_STATS_ADDQ(cpup,
-					    vm, pgswapout, stack_pages);
-
-					mutex_enter(&pp->p_lock);
-					pp->p_swapcnt++;
-					swapped_lwps++;
-					goto top;
-				}
-			}
-		}
-		thread_unlock(tp);
-	} while ((tp = tp->t_forw) != pp->p_tlist);
-
-	/*
-	 * Unload address space when all lwps are swapped out.
-	 */
-	if (pp->p_swapcnt == pp->p_lwpcnt) {
-		size_t as_size = 0;
-
-		/*
-		 * Avoid invoking as_swapout() if the process has
-		 * no MMU resources since pageout will eventually
-		 * steal pages belonging to this address space.  This
-		 * saves CPU cycles as the number of pages that are
-		 * potentially freed or pushed out by the segment
-		 * swapout operation is very small.
-		 */
-		if (rm_asrss(pp->p_as) != 0)
-			as_size = as_swapout(as);
-
-		CPU_STATS_ADDQ(cpup, vm, pgswapout, btop(as_size));
-		CPU_STATS_ADDQ(cpup, vm, swapout, 1);
-		ws_pages += btop(as_size);
-
-		TRACE_2(TR_FAC_SCHED, TR_SWAPOUT,
-		    "swapout: pp %p pages_pushed %lu", pp, ws_pages);
-		/* Kernel probe */
-		TNF_PROBE_2(swapout_process, "vm swap swapout", /* CSTYLED */,
-		    tnf_pid,	pid,		pp->p_pid,
-		    tnf_ulong,	page_count,	ws_pages);
-	}
-	*swrss = ws_pages;
-	return (swapped_lwps);
-}
-
-void
-swapout_lwp(klwp_t *lwp)
-{
-	kthread_id_t tp = curthread;
-
-	ASSERT(curthread == lwptot(lwp));
-
-	/*
-	 * Don't insert the thread onto the swap queue if
-	 * sufficient memory is available.
-	 */
-	if (avefree > desfree || avefree < desfree && freemem > desfree) {
-		thread_lock(tp);
-		tp->t_schedflag &= ~TS_SWAPENQ;
-		thread_unlock(tp);
-		return;
-	}
-
-	/*
-	 * Lock the thread, then move it to the swapped queue from the
-	 * onproc queue and set its state to be TS_RUN.
-	 */
-	thread_lock(tp);
-	ASSERT(tp->t_state == TS_ONPROC);
-	if (tp->t_schedflag & TS_SWAPENQ) {
-		tp->t_schedflag &= ~TS_SWAPENQ;
-
-		/*
-		 * Set the state of this thread to be runnable
-		 * and move it from the onproc queue to the swap queue.
-		 */
-		disp_swapped_enq(tp);
-
-		/*
-		 * Insert the thread onto the swap queue.
-		 */
-		tp->t_link = tswap_queue;
-		tswap_queue = tp;
-		tp->t_schedflag |= TS_ON_SWAPQ;
-
-		thread_unlock_nopreempt(tp);
-
-		TRACE_1(TR_FAC_SCHED, TR_SWAPOUT_LWP, "swapout_lwp:%x", lwp);
-
-		swtch();
-	} else {
-		thread_unlock(tp);
-	}
-}
-
-/*
- * Swap all threads on the swap queue.
- */
-static void
-process_swap_queue(void)
-{
-	kthread_id_t tp;
-	uint_t ws_pages;
-	proc_t *pp;
-	struct cpu *cpup = CPU;
-	klwp_t *lwp;
-	int err;
-
-	if (tswap_queue == NULL)
-		return;
-
-	/*
-	 * Acquire the "swapped_lock" which locks the swap queue,
-	 * and unload the stacks of all threads on it.
-	 */
-	disp_lock_enter(&swapped_lock);
-	while ((tp = tswap_queue) != NULL) {
-		pgcnt_t stack_pages;
-		size_t stack_size;
-
-		tswap_queue = tp->t_link;
-		tp->t_link = NULL;
-
-		/*
-		 * Drop the "dispatcher lock" before acquiring "t_lock"
-		 * to avoid spinning on it since the thread at the front
-		 * of the swap queue could be pinned before giving up
-		 * its "t_lock" in resume.
-		 */
-		disp_lock_exit(&swapped_lock);
-		lock_set(&tp->t_lock);
-
-		/*
-		 * Now, re-acquire the "swapped_lock".  Acquiring this lock
-		 * results in locking the thread since its dispatcher lock
-		 * (t_lockp) is the "swapped_lock".
-		 */
-		disp_lock_enter(&swapped_lock);
-		ASSERT(tp->t_state == TS_RUN);
-		ASSERT(tp->t_schedflag & (TS_LOAD | TS_ON_SWAPQ));
-
-		tp->t_schedflag &= ~(TS_LOAD | TS_ON_SWAPQ);
-		tp->t_stime = ddi_get_lbolt();		/* swapout time */
-		disp_lock_exit(&swapped_lock);
-		lock_clear(&tp->t_lock);
-
-		lwp = ttolwp(tp);
-		lwp->lwp_ru.nswap++;
-
-		pp = ttoproc(tp);
-		stack_size = swapsize(tp->t_swap);
-		stack_pages = btopr(stack_size);
-
-		/* Kernel probe */
-		TNF_PROBE_4(swapout_lwp, "vm swap swapout", /* CSTYLED */,
-		    tnf_pid,		pid,		pp->p_pid,
-		    tnf_lwpid,		lwpid,		tp->t_tid,
-		    tnf_kthread_id,	tid,		tp,
-		    tnf_ulong,		page_count,	stack_pages);
-
-		rw_enter(&kas.a_lock, RW_READER);
-		err = segkp_fault(segkp->s_as->a_hat, segkp, tp->t_swap,
-		    stack_size, F_SOFTUNLOCK, S_WRITE);
-		rw_exit(&kas.a_lock);
-
-		if (err) {
-			cmn_err(CE_PANIC,
-			"process_swap_list: segkp_fault failed err: %d", err);
-		}
-		CPU_STATS_ADDQ(cpup, vm, pgswapout, stack_pages);
-
-		nswapped++;
-		tot_swapped_out++;
-		swapqswap++;
-
-		/*
-		 * Don't need p_lock since the swapper is the only
-		 * thread which increments/decrements p_swapcnt and p_swrss.
-		 */
-		ws_pages = stack_pages;
-		pp->p_swapcnt++;
-
-		TRACE_1(TR_FAC_SCHED, TR_SWAPQ_LWP, "swaplist: pp %p", pp);
-
-		/*
-		 * Unload address space when all lwps are swapped out.
-		 */
-		if (pp->p_swapcnt == pp->p_lwpcnt) {
-			size_t as_size = 0;
-
-			if (rm_asrss(pp->p_as) != 0)
-				as_size = as_swapout(pp->p_as);
-
-			CPU_STATS_ADDQ(cpup, vm, pgswapout,
-			    btop(as_size));
-			CPU_STATS_ADDQ(cpup, vm, swapout, 1);
-
-			ws_pages += btop(as_size);
-
-			TRACE_2(TR_FAC_SCHED, TR_SWAPQ_PROC,
-			    "swaplist_proc: pp %p pages_pushed: %lu",
-			    pp, ws_pages);
-			/* Kernel probe */
-			TNF_PROBE_2(swapout_process, "vm swap swapout",
-			    /* CSTYLED */,
-			    tnf_pid,	pid,		pp->p_pid,
-			    tnf_ulong,	page_count,	ws_pages);
-		}
-		pp->p_swrss += ws_pages;
-		disp_lock_enter(&swapped_lock);
 	}
-	disp_lock_exit(&swapped_lock);
 }
--- old/usr/src/uts/common/os/sunddi.c	2015-05-08 18:10:30.296018950 -0400
+++ new/usr/src/uts/common/os/sunddi.c	2015-05-08 18:10:30.303384653 -0400
@@ -8368,8 +8368,8 @@
 	 * locked) to be allowed for LONGTERM.
 	 */
 	if (flags & DDI_UMEMLOCK_LONGTERM) {
-		extern  struct seg_ops segspt_shmops;
-		extern	struct seg_ops segdev_ops;
+		extern const struct seg_ops segspt_shmops;
+		extern const struct seg_ops segdev_ops;
 		AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 		for (seg = as_segat(as, addr); ; seg = AS_SEGNEXT(as, seg)) {
 			if (seg == NULL || seg->s_base > addr + len)
@@ -8378,9 +8378,9 @@
 				continue;
 			if (((seg->s_ops != &segvn_ops) &&
 			    (seg->s_ops != &segspt_shmops)) ||
-			    ((SEGOP_GETVP(seg, addr, &vp) == 0 &&
+			    ((segop_getvp(seg, addr, &vp) == 0 &&
 			    vp != NULL && vp->v_type == VREG) &&
-			    (SEGOP_GETTYPE(seg, addr) & MAP_SHARED))) {
+			    (segop_gettype(seg, addr) & MAP_SHARED))) {
 				as_pageunlock(as, p->pparray,
 				    addr, len, p->s_flags);
 				AS_LOCK_EXIT(as, &as->a_lock);
--- old/usr/src/uts/common/os/timers.c	2015-05-08 18:10:30.769517670 -0400
+++ new/usr/src/uts/common/os/timers.c	2015-05-08 18:10:30.776353810 -0400
@@ -654,13 +654,6 @@
 		thread_lock(t);
 		switch (t->t_state) {
 		case TS_SLEEP:
-			/*
-			 * Don't touch the lwp is it is swapped out.
-			 */
-			if (!(t->t_schedflag & TS_LOAD)) {
-				mstate = LMS_SLEEP;
-				break;
-			}
 			switch (mstate = ttolwp(t)->lwp_mstate.ms_prev) {
 			case LMS_TFAULT:
 			case LMS_DFAULT:
--- old/usr/src/uts/common/os/urw.c	2015-05-08 18:10:31.007373983 -0400
+++ new/usr/src/uts/common/os/urw.c	2015-05-08 18:10:31.014197734 -0400
@@ -56,8 +56,8 @@
 #include <vm/seg_spt.h>
 #include <vm/seg_kmem.h>
 
-extern struct seg_ops segdev_ops;	/* needs a header file */
-extern struct seg_ops segspt_shmops;	/* needs a header file */
+extern const struct seg_ops segdev_ops;	/* needs a header file */
+extern const struct seg_ops segspt_shmops;	/* needs a header file */
 
 static int
 page_valid(struct seg *seg, caddr_t addr)
@@ -72,11 +72,11 @@
 	 */
 	vattr.va_mask = AT_SIZE;
 	if (seg->s_ops == &segvn_ops &&
-	    SEGOP_GETVP(seg, addr, &vp) == 0 &&
+	    segop_getvp(seg, addr, &vp) == 0 &&
 	    vp != NULL && vp->v_type == VREG &&
 	    VOP_GETATTR(vp, &vattr, 0, CRED(), NULL) == 0) {
 		u_offset_t size = roundup(vattr.va_size, (u_offset_t)PAGESIZE);
-		u_offset_t offset = SEGOP_GETOFFSET(seg, addr);
+		u_offset_t offset = segop_getoffset(seg, addr);
 
 		if (offset >= size)
 			return (0);
@@ -96,7 +96,7 @@
 	 * type is neither MAP_SHARED nor MAP_PRIVATE.
 	 */
 	if (seg->s_ops == &segdev_ops &&
-	    ((SEGOP_GETTYPE(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
+	    ((segop_gettype(seg, addr) & (MAP_SHARED | MAP_PRIVATE)) == 0))
 		return (0);
 
 	/*
@@ -117,7 +117,7 @@
 		 * then there is backing store for the page.
 		 */
 		char incore = 0;
-		(void) SEGOP_INCORE(seg, addr, PAGESIZE, &incore);
+		(void) segop_incore(seg, addr, PAGESIZE, &incore);
 		if (incore == 0)
 			return (0);
 	}
@@ -209,12 +209,12 @@
 		AS_LOCK_EXIT(as, &as->a_lock);
 		return (ENXIO);
 	}
-	SEGOP_GETPROT(seg, page, 0, &prot);
+	segop_getprot(seg, page, 0, &prot);
 
 	protchanged = 0;
 	if ((prot & prot_rw) == 0) {
 		protchanged = 1;
-		err = SEGOP_SETPROT(seg, page, PAGESIZE, prot | prot_rw);
+		err = segop_setprot(seg, page, PAGESIZE, prot | prot_rw);
 
 		if (err == IE_RETRY) {
 			protchanged = 0;
@@ -244,9 +244,9 @@
 	else
 		rw = S_READ;
 
-	if (SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
+	if (segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTLOCK, rw)) {
 		if (protchanged)
-			(void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
+			(void) segop_setprot(seg, page, PAGESIZE, prot);
 		AS_LOCK_EXIT(as, &as->a_lock);
 		return (ENXIO);
 	}
@@ -303,10 +303,10 @@
 	if (rw == S_READ_NOCOW)
 		rw = S_READ;
 
-	(void) SEGOP_FAULT(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
+	(void) segop_fault(as->a_hat, seg, page, PAGESIZE, F_SOFTUNLOCK, rw);
 
 	if (protchanged)
-		(void) SEGOP_SETPROT(seg, page, PAGESIZE, prot);
+		(void) segop_setprot(seg, page, PAGESIZE, prot);
 
 	AS_LOCK_EXIT(as, &as->a_lock);
 
--- old/usr/src/uts/common/os/vm_subr.c	2015-05-08 18:10:31.209479634 -0400
+++ new/usr/src/uts/common/os/vm_subr.c	2015-05-08 18:10:31.216290735 -0400
@@ -378,7 +378,7 @@
 		if (seg->s_ops != &segvn_ops) {
 			AS_LOCK_EXIT(as, &as->a_lock);
 			return (ENOTSUP);
-		} else if ((SEGOP_GETTYPE(seg, uaddr) & MAP_PRIVATE) == 0) {
+		} else if ((segop_gettype(seg, uaddr) & MAP_PRIVATE) == 0) {
 			AS_LOCK_EXIT(as, &as->a_lock);
 			return (ENOTSUP);
 		}
--- old/usr/src/uts/common/os/waitq.c	2015-05-08 18:10:31.415705322 -0400
+++ new/usr/src/uts/common/os/waitq.c	2015-05-08 18:10:31.422559840 -0400
@@ -223,11 +223,6 @@
 	 */
 	t->t_waitrq = gethrtime_unscaled();
 
-	/*
-	 * Mark thread as not swappable.  If necessary, it will get
-	 * swapped out when it returns to the userland.
-	 */
-	t->t_schedflag |= TS_DONT_SWAP;
 	DTRACE_SCHED1(cpucaps__sleep, kthread_t *, t);
 	waitq_link(wq, t);
 
--- old/usr/src/uts/common/os/watchpoint.c	2015-05-08 18:10:31.618637076 -0400
+++ new/usr/src/uts/common/os/watchpoint.c	2015-05-08 18:10:31.625463448 -0400
@@ -182,11 +182,7 @@
 	/*
 	 * as->a_wpage can only be changed while the process is totally stopped.
 	 * Don't grab p_lock here.  Holding p_lock while grabbing the address
-	 * space lock leads to deadlocks with the clock thread.  Note that if an
-	 * as_fault() is servicing a fault to a watched page on behalf of an
-	 * XHAT provider, watchpoint will be temporarily cleared (and wp_prot
-	 * will be set to wp_oprot).  Since this is done while holding as writer
-	 * lock, we need to grab as lock (reader lock is good enough).
+	 * space lock leads to deadlocks with the clock thread.
 	 *
 	 * p_maplock prevents simultaneous execution of this function.  Under
 	 * normal circumstances, holdwatch() will stop all other threads, so the
@@ -311,9 +307,9 @@
 		retry:
 			seg = as_segat(as, addr);
 			ASSERT(seg != NULL);
-			SEGOP_GETPROT(seg, addr, 0, &oprot);
+			segop_getprot(seg, addr, 0, &oprot);
 			if (prot != oprot) {
-				err = SEGOP_SETPROT(seg, addr, PAGESIZE, prot);
+				err = segop_setprot(seg, addr, PAGESIZE, prot);
 				if (err == IE_RETRY) {
 					ASSERT(retrycnt == 0);
 					retrycnt++;
@@ -406,7 +402,7 @@
 		if ((seg = as_segat(as, vaddr)) != NULL &&
 		    !(pwp->wp_flags & WP_NOWATCH)) {
 			prot = pwp->wp_prot;
-			err = SEGOP_SETPROT(seg, vaddr, PAGESIZE, prot);
+			err = segop_setprot(seg, vaddr, PAGESIZE, prot);
 			if (err == IE_RETRY) {
 				ASSERT(retrycnt == 0);
 				retrycnt++;
@@ -504,7 +500,6 @@
 	if ((as == &kas) || avl_numnodes(&as->a_wpage) == 0)
 		return (0);
 
-	/* Grab the lock because of XHAT (see comment in pr_mappage()) */
 	AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
 	rv = pr_is_watchpage_as(addr, rw, as);
 	AS_LOCK_EXIT(as, &as->a_lock);
--- old/usr/src/uts/common/os/zone.c	2015-05-08 18:10:31.864031124 -0400
+++ new/usr/src/uts/common/os/zone.c	2015-05-08 18:10:31.871287533 -0400
@@ -5625,7 +5625,7 @@
 		 * it.
 		 */
 		vp = NULL;
-		if (SEGOP_GETVP(seg, seg->s_base, &vp) != 0 || vp == NULL)
+		if (segop_getvp(seg, seg->s_base, &vp) != 0 || vp == NULL)
 			continue;
 		if (!vn_can_change_zones(vp)) { /* bail on first match */
 			allow = 0;
--- old/usr/src/uts/common/sys/class.h	2015-05-08 18:10:32.272154583 -0400
+++ new/usr/src/uts/common/sys/class.h	2015-05-08 18:10:32.279331255 -0400
@@ -81,8 +81,6 @@
 	void	(*cl_exit)(kthread_t *);
 	void	(*cl_active)(kthread_t *);
 	void	(*cl_inactive)(kthread_t *);
-	pri_t	(*cl_swapin)(kthread_t *, int);
-	pri_t 	(*cl_swapout)(kthread_t *, int);
 	void 	(*cl_trapret)(kthread_t *);
 	void	(*cl_preempt)(kthread_t *);
 	void	(*cl_setrun)(kthread_t *);
@@ -196,10 +194,6 @@
 
 #define	CL_INACTIVE(t)		(*(t)->t_clfuncs->cl_inactive)(t)
 
-#define	CL_SWAPIN(t, flags)	(*(t)->t_clfuncs->cl_swapin)(t, flags)
-
-#define	CL_SWAPOUT(t, flags)	(*(t)->t_clfuncs->cl_swapout)(t, flags)
-
 #define	CL_TICK(t)		(*(t)->t_clfuncs->cl_tick)(t)
 
 #define	CL_TRAPRET(t)		(*(t)->t_clfuncs->cl_trapret)(t)
--- old/usr/src/uts/common/sys/disp.h	2015-05-08 18:10:32.471776680 -0400
+++ new/usr/src/uts/common/sys/disp.h	2015-05-08 18:10:32.478675595 -0400
@@ -30,8 +30,6 @@
 #ifndef _SYS_DISP_H
 #define	_SYS_DISP_H
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.11	*/
-
 #include <sys/priocntl.h>
 #include <sys/thread.h>
 #include <sys/class.h>
@@ -143,8 +141,6 @@
 extern void		swtch_to(kthread_t *);
 extern void		swtch_from_zombie(void)
 				__NORETURN;
-extern void		dq_sruninc(kthread_t *);
-extern void		dq_srundec(kthread_t *);
 extern void		cpu_rechoose(kthread_t *);
 extern void		cpu_surrender(kthread_t *);
 extern void		kpreempt(int);
--- old/usr/src/uts/common/sys/proc.h	2015-05-08 18:10:32.668461815 -0400
+++ new/usr/src/uts/common/sys/proc.h	2015-05-08 18:10:32.675272707 -0400
@@ -129,10 +129,8 @@
 struct corectl_content;
 
 /*
- * One structure allocated per active process.  It contains all
- * data needed about the process while the process may be swapped
- * out.  Other per-process data (user.h) is also inside the proc structure.
- * Lightweight-process data (lwp.h) and the kernel stack may be swapped out.
+ * One structure allocated per active process.  Per-process data (user.h) is
+ * also inside the proc structure.
  */
 typedef struct	proc {
 	/*
@@ -146,7 +144,6 @@
 	/*
 	 * Fields protected by pidlock
 	 */
-	int	p_swapcnt;		/* number of swapped out lwps */
 	char	p_stat;			/* status of process */
 	char	p_wcode;		/* current wait code */
 	ushort_t p_pidflag;		/* flags protected only by pidlock */
--- old/usr/src/uts/common/sys/sysinfo.h	2015-05-08 18:10:32.885388756 -0400
+++ new/usr/src/uts/common/sys/sysinfo.h	2015-05-08 18:10:32.892140591 -0400
@@ -252,10 +252,6 @@
 	uint64_t pgpgin;		/* pages paged in */
 	uint64_t pgout;			/* pageouts */
 	uint64_t pgpgout;		/* pages paged out */
-	uint64_t swapin;		/* swapins */
-	uint64_t pgswapin;		/* pages swapped in */
-	uint64_t swapout;		/* swapouts */
-	uint64_t pgswapout;		/* pages swapped out */
 	uint64_t zfod;			/* pages zero filled on demand */
 	uint64_t dfree;			/* pages freed by daemon or auto */
 	uint64_t scan;			/* pages examined by pageout daemon */
--- old/usr/src/uts/common/sys/systm.h	2015-05-08 18:10:33.089030777 -0400
+++ new/usr/src/uts/common/sys/systm.h	2015-05-08 18:10:33.096041774 -0400
@@ -63,11 +63,6 @@
 extern struct vnode *devicesdir;	/* pointer to /devices vnode */
 extern int interrupts_unleashed;	/* set after the spl0() in main() */
 
-extern char runin;		/* scheduling flag */
-extern char runout;		/* scheduling flag */
-extern char wake_sched;		/* causes clock to wake swapper on next tick */
-extern char wake_sched_sec;	/* causes clock to wake swapper after a sec */
-
 extern pgcnt_t	maxmem;		/* max available memory (pages) */
 extern pgcnt_t	physmem;	/* physical memory (pages) on this CPU */
 extern pfn_t	physmax;	/* highest numbered physical page present */
--- old/usr/src/uts/common/sys/thread.h	2015-05-08 18:10:33.297068354 -0400
+++ new/usr/src/uts/common/sys/thread.h	2015-05-08 18:10:33.303892324 -0400
@@ -155,9 +155,6 @@
 	struct _kcpc_ctx *t_cpc_ctx;	/* performance counter context */
 	struct _kcpc_set *t_cpc_set;	/* set this thread has bound */
 
-	/*
-	 * non swappable part of the lwp state.
-	 */
 	id_t		t_tid;		/* lwp's id */
 	id_t		t_waitfor;	/* target lwp id in lwp_wait() */
 	struct sigqueue	*t_sigqueue;	/* queue of siginfo structs */
@@ -268,7 +265,6 @@
 		void		  **ts_value;	/* array of value/key */
 	} *t_tsd;
 
-	clock_t		t_stime;	/* time stamp used by the swapper */
 	struct door_data *t_door;	/* door invocation data */
 	kmutex_t	*t_plockp;	/* pointer to process's p_lock */
 
@@ -399,10 +395,6 @@
  * Thread scheduler flag (t_schedflag) definitions.
  *	The thread must be locked via thread_lock() or equiv. to change these.
  */
-#define	TS_LOAD		0x0001	/* thread is in memory */
-#define	TS_DONT_SWAP	0x0002	/* thread/lwp should not be swapped */
-#define	TS_SWAPENQ	0x0004	/* swap thread when it reaches a safe point */
-#define	TS_ON_SWAPQ	0x0008	/* thread is on the swap queue */
 #define	TS_SIGNALLED	0x0010	/* thread was awakened by cv_signal() */
 #define	TS_PROJWAITQ	0x0020	/* thread is on its project's waitq */
 #define	TS_ZONEWAITQ	0x0040	/* thread is on its zone's waitq */
@@ -480,12 +472,6 @@
 #define	ASSIGNED_PRIO(t)	((t)->t_pri)
 
 /*
- * Macros to determine whether a thread can be swapped.
- * If t_lock is held, the thread is either on a processor or being swapped.
- */
-#define	SWAP_OK(t)	(!LOCK_HELD(&(t)->t_lock))
-
-/*
  * proctot(x)
  *	convert a proc pointer to a thread pointer. this only works with
  *	procs that have only one lwp.
@@ -653,12 +639,6 @@
 #define	THREAD_WAIT(tp, lp)	THREAD_SET_STATE(tp, TS_WAIT, lp)
 
 /*
- * Put thread in run state, and set the lock pointer to the dispatcher queue
- * lock pointer provided (i.e., the "swapped_lock").  This lock should be held.
- */
-#define	THREAD_SWAP(tp, lp)	THREAD_SET_STATE(tp, TS_RUN, lp)
-
-/*
  * Put the thread in zombie state and set the lock pointer to NULL.
  * The NULL will catch anything that tries to lock a zombie.
  */
--- old/usr/src/uts/common/sys/vmsystm.h	2015-05-08 18:10:33.513868255 -0400
+++ new/usr/src/uts/common/sys/vmsystm.h	2015-05-08 18:10:33.520677878 -0400
@@ -121,10 +121,8 @@
 struct page;
 struct anon;
 
-extern int maxslp;
 extern ulong_t pginrate;
 extern ulong_t pgoutrate;
-extern void swapout_lwp(klwp_t *);
 
 extern	int valid_va_range(caddr_t *basep, size_t *lenp, size_t minlen,
 		int dir);
--- old/usr/src/uts/common/sys/watchpoint.h	2015-05-08 18:10:33.715690252 -0400
+++ new/usr/src/uts/common/sys/watchpoint.h	2015-05-08 18:10:33.722538203 -0400
@@ -74,7 +74,7 @@
 
 /* wp_flags */
 #define	WP_NOWATCH	0x01	/* protections temporarily restored */
-#define	WP_SETPROT	0x02	/* SEGOP_SETPROT() needed on this page */
+#define	WP_SETPROT	0x02	/* segop_setprot() needed on this page */
 
 #ifdef	_KERNEL
 
--- old/usr/src/uts/common/syscall/utssys.c	2015-05-08 18:10:33.912430640 -0400
+++ new/usr/src/uts/common/syscall/utssys.c	2015-05-08 18:10:33.919223915 -0400
@@ -542,7 +542,7 @@
 				 * segment then skip it
 				 */
 				vp = NULL;
-				if ((SEGOP_GETVP(seg, seg->s_base, &vp)) ||
+				if ((segop_getvp(seg, seg->s_base, &vp)) ||
 				    (vp == NULL))
 					continue;
 
--- old/usr/src/uts/common/vm/anon.h	2015-05-08 18:10:34.131330880 -0400
+++ new/usr/src/uts/common/vm/anon.h	2015-05-08 18:10:34.138147859 -0400
@@ -439,8 +439,6 @@
 extern pgcnt_t	anon_grow(struct anon_hdr *, ulong_t *, pgcnt_t, pgcnt_t, int);
 extern void	anon_array_enter(struct anon_map *, ulong_t,
 			anon_sync_obj_t *);
-extern int	anon_array_try_enter(struct anon_map *, ulong_t,
-			anon_sync_obj_t *);
 extern void	anon_array_exit(anon_sync_obj_t *);
 
 /*
--- old/usr/src/uts/common/vm/as.h	2015-05-08 18:10:34.339474551 -0400
+++ new/usr/src/uts/common/vm/as.h	2015-05-08 18:10:34.346430007 -0400
@@ -125,7 +125,6 @@
 	vnode_t	**a_objectdir;	/* object directory (procfs) */
 	size_t	a_sizedir;	/* size of object directory */
 	struct as_callback *a_callbacks; /* callback list */
-	void *a_xhat;		/* list of xhat providers */
 	proc_t	*a_proc;	/* back pointer to proc */
 	size_t	a_resvsize;	/* size of reserved part of address space */
 };
@@ -135,24 +134,20 @@
 #define	AS_UNMAPWAIT		0x20
 #define	AS_NEEDSPURGE		0x10	/* mostly for seg_nf, see as_purge() */
 #define	AS_NOUNMAPWAIT		0x02
-#define	AS_BUSY			0x01	/* needed by XHAT framework */
 
 #define	AS_ISPGLCK(as)		((as)->a_flags & AS_PAGLCK)
 #define	AS_ISCLAIMGAP(as)	((as)->a_flags & AS_CLAIMGAP)
 #define	AS_ISUNMAPWAIT(as)	((as)->a_flags & AS_UNMAPWAIT)
-#define	AS_ISBUSY(as)		((as)->a_flags & AS_BUSY)
 #define	AS_ISNOUNMAPWAIT(as)	((as)->a_flags & AS_NOUNMAPWAIT)
 
 #define	AS_SETPGLCK(as)		((as)->a_flags |= AS_PAGLCK)
 #define	AS_SETCLAIMGAP(as)	((as)->a_flags |= AS_CLAIMGAP)
 #define	AS_SETUNMAPWAIT(as)	((as)->a_flags |= AS_UNMAPWAIT)
-#define	AS_SETBUSY(as)		((as)->a_flags |= AS_BUSY)
 #define	AS_SETNOUNMAPWAIT(as)	((as)->a_flags |= AS_NOUNMAPWAIT)
 
 #define	AS_CLRPGLCK(as)		((as)->a_flags &= ~AS_PAGLCK)
 #define	AS_CLRCLAIMGAP(as)	((as)->a_flags &= ~AS_CLAIMGAP)
 #define	AS_CLRUNMAPWAIT(as)	((as)->a_flags &= ~AS_UNMAPWAIT)
-#define	AS_CLRBUSY(as)		((as)->a_flags &= ~AS_BUSY)
 #define	AS_CLRNOUNMAPWAIT(as)	((as)->a_flags &= ~AS_NOUNMAPWAIT)
 
 #define	AS_TYPE_64BIT(as)	\
@@ -288,7 +283,6 @@
 	    size_t redzone, size_t off);
 
 int	as_memory(struct as *as, caddr_t *basep, size_t *lenp);
-size_t	as_swapout(struct as *as);
 int	as_incore(struct as *as, caddr_t addr, size_t size, char *vec,
 		size_t *sizep);
 int	as_ctl(struct as *as, caddr_t addr, size_t size, int func, int attr,
--- old/usr/src/uts/common/vm/hat.h	2015-05-08 18:10:34.545267532 -0400
+++ new/usr/src/uts/common/vm/hat.h	2015-05-08 18:10:34.552034034 -0400
@@ -106,12 +106,6 @@
  *	informs hat layer as is being destroyed.  hat layer cannot use as
  *	pointer after this call.
  *
- * void hat_swapin(hat)
- *	allocate any hat resources required for process being swapped in.
- *
- * void hat_swapout(hat)
- *	deallocate hat resources for process being swapped out.
- *
  * size_t hat_get_mapped_size(hat)
  *	returns number of bytes that have valid mappings in hat.
  *
@@ -133,8 +127,6 @@
 void	hat_free_start(struct hat *);
 void	hat_free_end(struct hat *);
 int	hat_dup(struct hat *, struct hat *, caddr_t, size_t, uint_t);
-void	hat_swapin(struct hat *);
-void	hat_swapout(struct hat *);
 size_t	hat_get_mapped_size(struct hat *);
 int	hat_stats_enable(struct hat *);
 void	hat_stats_disable(struct hat *);
--- old/usr/src/uts/common/vm/seg.h	2015-05-08 18:10:34.759848221 -0400
+++ new/usr/src/uts/common/vm/seg.h	2015-05-08 18:10:34.766697848 -0400
@@ -106,7 +106,7 @@
 	uint_t	s_flags;		/* flags for segment, see below */
 	struct	as *s_as;		/* containing address space */
 	avl_node_t s_tree;		/* AVL tree links to segs in this as */
-	struct	seg_ops *s_ops;		/* ops vector: see below */
+	const struct seg_ops *s_ops;	/* ops vector: see below */
 	void *s_data;			/* private data for instance */
 	kmutex_t s_pmtx;		/* protects seg's pcache list */
 	pcache_link_t s_phead;		/* head of seg's pcache list */
@@ -124,7 +124,6 @@
 	int	(*setprot)(struct seg *, caddr_t, size_t, uint_t);
 	int	(*checkprot)(struct seg *, caddr_t, size_t, uint_t);
 	int	(*kluster)(struct seg *, caddr_t, ssize_t);
-	size_t	(*swapout)(struct seg *);
 	int	(*sync)(struct seg *, caddr_t, size_t, int, uint_t);
 	size_t	(*incore)(struct seg *, caddr_t, size_t, char *);
 	int	(*lockop)(struct seg *, caddr_t, size_t, int, int, ulong_t *,
@@ -210,36 +209,6 @@
 #define	SEG_PAGE_ANON		0x20	/* VA has an anonymous page */
 #define	SEG_PAGE_VNODE		0x40	/* VA has a vnode page backing it */
 
-#define	SEGOP_DUP(s, n)		    (*(s)->s_ops->dup)((s), (n))
-#define	SEGOP_UNMAP(s, a, l)	    (*(s)->s_ops->unmap)((s), (a), (l))
-#define	SEGOP_FREE(s)		    (*(s)->s_ops->free)((s))
-#define	SEGOP_FAULT(h, s, a, l, t, rw) \
-		(*(s)->s_ops->fault)((h), (s), (a), (l), (t), (rw))
-#define	SEGOP_FAULTA(s, a)	    (*(s)->s_ops->faulta)((s), (a))
-#define	SEGOP_SETPROT(s, a, l, p)   (*(s)->s_ops->setprot)((s), (a), (l), (p))
-#define	SEGOP_CHECKPROT(s, a, l, p) (*(s)->s_ops->checkprot)((s), (a), (l), (p))
-#define	SEGOP_KLUSTER(s, a, d)	    (*(s)->s_ops->kluster)((s), (a), (d))
-#define	SEGOP_SWAPOUT(s)	    (*(s)->s_ops->swapout)((s))
-#define	SEGOP_SYNC(s, a, l, atr, f) \
-		(*(s)->s_ops->sync)((s), (a), (l), (atr), (f))
-#define	SEGOP_INCORE(s, a, l, v)    (*(s)->s_ops->incore)((s), (a), (l), (v))
-#define	SEGOP_LOCKOP(s, a, l, atr, op, b, p) \
-		(*(s)->s_ops->lockop)((s), (a), (l), (atr), (op), (b), (p))
-#define	SEGOP_GETPROT(s, a, l, p)   (*(s)->s_ops->getprot)((s), (a), (l), (p))
-#define	SEGOP_GETOFFSET(s, a)	    (*(s)->s_ops->getoffset)((s), (a))
-#define	SEGOP_GETTYPE(s, a)	    (*(s)->s_ops->gettype)((s), (a))
-#define	SEGOP_GETVP(s, a, vpp)	    (*(s)->s_ops->getvp)((s), (a), (vpp))
-#define	SEGOP_ADVISE(s, a, l, b)    (*(s)->s_ops->advise)((s), (a), (l), (b))
-#define	SEGOP_DUMP(s)		    (*(s)->s_ops->dump)((s))
-#define	SEGOP_PAGELOCK(s, a, l, p, t, rw) \
-		(*(s)->s_ops->pagelock)((s), (a), (l), (p), (t), (rw))
-#define	SEGOP_SETPAGESIZE(s, a, l, szc) \
-		(*(s)->s_ops->setpagesize)((s), (a), (l), (szc))
-#define	SEGOP_GETMEMID(s, a, mp)    (*(s)->s_ops->getmemid)((s), (a), (mp))
-#define	SEGOP_GETPOLICY(s, a)	    (*(s)->s_ops->getpolicy)((s), (a))
-#define	SEGOP_CAPABLE(s, c)	    (*(s)->s_ops->capable)((s), (c))
-#define	SEGOP_INHERIT(s, a, l, b)   (*(s)->s_ops->inherit)((s), (a), (l), (b))
-
 #define	seg_page(seg, addr) \
 	(((uintptr_t)((addr) - (seg)->s_base)) >> PAGESHIFT)
 
@@ -250,11 +219,9 @@
 #define	IE_RETRY	-2	/* internal to seg layer */
 #define	IE_REATTACH	-3	/* internal to seg layer */
 
-/* Values for SEGOP_INHERIT */
+/* Values for segop_inherit */
 #define	SEGP_INH_ZERO	0x01
 
-int seg_inherit_notsup(struct seg *, caddr_t, size_t, uint_t);
-
 /* Delay/retry factors for seg_p_mem_config_pre_del */
 #define	SEGP_PREDEL_DELAY_FACTOR	4
 /*
@@ -278,6 +245,31 @@
 boolean_t	seg_can_change_zones(struct seg *);
 size_t		seg_swresv(struct seg *);
 
+/* segop wrappers */
+int segop_dup(struct seg *, struct seg *);
+int segop_unmap(struct seg *, caddr_t, size_t);
+void segop_free(struct seg *);
+faultcode_t segop_fault(struct hat *, struct seg *, caddr_t, size_t, enum fault_type, enum seg_rw);
+faultcode_t segop_faulta(struct seg *, caddr_t);
+int segop_setprot(struct seg *, caddr_t, size_t, uint_t);
+int segop_checkprot(struct seg *, caddr_t, size_t, uint_t);
+int segop_kluster(struct seg *, caddr_t, ssize_t);
+int segop_sync(struct seg *, caddr_t, size_t, int, uint_t);
+size_t segop_incore(struct seg *, caddr_t, size_t, char *);
+int segop_lockop(struct seg *, caddr_t, size_t, int, int, ulong_t *, size_t );
+int segop_getprot(struct seg *, caddr_t, size_t, uint_t *);
+u_offset_t segop_getoffset(struct seg *, caddr_t);
+int segop_gettype(struct seg *, caddr_t);
+int segop_getvp(struct seg *, caddr_t, struct vnode **);
+int segop_advise(struct seg *, caddr_t, size_t, uint_t);
+void segop_dump(struct seg *);
+int segop_pagelock(struct seg *, caddr_t, size_t, struct page ***, enum lock_type, enum seg_rw);
+int segop_setpagesize(struct seg *, caddr_t, size_t, uint_t);
+int segop_getmemid(struct seg *, caddr_t, memid_t *);
+struct lgrp_mem_policy_info *segop_getpolicy(struct seg *, caddr_t);
+int segop_capable(struct seg *, segcapability_t);
+int segop_inherit(struct seg *, caddr_t, size_t, uint_t);
+
 #endif	/* _KERNEL */
 
 #ifdef	__cplusplus
--- old/usr/src/uts/common/vm/seg_dev.c	2015-05-08 18:10:34.963944061 -0400
+++ new/usr/src/uts/common/vm/seg_dev.c	2015-05-08 18:10:34.970900228 -0400
@@ -178,44 +178,34 @@
 static int	segdev_gettype(struct seg *, caddr_t);
 static int	segdev_getvp(struct seg *, caddr_t, struct vnode **);
 static int	segdev_advise(struct seg *, caddr_t, size_t, uint_t);
-static void	segdev_dump(struct seg *);
 static int	segdev_pagelock(struct seg *, caddr_t, size_t,
 		    struct page ***, enum lock_type, enum seg_rw);
-static int	segdev_setpagesize(struct seg *, caddr_t, size_t, uint_t);
 static int	segdev_getmemid(struct seg *, caddr_t, memid_t *);
-static lgrp_mem_policy_info_t	*segdev_getpolicy(struct seg *, caddr_t);
-static int	segdev_capable(struct seg *, segcapability_t);
 
 /*
  * XXX	this struct is used by rootnex_map_fault to identify
  *	the segment it has been passed. So if you make it
  *	"static" you'll need to fix rootnex_map_fault.
  */
-struct seg_ops segdev_ops = {
-	segdev_dup,
-	segdev_unmap,
-	segdev_free,
-	segdev_fault,
-	segdev_faulta,
-	segdev_setprot,
-	segdev_checkprot,
-	(int (*)())segdev_badop,	/* kluster */
-	(size_t (*)(struct seg *))NULL,	/* swapout */
-	segdev_sync,			/* sync */
-	segdev_incore,
-	segdev_lockop,			/* lockop */
-	segdev_getprot,
-	segdev_getoffset,
-	segdev_gettype,
-	segdev_getvp,
-	segdev_advise,
-	segdev_dump,
-	segdev_pagelock,
-	segdev_setpagesize,
-	segdev_getmemid,
-	segdev_getpolicy,
-	segdev_capable,
-	seg_inherit_notsup
+const struct seg_ops segdev_ops = {
+	.dup		= segdev_dup,
+	.unmap		= segdev_unmap,
+	.free		= segdev_free,
+	.fault		= segdev_fault,
+	.faulta		= segdev_faulta,
+	.setprot	= segdev_setprot,
+	.checkprot	= segdev_checkprot,
+	.kluster	= (int (*)())segdev_badop,
+	.sync		= segdev_sync,
+	.incore		= segdev_incore,
+	.lockop		= segdev_lockop,
+	.getprot	= segdev_getprot,
+	.getoffset	= segdev_getoffset,
+	.gettype	= segdev_gettype,
+	.getvp		= segdev_getvp,
+	.advise		= segdev_advise,
+	.pagelock	= segdev_pagelock,
+	.getmemid	= segdev_getmemid,
 };
 
 /*
@@ -432,7 +422,7 @@
 		 * Mappings of /dev/null don't count towards the VSZ of a
 		 * process.  Mappings of /dev/null have no mapping type.
 		 */
-		if ((SEGOP_GETTYPE(seg, (seg)->s_base) & (MAP_SHARED |
+		if ((segop_gettype(seg, seg->s_base) & (MAP_SHARED |
 		    MAP_PRIVATE)) == 0) {
 			seg->s_as->a_resvsize -= seg->s_size;
 		}
@@ -2381,14 +2371,6 @@
 }
 
 /*
- * segdev pages are not dumped, so we just return
- */
-/*ARGSUSED*/
-static void
-segdev_dump(struct seg *seg)
-{}
-
-/*
  * ddi_segmap_setup:	Used by drivers who wish specify mapping attributes
  *			for a segment.	Called from a drivers segmap(9E)
  *			routine.
@@ -2480,14 +2462,6 @@
 	return (ENOTSUP);
 }
 
-/*ARGSUSED*/
-static int
-segdev_setpagesize(struct seg *seg, caddr_t addr, size_t len,
-    uint_t szc)
-{
-	return (ENOTSUP);
-}
-
 /*
  * devmap_device: Used by devmap framework to establish mapping
  *                called by devmap_seup(9F) during map setup time.
@@ -4032,20 +4006,6 @@
 	return (0);
 }
 
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segdev_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
-
-/*ARGSUSED*/
-static int
-segdev_capable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
-
 /*
  * ddi_umem_alloc() non-pageable quantum cache max size.
  * This is just a SWAG.
--- old/usr/src/uts/common/vm/seg_dev.h	2015-05-08 18:10:35.296130416 -0400
+++ new/usr/src/uts/common/vm/seg_dev.h	2015-05-08 18:10:35.302978462 -0400
@@ -118,7 +118,7 @@
 
 #define	SEG_IS_DEVNULL_MAPPING(seg)	\
 	((seg)->s_ops == &segdev_ops &&	\
-	((SEGOP_GETTYPE(seg, (seg)->s_base) & (MAP_SHARED | MAP_PRIVATE)) == 0))
+	((segop_gettype((seg), (seg)->s_base) & (MAP_SHARED | MAP_PRIVATE)) == 0))
 
 extern void segdev_init(void);
 
@@ -126,7 +126,7 @@
 
 extern int segdev_copyto(struct seg *, caddr_t, const void *, void *, size_t);
 extern int segdev_copyfrom(struct seg *, caddr_t, const void *, void *, size_t);
-extern struct seg_ops segdev_ops;
+extern const struct seg_ops segdev_ops;
 
 #endif	/* _KERNEL */
 
--- old/usr/src/uts/common/vm/seg_kmem.c	2015-05-08 18:10:35.492308118 -0400
+++ new/usr/src/uts/common/vm/seg_kmem.c	2015-05-08 18:10:35.499166727 -0400
@@ -428,14 +428,6 @@
 	return (addr);
 }
 
-static void
-segkmem_badop()
-{
-	panic("segkmem_badop");
-}
-
-#define	SEGKMEM_BADOP(t)	(t(*)())segkmem_badop
-
 /*ARGSUSED*/
 static faultcode_t
 segkmem_fault(struct hat *hat, struct seg *seg, caddr_t addr, size_t size,
@@ -457,7 +449,7 @@
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_FAULT(hat, segkp, addr, size, type, rw));
+		return (segop_fault(hat, segkp, addr, size, type, rw));
 
 	if (rw != S_READ && rw != S_WRITE && rw != S_OTHER)
 		return (FC_NOSUPPORT);
@@ -519,7 +511,7 @@
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_SETPROT(segkp, addr, size, prot));
+		return (segop_setprot(segkp, addr, size, prot));
 
 	if (prot == 0)
 		hat_unload(kas.a_hat, addr, size, HAT_UNLOAD);
@@ -539,16 +531,16 @@
 	ASSERT(RW_LOCK_HELD(&seg->s_as->a_lock));
 
 	if (seg->s_as != &kas)
-		segkmem_badop();
+		panic("segkmem badop");
 
 	/*
 	 * If it is one of segkp pages, call into segkp.
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_CHECKPROT(segkp, addr, size, prot));
+		return (segop_checkprot(segkp, addr, size, prot));
 
-	segkmem_badop();
+	panic("segkmem badop");
 	return (0);
 }
 
@@ -563,16 +555,16 @@
 	ASSERT(RW_LOCK_HELD(&seg->s_as->a_lock));
 
 	if (seg->s_as != &kas)
-		segkmem_badop();
+		panic("segkmem badop");
 
 	/*
 	 * If it is one of segkp pages, call into segkp.
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_KLUSTER(segkp, addr, delta));
+		return (segop_kluster(segkp, addr, delta));
 
-	segkmem_badop();
+	panic("segkmem badop");
 	return (0);
 }
 
@@ -691,7 +683,7 @@
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_PAGELOCK(segkp, addr, len, ppp, type, rw));
+		return (segop_pagelock(segkp, addr, len, ppp, type, rw));
 
 	npages = btopr(len);
 	nb = sizeof (page_t *) * npages;
@@ -744,27 +736,20 @@
 	ASSERT(RW_LOCK_HELD(&seg->s_as->a_lock));
 
 	if (seg->s_as != &kas)
-		segkmem_badop();
+		panic("segkmem badop");
 
 	/*
 	 * If it is one of segkp pages, call into segkp.
 	 */
 	if (segkp_bitmap && seg == &kvseg &&
 	    BT_TEST(segkp_bitmap, btop((uintptr_t)(addr - seg->s_base))))
-		return (SEGOP_GETMEMID(segkp, addr, memidp));
+		return (segop_getmemid(segkp, addr, memidp));
 
-	segkmem_badop();
+	panic("segkmem badop");
 	return (0);
 }
 
 /*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segkmem_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
-
-/*ARGSUSED*/
 static int
 segkmem_capable(struct seg *seg, segcapability_t capability)
 {
@@ -773,31 +758,15 @@
 	return (0);
 }
 
-static struct seg_ops segkmem_ops = {
-	SEGKMEM_BADOP(int),		/* dup */
-	SEGKMEM_BADOP(int),		/* unmap */
-	SEGKMEM_BADOP(void),		/* free */
-	segkmem_fault,
-	SEGKMEM_BADOP(faultcode_t),	/* faulta */
-	segkmem_setprot,
-	segkmem_checkprot,
-	segkmem_kluster,
-	SEGKMEM_BADOP(size_t),		/* swapout */
-	SEGKMEM_BADOP(int),		/* sync */
-	SEGKMEM_BADOP(size_t),		/* incore */
-	SEGKMEM_BADOP(int),		/* lockop */
-	SEGKMEM_BADOP(int),		/* getprot */
-	SEGKMEM_BADOP(u_offset_t),	/* getoffset */
-	SEGKMEM_BADOP(int),		/* gettype */
-	SEGKMEM_BADOP(int),		/* getvp */
-	SEGKMEM_BADOP(int),		/* advise */
-	segkmem_dump,
-	segkmem_pagelock,
-	SEGKMEM_BADOP(int),		/* setpgsz */
-	segkmem_getmemid,
-	segkmem_getpolicy,		/* getpolicy */
-	segkmem_capable,		/* capable */
-	seg_inherit_notsup		/* inherit */
+static const struct seg_ops segkmem_ops = {
+	.fault		= segkmem_fault,
+	.setprot	= segkmem_setprot,
+	.checkprot	= segkmem_checkprot,
+	.kluster	= segkmem_kluster,
+	.dump		= segkmem_dump,
+	.pagelock	= segkmem_pagelock,
+	.getmemid	= segkmem_getmemid,
+	.capable	= segkmem_capable,
 };
 
 int
--- old/usr/src/uts/common/vm/seg_kp.c	2015-05-08 18:10:35.736191120 -0400
+++ new/usr/src/uts/common/vm/seg_kp.c	2015-05-08 18:10:35.742963823 -0400
@@ -75,7 +75,6 @@
 /*
  * Private seg op routines
  */
-static void	segkp_badop(void);
 static void	segkp_dump(struct seg *seg);
 static int	segkp_checkprot(struct seg *seg, caddr_t addr, size_t len,
 			uint_t prot);
@@ -94,10 +93,6 @@
 static int	segkp_load(struct hat *hat, struct seg *seg, caddr_t vaddr,
 			size_t len, struct segkp_data *kpd, uint_t flags);
 static struct	segkp_data *segkp_find(struct seg *seg, caddr_t vaddr);
-static int	segkp_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
-static lgrp_mem_policy_info_t	*segkp_getpolicy(struct seg *seg,
-    caddr_t addr);
-static int	segkp_capable(struct seg *seg, segcapability_t capability);
 
 /*
  * Lock used to protect the hash table(s) and caches.
@@ -109,8 +104,6 @@
  */
 static struct segkp_cache segkp_cache[SEGKP_MAX_CACHE];
 
-#define	SEGKP_BADOP(t)	(t(*)())segkp_badop
-
 /*
  * When there are fewer than red_minavail bytes left on the stack,
  * segkp_map_red() will map in the redzone (if called).  5000 seems
@@ -145,41 +138,15 @@
 pgcnt_t anon_segkp_pages_locked;	/* See vm/anon.h */
 pgcnt_t anon_segkp_pages_resv;		/* anon reserved by seg_kp */
 
-static struct	seg_ops segkp_ops = {
-	SEGKP_BADOP(int),		/* dup */
-	SEGKP_BADOP(int),		/* unmap */
-	SEGKP_BADOP(void),		/* free */
-	segkp_fault,
-	SEGKP_BADOP(faultcode_t),	/* faulta */
-	SEGKP_BADOP(int),		/* setprot */
-	segkp_checkprot,
-	segkp_kluster,
-	SEGKP_BADOP(size_t),		/* swapout */
-	SEGKP_BADOP(int),		/* sync */
-	SEGKP_BADOP(size_t),		/* incore */
-	SEGKP_BADOP(int),		/* lockop */
-	SEGKP_BADOP(int),		/* getprot */
-	SEGKP_BADOP(u_offset_t),		/* getoffset */
-	SEGKP_BADOP(int),		/* gettype */
-	SEGKP_BADOP(int),		/* getvp */
-	SEGKP_BADOP(int),		/* advise */
-	segkp_dump,			/* dump */
-	segkp_pagelock,			/* pagelock */
-	SEGKP_BADOP(int),		/* setpgsz */
-	segkp_getmemid,			/* getmemid */
-	segkp_getpolicy,		/* getpolicy */
-	segkp_capable,			/* capable */
-	seg_inherit_notsup		/* inherit */
+static const struct seg_ops segkp_ops = {
+	.fault		= segkp_fault,
+	.checkprot	= segkp_checkprot,
+	.kluster	= segkp_kluster,
+	.dump		= segkp_dump,
+	.pagelock	= segkp_pagelock,
 };
 
 
-static void
-segkp_badop(void)
-{
-	panic("segkp_badop");
-	/*NOTREACHED*/
-}
-
 static void segkpinit_mem_config(struct seg *);
 
 static uint32_t segkp_indel;
@@ -760,15 +727,11 @@
  * stack base.  If the amount of stack remaining is questionable
  * (less than red_minavail), then segkp_map_red() will map in the redzone
  * and return 1.  Otherwise, it will return 0.  segkp_map_red() can
- * _only_ be called when:
- *
- *   - it is safe to sleep on page_create_va().
- *   - the caller is non-swappable.
+ * _only_ be called when it is safe to sleep on page_create_va().
  *
  * It is up to the caller to remember whether segkp_map_red() successfully
  * mapped the redzone, and, if so, to call segkp_unmap_red() at a later
- * time.  Note that the caller must _remain_ non-swappable until after
- * calling segkp_unmap_red().
+ * time.
  *
  * Currently, this routine is only called from pagefault() (which necessarily
  * satisfies the above conditions).
@@ -782,8 +745,6 @@
 	caddr_t stkbase;
 #endif
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	/*
 	 * Optimize for the common case where we simply return.
 	 */
@@ -884,7 +845,6 @@
 	    (uintptr_t)PAGEMASK) - PAGESIZE);
 
 	ASSERT(curthread->t_red_pp != NULL);
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
 
 	/*
 	 * Because we locked the mapping down, we can't simply rely
@@ -1399,27 +1359,6 @@
 	return (ENOTSUP);
 }
 
-/*ARGSUSED*/
-static int
-segkp_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
-{
-	return (ENODEV);
-}
-
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t	*
-segkp_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
-
-/*ARGSUSED*/
-static int
-segkp_capable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
-
 #include <sys/mem_config.h>
 
 /*ARGSUSED*/
--- old/usr/src/uts/common/vm/seg_kpm.c	2015-05-08 18:10:35.975007349 -0400
+++ new/usr/src/uts/common/vm/seg_kpm.c	2015-05-08 18:10:35.981707427 -0400
@@ -102,39 +102,33 @@
  */
 faultcode_t segkpm_fault(struct hat *hat, struct seg *seg, caddr_t addr,
 			size_t len, enum fault_type type, enum seg_rw rw);
-static void	segkpm_dump(struct seg *);
-static void	segkpm_badop(void);
-static int	segkpm_notsup(void);
-static int	segkpm_capable(struct seg *, segcapability_t);
-
-#define	SEGKPM_BADOP(t)	(t(*)())segkpm_badop
-#define	SEGKPM_NOTSUP	(int(*)())segkpm_notsup
-
-static struct seg_ops segkpm_ops = {
-	SEGKPM_BADOP(int),	/* dup */
-	SEGKPM_BADOP(int),	/* unmap */
-	SEGKPM_BADOP(void),	/* free */
-	segkpm_fault,
-	SEGKPM_BADOP(int),	/* faulta */
-	SEGKPM_BADOP(int),	/* setprot */
-	SEGKPM_BADOP(int),	/* checkprot */
-	SEGKPM_BADOP(int),	/* kluster */
-	SEGKPM_BADOP(size_t),	/* swapout */
-	SEGKPM_BADOP(int),	/* sync */
-	SEGKPM_BADOP(size_t),	/* incore */
-	SEGKPM_BADOP(int),	/* lockop */
-	SEGKPM_BADOP(int),	/* getprot */
-	SEGKPM_BADOP(u_offset_t), /* getoffset */
-	SEGKPM_BADOP(int),	/* gettype */
-	SEGKPM_BADOP(int),	/* getvp */
-	SEGKPM_BADOP(int),	/* advise */
-	segkpm_dump,		/* dump */
-	SEGKPM_NOTSUP,		/* pagelock */
-	SEGKPM_BADOP(int),	/* setpgsz */
-	SEGKPM_BADOP(int),	/* getmemid */
-	SEGKPM_BADOP(lgrp_mem_policy_info_t *),	/* getpolicy */
-	segkpm_capable,		/* capable */
-	seg_inherit_notsup	/* inherit */
+static int	segkpm_pagelock(struct seg *seg, caddr_t addr, size_t len,
+			struct page ***page, enum lock_type type,
+			enum seg_rw rw);
+
+static const struct seg_ops segkpm_ops = {
+	.fault		= segkpm_fault,
+	.pagelock	= segkpm_pagelock,
+//#ifndef SEGKPM_SUPPORT
+#if 0
+#error FIXME: define nop
+	.dup		= nop,
+	.unmap		= nop,
+	.free		= nop,
+	.faulta		= nop,
+	.setprot	= nop,
+	.checkprot	= nop,
+	.kluster	= nop,
+	.sync		= nop,
+	.incore		= nop,
+	.lockop		= nop,
+	.getprot	= nop,
+	.getoffset	= nop,
+	.gettype	= nop,
+	.getvp		= nop,
+	.advise		= nop,
+	.getpolicy	= nop,
+#endif
 };
 
 /*
@@ -284,58 +278,41 @@
 	page_unlock(pp);
 }
 
-static void
-segkpm_badop()
-{
-	panic("segkpm_badop");
-}
-
 #else	/* SEGKPM_SUPPORT */
 
 /* segkpm stubs */
 
 /*ARGSUSED*/
-int segkpm_create(struct seg *seg, void *argsp) { return (0); }
+int segkpm_create(struct seg *seg, void *argsp)
+{
+	return (0);
+}
 
 /* ARGSUSED */
 faultcode_t
 segkpm_fault(struct hat *hat, struct seg *seg, caddr_t addr, size_t len,
 	enum fault_type type, enum seg_rw rw)
 {
-	return ((faultcode_t)0);
+	return (0);
 }
 
 /* ARGSUSED */
-caddr_t segkpm_create_va(u_offset_t off) { return (NULL); }
+caddr_t segkpm_create_va(u_offset_t off)
+{
+	return (NULL);
+}
 
 /* ARGSUSED */
-void segkpm_mapout_validkpme(struct kpme *kpme) {}
-
-static void
-segkpm_badop() {}
-
-#endif	/* SEGKPM_SUPPORT */
-
-static int
-segkpm_notsup()
+void segkpm_mapout_validkpme(struct kpme *kpme)
 {
-	return (ENOTSUP);
 }
 
-/*
- * segkpm pages are not dumped, so we just return
- */
-/*ARGSUSED*/
-static void
-segkpm_dump(struct seg *seg)
-{}
+#endif	/* SEGKPM_SUPPORT */
 
-/*
- * We claim to have no special capabilities.
- */
-/*ARGSUSED*/
+/* ARGSUSED */
 static int
-segkpm_capable(struct seg *seg, segcapability_t capability)
+segkpm_pagelock(struct seg *seg, caddr_t addr, size_t len,
+	struct page ***page, enum lock_type type, enum seg_rw rw)
 {
-	return (0);
+	return (ENOTSUP);
 }
--- old/usr/src/uts/common/vm/seg_map.c	2015-05-08 18:10:36.179516353 -0400
+++ new/usr/src/uts/common/vm/seg_map.c	2015-05-08 18:10:36.186358439 -0400
@@ -87,44 +87,26 @@
 static int	segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
 			struct page ***ppp, enum lock_type type,
 			enum seg_rw rw);
-static void	segmap_badop(void);
 static int	segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
-static lgrp_mem_policy_info_t	*segmap_getpolicy(struct seg *seg,
-    caddr_t addr);
-static int	segmap_capable(struct seg *seg, segcapability_t capability);
 
 /* segkpm support */
 static caddr_t	segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
 			struct smap *, enum seg_rw);
 struct smap	*get_smap_kpm(caddr_t, page_t **);
 
-#define	SEGMAP_BADOP(t)	(t(*)())segmap_badop
-
-static struct seg_ops segmap_ops = {
-	SEGMAP_BADOP(int),	/* dup */
-	SEGMAP_BADOP(int),	/* unmap */
-	segmap_free,
-	segmap_fault,
-	segmap_faulta,
-	SEGMAP_BADOP(int),	/* setprot */
-	segmap_checkprot,
-	segmap_kluster,
-	SEGMAP_BADOP(size_t),	/* swapout */
-	SEGMAP_BADOP(int),	/* sync */
-	SEGMAP_BADOP(size_t),	/* incore */
-	SEGMAP_BADOP(int),	/* lockop */
-	segmap_getprot,
-	segmap_getoffset,
-	segmap_gettype,
-	segmap_getvp,
-	SEGMAP_BADOP(int),	/* advise */
-	segmap_dump,
-	segmap_pagelock,	/* pagelock */
-	SEGMAP_BADOP(int),	/* setpgsz */
-	segmap_getmemid,	/* getmemid */
-	segmap_getpolicy,	/* getpolicy */
-	segmap_capable,		/* capable */
-	seg_inherit_notsup	/* inherit */
+static const struct seg_ops segmap_ops = {
+	.free		= segmap_free,
+	.fault		= segmap_fault,
+	.faulta		= segmap_faulta,
+	.checkprot	= segmap_checkprot,
+	.kluster	= segmap_kluster,
+	.getprot	= segmap_getprot,
+	.getoffset	= segmap_getoffset,
+	.gettype	= segmap_gettype,
+	.getvp		= segmap_getvp,
+	.dump		= segmap_dump,
+	.pagelock	= segmap_pagelock,
+	.getmemid	= segmap_getmemid,
 };
 
 /*
@@ -909,13 +891,6 @@
 	return (0);
 }
 
-static void
-segmap_badop()
-{
-	panic("segmap_badop");
-	/*NOTREACHED*/
-}
-
 /*
  * Special private segmap operations
  */
@@ -2191,20 +2166,6 @@
 	return (0);
 }
 
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segmap_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
-
-/*ARGSUSED*/
-static int
-segmap_capable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
-
 
 #ifdef	SEGKPM_SUPPORT
 
--- old/usr/src/uts/common/vm/seg_spt.c	2015-05-08 18:10:36.447101464 -0400
+++ new/usr/src/uts/common/vm/seg_spt.c	2015-05-08 18:10:36.454058642 -0400
@@ -76,40 +76,10 @@
 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
 
-static void
-segspt_badop()
-{
-	panic("segspt_badop called");
-	/*NOTREACHED*/
-}
-
-#define	SEGSPT_BADOP(t)	(t(*)())segspt_badop
-
-struct seg_ops segspt_ops = {
-	SEGSPT_BADOP(int),		/* dup */
-	segspt_unmap,
-	segspt_free,
-	SEGSPT_BADOP(int),		/* fault */
-	SEGSPT_BADOP(faultcode_t),	/* faulta */
-	SEGSPT_BADOP(int),		/* setprot */
-	SEGSPT_BADOP(int),		/* checkprot */
-	SEGSPT_BADOP(int),		/* kluster */
-	SEGSPT_BADOP(size_t),		/* swapout */
-	SEGSPT_BADOP(int),		/* sync */
-	SEGSPT_BADOP(size_t),		/* incore */
-	SEGSPT_BADOP(int),		/* lockop */
-	SEGSPT_BADOP(int),		/* getprot */
-	SEGSPT_BADOP(u_offset_t), 	/* getoffset */
-	SEGSPT_BADOP(int),		/* gettype */
-	SEGSPT_BADOP(int),		/* getvp */
-	SEGSPT_BADOP(int),		/* advise */
-	SEGSPT_BADOP(void),		/* dump */
-	SEGSPT_BADOP(int),		/* pagelock */
-	SEGSPT_BADOP(int),		/* setpgsz */
-	SEGSPT_BADOP(int),		/* getmemid */
-	segspt_getpolicy,		/* getpolicy */
-	SEGSPT_BADOP(int),		/* capable */
-	seg_inherit_notsup		/* inherit */
+static const struct seg_ops segspt_ops = {
+	.unmap		= segspt_unmap,
+	.free		= segspt_free,
+	.getpolicy	= segspt_getpolicy,
 };
 
 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
@@ -123,7 +93,6 @@
 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
 			uint_t prot);
 static int	segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
-static size_t	segspt_shmswapout(struct seg *seg);
 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
 			register char *vec);
 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
@@ -137,39 +106,31 @@
 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
 			uint_t behav);
-static void segspt_shmdump(struct seg *seg);
 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
 			struct page ***, enum lock_type, enum seg_rw);
-static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
-static int segspt_shmcapable(struct seg *, segcapability_t);
 
-struct seg_ops segspt_shmops = {
-	segspt_shmdup,
-	segspt_shmunmap,
-	segspt_shmfree,
-	segspt_shmfault,
-	segspt_shmfaulta,
-	segspt_shmsetprot,
-	segspt_shmcheckprot,
-	segspt_shmkluster,
-	segspt_shmswapout,
-	segspt_shmsync,
-	segspt_shmincore,
-	segspt_shmlockop,
-	segspt_shmgetprot,
-	segspt_shmgetoffset,
-	segspt_shmgettype,
-	segspt_shmgetvp,
-	segspt_shmadvise,	/* advise */
-	segspt_shmdump,
-	segspt_shmpagelock,
-	segspt_shmsetpgsz,
-	segspt_shmgetmemid,
-	segspt_shmgetpolicy,
-	segspt_shmcapable,
-	seg_inherit_notsup
+const struct seg_ops segspt_shmops = {
+	.dup		= segspt_shmdup,
+	.unmap		= segspt_shmunmap,
+	.free		= segspt_shmfree,
+	.fault		= segspt_shmfault,
+	.faulta		= segspt_shmfaulta,
+	.setprot	= segspt_shmsetprot,
+	.checkprot	= segspt_shmcheckprot,
+	.kluster	= segspt_shmkluster,
+	.sync		= segspt_shmsync,
+	.incore		= segspt_shmincore,
+	.lockop		= segspt_shmlockop,
+	.getprot	= segspt_shmgetprot,
+	.getoffset	= segspt_shmgetoffset,
+	.gettype	= segspt_shmgettype,
+	.getvp		= segspt_shmgetvp,
+	.advise		= segspt_shmadvise,
+	.pagelock	= segspt_shmpagelock,
+	.getmemid	= segspt_shmgetmemid,
+	.getpolicy	= segspt_shmgetpolicy,
 };
 
 static void segspt_purge(struct seg *seg);
@@ -1924,27 +1885,17 @@
 				    HAT_LOAD_LOCK | HAT_LOAD_SHARE);
 			}
 		} else {
-			if (hat == seg->s_as->a_hat) {
+			/*
+			 * Migrate pages marked for migration
+			 */
+			if (lgrp_optimizations())
+				page_migrate(seg, shm_addr, ppa, npages);
 
-				/*
-				 * Migrate pages marked for migration
-				 */
-				if (lgrp_optimizations())
-					page_migrate(seg, shm_addr, ppa,
-					    npages);
-
-				/* CPU HAT */
-				for (; pidx < npages;
-				    a += pgsz, pidx += pgcnt) {
-					hat_memload_array(sptseg->s_as->a_hat,
-					    a, pgsz, &ppa[pidx],
-					    sptd->spt_prot,
-					    HAT_LOAD_SHARE);
-				}
-			} else {
-				/* XHAT. Pass real address */
-				hat_memload_array(hat, shm_addr,
-				    size, ppa, sptd->spt_prot, HAT_LOAD_SHARE);
+			for (; pidx < npages; a += pgsz, pidx += pgcnt) {
+				hat_memload_array(sptseg->s_as->a_hat,
+				    a, pgsz, &ppa[pidx],
+				    sptd->spt_prot,
+				    HAT_LOAD_SHARE);
 			}
 
 			/*
@@ -2184,28 +2135,17 @@
 				    HAT_LOAD_LOCK | HAT_LOAD_SHARE);
 			}
 		} else {
-			if (hat == seg->s_as->a_hat) {
+			/*
+			 * Migrate pages marked for migration.
+			 */
+			if (lgrp_optimizations())
+				page_migrate(seg, shm_addr, ppa, npages);
 
-				/*
-				 * Migrate pages marked for migration.
-				 */
-				if (lgrp_optimizations())
-					page_migrate(seg, shm_addr, ppa,
-					    npages);
-
-				/* CPU HAT */
-				for (; pidx < npages;
-				    a += pgsz, pidx += pgcnt) {
-					sz = MIN(pgsz, ptob(npages - pidx));
-					hat_memload_array(sptseg->s_as->a_hat,
-					    a, sz, &ppa[pidx],
-					    sptd->spt_prot, HAT_LOAD_SHARE);
-				}
-			} else {
-				/* XHAT. Pass real address */
-				hat_memload_array(hat, shm_addr,
-				    ptob(npages), ppa, sptd->spt_prot,
-				    HAT_LOAD_SHARE);
+			for (; pidx < npages; a += pgsz, pidx += pgcnt) {
+				sz = MIN(pgsz, ptob(npages - pidx));
+				hat_memload_array(sptseg->s_as->a_hat,
+				    a, sz, &ppa[pidx],
+				    sptd->spt_prot, HAT_LOAD_SHARE);
 			}
 
 			/*
@@ -2264,13 +2204,6 @@
 	return (0);
 }
 
-/*ARGSUSED*/
-static size_t
-segspt_shmswapout(struct seg *seg)
-{
-	return (0);
-}
-
 /*
  * duplicate the shared page tables
  */
@@ -3014,20 +2947,6 @@
 	return (0);
 }
 
-/*ARGSUSED*/
-void
-segspt_shmdump(struct seg *seg)
-{
-	/* no-op for ISM segment */
-}
-
-/*ARGSUSED*/
-static faultcode_t
-segspt_shmsetpgsz(struct seg *seg, caddr_t addr, size_t len, uint_t szc)
-{
-	return (ENOTSUP);
-}
-
 /*
  * get a memory ID for an addr in a given segment
  */
@@ -3108,10 +3027,3 @@
 
 	return (policy_info);
 }
-
-/*ARGSUSED*/
-static int
-segspt_shmcapable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
--- old/usr/src/uts/common/vm/seg_vn.c	2015-05-08 18:10:36.752580253 -0400
+++ new/usr/src/uts/common/vm/seg_vn.c	2015-05-08 18:10:36.760355688 -0400
@@ -78,23 +78,12 @@
 
 /*
  * segvn_fault needs a temporary page list array.  To avoid calling kmem all
- * the time, it creates a small (PVN_GETPAGE_NUM entry) array and uses it if
- * it can.  In the rare case when this page list is not large enough, it
- * goes and gets a large enough array from kmem.
- *
- * This small page list array covers either 8 pages or 64kB worth of pages -
- * whichever is smaller.
+ * the time, it creates a small (FAULT_TMP_PAGES_NUM entry) array and uses
+ * it if it can.  In the rare case when this page list is not large enough,
+ * it goes and gets a large enough array from kmem.
  */
-#define	PVN_MAX_GETPAGE_SZ	0x10000
-#define	PVN_MAX_GETPAGE_NUM	0x8
-
-#if PVN_MAX_GETPAGE_SZ > PVN_MAX_GETPAGE_NUM * PAGESIZE
-#define	PVN_GETPAGE_SZ	ptob(PVN_MAX_GETPAGE_NUM)
-#define	PVN_GETPAGE_NUM	PVN_MAX_GETPAGE_NUM
-#else
-#define	PVN_GETPAGE_SZ	PVN_MAX_GETPAGE_SZ
-#define	PVN_GETPAGE_NUM	btop(PVN_MAX_GETPAGE_SZ)
-#endif
+#define	FAULT_TMP_PAGES_NUM	0x8
+#define	FAULT_TMP_PAGES_SZ	ptob(FAULT_TMP_PAGES_NUM)
 
 /*
  * Private seg op routines.
@@ -111,7 +100,6 @@
 static int	segvn_checkprot(struct seg *seg, caddr_t addr,
 		    size_t len, uint_t prot);
 static int	segvn_kluster(struct seg *seg, caddr_t addr, ssize_t delta);
-static size_t	segvn_swapout(struct seg *seg);
 static int	segvn_sync(struct seg *seg, caddr_t addr, size_t len,
 		    int attr, uint_t flags);
 static size_t	segvn_incore(struct seg *seg, caddr_t addr, size_t len,
@@ -134,34 +122,31 @@
 static int	segvn_getmemid(struct seg *seg, caddr_t addr,
 		    memid_t *memidp);
 static lgrp_mem_policy_info_t	*segvn_getpolicy(struct seg *, caddr_t);
-static int	segvn_capable(struct seg *seg, segcapability_t capable);
 static int	segvn_inherit(struct seg *, caddr_t, size_t, uint_t);
 
-struct	seg_ops segvn_ops = {
-	segvn_dup,
-	segvn_unmap,
-	segvn_free,
-	segvn_fault,
-	segvn_faulta,
-	segvn_setprot,
-	segvn_checkprot,
-	segvn_kluster,
-	segvn_swapout,
-	segvn_sync,
-	segvn_incore,
-	segvn_lockop,
-	segvn_getprot,
-	segvn_getoffset,
-	segvn_gettype,
-	segvn_getvp,
-	segvn_advise,
-	segvn_dump,
-	segvn_pagelock,
-	segvn_setpagesize,
-	segvn_getmemid,
-	segvn_getpolicy,
-	segvn_capable,
-	segvn_inherit
+const struct seg_ops segvn_ops = {
+	.dup		= segvn_dup,
+	.unmap		= segvn_unmap,
+	.free		= segvn_free,
+	.fault		= segvn_fault,
+	.faulta		= segvn_faulta,
+	.setprot	= segvn_setprot,
+	.checkprot	= segvn_checkprot,
+	.kluster	= segvn_kluster,
+	.sync		= segvn_sync,
+	.incore		= segvn_incore,
+	.lockop		= segvn_lockop,
+	.getprot	= segvn_getprot,
+	.getoffset	= segvn_getoffset,
+	.gettype	= segvn_gettype,
+	.getvp		= segvn_getvp,
+	.advise		= segvn_advise,
+	.dump		= segvn_dump,
+	.pagelock	= segvn_pagelock,
+	.setpagesize	= segvn_setpagesize,
+	.getmemid	= segvn_getmemid,
+	.getpolicy	= segvn_getpolicy,
+	.inherit	= segvn_inherit,
 };
 
 /*
@@ -3856,7 +3841,6 @@
 	int alloc_failed = 0;
 	int adjszc_chk;
 	struct vattr va;
-	int xhat = 0;
 	page_t *pplist;
 	pfn_t pfn;
 	int physcontig;
@@ -3906,10 +3890,6 @@
 		/* caller has already done segment level protection check. */
 	}
 
-	if (seg->s_as->a_hat != hat) {
-		xhat = 1;
-	}
-
 	if (rw == S_WRITE && segtype == MAP_PRIVATE) {
 		SEGVN_VMSTAT_FLTVNPAGES(2);
 		arw = S_READ;
@@ -4265,25 +4245,9 @@
 				}
 				SEGVN_UPDATE_MODBITS(ppa, pages, rw,
 				    prot, vpprot);
-				if (!xhat) {
-					hat_memload_array_region(hat, a, pgsz,
-					    ppa, prot & vpprot, hat_flag,
-					    svd->rcookie);
-				} else {
-					/*
-					 * avoid large xhat mappings to FS
-					 * pages so that hat_page_demote()
-					 * doesn't need to check for xhat
-					 * large mappings.
-					 * Don't use regions with xhats.
-					 */
-					for (i = 0; i < pages; i++) {
-						hat_memload(hat,
-						    a + (i << PAGESHIFT),
-						    ppa[i], prot & vpprot,
-						    hat_flag);
-					}
-				}
+				hat_memload_array_region(hat, a, pgsz,
+				    ppa, prot & vpprot, hat_flag,
+				    svd->rcookie);
 
 				if (!(hat_flag & HAT_LOAD_LOCK)) {
 					for (i = 0; i < pages; i++) {
@@ -4337,7 +4301,7 @@
 			 * check if we should use smallest mapping size.
 			 */
 			upgrdfail = 0;
-			if (szc == 0 || xhat ||
+			if (szc == 0 ||
 			    (pszc >= szc &&
 			    !IS_P2ALIGNED(pfn, pages)) ||
 			    (pszc < szc &&
@@ -4369,7 +4333,7 @@
 					ierr = -1;
 					break;
 				}
-				if (szc != 0 && !xhat && !upgrdfail) {
+				if (szc != 0 && !upgrdfail) {
 					segvn_faultvnmpss_align_err5++;
 				}
 				SEGVN_VMSTAT_FLTVNPAGES(34);
@@ -4950,7 +4914,7 @@
 	struct vpage *vpage;
 	uint_t vpprot, prot;
 	int err;
-	page_t *pl[PVN_GETPAGE_NUM + 1];
+	page_t *pl[FAULT_TMP_PAGES_NUM + 1];
 	size_t plsz, pl_alloc_sz;
 	size_t page;
 	ulong_t anon_index;
@@ -5389,7 +5353,7 @@
 			enum seg_rw arw;
 			struct as *as = seg->s_as;
 
-			if (len > ptob((sizeof (pl) / sizeof (pl[0])) - 1)) {
+			if (len > FAULT_TMP_PAGES_SZ) {
 				/*
 				 * Page list won't fit in local array,
 				 * allocate one of the needed size.
@@ -5417,7 +5381,7 @@
 				 * Ask VOP_GETPAGE to return adjacent pages
 				 * within the segment.
 				 */
-				plsz = MIN((size_t)PVN_GETPAGE_SZ, (size_t)
+				plsz = MIN((size_t)FAULT_TMP_PAGES_SZ, (size_t)
 				    ((seg->s_base + seg->s_size) - addr));
 				ASSERT((addr + plsz) <=
 				    (seg->s_base + seg->s_size));
@@ -6084,7 +6048,7 @@
 }
 
 /*
- * segvn_setpagesize is called via SEGOP_SETPAGESIZE from as_setpagesize,
+ * segvn_setpagesize is called via segop_setpagesize from as_setpagesize,
  * to determine if the seg is capable of mapping the requested szc.
  */
 static int
@@ -7072,189 +7036,6 @@
 }
 
 /*
- * Swap the pages of seg out to secondary storage, returning the
- * number of bytes of storage freed.
- *
- * The basic idea is first to unload all translations and then to call
- * VOP_PUTPAGE() for all newly-unmapped pages, to push them out to the
- * swap device.  Pages to which other segments have mappings will remain
- * mapped and won't be swapped.  Our caller (as_swapout) has already
- * performed the unloading step.
- *
- * The value returned is intended to correlate well with the process's
- * memory requirements.  However, there are some caveats:
- * 1)	When given a shared segment as argument, this routine will
- *	only succeed in swapping out pages for the last sharer of the
- *	segment.  (Previous callers will only have decremented mapping
- *	reference counts.)
- * 2)	We assume that the hat layer maintains a large enough translation
- *	cache to capture process reference patterns.
- */
-static size_t
-segvn_swapout(struct seg *seg)
-{
-	struct segvn_data *svd = (struct segvn_data *)seg->s_data;
-	struct anon_map *amp;
-	pgcnt_t pgcnt = 0;
-	pgcnt_t npages;
-	pgcnt_t page;
-	ulong_t anon_index;
-
-	ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
-
-	SEGVN_LOCK_ENTER(seg->s_as, &svd->lock, RW_READER);
-	/*
-	 * Find pages unmapped by our caller and force them
-	 * out to the virtual swap device.
-	 */
-	if ((amp = svd->amp) != NULL)
-		anon_index = svd->anon_index;
-	npages = seg->s_size >> PAGESHIFT;
-	for (page = 0; page < npages; page++) {
-		page_t *pp;
-		struct anon *ap;
-		struct vnode *vp;
-		u_offset_t off;
-		anon_sync_obj_t cookie;
-
-		/*
-		 * Obtain <vp, off> pair for the page, then look it up.
-		 *
-		 * Note that this code is willing to consider regular
-		 * pages as well as anon pages.  Is this appropriate here?
-		 */
-		ap = NULL;
-		if (amp != NULL) {
-			ANON_LOCK_ENTER(&amp->a_rwlock, RW_READER);
-			if (anon_array_try_enter(amp, anon_index + page,
-			    &cookie)) {
-				ANON_LOCK_EXIT(&amp->a_rwlock);
-				continue;
-			}
-			ap = anon_get_ptr(amp->ahp, anon_index + page);
-			if (ap != NULL) {
-				swap_xlate(ap, &vp, &off);
-			} else {
-				vp = svd->vp;
-				off = svd->offset + ptob(page);
-			}
-			anon_array_exit(&cookie);
-			ANON_LOCK_EXIT(&amp->a_rwlock);
-		} else {
-			vp = svd->vp;
-			off = svd->offset + ptob(page);
-		}
-		if (vp == NULL) {		/* untouched zfod page */
-			ASSERT(ap == NULL);
-			continue;
-		}
-
-		pp = page_lookup_nowait(vp, off, SE_SHARED);
-		if (pp == NULL)
-			continue;
-
-
-		/*
-		 * Examine the page to see whether it can be tossed out,
-		 * keeping track of how many we've found.
-		 */
-		if (!page_tryupgrade(pp)) {
-			/*
-			 * If the page has an i/o lock and no mappings,
-			 * it's very likely that the page is being
-			 * written out as a result of klustering.
-			 * Assume this is so and take credit for it here.
-			 */
-			if (!page_io_trylock(pp)) {
-				if (!hat_page_is_mapped(pp))
-					pgcnt++;
-			} else {
-				page_io_unlock(pp);
-			}
-			page_unlock(pp);
-			continue;
-		}
-		ASSERT(!page_iolock_assert(pp));
-
-
-		/*
-		 * Skip if page is locked or has mappings.
-		 * We don't need the page_struct_lock to look at lckcnt
-		 * and cowcnt because the page is exclusive locked.
-		 */
-		if (pp->p_lckcnt != 0 || pp->p_cowcnt != 0 ||
-		    hat_page_is_mapped(pp)) {
-			page_unlock(pp);
-			continue;
-		}
-
-		/*
-		 * dispose skips large pages so try to demote first.
-		 */
-		if (pp->p_szc != 0 && !page_try_demote_pages(pp)) {
-			page_unlock(pp);
-			/*
-			 * XXX should skip the remaining page_t's of this
-			 * large page.
-			 */
-			continue;
-		}
-
-		ASSERT(pp->p_szc == 0);
-
-		/*
-		 * No longer mapped -- we can toss it out.  How
-		 * we do so depends on whether or not it's dirty.
-		 */
-		if (hat_ismod(pp) && pp->p_vnode) {
-			/*
-			 * We must clean the page before it can be
-			 * freed.  Setting B_FREE will cause pvn_done
-			 * to free the page when the i/o completes.
-			 * XXX:	This also causes it to be accounted
-			 *	as a pageout instead of a swap: need
-			 *	B_SWAPOUT bit to use instead of B_FREE.
-			 *
-			 * Hold the vnode before releasing the page lock
-			 * to prevent it from being freed and re-used by
-			 * some other thread.
-			 */
-			VN_HOLD(vp);
-			page_unlock(pp);
-
-			/*
-			 * Queue all i/o requests for the pageout thread
-			 * to avoid saturating the pageout devices.
-			 */
-			if (!queue_io_request(vp, off))
-				VN_RELE(vp);
-		} else {
-			/*
-			 * The page was clean, free it.
-			 *
-			 * XXX:	Can we ever encounter modified pages
-			 *	with no associated vnode here?
-			 */
-			ASSERT(pp->p_vnode != NULL);
-			/*LINTED: constant in conditional context*/
-			VN_DISPOSE(pp, B_FREE, 0, kcred);
-		}
-
-		/*
-		 * Credit now even if i/o is in progress.
-		 */
-		pgcnt++;
-	}
-	SEGVN_LOCK_EXIT(seg->s_as, &svd->lock);
-
-	/*
-	 * Wakeup pageout to initiate i/o on all queued requests.
-	 */
-	cv_signal_pageout();
-	return (ptob(pgcnt));
-}
-
-/*
  * Synchronize primary storage cache with real object in virtual memory.
  *
  * XXX - Anonymous pages should not be sync'ed out at all.
@@ -9691,13 +9472,6 @@
 	return (policy_info);
 }
 
-/*ARGSUSED*/
-static int
-segvn_capable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
-
 /*
  * Bind text vnode segment to an amp. If we bind successfully mappings will be
  * established to per vnode mapping per lgroup amp pages instead of to vnode
--- old/usr/src/uts/common/vm/seg_vn.h	2015-05-08 18:10:37.295488544 -0400
+++ new/usr/src/uts/common/vm/seg_vn.h	2015-05-08 18:10:37.302167909 -0400
@@ -230,7 +230,7 @@
 extern void	segvn_init(void);
 extern int	segvn_create(struct seg *, void *);
 
-extern	struct seg_ops segvn_ops;
+extern const struct seg_ops segvn_ops;
 
 /*
  * Provided as shorthand for creating user zfod segments.
--- old/usr/src/uts/common/vm/vm_anon.c	2015-05-08 18:10:37.499117358 -0400
+++ new/usr/src/uts/common/vm/vm_anon.c	2015-05-08 18:10:37.506200966 -0400
@@ -67,8 +67,8 @@
  * we don't require backing store all anonymous pages in the system.
  * This is important for consideration for large memory systems.
  * We can also use this technique to delay binding physical locations
- * to anonymous pages until pageout/swapout time where we can make
- * smarter allocation decisions to improve anonymous klustering.
+ * to anonymous pages until pageout time where we can make smarter
+ * allocation decisions to improve anonymous klustering.
  *
  * Many of the routines defined here take a (struct anon **) argument,
  * which allows the code at this level to manage anon pages directly,
@@ -3578,43 +3578,6 @@
 	mutex_exit(mtx);
 }
 
-int
-anon_array_try_enter(struct anon_map *amp, ulong_t an_idx,
-			anon_sync_obj_t *sobj)
-{
-	ulong_t		*ap_slot;
-	kmutex_t	*mtx;
-	int		hash;
-
-	/*
-	 * Try to lock a range of anon slots.
-	 * Use szc to determine anon slot(s) to appear atomic.
-	 * If szc = 0, then lock the anon slot and mark it busy.
-	 * If szc > 0, then lock the range of slots by getting the
-	 * anon_array_lock for the first anon slot, and mark only the
-	 * first anon slot busy to represent whole range being busy.
-	 * Fail if the mutex or the anon_array are busy.
-	 */
-
-	ASSERT(RW_READ_HELD(&amp->a_rwlock));
-	an_idx = P2ALIGN(an_idx, page_get_pagecnt(amp->a_szc));
-	hash = ANON_ARRAY_HASH(amp, an_idx);
-	sobj->sync_mutex = mtx = &anon_array_lock[hash].pad_mutex;
-	sobj->sync_cv = &anon_array_cv[hash];
-	if (!mutex_tryenter(mtx)) {
-		return (EWOULDBLOCK);
-	}
-	ap_slot = anon_get_slot(amp->ahp, an_idx);
-	if (ANON_ISBUSY(ap_slot)) {
-		mutex_exit(mtx);
-		return (EWOULDBLOCK);
-	}
-	ANON_SETBUSY(ap_slot);
-	sobj->sync_data = ap_slot;
-	mutex_exit(mtx);
-	return (0);
-}
-
 void
 anon_array_exit(anon_sync_obj_t *sobj)
 {
--- old/usr/src/uts/common/vm/vm_as.c	2015-05-08 18:10:37.802210800 -0400
+++ new/usr/src/uts/common/vm/vm_as.c	2015-05-08 18:10:37.809063933 -0400
@@ -59,7 +59,6 @@
 #include <sys/vtrace.h>
 
 #include <vm/hat.h>
-#include <vm/xhat.h>
 #include <vm/as.h>
 #include <vm/seg.h>
 #include <vm/seg_vn.h>
@@ -474,7 +473,7 @@
 		if (base + seg->s_size > addr) {
 			if (addr >= base || eaddr > base) {
 #ifdef __sparc
-				extern struct seg_ops segnf_ops;
+				extern const struct seg_ops segnf_ops;
 
 				/*
 				 * no-fault segs must disappear if overlaid.
@@ -671,8 +670,6 @@
 	as->a_hat = hat_alloc(as);	/* create hat for default system mmu */
 	AS_LOCK_EXIT(as, &as->a_lock);
 
-	as->a_xhat = NULL;
-
 	return (as);
 }
 
@@ -687,7 +684,7 @@
 {
 	struct hat *hat = as->a_hat;
 	struct seg *seg, *next;
-	int called = 0;
+	boolean_t free_started = B_FALSE;
 
 top:
 	/*
@@ -699,24 +696,19 @@
 	while (as->a_callbacks && as_do_callbacks(as, AS_ALL_EVENT, 0, 0))
 		;
 
-	/* This will prevent new XHATs from attaching to as */
-	if (!called)
-		AS_SETBUSY(as);
 	mutex_exit(&as->a_contents);
 	AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
 
-	if (!called) {
-		called = 1;
+	if (!free_started) {
+		free_started = B_TRUE;
 		hat_free_start(hat);
-		if (as->a_xhat != NULL)
-			xhat_free_start_all(as);
 	}
 	for (seg = AS_SEGFIRST(as); seg != NULL; seg = next) {
 		int err;
 
 		next = AS_SEGNEXT(as, seg);
 retry:
-		err = SEGOP_UNMAP(seg, seg->s_base, seg->s_size);
+		err = segop_unmap(seg, seg->s_base, seg->s_size);
 		if (err == EAGAIN) {
 			mutex_enter(&as->a_contents);
 			if (as->a_callbacks) {
@@ -759,8 +751,6 @@
 		}
 	}
 	hat_free_end(hat);
-	if (as->a_xhat != NULL)
-		xhat_free_end_all(as);
 	AS_LOCK_EXIT(as, &as->a_lock);
 
 	/* /proc stuff */
@@ -794,14 +784,6 @@
 
 	AS_LOCK_ENTER(newas, &newas->a_lock, RW_WRITER);
 
-	/* This will prevent new XHATs from attaching */
-	mutex_enter(&as->a_contents);
-	AS_SETBUSY(as);
-	mutex_exit(&as->a_contents);
-	mutex_enter(&newas->a_contents);
-	AS_SETBUSY(newas);
-	mutex_exit(&newas->a_contents);
-
 	(void) hat_dup(as->a_hat, newas->a_hat, NULL, 0, HAT_DUP_SRD);
 
 	for (seg = AS_SEGFIRST(as); seg != NULL; seg = AS_SEGNEXT(as, seg)) {
@@ -815,23 +797,17 @@
 		if (newseg == NULL) {
 			AS_LOCK_EXIT(newas, &newas->a_lock);
 			as_setwatch(as);
-			mutex_enter(&as->a_contents);
-			AS_CLRBUSY(as);
-			mutex_exit(&as->a_contents);
 			AS_LOCK_EXIT(as, &as->a_lock);
 			as_free(newas);
 			return (-1);
 		}
-		if ((error = SEGOP_DUP(seg, newseg)) != 0) {
+		if ((error = segop_dup(seg, newseg)) != 0) {
 			/*
 			 * We call seg_free() on the new seg
 			 * because the segment is not set up
 			 * completely; i.e. it has no ops.
 			 */
 			as_setwatch(as);
-			mutex_enter(&as->a_contents);
-			AS_CLRBUSY(as);
-			mutex_exit(&as->a_contents);
 			AS_LOCK_EXIT(as, &as->a_lock);
 			seg_free(newseg);
 			AS_LOCK_EXIT(newas, &newas->a_lock);
@@ -843,18 +819,10 @@
 	newas->a_resvsize = as->a_resvsize - purgesize;
 
 	error = hat_dup(as->a_hat, newas->a_hat, NULL, 0, HAT_DUP_ALL);
-	if (as->a_xhat != NULL)
-		error |= xhat_dup_all(as, newas, NULL, 0, HAT_DUP_ALL);
 
-	mutex_enter(&newas->a_contents);
-	AS_CLRBUSY(newas);
-	mutex_exit(&newas->a_contents);
 	AS_LOCK_EXIT(newas, &newas->a_lock);
 
 	as_setwatch(as);
-	mutex_enter(&as->a_contents);
-	AS_CLRBUSY(as);
-	mutex_exit(&as->a_contents);
 	AS_LOCK_EXIT(as, &as->a_lock);
 	if (error != 0) {
 		as_free(newas);
@@ -880,57 +848,45 @@
 	struct seg *segsav;
 	int as_lock_held;
 	klwp_t *lwp = ttolwp(curthread);
-	int is_xhat = 0;
 	int holding_wpage = 0;
-	extern struct seg_ops   segdev_ops;
-
 
 
-	if (as->a_hat != hat) {
-		/* This must be an XHAT then */
-		is_xhat = 1;
-
-		if ((type != F_INVAL) || (as == &kas))
-			return (FC_NOSUPPORT);
-	}
 
 retry:
-	if (!is_xhat) {
-		/*
-		 * Indicate that the lwp is not to be stopped while waiting
-		 * for a pagefault.  This is to avoid deadlock while debugging
-		 * a process via /proc over NFS (in particular).
-		 */
-		if (lwp != NULL)
-			lwp->lwp_nostop++;
+	/*
+	 * Indicate that the lwp is not to be stopped while waiting for a
+	 * pagefault.  This is to avoid deadlock while debugging a process
+	 * via /proc over NFS (in particular).
+	 */
+	if (lwp != NULL)
+		lwp->lwp_nostop++;
 
-		/*
-		 * same length must be used when we softlock and softunlock.
-		 * We don't support softunlocking lengths less than
-		 * the original length when there is largepage support.
-		 * See seg_dev.c for more comments.
-		 */
-		switch (type) {
+	/*
+	 * same length must be used when we softlock and softunlock.  We
+	 * don't support softunlocking lengths less than the original length
+	 * when there is largepage support.  See seg_dev.c for more
+	 * comments.
+	 */
+	switch (type) {
 
-		case F_SOFTLOCK:
-			CPU_STATS_ADD_K(vm, softlock, 1);
-			break;
+	case F_SOFTLOCK:
+		CPU_STATS_ADD_K(vm, softlock, 1);
+		break;
 
-		case F_SOFTUNLOCK:
-			break;
+	case F_SOFTUNLOCK:
+		break;
 
-		case F_PROT:
-			CPU_STATS_ADD_K(vm, prot_fault, 1);
-			break;
+	case F_PROT:
+		CPU_STATS_ADD_K(vm, prot_fault, 1);
+		break;
 
-		case F_INVAL:
-			CPU_STATS_ENTER_K();
-			CPU_STATS_ADDQ(CPU, vm, as_fault, 1);
-			if (as == &kas)
-				CPU_STATS_ADDQ(CPU, vm, kernel_asflt, 1);
-			CPU_STATS_EXIT_K();
-			break;
-		}
+	case F_INVAL:
+		CPU_STATS_ENTER_K();
+		CPU_STATS_ADDQ(CPU, vm, as_fault, 1);
+		if (as == &kas)
+			CPU_STATS_ADDQ(CPU, vm, kernel_asflt, 1);
+		CPU_STATS_EXIT_K();
+		break;
 	}
 
 	/* Kernel probe */
@@ -952,35 +908,15 @@
 	 */
 	if (as == &kas && segkmap && segkmap->s_base <= raddr &&
 	    raddr + size < segkmap->s_base + segkmap->s_size) {
-		/*
-		 * if (as==&kas), this can't be XHAT: we've already returned
-		 * FC_NOSUPPORT.
-		 */
 		seg = segkmap;
 		as_lock_held = 0;
 	} else {
 		AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
-		if (is_xhat && avl_numnodes(&as->a_wpage) != 0) {
-			/*
-			 * Grab and hold the writers' lock on the as
-			 * if the fault is to a watched page.
-			 * This will keep CPUs from "peeking" at the
-			 * address range while we're temporarily boosting
-			 * the permissions for the XHAT device to
-			 * resolve the fault in the segment layer.
-			 *
-			 * We could check whether faulted address
-			 * is within a watched page and only then grab
-			 * the writer lock, but this is simpler.
-			 */
-			AS_LOCK_EXIT(as, &as->a_lock);
-			AS_LOCK_ENTER(as, &as->a_lock, RW_WRITER);
-		}
 
 		seg = as_segat(as, raddr);
 		if (seg == NULL) {
 			AS_LOCK_EXIT(as, &as->a_lock);
-			if ((lwp != NULL) && (!is_xhat))
+			if (lwp != NULL)
 				lwp->lwp_nostop--;
 			return (FC_NOMAP);
 		}
@@ -1004,35 +940,16 @@
 		else
 			ssize = rsize;
 
-		if (!is_xhat || (seg->s_ops != &segdev_ops)) {
-
-			if (is_xhat && avl_numnodes(&as->a_wpage) != 0 &&
-			    pr_is_watchpage_as(raddr, rw, as)) {
-				/*
-				 * Handle watch pages.  If we're faulting on a
-				 * watched page from an X-hat, we have to
-				 * restore the original permissions while we
-				 * handle the fault.
-				 */
-				as_clearwatch(as);
-				holding_wpage = 1;
-			}
-
-			res = SEGOP_FAULT(hat, seg, raddr, ssize, type, rw);
+		res = segop_fault(hat, seg, raddr, ssize, type, rw);
 
-			/* Restore watchpoints */
-			if (holding_wpage) {
-				as_setwatch(as);
-				holding_wpage = 0;
-			}
+		/* Restore watchpoints */
+		if (holding_wpage) {
+			as_setwatch(as);
+			holding_wpage = 0;
+		}
 
-			if (res != 0)
-				break;
-		} else {
-			/* XHAT does not support seg_dev */
-			res = FC_NOSUPPORT;
+		if (res != 0)
 			break;
-		}
 	}
 
 	/*
@@ -1055,13 +972,13 @@
 				ssize = seg->s_base + seg->s_size - addrsav;
 			else
 				ssize = raddr - addrsav;
-			(void) SEGOP_FAULT(hat, seg, addrsav, ssize,
+			(void) segop_fault(hat, seg, addrsav, ssize,
 			    F_SOFTUNLOCK, S_OTHER);
 		}
 	}
 	if (as_lock_held)
 		AS_LOCK_EXIT(as, &as->a_lock);
-	if ((lwp != NULL) && (!is_xhat))
+	if (lwp != NULL)
 		lwp->lwp_nostop--;
 
 	/*
@@ -1125,7 +1042,7 @@
 				break;
 			}
 		}
-		res = SEGOP_FAULTA(seg, raddr);
+		res = segop_faulta(seg, raddr);
 		if (res != 0)
 			break;
 	}
@@ -1215,7 +1132,7 @@
 		else
 			ssize = rsize;
 retry:
-		error = SEGOP_SETPROT(seg, raddr, ssize, prot);
+		error = segop_setprot(seg, raddr, ssize, prot);
 
 		if (error == IE_NOMEM) {
 			error = EAGAIN;
@@ -1366,7 +1283,7 @@
 		else
 			ssize = rsize;
 
-		error = SEGOP_CHECKPROT(seg, raddr, ssize, prot);
+		error = segop_checkprot(seg, raddr, ssize, prot);
 		if (error != 0)
 			break;
 	}
@@ -1432,7 +1349,7 @@
 			rsize = ssize;
 
 retry:
-		err = SEGOP_UNMAP(seg, raddr, ssize);
+		err = segop_unmap(seg, raddr, ssize);
 		if (err == EAGAIN) {
 			/*
 			 * Memory is currently locked.  It must be unlocked
@@ -1870,7 +1787,7 @@
 	while (seg != NULL) {
 		next_seg = AS_SEGNEXT(as, seg);
 		if (seg->s_flags & S_PURGE)
-			SEGOP_UNMAP(seg, seg->s_base, seg->s_size);
+			segop_unmap(seg, seg->s_base, seg->s_size);
 		seg = next_seg;
 	}
 	AS_LOCK_EXIT(as, &as->a_lock);
@@ -2088,7 +2005,7 @@
 int
 as_memory(struct as *as, caddr_t *basep, size_t *lenp)
 {
-	extern struct seg_ops segspt_shmops;	/* needs a header file */
+	extern const struct seg_ops segspt_shmops;	/* needs a header file */
 	struct seg *seg;
 	caddr_t addr, eaddr;
 	caddr_t segend;
@@ -2141,73 +2058,6 @@
 }
 
 /*
- * Swap the pages associated with the address space as out to
- * secondary storage, returning the number of bytes actually
- * swapped.
- *
- * The value returned is intended to correlate well with the process's
- * memory requirements.  Its usefulness for this purpose depends on
- * how well the segment-level routines do at returning accurate
- * information.
- */
-size_t
-as_swapout(struct as *as)
-{
-	struct seg *seg;
-	size_t swpcnt = 0;
-
-	/*
-	 * Kernel-only processes have given up their address
-	 * spaces.  Of course, we shouldn't be attempting to
-	 * swap out such processes in the first place...
-	 */
-	if (as == NULL)
-		return (0);
-
-	AS_LOCK_ENTER(as, &as->a_lock, RW_READER);
-
-	/* Prevent XHATs from attaching */
-	mutex_enter(&as->a_contents);
-	AS_SETBUSY(as);
-	mutex_exit(&as->a_contents);
-
-
-	/*
-	 * Free all mapping resources associated with the address
-	 * space.  The segment-level swapout routines capitalize
-	 * on this unmapping by scavanging pages that have become
-	 * unmapped here.
-	 */
-	hat_swapout(as->a_hat);
-	if (as->a_xhat != NULL)
-		xhat_swapout_all(as);
-
-	mutex_enter(&as->a_contents);
-	AS_CLRBUSY(as);
-	mutex_exit(&as->a_contents);
-
-	/*
-	 * Call the swapout routines of all segments in the address
-	 * space to do the actual work, accumulating the amount of
-	 * space reclaimed.
-	 */
-	for (seg = AS_SEGFIRST(as); seg != NULL; seg = AS_SEGNEXT(as, seg)) {
-		struct seg_ops *ov = seg->s_ops;
-
-		/*
-		 * We have to check to see if the seg has
-		 * an ops vector because the seg may have
-		 * been in the middle of being set up when
-		 * the process was picked for swapout.
-		 */
-		if ((ov != NULL) && (ov->swapout != NULL))
-			swpcnt += SEGOP_SWAPOUT(seg);
-	}
-	AS_LOCK_EXIT(as, &as->a_lock);
-	return (swpcnt);
-}
-
-/*
  * Determine whether data from the mappings in interval [addr, addr + size)
  * are in the primary memory (core) cache.
  */
@@ -2249,7 +2099,7 @@
 			ssize = seg->s_base + seg->s_size - raddr;
 		else
 			ssize = rsize;
-		*sizep += isize = SEGOP_INCORE(seg, raddr, ssize, vec);
+		*sizep += isize = segop_incore(seg, raddr, ssize, vec);
 		if (isize != ssize) {
 			error = -1;
 			break;
@@ -2275,7 +2125,7 @@
 		range_start = (caddr_t)((uintptr_t)addr +
 		    ptob(pos1 - position));
 
-		(void) SEGOP_LOCKOP(seg, range_start, size, attr, MC_UNLOCK,
+		(void) segop_lockop(seg, range_start, size, attr, MC_UNLOCK,
 		    (ulong_t *)NULL, (size_t)NULL);
 		pos1 = pos2;
 	}
@@ -2371,7 +2221,7 @@
 		}
 
 		for (seg = AS_SEGFIRST(as); seg; seg = AS_SEGNEXT(as, seg)) {
-			error = SEGOP_LOCKOP(seg, seg->s_base,
+			error = segop_lockop(seg, seg->s_base,
 			    seg->s_size, attr, MC_LOCK, mlock_map, pos);
 			if (error != 0)
 				break;
@@ -2400,7 +2250,7 @@
 		mutex_exit(&as->a_contents);
 
 		for (seg = AS_SEGFIRST(as); seg; seg = AS_SEGNEXT(as, seg)) {
-			error = SEGOP_LOCKOP(seg, seg->s_base,
+			error = segop_lockop(seg, seg->s_base,
 			    seg->s_size, attr, MC_UNLOCK, NULL, 0);
 			if (error != 0)
 				break;
@@ -2478,7 +2328,7 @@
 		 * objects.
 		 */
 		case MC_SYNC:
-			if (error = SEGOP_SYNC(seg, raddr, ssize,
+			if (error = segop_sync(seg, raddr, ssize,
 			    attr, (uint_t)arg)) {
 				AS_LOCK_EXIT(as, &as->a_lock);
 				return (error);
@@ -2489,7 +2339,7 @@
 		 * Lock pages in memory.
 		 */
 		case MC_LOCK:
-			if (error = SEGOP_LOCKOP(seg, raddr, ssize,
+			if (error = segop_lockop(seg, raddr, ssize,
 			    attr, func, mlock_map, pos)) {
 				as_unlockerr(as, attr, mlock_map, initraddr,
 				    initrsize - rsize + ssize);
@@ -2504,7 +2354,7 @@
 		 * Unlock mapped pages.
 		 */
 		case MC_UNLOCK:
-			(void) SEGOP_LOCKOP(seg, raddr, ssize, attr, func,
+			(void) segop_lockop(seg, raddr, ssize, attr, func,
 			    (ulong_t *)NULL, (size_t)NULL);
 			break;
 
@@ -2512,7 +2362,7 @@
 		 * Store VM advise for mapped pages in segment layer.
 		 */
 		case MC_ADVISE:
-			error = SEGOP_ADVISE(seg, raddr, ssize, (uint_t)arg);
+			error = segop_advise(seg, raddr, ssize, (uint_t)arg);
 
 			/*
 			 * Check for regular errors and special retry error
@@ -2548,12 +2398,7 @@
 			break;
 
 		case MC_INHERIT_ZERO:
-			if (seg->s_ops->inherit == NULL) {
-				error = ENOTSUP;
-			} else {
-				error = SEGOP_INHERIT(seg, raddr, ssize,
-				    SEGP_INH_ZERO);
-			}
+			error = segop_inherit(seg, raddr, ssize, SEGP_INH_ZERO);
 			if (error != 0) {
 				AS_LOCK_EXIT(as, &as->a_lock);
 				return (error);
@@ -2637,7 +2482,7 @@
 	caddr_t eaddr;
 	faultcode_t fault_err = 0;
 	pgcnt_t pl_off;
-	extern struct seg_ops segspt_shmops;
+	extern const struct seg_ops segspt_shmops;
 
 	ASSERT(AS_LOCK_HELD(as, &as->a_lock));
 	ASSERT(seg != NULL);
@@ -2666,7 +2511,7 @@
 			if (seg->s_ops == &segvn_ops) {
 				vnode_t *vp;
 
-				if (SEGOP_GETVP(seg, addr, &vp) != 0 ||
+				if (segop_getvp(seg, addr, &vp) != 0 ||
 				    vp != NULL) {
 					AS_LOCK_EXIT(as, &as->a_lock);
 					goto slow;
@@ -2704,7 +2549,7 @@
 			ssize = size;
 		}
 		pl = &plist[npages + cnt];
-		error = SEGOP_PAGELOCK(seg, addr, ssize, (page_t ***)pl,
+		error = segop_pagelock(seg, addr, ssize, (page_t ***)pl,
 		    L_PAGELOCK, rw);
 		if (error) {
 			break;
@@ -2747,7 +2592,7 @@
 		}
 		pl = &plist[npages + cnt];
 		ASSERT(*pl != NULL);
-		(void) SEGOP_PAGELOCK(seg, addr, ssize, (page_t ***)pl,
+		(void) segop_pagelock(seg, addr, ssize, (page_t ***)pl,
 		    L_PAGEUNLOCK, rw);
 	}
 
@@ -2822,7 +2667,7 @@
 	/*
 	 * try to lock pages and pass back shadow list
 	 */
-	err = SEGOP_PAGELOCK(seg, raddr, rsize, ppp, L_PAGELOCK, rw);
+	err = segop_pagelock(seg, raddr, rsize, ppp, L_PAGELOCK, rw);
 
 	TRACE_0(TR_FAC_PHYSIO, TR_PHYSIO_SEG_LOCK_END, "seg_lock_1_end");
 
@@ -2885,7 +2730,7 @@
 		}
 		pl = &plist[npages + cnt];
 		ASSERT(*pl != NULL);
-		(void) SEGOP_PAGELOCK(seg, addr, ssize, (page_t ***)pl,
+		(void) segop_pagelock(seg, addr, ssize, (page_t ***)pl,
 		    L_PAGEUNLOCK, rw);
 	}
 	ASSERT(cnt > 0);
@@ -2931,7 +2776,7 @@
 
 	ASSERT(raddr >= seg->s_base && raddr < seg->s_base + seg->s_size);
 	if (raddr + rsize <= seg->s_base + seg->s_size) {
-		SEGOP_PAGELOCK(seg, raddr, rsize, &pp, L_PAGEUNLOCK, rw);
+		segop_pagelock(seg, raddr, rsize, &pp, L_PAGEUNLOCK, rw);
 	} else {
 		as_pageunlock_segs(as, seg, raddr, rsize, pp, rw);
 		return;
@@ -2986,7 +2831,7 @@
 		}
 
 retry:
-		error = SEGOP_SETPAGESIZE(seg, raddr, ssize, szc);
+		error = segop_setpagesize(seg, raddr, ssize, szc);
 
 		if (error == IE_NOMEM) {
 			error = EAGAIN;
@@ -3065,7 +2910,7 @@
 }
 
 /*
- * as_iset3_default_lpsize() just calls SEGOP_SETPAGESIZE() on all segments
+ * as_iset3_default_lpsize() just calls segop_setpagesize() on all segments
  * in its chunk where s_szc is less than the szc we want to set.
  */
 static int
@@ -3097,12 +2942,12 @@
 		}
 
 		if (szc > seg->s_szc) {
-			error = SEGOP_SETPAGESIZE(seg, raddr, ssize, szc);
+			error = segop_setpagesize(seg, raddr, ssize, szc);
 			/* Only retry on EINVAL segments that have no vnode. */
 			if (error == EINVAL) {
 				vnode_t *vp = NULL;
-				if ((SEGOP_GETTYPE(seg, raddr) & MAP_SHARED) &&
-				    (SEGOP_GETVP(seg, raddr, &vp) != 0 ||
+				if ((segop_gettype(seg, raddr) & MAP_SHARED) &&
+				    (segop_getvp(seg, raddr, &vp) != 0 ||
 				    vp == NULL)) {
 					*retry = 1;
 				} else {
@@ -3345,7 +3190,7 @@
 		return (ENOMEM);
 	}
 	if (seg->s_ops == &segvn_ops) {
-		rtype = SEGOP_GETTYPE(seg, addr);
+		rtype = segop_gettype(seg, addr);
 		rflags = rtype & (MAP_TEXT | MAP_INITDATA);
 		rtype = rtype & (MAP_SHARED | MAP_PRIVATE);
 		segvn = 1;
@@ -3363,7 +3208,7 @@
 				break;
 			}
 			if (seg->s_ops == &segvn_ops) {
-				stype = SEGOP_GETTYPE(seg, raddr);
+				stype = segop_gettype(seg, raddr);
 				sflags = stype & (MAP_TEXT | MAP_INITDATA);
 				stype &= (MAP_SHARED | MAP_PRIVATE);
 				if (segvn && (rflags != sflags ||
@@ -3477,7 +3322,7 @@
 		vaddr = pwp->wp_vaddr;
 		if (pwp->wp_oprot != 0 ||	/* already set up */
 		    (seg = as_segat(as, vaddr)) == NULL ||
-		    SEGOP_GETPROT(seg, vaddr, 0, &prot) != 0)
+		    segop_getprot(seg, vaddr, 0, &prot) != 0)
 			continue;
 
 		pwp->wp_oprot = prot;
@@ -3488,7 +3333,7 @@
 		if (pwp->wp_exec)
 			prot &= ~(PROT_READ|PROT_WRITE|PROT_EXEC);
 		if (!(pwp->wp_flags & WP_NOWATCH) && prot != pwp->wp_oprot) {
-			err = SEGOP_SETPROT(seg, vaddr, PAGESIZE, prot);
+			err = segop_setprot(seg, vaddr, PAGESIZE, prot);
 			if (err == IE_RETRY) {
 				pwp->wp_oprot = 0;
 				ASSERT(retrycnt == 0);
@@ -3527,7 +3372,7 @@
 			continue;
 
 		if ((prot = pwp->wp_oprot) != pwp->wp_prot) {
-			err = SEGOP_SETPROT(seg, vaddr, PAGESIZE, prot);
+			err = segop_setprot(seg, vaddr, PAGESIZE, prot);
 			if (err == IE_RETRY) {
 				ASSERT(retrycnt == 0);
 				retrycnt++;
@@ -3581,7 +3426,7 @@
 				panic("as_setwatchprot: no seg");
 				/*NOTREACHED*/
 			}
-			err = SEGOP_SETPROT(seg, vaddr, PAGESIZE, wprot);
+			err = segop_setprot(seg, vaddr, PAGESIZE, wprot);
 			if (err == IE_RETRY) {
 				ASSERT(retrycnt == 0);
 				retrycnt++;
@@ -3628,7 +3473,7 @@
 				seg = as_segat(as, pwp->wp_vaddr);
 				if (seg == NULL)
 					continue;
-				err = SEGOP_SETPROT(seg, pwp->wp_vaddr,
+				err = segop_setprot(seg, pwp->wp_vaddr,
 				    PAGESIZE, prot);
 				if (err == IE_RETRY) {
 					ASSERT(retrycnt == 0);
@@ -3677,15 +3522,8 @@
 		AS_LOCK_EXIT(as, &as->a_lock);
 		return (EFAULT);
 	}
-	/*
-	 * catch old drivers which may not support getmemid
-	 */
-	if (seg->s_ops->getmemid == NULL) {
-		AS_LOCK_EXIT(as, &as->a_lock);
-		return (ENODEV);
-	}
 
-	sts = SEGOP_GETMEMID(seg, addr, memidp);
+	sts = segop_getmemid(seg, addr, memidp);
 
 	AS_LOCK_EXIT(as, &as->a_lock);
 	return (sts);
--- old/usr/src/uts/common/vm/vm_pvn.c	2015-05-08 18:10:38.149168822 -0400
+++ new/usr/src/uts/common/vm/vm_pvn.c	2015-05-08 18:10:38.155875839 -0400
@@ -140,7 +140,7 @@
 	vp_end = vp_off + vp_len;
 	ASSERT(off >= vp_off && off < vp_end);
 
-	if (isra && SEGOP_KLUSTER(seg, addr, 0))
+	if (isra && segop_kluster(seg, addr, 0))
 		return ((page_t *)NULL);	/* segment driver says no */
 
 	if ((plist = page_create_va(vp, off,
@@ -162,7 +162,7 @@
 			 * Call back to the segment driver to verify that
 			 * the klustering/read ahead operation makes sense.
 			 */
-			if (SEGOP_KLUSTER(seg, addr, -deltab))
+			if (segop_kluster(seg, addr, -deltab))
 				break;		/* page not eligible */
 			if ((pp = page_create_va(vp, off - deltab,
 			    PAGESIZE, PG_EXCL, seg, addr - deltab))
@@ -182,7 +182,7 @@
 			 * Call back to the segment driver to verify that
 			 * the klustering/read ahead operation makes sense.
 			 */
-			if (SEGOP_KLUSTER(seg, addr, deltaf))
+			if (segop_kluster(seg, addr, deltaf))
 				break;		/* page not file extension */
 			if ((pp = page_create_va(vp, off + deltaf,
 			    PAGESIZE, PG_EXCL, seg, addr + deltaf))
--- old/usr/src/uts/common/vm/vm_rm.c	2015-05-08 18:10:38.381356527 -0400
+++ new/usr/src/uts/common/vm/vm_rm.c	2015-05-08 18:10:38.388070758 -0400
@@ -65,7 +65,7 @@
  * physical page is present and the hardware translation is missing;
  * and it can overestimate the rss, eg, if there are active
  * translations to a frame buffer with page structs.
- * Also, it does not take sharing and XHATs into account.
+ * Also, it does not take sharing into account.
  */
 size_t
 rm_asrss(as)
--- old/usr/src/uts/common/vm/vm_seg.c	2015-05-08 18:10:38.574607051 -0400
+++ new/usr/src/uts/common/vm/vm_seg.c	2015-05-08 18:10:38.581398881 -0400
@@ -126,7 +126,6 @@
  */
 
 int	segpcache_enabled = 1;		/* if 1, shadow lists are cached */
-pgcnt_t	segpcache_maxwindow = 0;	/* max # of pages that can be cached */
 ulong_t	segpcache_hashsize_win = 0;	/* # of non wired buckets */
 ulong_t	segpcache_hashsize_wired = 0;	/* # of wired buckets */
 int	segpcache_reap_sec = 1;		/* reap check rate in secs */
@@ -149,14 +148,13 @@
  */
 static struct p_ctrl1 {
 	uint_t p_disabled;		/* if not 0, caching temporarily off */
-	pgcnt_t p_maxwin;		/* max # of pages that can be cached */
 	size_t p_hashwin_sz;		/* # of non wired buckets */
 	struct seg_phash *p_htabwin;	/* hash table for non wired entries */
 	size_t p_hashwired_sz;		/* # of wired buckets */
 	struct seg_phash_wired *p_htabwired; /* hash table for wired entries */
 	kmem_cache_t *p_kmcache;	/* kmem cache for seg_pcache structs */
 #ifdef _LP64
-	ulong_t pad[1];
+	ulong_t pad[2];
 #endif /* _LP64 */
 } pctrl1;
 
@@ -181,7 +179,6 @@
 } pctrl3;
 
 #define	seg_pdisabled			pctrl1.p_disabled
-#define	seg_pmaxwindow			pctrl1.p_maxwin
 #define	seg_phashsize_win		pctrl1.p_hashwin_sz
 #define	seg_phashtab_win		pctrl1.p_htabwin
 #define	seg_phashsize_wired		pctrl1.p_hashwired_sz
@@ -205,8 +202,8 @@
 
 kthread_t *seg_pasync_thr;
 
-extern struct seg_ops segvn_ops;
-extern struct seg_ops segspt_shmops;
+extern const struct seg_ops segvn_ops;
+extern const struct seg_ops segspt_shmops;
 
 #define	IS_PFLAGS_WIRED(flags) ((flags) & SEGP_FORCE_WIRED)
 #define	IS_PCP_WIRED(pcp) IS_PFLAGS_WIRED((pcp)->p_flags)
@@ -756,10 +753,6 @@
 		return (SEGP_SUCCESS);
 	}
 
-	if (seg_plocked_window + btop(len) > seg_pmaxwindow) {
-		return (SEGP_FAIL);
-	}
-
 	if (freemem < desfree) {
 		return (SEGP_FAIL);
 	}
@@ -829,10 +822,6 @@
 	npages = btop(len);
 	mutex_enter(&seg_pmem_mtx);
 	if (!IS_PFLAGS_WIRED(flags)) {
-		if (seg_plocked_window + npages > seg_pmaxwindow) {
-			mutex_exit(&seg_pmem_mtx);
-			return (SEGP_FAIL);
-		}
 		seg_plocked_window += npages;
 	}
 	seg_plocked += npages;
@@ -948,7 +937,6 @@
 	pcache_link_t *hlinkp;
 	pcache_link_t *hlnextp = NULL;
 	int lowmem;
-	int trim;
 
 	ASSERT(seg_phashsize_win != 0);
 
@@ -961,7 +949,6 @@
 
 	if (!force) {
 		lowmem = 0;
-		trim = 0;
 		if (freemem < lotsfree + needfree) {
 			spgcnt_t fmem = MAX((spgcnt_t)(freemem - needfree), 0);
 			if (fmem <= 5 * (desfree >> 2)) {
@@ -978,10 +965,7 @@
 				}
 			}
 		}
-		if (seg_plocked_window >= 7 * (seg_pmaxwindow >> 3)) {
-			trim = 1;
-		}
-		if (!lowmem && !trim) {
+		if (!lowmem) {
 			return;
 		}
 		npgs_to_purge = seg_plocked_window >>
@@ -1109,7 +1093,7 @@
 			if (npgs_purged >= npgs_to_purge) {
 				break;
 			}
-			if (!trim && !(seg_pathr_full_ahb & 15)) {
+			if (!(seg_pathr_full_ahb & 15)) {
 				ASSERT(lowmem);
 				if (freemem >= lotsfree + needfree) {
 					break;
@@ -1470,25 +1454,6 @@
 		mutex_init(&hp->p_hmutex, NULL, MUTEX_DEFAULT, NULL);
 	}
 
-	if (segpcache_maxwindow == 0) {
-		if (physmegs < 64) {
-			/* 3% of memory */
-			segpcache_maxwindow = availrmem >> 5;
-		} else if (physmegs < 512) {
-			/* 12% of memory */
-			segpcache_maxwindow = availrmem >> 3;
-		} else if (physmegs < 1024) {
-			/* 25% of memory */
-			segpcache_maxwindow = availrmem >> 2;
-		} else if (physmegs < 2048) {
-			/* 50% of memory */
-			segpcache_maxwindow = availrmem >> 1;
-		} else {
-			/* no limit */
-			segpcache_maxwindow = (pgcnt_t)-1;
-		}
-	}
-	seg_pmaxwindow = segpcache_maxwindow;
 	seg_pinit_mem_config();
 }
 
@@ -1636,7 +1601,7 @@
 /*
  * Unmap a segment and free it from its associated address space.
  * This should be called by anybody who's finished with a whole segment's
- * mapping.  Just calls SEGOP_UNMAP() on the whole mapping .  It is the
+ * mapping.  Just calls segop_unmap() on the whole mapping .  It is the
  * responsibility of the segment driver to unlink the the segment
  * from the address space, and to free public and private data structures
  * associated with the segment.  (This is typically done by a call to
@@ -1656,10 +1621,10 @@
 
 	/* Unmap the whole mapping */
 #ifdef DEBUG
-	ret = SEGOP_UNMAP(seg, seg->s_base, seg->s_size);
+	ret = segop_unmap(seg, seg->s_base, seg->s_size);
 	ASSERT(ret == 0);
 #else
-	SEGOP_UNMAP(seg, seg->s_base, seg->s_size);
+	segop_unmap(seg, seg->s_base, seg->s_size);
 #endif /* DEBUG */
 }
 
@@ -1685,7 +1650,7 @@
 	 * then segment driver is not attached yet.
 	 */
 	if (seg->s_data != NULL)
-		SEGOP_FREE(seg);
+		segop_free(seg);
 
 	mutex_destroy(&seg->s_pmtx);
 	ASSERT(seg->s_phead.p_lnext == &seg->s_phead);
@@ -1854,11 +1819,197 @@
 }
 
 /*
- * General not supported function for SEGOP_INHERIT
+ * segop wrappers
  */
-/* ARGSUSED */
 int
-seg_inherit_notsup(struct seg *seg, caddr_t addr, size_t len, uint_t op)
+segop_dup(struct seg *seg, struct seg *new)
+{
+	VERIFY3P(seg->s_ops->dup, !=, NULL);
+
+	return (seg->s_ops->dup(seg, new));
+}
+
+int
+segop_unmap(struct seg *seg, caddr_t addr, size_t len)
+{
+	VERIFY3P(seg->s_ops->unmap, !=, NULL);
+
+	return (seg->s_ops->unmap(seg, addr, len));
+}
+
+void
+segop_free(struct seg *seg)
+{
+	VERIFY3P(seg->s_ops->free, !=, NULL);
+
+	seg->s_ops->free(seg);
+}
+
+faultcode_t
+segop_fault(struct hat *hat, struct seg *seg, caddr_t addr, size_t len,
+    enum fault_type type, enum seg_rw rw)
+{
+	VERIFY3P(seg->s_ops->fault, !=, NULL);
+
+	return (seg->s_ops->fault(hat, seg, addr, len, type, rw));
+}
+
+faultcode_t
+segop_faulta(struct seg *seg, caddr_t addr)
+{
+	VERIFY3P(seg->s_ops->faulta, !=, NULL);
+
+	return (seg->s_ops->faulta(seg, addr));
+}
+
+int
+segop_setprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
+{
+	VERIFY3P(seg->s_ops->setprot, !=, NULL);
+
+	return (seg->s_ops->setprot(seg, addr, len, prot));
+}
+
+int
+segop_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
+{
+	VERIFY3P(seg->s_ops->checkprot, !=, NULL);
+
+	return (seg->s_ops->checkprot(seg, addr, len, prot));
+}
+
+int
+segop_kluster(struct seg *seg, caddr_t addr, ssize_t d)
+{
+	VERIFY3P(seg->s_ops->kluster, !=, NULL);
+
+	return (seg->s_ops->kluster(seg, addr, d));
+}
+
+int
+segop_sync(struct seg *seg, caddr_t addr, size_t len, int atr, uint_t f)
+{
+	VERIFY3P(seg->s_ops->sync, !=, NULL);
+
+	return (seg->s_ops->sync(seg, addr, len, atr, f));
+}
+
+size_t
+segop_incore(struct seg *seg, caddr_t addr, size_t len, char *v)
 {
-	return (ENOTSUP);
+	VERIFY3P(seg->s_ops->incore, !=, NULL);
+
+	return (seg->s_ops->incore(seg, addr, len, v));
+}
+
+int
+segop_lockop(struct seg *seg, caddr_t addr, size_t len, int atr, int op,
+    ulong_t *b, size_t p)
+{
+	VERIFY3P(seg->s_ops->lockop, !=, NULL);
+
+	return (seg->s_ops->lockop(seg, addr, len, atr, op, b, p));
+}
+
+int
+segop_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *p)
+{
+	VERIFY3P(seg->s_ops->getprot, !=, NULL);
+
+	return (seg->s_ops->getprot(seg, addr, len, p));
+}
+
+u_offset_t
+segop_getoffset(struct seg *seg, caddr_t addr)
+{
+	VERIFY3P(seg->s_ops->getoffset, !=, NULL);
+
+	return (seg->s_ops->getoffset(seg, addr));
+}
+
+int
+segop_gettype(struct seg *seg, caddr_t addr)
+{
+	VERIFY3P(seg->s_ops->gettype, !=, NULL);
+
+	return (seg->s_ops->gettype(seg, addr));
+}
+
+int
+segop_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
+{
+	VERIFY3P(seg->s_ops->getvp, !=, NULL);
+
+	return (seg->s_ops->getvp(seg, addr, vpp));
+}
+
+int
+segop_advise(struct seg *seg, caddr_t addr, size_t len, uint_t b)
+{
+	VERIFY3P(seg->s_ops->advise, !=, NULL);
+
+	return (seg->s_ops->advise(seg, addr, len, b));
+}
+
+void
+segop_dump(struct seg *seg)
+{
+	if (seg->s_ops->dump == NULL)
+		return;
+
+	seg->s_ops->dump(seg);
+}
+
+int
+segop_pagelock(struct seg *seg, caddr_t addr, size_t len, struct page ***page,
+    enum lock_type type, enum seg_rw rw)
+{
+	VERIFY3P(seg->s_ops->pagelock, !=, NULL);
+
+	return (seg->s_ops->pagelock(seg, addr, len, page, type, rw));
+}
+
+int
+segop_setpagesize(struct seg *seg, caddr_t addr, size_t len, uint_t szc)
+{
+	if (seg->s_ops->setpagesize == NULL)
+		return (ENOTSUP);
+
+	return (seg->s_ops->setpagesize(seg, addr, len, szc));
+}
+
+int
+segop_getmemid(struct seg *seg, caddr_t addr, memid_t *mp)
+{
+	if (seg->s_ops->getmemid == NULL)
+		return (ENODEV);
+
+	return (seg->s_ops->getmemid(seg, addr, mp));
+}
+
+struct lgrp_mem_policy_info *
+segop_getpolicy(struct seg *seg, caddr_t addr)
+{
+	if (seg->s_ops->getpolicy == NULL)
+		return (NULL);
+
+	return (seg->s_ops->getpolicy(seg, addr));
+}
+
+int
+segop_capable(struct seg *seg, segcapability_t cap)
+{
+	if (seg->s_ops->capable == NULL)
+		return (0);
+
+	return (seg->s_ops->capable(seg, cap));
+}
+
+int
+segop_inherit(struct seg *seg, caddr_t addr, size_t len, uint_t op)
+{
+	if (seg->s_ops->inherit == NULL)
+		return (ENOTSUP);
+
+	return (seg->s_ops->inherit(seg, addr, len, op));
 }
--- old/usr/src/uts/common/vm/vm_usage.c	2015-05-08 18:10:38.838522958 -0400
+++ new/usr/src/uts/common/vm/vm_usage.c	2015-05-08 18:10:38.845608122 -0400
@@ -297,8 +297,8 @@
 extern struct as kas;
 extern proc_t *practive;
 extern zone_t *global_zone;
-extern struct seg_ops segvn_ops;
-extern struct seg_ops segspt_shmops;
+extern const struct seg_ops segvn_ops;
+extern const struct seg_ops segspt_shmops;
 
 static vmu_data_t vmu_data;
 static kmem_cache_t *vmu_bound_cache;
--- old/usr/src/uts/common/vm/xhat.c	2015-05-08 18:10:39.094408577 -0400
+++ /dev/null	2015-05-08 18:10:39.000000000 -0400
@@ -1,555 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/mman.h>
-#include <sys/systm.h>
-#include <vm/xhat.h>
-#include <vm/page.h>
-#include <vm/as.h>
-
-int xhat_debug = 0;
-
-krwlock_t xhat_provider_rwlock;
-xhat_provider_t *xhat_provider = NULL;
-
-void
-xhat_init()
-{
-	rw_init(&xhat_provider_rwlock, NULL, RW_DEFAULT, NULL);
-}
-
-
-
-int
-xhat_provider_register(xhat_provider_t *provider)
-{
-	/* strlen("_cache") = 7 */
-	char	cache_name[XHAT_CACHE_NAMELEN + 7];
-
-
-	if (provider->xhat_provider_version != XHAT_PROVIDER_VERSION) {
-		cmn_err(CE_WARN, "XHAT provider version mismatch");
-		return (-1);
-	}
-
-	if ((XHAT_POPS(provider)->xhat_alloc == NULL) ||
-	    (XHAT_POPS(provider)->xhat_free == NULL)) {
-		cmn_err(CE_WARN, "Malformed XHAT provider");
-		return (-1);
-	}
-
-	/* Allocate kmem_cache which will manage xhat blocks */
-	provider->xblkcache->free_blks = NULL;
-	(void) strncpy(cache_name, provider->xhat_provider_name,
-	    XHAT_CACHE_NAMELEN);
-	(void) strcat(cache_name, "_cache");
-	provider->xblkcache->cache = kmem_cache_create(cache_name,
-	    provider->xhat_provider_blk_size, 0, NULL, NULL,
-	    provider->xblkcache->reclaim,
-	    (void *)provider, NULL, 0);
-	if (provider->xblkcache->cache == NULL) {
-		cmn_err(CE_WARN, "Failed to allocate cache for %s",
-		    provider->xhat_provider_name);
-		return (-1);
-	}
-
-	mutex_init(&provider->xblkcache->lock, NULL, MUTEX_DEFAULT, NULL);
-
-
-	/* Insert provider in the global list */
-	rw_enter(&xhat_provider_rwlock, RW_WRITER);
-	provider->next = xhat_provider;
-	provider->prev = NULL;
-	if (xhat_provider)
-		xhat_provider->prev = provider;
-	xhat_provider = provider;
-	xhat_provider->xhat_provider_refcnt = 0;
-	rw_exit(&xhat_provider_rwlock);
-	return (0);
-}
-
-
-
-int
-xhat_provider_unregister(xhat_provider_t *provider)
-{
-	if (provider->xhat_provider_version != XHAT_PROVIDER_VERSION)
-		return (-1);
-
-	rw_enter(&xhat_provider_rwlock, RW_WRITER);
-
-	if (provider->xhat_provider_refcnt) {
-		rw_exit(&xhat_provider_rwlock);
-		return (-1);
-	}
-
-	if (provider->next)
-		provider->next->prev = provider->prev;
-	if (provider->prev)
-		provider->prev->next = provider->next;
-	else
-		xhat_provider = provider->next;
-	provider->prev = NULL;
-	provider->next = NULL;
-	rw_exit(&xhat_provider_rwlock);
-
-	/* Free all xblks that are sitting on free_blks list */
-	provider->xblkcache->reclaim(provider);
-
-	kmem_cache_destroy(provider->xblkcache->cache);
-
-	return (0);
-}
-
-
-
-/* Attaches an XHAT to the address space */
-int
-xhat_attach_xhat(xhat_provider_t *provider, struct as *as,
-    struct xhat **xhatp, void *arg)
-{
-	struct xhat *xh;
-
-
-
-	xh = XHAT_POPS(provider)->xhat_alloc(arg);
-	if (xh == NULL) {
-		*xhatp = NULL;
-		return (XH_PRVDR);
-	}
-
-	mutex_init(&xh->xhat_lock, NULL, MUTEX_DEFAULT, NULL);
-	xh->xhat_provider = provider;
-
-	rw_enter(&xhat_provider_rwlock, RW_WRITER);
-	provider->xhat_provider_refcnt++;
-	rw_exit(&xhat_provider_rwlock);
-
-	mutex_enter(&as->a_contents);
-
-	/* Is address space busy (being freed, dup'd or swapped)? */
-	if (AS_ISBUSY(as)) {
-		mutex_exit(&as->a_contents);
-		XHAT_POPS(provider)->xhat_free(xh);
-
-		rw_enter(&xhat_provider_rwlock, RW_WRITER);
-		provider->xhat_provider_refcnt--;
-		rw_exit(&xhat_provider_rwlock);
-
-		*xhatp = NULL;
-		return (XH_ASBUSY);
-	}
-
-	xh->xhat_as = as;
-	xh->xhat_refcnt = 0;
-	xh->holder = NULL;
-	xh->arg = arg;
-	xh->next = (struct xhat *)as->a_xhat;
-	if (xh->next)
-		xh->next->prev = xh;
-	as->a_xhat = xh;
-	mutex_exit(&as->a_contents);
-	*xhatp = xh;
-	return (0);
-}
-
-
-int
-xhat_detach_xhat(xhat_provider_t *provider, struct as *as)
-{
-	struct xhat *xh;
-
-
-	mutex_enter(&as->a_contents);
-
-	for (xh = (struct xhat *)as->a_xhat; xh != NULL; xh = xh->next)
-		if (xh->xhat_provider == provider) {
-
-
-			if (xh->holder != NULL) {
-				/*
-				 * The address space is being freed,
-				 * dup'd or swapped out.
-				 * If we are the thread which doing one
-				 * of those operations, we can go ahead
-				 * and free up the XHAT.
-				 * Otherwise, return.
-				 */
-				if (xh->holder != curthread) {
-					mutex_exit(&as->a_contents);
-					return (XH_ASBUSY);
-				} else
-					xhat_hat_rele(xh);
-			}
-
-			if (xh->xhat_refcnt > 0) {
-				/*
-				 * There are still "users" of the XHAT.
-				 * This may be either because the caller
-				 * forgot to free something up (which is a bug)
-				 * or because xhat_op_all() is in progress.
-				 * Since we are not allowing any of
-				 * xhat_op_all's ops to call xhat_detach_xhat(),
-				 * This can only be some other thread. It
-				 * may want to wait a bit and retry.
-				 */
-
-
-				/* Restore the hold on the XHAT */
-				if (xh->holder == curthread)
-					xhat_hat_hold(xh);
-
-				mutex_exit(&as->a_contents);
-				return (XH_XHHELD);
-			}
-
-			rw_enter(&xhat_provider_rwlock, RW_WRITER);
-			provider->xhat_provider_refcnt--;
-			rw_exit(&xhat_provider_rwlock);
-
-			if (xh->next)
-				xh->next->prev = xh->prev;
-			if (xh->prev)
-				xh->prev->next = xh->next;
-			else
-				as->a_xhat = (void *) xh->next;
-			mutex_exit(&as->a_contents);
-
-			XHAT_POPS(provider)->xhat_free(xh);
-
-			return (0);
-		}
-	mutex_exit(&as->a_contents);
-	return (XH_NOTATTCHD);
-}
-
-void
-xhat_hat_hold(struct xhat *xhat)
-{
-	mutex_enter(&xhat->xhat_lock);
-	xhat->xhat_refcnt++;
-	mutex_exit(&xhat->xhat_lock);
-}
-
-void
-xhat_hat_rele(struct xhat *xhat)
-{
-	mutex_enter(&xhat->xhat_lock);
-	xhat->xhat_refcnt--;
-	ASSERT(xhat->xhat_refcnt >= 0);
-	mutex_exit(&xhat->xhat_lock);
-}
-
-
-int
-xhat_hat_holders(struct xhat *xhat)
-{
-	return (xhat->xhat_refcnt);
-}
-
-
-/*
- * Assumes that address space is already locked
- * and that AS_FREE is set for as->a_flags.
- */
-void
-xhat_free_start_all(struct as *as)
-{
-	struct xhat *xh, *xh_nxt;
-
-
-	ASSERT(AS_ISBUSY(as));
-
-	mutex_enter(&as->a_contents);
-	xh = (struct xhat *)as->a_xhat;
-
-	/*
-	 * Simply calling xhat_hat_hold() won't work because we will
-	 * not be able to succeed in xhat_detach_xhat(), which may
-	 * get called from here. We need to know _who_ the holder is.
-	 */
-	if (xh != NULL) {
-		xhat_hat_hold(xh);
-		ASSERT(xh->holder == NULL);
-		xh->holder = curthread;
-	}
-
-	while (xh != NULL) {
-
-		xh_nxt = xh->next;
-		if (xh_nxt != NULL) {
-			ASSERT(xh_nxt->holder == NULL);
-			xhat_hat_hold(xh_nxt);
-			xh_nxt->holder = curthread;
-		}
-
-		mutex_exit(&as->a_contents);
-
-		XHAT_FREE_START(xh);
-
-		mutex_enter(&as->a_contents);
-
-		xh = xh_nxt;
-	}
-
-	mutex_exit(&as->a_contents);
-}
-
-
-
-/*
- * Assumes that address space is already locked.
- * Since xhat_free_start_all() must have been called
- * earlier, for all XHATs holder is set to curthread.
- * Also, since AS_BUSY is set for as->a_flags, no new
- * XHATs could have been added.
- */
-void
-xhat_free_end_all(struct as *as)
-{
-
-	struct xhat *xh, *xh_nxt;
-
-	ASSERT(AS_ISBUSY(as));
-
-	mutex_enter(&as->a_contents);
-	xh = (struct xhat *)as->a_xhat;
-
-
-	while (xh != NULL) {
-
-		ASSERT(xh->holder == curthread);
-
-		xh_nxt = xh->next;
-
-		mutex_exit(&as->a_contents);
-
-		XHAT_FREE_END(xh);
-
-		mutex_enter(&as->a_contents);
-
-		xh = xh_nxt;
-	}
-
-	mutex_exit(&as->a_contents);
-}
-
-
-/* Assumes that address space is already locked */
-
-/* ARGSUSED */
-int
-xhat_dup_all(struct as *as, struct as *newas, caddr_t addr, size_t len,
-    uint_t flag)
-{
-	/* This is not supported. Should we return some sort of error? */
-
-	ASSERT(AS_ISBUSY(as));
-
-	return (0);
-}
-
-
-/* Assumes that address space is already locked */
-void
-xhat_swapout_all(struct as *as)
-{
-	struct xhat *xh, *xh_nxt;
-
-
-	ASSERT(AS_ISBUSY(as));
-
-	mutex_enter(&as->a_contents);
-	xh = (struct xhat *)as->a_xhat;
-
-	if (xh != NULL) {
-		xhat_hat_hold(xh);
-		ASSERT(xh->holder == NULL);
-		xh->holder = curthread;
-	}
-
-
-	while (xh != NULL) {
-
-		xh_nxt = xh->next;
-		if (xh_nxt != NULL) {
-			ASSERT(xh_nxt->holder == NULL);
-			xhat_hat_hold(xh_nxt);
-			xh_nxt->holder = curthread;
-		}
-
-		mutex_exit(&as->a_contents);
-
-		XHAT_SWAPOUT(xh);
-
-		mutex_enter(&as->a_contents);
-
-		/*
-		 * If the xh is still there (i.e. swapout did not
-		 * destroy it), clear the holder field.
-		 * xh_nxt->prev couldn't have been changed in xhat_attach_xhat()
-		 * because AS_BUSY is set. xhat_detach_xhat() also couldn't
-		 * have modified it because (holder != NULL).
-		 * If there is only one XHAT, just see if a_xhat still
-		 * points to us.
-		 */
-		if (((xh_nxt != NULL) && (xh_nxt->prev == xh)) ||
-		    ((as->a_xhat != NULL) && (as->a_xhat == xh))) {
-			xhat_hat_rele(xh);
-			xh->holder = NULL;
-		}
-
-		xh = xh_nxt;
-	}
-
-	mutex_exit(&as->a_contents);
-}
-
-
-
-
-/*
- * In the following routines, the appropriate xhat_op
- * should never attempt to call xhat_detach_xhat(): it will
- * never succeed since the XHAT is held.
- */
-
-
-#define	XHAT_UNLOAD_CALLBACK_OP	(0)
-#define	XHAT_SETATTR_OP		(1)
-#define	XHAT_CLRATTR_OP		(2)
-#define	XHAT_CHGATTR_OP		(3)
-#define	XHAT_CHGPROT_OP		(4)
-#define	XHAT_UNSHARE_OP		(5)
-
-
-static void
-xhat_op_all(int op, struct as *as, caddr_t addr,
-    size_t len, uint_t flags, void *ptr)
-{
-	struct xhat *xh, *xh_nxt;
-
-	mutex_enter(&as->a_contents);
-	xh = (struct xhat *)as->a_xhat;
-
-	while (xh != NULL) {
-
-		xhat_hat_hold(xh);
-
-		xh_nxt = xh->next;
-		if (xh_nxt != NULL)
-			xhat_hat_hold(xh_nxt);
-
-		mutex_exit(&as->a_contents);
-
-		switch (op) {
-		case XHAT_UNLOAD_CALLBACK_OP:
-			XHAT_UNLOAD_CALLBACK(xh, addr,
-			    len, flags, (hat_callback_t *)ptr);
-			break;
-		case XHAT_SETATTR_OP:
-			XHAT_SETATTR(xh, addr, len, flags);
-			break;
-		case XHAT_CLRATTR_OP:
-			XHAT_CLRATTR(xh, addr, len, flags);
-			break;
-		case XHAT_CHGATTR_OP:
-			XHAT_CHGATTR(xh, addr, len, flags);
-			break;
-		case XHAT_CHGPROT_OP:
-			XHAT_CHGPROT(xh, addr, len, flags);
-			break;
-		case XHAT_UNSHARE_OP:
-			XHAT_UNSHARE(xh, addr, len);
-			break;
-		default:
-			panic("Unknown op %d in xhat_op_all", op);
-		}
-
-		mutex_enter(&as->a_contents);
-
-		/*
-		 * Both pointers are still valid because both
-		 * XHATs are held.
-		 */
-		xhat_hat_rele(xh);
-		if (xh_nxt != NULL)
-			xhat_hat_rele(xh_nxt);
-		xh = xh_nxt;
-	}
-
-	mutex_exit(&as->a_contents);
-}
-
-
-
-void
-xhat_unload_callback_all(struct as *as, caddr_t addr, size_t len, uint_t flags,
-    hat_callback_t *callback)
-{
-	xhat_op_all(XHAT_UNLOAD_CALLBACK_OP, as, addr, len, flags, callback);
-}
-
-
-void
-xhat_setattr_all(struct as *as, caddr_t addr, size_t len, uint_t attr)
-{
-	xhat_op_all(XHAT_SETATTR_OP, as, addr, len, attr, NULL);
-}
-
-
-
-void
-xhat_clrattr_all(struct as *as, caddr_t addr, size_t len, uint_t attr)
-{
-	xhat_op_all(XHAT_CLRATTR_OP, as, addr, len, attr, NULL);
-}
-
-
-void
-xhat_chgattr_all(struct as *as, caddr_t addr, size_t len, uint_t attr)
-{
-	xhat_op_all(XHAT_CHGATTR_OP, as, addr, len, attr, NULL);
-}
-
-
-void
-xhat_chgprot_all(struct as *as, caddr_t addr, size_t len, uint_t prot)
-{
-	xhat_op_all(XHAT_CHGPROT_OP, as, addr, len, prot, NULL);
-}
-
-
-void
-xhat_unshare_all(struct as *as, caddr_t addr, size_t len)
-{
-	xhat_op_all(XHAT_UNSHARE_OP, as, addr, len, 0, NULL);
-}
--- old/usr/src/uts/common/vm/xhat.h	2015-05-08 18:10:39.168541044 -0400
+++ /dev/null	2015-05-08 18:10:39.000000000 -0400
@@ -1,208 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _VM_XHAT_H
-#define	_VM_XHAT_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#ifndef _ASM
-
-#include <sys/types.h>
-#include <vm/page.h>
-#include <sys/kmem.h>
-
-struct xhat;
-struct xhat_hme_blk;
-
-struct xhat_ops {
-	struct xhat	*(*xhat_alloc)(void *);
-	void		(*xhat_free)(struct xhat *);
-	void		(*xhat_free_start)(struct xhat *);
-	void		(*xhat_free_end)(struct xhat *);
-	int		(*xhat_dup)(struct xhat *, struct xhat *, caddr_t,
-	    size_t, uint_t);
-	void		(*xhat_swapin)(struct xhat *);
-	void		(*xhat_swapout)(struct xhat *);
-	void		(*xhat_memload)(struct xhat *, caddr_t, struct page *,
-			    uint_t, uint_t);
-	void		(*xhat_memload_array)(struct xhat *, caddr_t, size_t,
-			    struct page **, uint_t, uint_t);
-	void		(*xhat_devload)(struct xhat *, caddr_t, size_t, pfn_t,
-	    uint_t, int);
-	void		(*xhat_unload)(struct xhat *, caddr_t, size_t, uint_t);
-	void		(*xhat_unload_callback)(struct xhat *, caddr_t, size_t,
-	    uint_t, hat_callback_t *);
-	void		(*xhat_setattr)(struct xhat *, caddr_t, size_t, uint_t);
-	void		(*xhat_clrattr)(struct xhat *, caddr_t, size_t, uint_t);
-	void		(*xhat_chgattr)(struct xhat *, caddr_t, size_t, uint_t);
-	void		(*xhat_unshare)(struct xhat *, caddr_t, size_t);
-	void		(*xhat_chgprot)(struct xhat *, caddr_t, size_t, uint_t);
-	int		(*xhat_pageunload)(struct xhat *, struct page *, uint_t,
-			    void *);
-};
-
-
-#define	XHAT_POPS(_p)	(_p)->xhat_provider_ops
-#define	XHAT_PROPS(_h)	XHAT_POPS(((struct xhat *)(_h))->xhat_provider)
-#define	XHAT_HOPS(hat, func, args) \
-	{ \
-		if (XHAT_PROPS(hat)-> /* */ func) \
-			XHAT_PROPS(hat)-> /* */ func /* */ args; \
-	}
-
-#define	XHAT_FREE_START(a) \
-	XHAT_HOPS(a, xhat_free_start, ((struct xhat *)(a)))
-#define	XHAT_FREE_END(a) \
-	XHAT_HOPS(a, xhat_free_end, ((struct xhat *)(a)))
-#define	XHAT_DUP(a, b, c, d, e) \
-	((XHAT_PROPS(a)->xhat_dup == NULL) ? (0) : \
-	XHAT_PROPS(a)->xhat_dup((struct xhat *)(a), \
-				(struct xhat *)(b), c, d, e))
-#define	XHAT_SWAPIN(a) \
-	XHAT_HOPS(a, xhat_swapin, ((struct xhat *)(a)))
-#define	XHAT_SWAPOUT(a) \
-	XHAT_HOPS(a, xhat_swapout, ((struct xhat *)(a)))
-#define	XHAT_MEMLOAD(a, b, c, d, e) \
-	XHAT_HOPS(a, xhat_memload, ((struct xhat *)(a), b, c, d, e))
-#define	XHAT_MEMLOAD_ARRAY(a, b, c, d, e, f) \
-	XHAT_HOPS(a, xhat_memload_array, ((struct xhat *)(a), b, c, d, e, f))
-#define	XHAT_DEVLOAD(a, b, c, d, e, f) \
-	XHAT_HOPS(a, xhat_devload, ((struct xhat *)(a), b, c, d, e, f))
-#define	XHAT_UNLOAD(a, b, c, d) \
-	XHAT_HOPS(a, xhat_unload, ((struct xhat *)(a), b, c, d))
-#define	XHAT_UNLOAD_CALLBACK(a, b, c, d, e) \
-	XHAT_HOPS(a, xhat_unload_callback, ((struct xhat *)(a), b, c, d, e))
-#define	XHAT_SETATTR(a, b, c, d) \
-	XHAT_HOPS(a, xhat_setattr, ((struct xhat *)(a), b, c, d))
-#define	XHAT_CLRATTR(a, b, c, d) \
-	XHAT_HOPS(a, xhat_clrattr, ((struct xhat *)(a), b, c, d))
-#define	XHAT_CHGATTR(a, b, c, d) \
-	XHAT_HOPS(a, xhat_chgattr, ((struct xhat *)(a), b, c, d))
-#define	XHAT_UNSHARE(a, b, c) \
-	XHAT_HOPS(a, xhat_unshare, ((struct xhat *)(a), b, c))
-#define	XHAT_CHGPROT(a, b, c, d) \
-	XHAT_HOPS(a, xhat_chgprot, ((struct xhat *)(a), b, c, d))
-#define	XHAT_PAGEUNLOAD(a, b, c, d) \
-	((XHAT_PROPS(a)->xhat_pageunload == NULL) ? (0) : \
-	XHAT_PROPS(a)->xhat_pageunload((struct xhat *)(a), b, c, d))
-
-
-
-#define	XHAT_PROVIDER_VERSION	1
-
-/*
- * Provider name will be appended with "_cache"
- * when initializing kmem cache.
- * The resulting sring must be less than
- * KMEM_CACHE_NAMELEN
- */
-#define	XHAT_CACHE_NAMELEN	24
-
-typedef struct xblk_cache {
-	kmutex_t	lock;
-	kmem_cache_t	*cache;
-	void		*free_blks;
-	void		(*reclaim)(void *);
-} xblk_cache_t;
-
-typedef struct xhat_provider {
-	int		xhat_provider_version;
-	int		xhat_provider_refcnt;
-	struct xhat_provider *next;
-	struct xhat_provider *prev;
-	char		xhat_provider_name[XHAT_CACHE_NAMELEN];
-	xblk_cache_t	*xblkcache;
-	struct xhat_ops *xhat_provider_ops;
-	int		xhat_provider_blk_size;
-} xhat_provider_t;
-
-/*
- * The xhat structure is protected by xhat_lock.
- * A particular xhat implementation is a extension of the
- * xhat structure and may contain its own lock(s) to
- * protect those additional fields.
- * The xhat structure is never allocated directly.
- * Instead its allocation is provided by the hat implementation.
- * The xhat provider ops xhat_alloc/xhat_free are used to
- * alloc/free a implementation dependant xhat structure.
- */
-struct xhat {
-	xhat_provider_t		*xhat_provider;
-	struct as		*xhat_as;
-	void			*arg;
-	struct xhat		*prev;
-	struct xhat		*next;
-	kmutex_t		xhat_lock;
-	int			xhat_refcnt;
-	kthread_t		*holder;
-};
-
-
-/* Error codes */
-#define	XH_PRVDR	(1)	/* Provider-specific error */
-#define	XH_ASBUSY	(2)	/* Address space is busy */
-#define	XH_XHHELD	(3)	/* XHAT is being held */
-#define	XH_NOTATTCHD	(4)	/* Provider is not attached to as */
-
-
-int	xhat_provider_register(xhat_provider_t *);
-int	xhat_provider_unregister(xhat_provider_t *);
-void	xhat_init(void);
-int	xhat_attach_xhat(xhat_provider_t *, struct as *, struct xhat **,
-    void *);
-int	xhat_detach_xhat(xhat_provider_t *, struct as *);
-pfn_t	xhat_insert_xhatblk(page_t *, struct xhat *, void **);
-int	xhat_delete_xhatblk(void *, int);
-void	xhat_hat_hold(struct xhat *);
-void	xhat_hat_rele(struct xhat *);
-int	xhat_hat_holders(struct xhat *);
-
-void	xhat_free_start_all(struct as *);
-void	xhat_free_end_all(struct as *);
-int	xhat_dup_all(struct as *, struct as *, caddr_t, size_t, uint_t);
-void	xhat_swapout_all(struct as *);
-void	xhat_unload_callback_all(struct as *, caddr_t, size_t, uint_t,
-    hat_callback_t *);
-void	xhat_setattr_all(struct as *, caddr_t, size_t, uint_t);
-void	xhat_clrattr_all(struct as *, caddr_t, size_t, uint_t);
-void	xhat_chgattr_all(struct as *, caddr_t, size_t, uint_t);
-void	xhat_chgprot_all(struct as *, caddr_t, size_t, uint_t);
-void	xhat_unshare_all(struct as *, caddr_t, size_t);
-
-
-#endif /* _ASM */
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _VM_XHAT_H */
--- old/usr/src/uts/i86pc/io/rootnex.c	2015-05-08 18:10:39.239012582 -0400
+++ new/usr/src/uts/i86pc/io/rootnex.c	2015-05-08 18:10:39.246070379 -0400
@@ -345,7 +345,7 @@
 /*
  *  extern hacks
  */
-extern struct seg_ops segdev_ops;
+extern const struct seg_ops segdev_ops;
 extern int ignore_hardware_nodes;	/* force flag from ddi_impl.c */
 #ifdef	DDI_MAP_DEBUG
 extern int ddi_map_debug_flag;
--- old/usr/src/uts/i86pc/os/mlsetup.c	2015-05-08 18:10:39.587777219 -0400
+++ new/usr/src/uts/i86pc/os/mlsetup.c	2015-05-08 18:10:39.594473348 -0400
@@ -277,7 +277,7 @@
 	t0.t_stk = (caddr_t)rp - MINFRAME;
 	t0.t_stkbase = t0stack;
 	t0.t_pri = maxclsyspri - 3;
-	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t0.t_schedflag = 0;
 	t0.t_procp = &p0;
 	t0.t_plockp = &p0lock.pl_lock;
 	t0.t_lwp = &lwp0;
--- old/usr/src/uts/i86pc/os/trap.c	2015-05-08 18:10:39.798585390 -0400
+++ new/usr/src/uts/i86pc/os/trap.c	2015-05-08 18:10:39.805829495 -0400
@@ -491,7 +491,6 @@
 
 	type = rp->r_trapno;
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
-	ASSERT(ct->t_schedflag & TS_DONT_SWAP);
 
 	if (type == T_PGFLT) {
 
--- old/usr/src/uts/i86pc/vm/hat_i86.c	2015-05-08 18:10:40.065438067 -0400
+++ new/usr/src/uts/i86pc/vm/hat_i86.c	2015-05-08 18:10:40.072924424 -0400
@@ -1125,88 +1125,6 @@
 }
 
 /*
- * Allocate any hat resources required for a process being swapped in.
- */
-/*ARGSUSED*/
-void
-hat_swapin(hat_t *hat)
-{
-	/* do nothing - we let everything fault back in */
-}
-
-/*
- * Unload all translations associated with an address space of a process
- * that is being swapped out.
- */
-void
-hat_swapout(hat_t *hat)
-{
-	uintptr_t	vaddr = (uintptr_t)0;
-	uintptr_t	eaddr = _userlimit;
-	htable_t	*ht = NULL;
-	level_t		l;
-
-	XPV_DISALLOW_MIGRATE();
-	/*
-	 * We can't just call hat_unload(hat, 0, _userlimit...)  here, because
-	 * seg_spt and shared pagetables can't be swapped out.
-	 * Take a look at segspt_shmswapout() - it's a big no-op.
-	 *
-	 * Instead we'll walk through all the address space and unload
-	 * any mappings which we are sure are not shared, not locked.
-	 */
-	ASSERT(IS_PAGEALIGNED(vaddr));
-	ASSERT(IS_PAGEALIGNED(eaddr));
-	ASSERT(AS_LOCK_HELD(hat->hat_as, &hat->hat_as->a_lock));
-	if ((uintptr_t)hat->hat_as->a_userlimit < eaddr)
-		eaddr = (uintptr_t)hat->hat_as->a_userlimit;
-
-	while (vaddr < eaddr) {
-		(void) htable_walk(hat, &ht, &vaddr, eaddr);
-		if (ht == NULL)
-			break;
-
-		ASSERT(!IN_VA_HOLE(vaddr));
-
-		/*
-		 * If the page table is shared skip its entire range.
-		 */
-		l = ht->ht_level;
-		if (ht->ht_flags & HTABLE_SHARED_PFN) {
-			vaddr = ht->ht_vaddr + LEVEL_SIZE(l + 1);
-			htable_release(ht);
-			ht = NULL;
-			continue;
-		}
-
-		/*
-		 * If the page table has no locked entries, unload this one.
-		 */
-		if (ht->ht_lock_cnt == 0)
-			hat_unload(hat, (caddr_t)vaddr, LEVEL_SIZE(l),
-			    HAT_UNLOAD_UNMAP);
-
-		/*
-		 * If we have a level 0 page table with locked entries,
-		 * skip the entire page table, otherwise skip just one entry.
-		 */
-		if (ht->ht_lock_cnt > 0 && l == 0)
-			vaddr = ht->ht_vaddr + LEVEL_SIZE(1);
-		else
-			vaddr += LEVEL_SIZE(l);
-	}
-	if (ht)
-		htable_release(ht);
-
-	/*
-	 * We're in swapout because the system is low on memory, so
-	 * go back and flush all the htables off the cached list.
-	 */
-	htable_purge_hat(hat);
-	XPV_ALLOW_MIGRATE();
-}
-
-/*
  * returns number of bytes that have valid mappings in hat.
  */
 size_t
--- old/usr/src/uts/i86xpv/vm/seg_mf.c	2015-05-08 18:10:40.386144098 -0400
+++ new/usr/src/uts/i86xpv/vm/seg_mf.c	2015-05-08 18:10:40.392818892 -0400
@@ -99,7 +99,7 @@
 	segmf_map_t	*map;
 };
 
-static struct seg_ops segmf_ops;
+static const struct seg_ops segmf_ops;
 
 static int segmf_fault_gref_range(struct seg *seg, caddr_t addr, size_t len);
 
@@ -470,11 +470,6 @@
 }
 
 /*ARGSUSED*/
-static void
-segmf_dump(struct seg *seg)
-{}
-
-/*ARGSUSED*/
 static int
 segmf_pagelock(struct seg *seg, caddr_t addr, size_t len,
     struct page ***ppp, enum lock_type type, enum seg_rw rw)
@@ -482,13 +477,6 @@
 	return (ENOTSUP);
 }
 
-/*ARGSUSED*/
-static int
-segmf_setpagesize(struct seg *seg, caddr_t addr, size_t len, uint_t szc)
-{
-	return (ENOTSUP);
-}
-
 static int
 segmf_getmemid(struct seg *seg, caddr_t addr, memid_t *memid)
 {
@@ -499,20 +487,6 @@
 	return (0);
 }
 
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segmf_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
-
-/*ARGSUSED*/
-static int
-segmf_capable(struct seg *seg, segcapability_t capability)
-{
-	return (0);
-}
-
 /*
  * Add a set of contiguous foreign MFNs to the segment. soft-locking them.  The
  * pre-faulting is necessary due to live migration; in particular we must
@@ -757,29 +731,23 @@
 	return (0);
 }
 
-static struct seg_ops segmf_ops = {
-	segmf_dup,
-	segmf_unmap,
-	segmf_free,
-	segmf_fault,
-	segmf_faulta,
-	segmf_setprot,
-	segmf_checkprot,
-	(int (*)())segmf_kluster,
-	(size_t (*)(struct seg *))NULL,	/* swapout */
-	segmf_sync,
-	segmf_incore,
-	segmf_lockop,
-	segmf_getprot,
-	segmf_getoffset,
-	segmf_gettype,
-	segmf_getvp,
-	segmf_advise,
-	segmf_dump,
-	segmf_pagelock,
-	segmf_setpagesize,
-	segmf_getmemid,
-	segmf_getpolicy,
-	segmf_capable,
-	seg_inherit_notsup
+static const struct seg_ops segmf_ops = {
+	.dup		= segmf_dup,
+	.unmap		= segmf_unmap,
+	.free		= segmf_free,
+	.fault		= segmf_fault,
+	.faulta		= segmf_faulta,
+	.setprot	= segmf_setprot,
+	.checkprot	= segmf_checkprot,
+	.kluster	= segmf_kluster,
+	.sync		= segmf_sync,
+	.incore		= segmf_incore,
+	.lockop		= segmf_lockop,
+	.getprot	= segmf_getprot,
+	.getoffset	= segmf_getoffset,
+	.gettype	= segmf_gettype,
+	.getvp		= segmf_getvp,
+	.advise		= segmf_advise,
+	.pagelock	= segmf_pagelock,
+	.getmemid	= segmf_getmemid,
 };
--- old/usr/src/uts/intel/ia32/os/syscall.c	2015-05-08 18:10:40.606781157 -0400
+++ new/usr/src/uts/intel/ia32/os/syscall.c	2015-05-08 18:10:40.613739003 -0400
@@ -149,7 +149,7 @@
 	int error = 0;
 	uint_t nargs;
 
-	ASSERT(t == curthread && curthread->t_schedflag & TS_DONT_SWAP);
+	ASSERT(t == curthread);
 
 	lwp->lwp_ru.sysc++;
 	lwp->lwp_eosys = NORMALRETURN;	/* assume this will be normal */
@@ -243,8 +243,6 @@
 
 	t->t_pre_sys = repost = 0;	/* clear pre-syscall processing flag */
 
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-
 #if defined(DEBUG)
 	/*
 	 * On the i386 kernel, lwp_ap points at the piece of the thread
--- old/usr/src/uts/sfmmu/vm/hat_sfmmu.c	2015-05-08 18:10:40.843211648 -0400
+++ new/usr/src/uts/sfmmu/vm/hat_sfmmu.c	2015-05-08 18:10:40.850699743 -0400
@@ -81,7 +81,6 @@
 #include <sys/mem_config.h>
 #include <sys/mem_cage.h>
 #include <vm/vm_dep.h>
-#include <vm/xhat_sfmmu.h>
 #include <sys/fpu/fpusystm.h>
 #include <vm/mach_kpm.h>
 #include <sys/callb.h>
@@ -1350,8 +1349,6 @@
 	}
 #endif
 
-	(void) xhat_init();
-
 	uhme_hash_pa = va_to_pa(uhme_hash);
 	khme_hash_pa = va_to_pa(khme_hash);
 
@@ -1539,7 +1536,6 @@
 	sfmmup->sfmmu_free = 0;
 	sfmmup->sfmmu_rmstat = 0;
 	sfmmup->sfmmu_clrbin = sfmmup->sfmmu_clrstart;
-	sfmmup->sfmmu_xhat_provider = NULL;
 	cv_init(&sfmmup->sfmmu_tsb_cv, NULL, CV_DEFAULT, NULL);
 	sfmmup->sfmmu_srdp = NULL;
 	SF_RGNMAP_ZERO(sfmmup->sfmmu_region_map);
@@ -1919,7 +1915,6 @@
 {
 	ASSERT(AS_WRITE_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
 	ASSERT(sfmmup != ksfmmup);
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 
 	sfmmup->sfmmu_free = 1;
 	if (sfmmup->sfmmu_scdp != NULL) {
@@ -1934,7 +1929,6 @@
 {
 	int i;
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 	ASSERT(sfmmup->sfmmu_free == 1);
 	ASSERT(sfmmup->sfmmu_ttecnt[TTE8K] == 0);
 	ASSERT(sfmmup->sfmmu_ttecnt[TTE64K] == 0);
@@ -1976,153 +1970,6 @@
 }
 
 /*
- * Set up any translation structures, for the specified address space,
- * that are needed or preferred when the process is being swapped in.
- */
-/* ARGSUSED */
-void
-hat_swapin(struct hat *hat)
-{
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
-}
-
-/*
- * Free all of the translation resources, for the specified address space,
- * that can be freed while the process is swapped out. Called from as_swapout.
- * Also, free up the ctx that this process was using.
- */
-void
-hat_swapout(struct hat *sfmmup)
-{
-	struct hmehash_bucket *hmebp;
-	struct hme_blk *hmeblkp;
-	struct hme_blk *pr_hblk = NULL;
-	struct hme_blk *nx_hblk;
-	int i;
-	struct hme_blk *list = NULL;
-	hatlock_t *hatlockp;
-	struct tsb_info *tsbinfop;
-	struct free_tsb {
-		struct free_tsb *next;
-		struct tsb_info *tsbinfop;
-	};			/* free list of TSBs */
-	struct free_tsb *freelist, *last, *next;
-
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
-	SFMMU_STAT(sf_swapout);
-
-	/*
-	 * There is no way to go from an as to all its translations in sfmmu.
-	 * Here is one of the times when we take the big hit and traverse
-	 * the hash looking for hme_blks to free up.  Not only do we free up
-	 * this as hme_blks but all those that are free.  We are obviously
-	 * swapping because we need memory so let's free up as much
-	 * as we can.
-	 *
-	 * Note that we don't flush TLB/TSB here -- it's not necessary
-	 * because:
-	 *  1) we free the ctx we're using and throw away the TSB(s);
-	 *  2) processes aren't runnable while being swapped out.
-	 */
-	ASSERT(sfmmup != KHATID);
-	for (i = 0; i <= UHMEHASH_SZ; i++) {
-		hmebp = &uhme_hash[i];
-		SFMMU_HASH_LOCK(hmebp);
-		hmeblkp = hmebp->hmeblkp;
-		pr_hblk = NULL;
-		while (hmeblkp) {
-
-			ASSERT(!hmeblkp->hblk_xhat_bit);
-
-			if ((hmeblkp->hblk_tag.htag_id == sfmmup) &&
-			    !hmeblkp->hblk_shw_bit && !hmeblkp->hblk_lckcnt) {
-				ASSERT(!hmeblkp->hblk_shared);
-				(void) sfmmu_hblk_unload(sfmmup, hmeblkp,
-				    (caddr_t)get_hblk_base(hmeblkp),
-				    get_hblk_endaddr(hmeblkp),
-				    NULL, HAT_UNLOAD);
-			}
-			nx_hblk = hmeblkp->hblk_next;
-			if (!hmeblkp->hblk_vcnt && !hmeblkp->hblk_hmecnt) {
-				ASSERT(!hmeblkp->hblk_lckcnt);
-				sfmmu_hblk_hash_rm(hmebp, hmeblkp, pr_hblk,
-				    &list, 0);
-			} else {
-				pr_hblk = hmeblkp;
-			}
-			hmeblkp = nx_hblk;
-		}
-		SFMMU_HASH_UNLOCK(hmebp);
-	}
-
-	sfmmu_hblks_list_purge(&list, 0);
-
-	/*
-	 * Now free up the ctx so that others can reuse it.
-	 */
-	hatlockp = sfmmu_hat_enter(sfmmup);
-
-	sfmmu_invalidate_ctx(sfmmup);
-
-	/*
-	 * Free TSBs, but not tsbinfos, and set SWAPPED flag.
-	 * If TSBs were never swapped in, just return.
-	 * This implies that we don't support partial swapping
-	 * of TSBs -- either all are swapped out, or none are.
-	 *
-	 * We must hold the HAT lock here to prevent racing with another
-	 * thread trying to unmap TTEs from the TSB or running the post-
-	 * relocator after relocating the TSB's memory.  Unfortunately, we
-	 * can't free memory while holding the HAT lock or we could
-	 * deadlock, so we build a list of TSBs to be freed after marking
-	 * the tsbinfos as swapped out and free them after dropping the
-	 * lock.
-	 */
-	if (SFMMU_FLAGS_ISSET(sfmmup, HAT_SWAPPED)) {
-		sfmmu_hat_exit(hatlockp);
-		return;
-	}
-
-	SFMMU_FLAGS_SET(sfmmup, HAT_SWAPPED);
-	last = freelist = NULL;
-	for (tsbinfop = sfmmup->sfmmu_tsb; tsbinfop != NULL;
-	    tsbinfop = tsbinfop->tsb_next) {
-		ASSERT((tsbinfop->tsb_flags & TSB_SWAPPED) == 0);
-
-		/*
-		 * Cast the TSB into a struct free_tsb and put it on the free
-		 * list.
-		 */
-		if (freelist == NULL) {
-			last = freelist = (struct free_tsb *)tsbinfop->tsb_va;
-		} else {
-			last->next = (struct free_tsb *)tsbinfop->tsb_va;
-			last = last->next;
-		}
-		last->next = NULL;
-		last->tsbinfop = tsbinfop;
-		tsbinfop->tsb_flags |= TSB_SWAPPED;
-		/*
-		 * Zero out the TTE to clear the valid bit.
-		 * Note we can't use a value like 0xbad because we want to
-		 * ensure diagnostic bits are NEVER set on TTEs that might
-		 * be loaded.  The intent is to catch any invalid access
-		 * to the swapped TSB, such as a thread running with a valid
-		 * context without first calling sfmmu_tsb_swapin() to
-		 * allocate TSB memory.
-		 */
-		tsbinfop->tsb_tte.ll = 0;
-	}
-
-	/* Now we can drop the lock and free the TSB memory. */
-	sfmmu_hat_exit(hatlockp);
-	for (; freelist != NULL; freelist = next) {
-		next = freelist->next;
-		sfmmu_tsb_free(freelist->tsbinfop);
-	}
-}
-
-/*
  * Duplicate the translations of an as into another newas
  */
 /* ARGSUSED */
@@ -2135,7 +1982,6 @@
 	int i;
 	extern uint_t get_color_start(struct as *);
 
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
 	ASSERT((flag == 0) || (flag == HAT_DUP_ALL) || (flag == HAT_DUP_COW) ||
 	    (flag == HAT_DUP_SRD));
 	ASSERT(hat != ksfmmup);
@@ -2205,8 +2051,7 @@
 	uint_t attr, uint_t flags, hat_region_cookie_t rcookie)
 {
 	uint_t rid;
-	if (rcookie == HAT_INVALID_REGION_COOKIE ||
-	    hat->sfmmu_xhat_provider != NULL) {
+	if (rcookie == HAT_INVALID_REGION_COOKIE) {
 		hat_do_memload(hat, addr, pp, attr, flags,
 		    SFMMU_INVALID_SHMERID);
 		return;
@@ -2240,13 +2085,6 @@
 		    (void *)pp);
 	}
 
-	if (hat->sfmmu_xhat_provider) {
-		/* no regions for xhats */
-		ASSERT(!SFMMU_IS_SHMERID_VALID(rid));
-		XHAT_MEMLOAD(hat, addr, pp, attr, flags);
-		return;
-	}
-
 	ASSERT((hat == ksfmmup) ||
 	    AS_LOCK_HELD(hat->sfmmu_as, &hat->sfmmu_as->a_lock));
 
@@ -2296,11 +2134,6 @@
 
 	ASSERT(hat != NULL);
 
-	if (hat->sfmmu_xhat_provider) {
-		XHAT_DEVLOAD(hat, addr, len, pfn, attr, flags);
-		return;
-	}
-
 	ASSERT(!(flags & ~SFMMU_LOAD_ALLFLAG));
 	ASSERT(!(attr & ~SFMMU_LOAD_ALLATTR));
 	ASSERT((hat == ksfmmup) ||
@@ -2447,8 +2280,7 @@
 	hat_region_cookie_t rcookie)
 {
 	uint_t rid;
-	if (rcookie == HAT_INVALID_REGION_COOKIE ||
-	    hat->sfmmu_xhat_provider != NULL) {
+	if (rcookie == HAT_INVALID_REGION_COOKIE) {
 		hat_do_memload_array(hat, addr, len, pps, attr, flags,
 		    SFMMU_INVALID_SHMERID);
 		return;
@@ -2483,12 +2315,6 @@
 	ASSERT(!((uintptr_t)addr & MMU_PAGEOFFSET));
 	SFMMU_VALIDATE_HMERID(hat, rid, addr, len);
 
-	if (hat->sfmmu_xhat_provider) {
-		ASSERT(!SFMMU_IS_SHMERID_VALID(rid));
-		XHAT_MEMLOAD_ARRAY(hat, addr, len, pps, attr, flags);
-		return;
-	}
-
 	if (hat->sfmmu_rmstat)
 		hat_resvstat(len, hat->sfmmu_as, addr);
 
@@ -3971,7 +3797,6 @@
 	caddr_t endaddr;
 
 	ASSERT(sfmmup != NULL);
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 
 	ASSERT((sfmmup == ksfmmup) ||
 	    AS_LOCK_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
@@ -4056,7 +3881,6 @@
 	}
 
 	ASSERT(sfmmup != NULL);
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 	ASSERT(sfmmup != ksfmmup);
 
 	srdp = sfmmup->sfmmu_srdp;
@@ -4768,7 +4592,6 @@
 	tte_t tte;
 
 	ASSERT(sfmmup != NULL);
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 
 	ASSERT((sfmmup == ksfmmup) ||
 	    AS_LOCK_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
@@ -4793,8 +4616,6 @@
 {
 	tte_t tte;
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
-
 	if (sfmmup == ksfmmup) {
 		if (sfmmu_vatopfn(addr, sfmmup, &tte) == PFN_INVALID) {
 			return (-1);
@@ -4814,8 +4635,6 @@
 {
 	tte_t tte;
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
-
 	if (sfmmup == ksfmmup) {
 		if (sfmmu_vatopfn(addr, sfmmup, &tte) == PFN_INVALID) {
 			tte.ll = 0;
@@ -4839,19 +4658,7 @@
 void
 hat_setattr(struct hat *hat, caddr_t addr, size_t len, uint_t attr)
 {
-	if (hat->sfmmu_xhat_provider) {
-		XHAT_SETATTR(hat, addr, len, attr);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, change attributes for all of them,
-		 * just in case
-		 */
-		ASSERT(hat->sfmmu_as != NULL);
-		if (hat->sfmmu_as->a_xhat != NULL)
-			xhat_setattr_all(hat->sfmmu_as, addr, len, attr);
-	}
+	ASSERT(hat->sfmmu_as != NULL);
 
 	sfmmu_chgattr(hat, addr, len, attr, SFMMU_SETATTR);
 }
@@ -4863,19 +4670,7 @@
 void
 hat_chgattr(struct hat *hat, caddr_t addr, size_t len, uint_t attr)
 {
-	if (hat->sfmmu_xhat_provider) {
-		XHAT_CHGATTR(hat, addr, len, attr);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, change attributes for all of them,
-		 * just in case
-		 */
-		ASSERT(hat->sfmmu_as != NULL);
-		if (hat->sfmmu_as->a_xhat != NULL)
-			xhat_chgattr_all(hat->sfmmu_as, addr, len, attr);
-	}
+	ASSERT(hat->sfmmu_as != NULL);
 
 	sfmmu_chgattr(hat, addr, len, attr, SFMMU_CHGATTR);
 }
@@ -4886,19 +4681,7 @@
 void
 hat_clrattr(struct hat *hat, caddr_t addr, size_t len, uint_t attr)
 {
-	if (hat->sfmmu_xhat_provider) {
-		XHAT_CLRATTR(hat, addr, len, attr);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, change attributes for all of them,
-		 * just in case
-		 */
-		ASSERT(hat->sfmmu_as != NULL);
-		if (hat->sfmmu_as->a_xhat != NULL)
-			xhat_clrattr_all(hat->sfmmu_as, addr, len, attr);
-	}
+	ASSERT(hat->sfmmu_as != NULL);
 
 	sfmmu_chgattr(hat, addr, len, attr, SFMMU_CLRATTR);
 }
@@ -5251,19 +5034,7 @@
 	ASSERT((len & MMU_PAGEOFFSET) == 0);
 	ASSERT(((uintptr_t)addr & MMU_PAGEOFFSET) == 0);
 
-	if (sfmmup->sfmmu_xhat_provider) {
-		XHAT_CHGPROT(sfmmup, addr, len, vprot);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, change attributes for all of them,
-		 * just in case
-		 */
-		ASSERT(sfmmup->sfmmu_as != NULL);
-		if (sfmmup->sfmmu_as->a_xhat != NULL)
-			xhat_chgprot_all(sfmmup->sfmmu_as, addr, len, vprot);
-	}
+	ASSERT(sfmmup->sfmmu_as != NULL);
 
 	CPUSET_ZERO(cpuset);
 
@@ -5698,20 +5469,7 @@
 	int issegkmap = ISSEGKMAP(sfmmup, addr);
 	demap_range_t dmr, *dmrp;
 
-	if (sfmmup->sfmmu_xhat_provider) {
-		XHAT_UNLOAD_CALLBACK(sfmmup, addr, len, flags, callback);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, unload the mappings for all of them,
-		 * just in case
-		 */
-		ASSERT(sfmmup->sfmmu_as != NULL);
-		if (sfmmup->sfmmu_as->a_xhat != NULL)
-			xhat_unload_callback_all(sfmmup->sfmmu_as, addr,
-			    len, flags, callback);
-	}
+	ASSERT(sfmmup->sfmmu_as != NULL);
 
 	ASSERT((sfmmup == ksfmmup) || (flags & HAT_UNLOAD_OTHER) || \
 	    AS_LOCK_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
@@ -5988,10 +5746,6 @@
 void
 hat_unload(struct hat *sfmmup, caddr_t addr, size_t len, uint_t flags)
 {
-	if (sfmmup->sfmmu_xhat_provider) {
-		XHAT_UNLOAD(sfmmup, addr, len, flags);
-		return;
-	}
 	hat_unload_callback(sfmmup, addr, len, flags, NULL);
 }
 
@@ -6331,7 +6085,6 @@
 	caddr_t endaddr;
 	cpuset_t cpuset;
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 	ASSERT((sfmmup == ksfmmup) ||
 	    AS_LOCK_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
 	ASSERT((len & MMU_PAGEOFFSET) == 0);
@@ -7138,14 +6891,11 @@
 #endif
 	cpuset_t cpuset, tset;
 	int index, cons;
-	int xhme_blks;
 	int pa_hments;
 
 	ASSERT(PAGE_EXCL(pp));
 
-retry_xhat:
 	tmphme = NULL;
-	xhme_blks = 0;
 	pa_hments = 0;
 	CPUSET_ZERO(cpuset);
 
@@ -7177,16 +6927,6 @@
 		}
 
 		hmeblkp = sfmmu_hmetohblk(sfhme);
-		if (hmeblkp->hblk_xhat_bit) {
-			struct xhat_hme_blk *xblk =
-			    (struct xhat_hme_blk *)hmeblkp;
-
-			(void) XHAT_PAGEUNLOAD(xblk->xhat_hme_blk_hat,
-			    pp, forceflag, XBLK2PROVBLK(xblk));
-
-			xhme_blks = 1;
-			continue;
-		}
 
 		/*
 		 * If there are kernel mappings don't unload them, they will
@@ -7223,7 +6963,7 @@
 	 * we were called from hat_page_relocate() in which case we
 	 * leave the locked mappings which will be suspended later.
 	 */
-	ASSERT(!PP_ISMAPPED(origpp) || xhme_blks || pa_hments ||
+	ASSERT(!PP_ISMAPPED(origpp) || pa_hments ||
 	    (forceflag == SFMMU_KERNEL_RELOC));
 
 #ifdef VAC
@@ -7258,22 +6998,11 @@
 			}
 		}
 
-		ASSERT(!PP_ISMAPPED(origpp) || xhme_blks);
+		ASSERT(!PP_ISMAPPED(origpp));
 	}
 
 	sfmmu_mlist_exit(pml);
 
-	/*
-	 * XHAT may not have finished unloading pages
-	 * because some other thread was waiting for
-	 * mlist lock and XHAT_PAGEUNLOAD let it do
-	 * the job.
-	 */
-	if (xhme_blks) {
-		pp = origpp;
-		goto retry_xhat;
-	}
-
 	return (0);
 }
 
@@ -7554,8 +7283,6 @@
 		 * reach the range we are seeking, just ignore it.
 		 */
 		hmeblkp = sfmmu_hmetohblk(sfhme);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 
 		if (hme_size(sfhme) < cons)
 			continue;
@@ -7715,12 +7442,6 @@
 	sfmmu_copytte(&sfhme->hme_tte, &tte);
 	if (TTE_IS_VALID(&tte) && TTE_IS_WRITABLE(&tte)) {
 		hmeblkp = sfmmu_hmetohblk(sfhme);
-
-		/*
-		 * xhat mappings should never be to a VMODSORT page.
-		 */
-		ASSERT(hmeblkp->hblk_xhat_bit == 0);
-
 		sfmmup = hblktosfmmu(hmeblkp);
 		addr = tte_to_vaddr(hmeblkp, tte);
 
@@ -7985,8 +7706,6 @@
 	 * the as lock.
 	 */
 
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
-
 	if (hat == ksfmmup) {
 		if (IS_KMEM_VA_LARGEPAGE(addr)) {
 			ASSERT(segkmem_lpszc > 0);
@@ -8170,7 +7889,6 @@
 hat_map(struct hat *hat, caddr_t addr, size_t len, uint_t flags)
 {
 	ASSERT(hat != NULL);
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
 }
 
 /*
@@ -8263,14 +7981,6 @@
 		}
 
 		hmeblkp = sfmmu_hmetohblk(sfhme);
-		if (hmeblkp->hblk_xhat_bit) {
-			cnt++;
-			if (cnt > sh_thresh) {
-				sfmmu_mlist_exit(pml);
-				return (1);
-			}
-			continue;
-		}
 		if (hme_size(sfhme) != sz) {
 			continue;
 		}
@@ -8385,10 +8095,6 @@
 			if (hme_size(sfhme) != sz) {
 				continue;
 			}
-			if (hmeblkp->hblk_xhat_bit) {
-				cmn_err(CE_PANIC,
-				    "hat_page_demote: xhat hmeblk");
-			}
 			tset = sfmmu_pageunload(rootpp, sfhme, sz);
 			CPUSET_OR(cpuset, tset);
 		}
@@ -8516,8 +8222,6 @@
 	if (hat == NULL)
 		return (0);
 
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
-
 	for (i = 0; i < mmu_page_sizes; i++)
 		assize += ((pgcnt_t)hat->sfmmu_ttecnt[i] +
 		    (pgcnt_t)hat->sfmmu_scdrttecnt[i]) * TTEBYTES(i);
@@ -8537,8 +8241,6 @@
 {
 	hatlock_t	*hatlockp;
 
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
-
 	hatlockp = sfmmu_hat_enter(hat);
 	hat->sfmmu_rmstat++;
 	sfmmu_hat_exit(hatlockp);
@@ -8550,8 +8252,6 @@
 {
 	hatlock_t	*hatlockp;
 
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
-
 	hatlockp = sfmmu_hat_enter(hat);
 	hat->sfmmu_rmstat--;
 	sfmmu_hat_exit(hatlockp);
@@ -8653,8 +8353,6 @@
 	if (!ISM_ALIGNED(ismshift, len))
 		return (EINVAL);
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
-
 	/*
 	 * Allocate ism_ment for the ism_hat's mapping list, and an
 	 * ism map blk in case we need one.  We must do our
@@ -8866,19 +8564,7 @@
 	ASSERT(sfmmup != NULL);
 	ASSERT(sfmmup != ksfmmup);
 
-	if (sfmmup->sfmmu_xhat_provider) {
-		XHAT_UNSHARE(sfmmup, addr, len);
-		return;
-	} else {
-		/*
-		 * This must be a CPU HAT. If the address space has
-		 * XHATs attached, inform all XHATs that ISM segment
-		 * is going away
-		 */
-		ASSERT(sfmmup->sfmmu_as != NULL);
-		if (sfmmup->sfmmu_as->a_xhat != NULL)
-			xhat_unshare_all(sfmmup->sfmmu_as, addr, len);
-	}
+	ASSERT(sfmmup->sfmmu_as != NULL);
 
 	/*
 	 * Make sure that during the entire time ISM mappings are removed,
@@ -9332,8 +9018,6 @@
 		if (IS_PAHME(sfhmep))
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhmep);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 		tmphat = hblktosfmmu(hmeblkp);
 		sfmmu_copytte(&sfhmep->hme_tte, &tte);
 		ASSERT(TTE_IS_VALID(&tte));
@@ -9360,8 +9044,6 @@
 		if (IS_PAHME(sfhmep))
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhmep);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 		ASSERT(!hmeblkp->hblk_shared);
 		(void) sfmmu_pageunload(pp, sfhmep, TTE8K);
 	}
@@ -9509,8 +9191,6 @@
 			if (IS_PAHME(sfhme))
 				continue;
 			hmeblkp = sfmmu_hmetohblk(sfhme);
-			if (hmeblkp->hblk_xhat_bit)
-				continue;
 
 			sfmmu_copytte(&sfhme->hme_tte, &tte);
 			ASSERT(TTE_IS_VALID(&tte));
@@ -9658,9 +9338,6 @@
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhme);
 
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
-
 		sfmmu_copytte(&sfhme->hme_tte, &tte);
 		ASSERT(TTE_IS_VALID(&tte));
 		vaddr = tte_to_vaddr(hmeblkp, tte);
@@ -9996,7 +9673,7 @@
 
 /*
  * Replace the specified TSB with a new TSB.  This function gets called when
- * we grow, shrink or swapin a TSB.  When swapping in a TSB (TSB_SWAPIN), the
+ * we grow, or shrink a TSB.  When swapping in a TSB (TSB_SWAPIN), the
  * TSB_FORCEALLOC flag may be used to force allocation of a minimum-sized TSB
  * (8K).
  *
@@ -13408,7 +13085,6 @@
 hat_softlock(struct hat *hat, caddr_t addr, size_t *lenp, page_t **ppp,
     uint_t flags)
 {
-	ASSERT(hat->sfmmu_xhat_provider == NULL);
 	return (FC_NOSUPPORT);
 }
 
@@ -13443,8 +13119,6 @@
 		if (IS_PAHME(sfhmep))
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhmep);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 		if (hme_size(sfhmep) == ttesz) {
 			/*
 			 * another mapping of the same size. don't clear index.
@@ -14029,7 +13703,6 @@
 		return (HAT_INVALID_REGION_COOKIE);
 	}
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
 	ASSERT(sfmmup != ksfmmup);
 	ASSERT(AS_WRITE_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
 	ASSERT(srdp->srd_refcnt > 0);
@@ -14336,12 +14009,6 @@
 	ASSERT(!(rgnp->rgn_flags & SFMMU_REGION_FREE));
 	ASSERT(AS_LOCK_HELD(sfmmup->sfmmu_as, &sfmmup->sfmmu_as->a_lock));
 
-	ASSERT(sfmmup->sfmmu_xhat_provider == NULL);
-	if (r_type == SFMMU_REGION_HME && sfmmup->sfmmu_as->a_xhat != NULL) {
-		xhat_unload_callback_all(sfmmup->sfmmu_as, rgnp->rgn_saddr,
-		    rgnp->rgn_size, 0, NULL);
-	}
-
 	if (sfmmup->sfmmu_free) {
 		ulong_t rttecnt;
 		r_pgszc = rgnp->rgn_pgszc;
--- old/usr/src/uts/sfmmu/vm/hat_sfmmu.h	2015-05-08 18:10:41.633267982 -0400
+++ new/usr/src/uts/sfmmu/vm/hat_sfmmu.h	2015-05-08 18:10:41.640178455 -0400
@@ -659,12 +659,9 @@
  * mappings will potentially be undersized. To compensate for the potential
  * underaccounting in this case we always add 1/4 of the region size to the 8K
  * ttecnt.
- *
- * Note that sfmmu_xhat_provider MUST be the first element.
  */
 
 struct hat {
-	void		*sfmmu_xhat_provider;	/* NULL for CPU hat */
 	cpuset_t	sfmmu_cpusran;	/* cpu bit mask for efficient xcalls */
 	struct	as	*sfmmu_as;	/* as this hat provides mapping for */
 	/* per pgsz private ttecnt + shme rgns ttecnt for rgns not in SCD */
@@ -1241,16 +1238,11 @@
  * the counts can be high and there are not enough bits in the tte. When
  * physio is fixed to not lock the translations we should be able to move
  * the lock cnt back to the tte.  See bug id 1198554.
- *
- * Note that xhat_hme_blk's layout follows this structure: hme_blk_misc
- * and sf_hment are at the same offsets in both structures. Whenever
- * hme_blk is changed, xhat_hme_blk may need to be updated as well.
  */
 
 struct hme_blk_misc {
-	uint_t	notused:25;
+	uint_t	notused:26;
 	uint_t	shared_bit:1;	/* set for SRD shared hmeblk */
-	uint_t	xhat_bit:1;	/* set for an xhat hme_blk */
 	uint_t	shadow_bit:1;	/* set for a shadow hme_blk */
 	uint_t	nucleus_bit:1;	/* set for a nucleus hme_blk */
 	uint_t	ttesize:3;	/* contains ttesz of hmeblk */
@@ -1290,7 +1282,6 @@
 };
 
 #define	hblk_shared	hblk_misc.shared_bit
-#define	hblk_xhat_bit   hblk_misc.xhat_bit
 #define	hblk_shw_bit	hblk_misc.shadow_bit
 #define	hblk_nuc_bit	hblk_misc.nucleus_bit
 #define	hblk_ttesz	hblk_misc.ttesize
@@ -2315,9 +2306,6 @@
 extern int	sfmmu_hat_lock_held(sfmmu_t *);
 extern int	sfmmu_alloc_ctx(sfmmu_t *, int, struct cpu *, int);
 
-/*
- * Functions exported to xhat_sfmmu.c
- */
 extern kmutex_t *sfmmu_mlist_enter(page_t *);
 extern void	sfmmu_mlist_exit(kmutex_t *);
 extern int	sfmmu_mlist_held(struct page *);
--- old/usr/src/uts/sfmmu/vm/xhat_sfmmu.c	2015-05-08 18:10:41.913203937 -0400
+++ /dev/null	2015-05-08 18:10:41.000000000 -0400
@@ -1,240 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/mman.h>
-#include <vm/hat_sfmmu.h>
-#include <vm/xhat.h>
-#include <vm/xhat_sfmmu.h>
-#include <vm/page.h>
-#include <vm/as.h>
-
-
-
-/*
- * Allocates a block that includes both struct xhat and
- * provider-specific data.
- */
-struct xhat_hme_blk *
-xhat_alloc_xhatblk(struct xhat *xhat)
-{
-	struct xhat_hme_blk *xblk;
-	xblk_cache_t	*xblkcache = xhat->xhat_provider->xblkcache;
-
-
-
-	mutex_enter(&xblkcache->lock);
-	if (xblkcache->free_blks) {
-		xblk = (struct xhat_hme_blk *)
-		    sfmmu_hmetohblk(xblkcache->free_blks);
-
-		/*
-		 * Since we are always walking the list in the
-		 * forward direction, we don't update prev pointers
-		 */
-		xblkcache->free_blks = xblk->xblk_hme[0].hme_next;
-		mutex_exit(&xblkcache->lock);
-	} else {
-		mutex_exit(&xblkcache->lock);
-		xblk = kmem_cache_alloc(xblkcache->cache, KM_SLEEP);
-	}
-
-	return (xblk);
-}
-
-
-/*
- * Return the block to free_blks pool. The memory will
- * be freed in the reclaim routine.
- */
-void
-xhat_free_xhatblk(struct xhat_hme_blk *xblk)
-{
-	xblk_cache_t	*xblkcache = xblk->xhat_hme_blk_hat->
-	    xhat_provider->xblkcache;
-
-
-	mutex_enter(&xblkcache->lock);
-	xblk->xblk_hme[0].hme_next = xblkcache->free_blks;
-	xblkcache->free_blks = &xblk->xblk_hme[0];
-	mutex_exit(&xblkcache->lock);
-}
-
-
-/*
- * Ran by kmem reaper thread. Also called when
- * provider unregisters
- */
-void
-xhat_xblkcache_reclaim(void *arg)
-{
-	xhat_provider_t *provider = (xhat_provider_t *)arg;
-	struct sf_hment	*sfhme;
-	struct xhat_hme_blk	*xblk;
-	xblk_cache_t	*xblkcache;
-
-	if (provider == NULL)
-		cmn_err(CE_PANIC, "xhat_xblkcache_reclaim() is passed NULL");
-
-	xblkcache = provider->xblkcache;
-
-
-	while (xblkcache->free_blks != NULL) {
-
-		/*
-		 * Put free blocks on a separate list
-		 * and free free_blks pointer.
-		 */
-		mutex_enter(&xblkcache->lock);
-		sfhme = xblkcache->free_blks;
-		xblkcache->free_blks = NULL;
-		mutex_exit(&xblkcache->lock);
-
-		while (sfhme != NULL) {
-			xblk = (struct xhat_hme_blk *)sfmmu_hmetohblk(sfhme);
-			ASSERT(xblk->xhat_hme_blk_misc.xhat_bit == 1);
-			sfhme = sfhme->hme_next;
-			kmem_cache_free(xblkcache->cache, xblk);
-		}
-	}
-}
-
-
-
-
-/*
- * Insert the xhat block (or, more precisely, the sf_hment)
- * into page's p_mapping list.
- */
-pfn_t
-xhat_insert_xhatblk(page_t *pp, struct xhat *xhat, void **blk)
-{
-	kmutex_t *pml;
-	pfn_t pfn;
-	struct xhat_hme_blk *xblk;
-
-
-
-	xblk = xhat_alloc_xhatblk(xhat);
-	if (xblk == NULL)
-		return (0);
-
-	/* Add a "user" to the XHAT */
-	xhat_hat_hold(xhat);
-
-	xblk->xhat_hme_blk_hat = xhat;
-	xblk->xhat_hme_blk_misc.xhat_bit = 1;
-
-	pml = sfmmu_mlist_enter(pp);
-
-
-	/* Insert at the head of p_mapping list */
-	xblk->xblk_hme[0].hme_prev = NULL;
-	xblk->xblk_hme[0].hme_next = pp->p_mapping;
-	xblk->xblk_hme[0].hme_page = pp;
-
-	/* Only one tte per xhat_hme_blk, at least for now */
-	xblk->xblk_hme[0].hme_tte.tte_hmenum = 0;
-
-	if (pp->p_mapping) {
-		((struct sf_hment *)(pp->p_mapping))->hme_prev =
-		    &(xblk->xblk_hme[0]);
-		ASSERT(pp->p_share > 0);
-	} else	{
-		/* EMPTY */
-		ASSERT(pp->p_share == 0);
-	}
-	pp->p_mapping = &(xblk->xblk_hme[0]);
-
-	/*
-	 * Update number of mappings.
-	 */
-	pp->p_share++;
-	pfn = pp->p_pagenum;
-
-	sfmmu_mlist_exit(pml);
-
-	*blk = XBLK2PROVBLK(xblk);
-
-	return (pfn);
-}
-
-
-/*
- * mlist_locked indicates whether the mapping list
- * is locked. If provider did not lock it himself, the
- * only time it is locked in HAT layer is in
- * hat_pageunload().
- */
-int
-xhat_delete_xhatblk(void *blk, int mlist_locked)
-{
-	struct xhat_hme_blk *xblk = PROVBLK2XBLK(blk);
-	page_t *pp = xblk->xblk_hme[0].hme_page;
-	kmutex_t *pml;
-
-
-	ASSERT(pp != NULL);
-	ASSERT(pp->p_share > 0);
-
-	if (!mlist_locked)
-		pml = sfmmu_mlist_enter(pp);
-	else
-		ASSERT(sfmmu_mlist_held(pp));
-
-	pp->p_share--;
-
-	if (xblk->xblk_hme[0].hme_prev) {
-		ASSERT(pp->p_mapping != &(xblk->xblk_hme[0]));
-		ASSERT(xblk->xblk_hme[0].hme_prev->hme_page == pp);
-		xblk->xblk_hme[0].hme_prev->hme_next =
-		    xblk->xblk_hme[0].hme_next;
-	} else {
-		ASSERT(pp->p_mapping == &(xblk->xblk_hme[0]));
-		pp->p_mapping = xblk->xblk_hme[0].hme_next;
-		ASSERT((pp->p_mapping == NULL) ?
-			(pp->p_share == 0) : 1);
-	}
-
-	if (xblk->xblk_hme->hme_next) {
-		ASSERT(xblk->xblk_hme[0].hme_next->hme_page == pp);
-		xblk->xblk_hme[0].hme_next->hme_prev =
-		    xblk->xblk_hme[0].hme_prev;
-	}
-
-	if (!mlist_locked)
-		sfmmu_mlist_exit(pml);
-
-	xhat_hat_rele(xblk->xhat_hme_blk_hat);
-	xhat_free_xhatblk(xblk);
-
-
-	return (0);
-}
--- old/usr/src/uts/sfmmu/vm/xhat_sfmmu.h	2015-05-08 18:10:41.986981253 -0400
+++ /dev/null	2015-05-08 18:10:41.000000000 -0400
@@ -1,94 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _XHAT_SFMMU_H
-#define	_XHAT_SFMMU_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#ifndef _ASM
-
-#include <sys/types.h>
-#include <sys/sysmacros.h>
-#include <vm/hat_sfmmu.h>
-#include <vm/page.h>
-#include <vm/xhat.h>
-
-struct xhat;
-struct xhat_hme_blk;
-
-
-/*
- * Pads to align xhat_hme_blk's xhat_hme_blk_misc
- * and with xblk_hme with corresponding fields in
- * those of hme_blk.
- */
-#define	XHAT_PADHI	(offsetof(struct hme_blk, hblk_misc) - \
-			    sizeof (struct xhat *))
-
-#define	XHAT_PADLO	(offsetof(struct hme_blk, hblk_hme[0]) - \
-				(offsetof(struct hme_blk, hblk_misc) + \
-					sizeof (struct hme_blk_misc)))
-
-/*
- * This (or, rather, xblk_hme[] member of the structure) is
- * what gets put on page's p_mappings list.
- */
-struct xhat_hme_blk {
-	struct xhat		*xhat_hme_blk_hat;
-	char			xblk_pad1[XHAT_PADHI];
-	struct hme_blk_misc	xhat_hme_blk_misc;
-	char			xblk_pad2[XHAT_PADLO];
-	struct sf_hment		xblk_hme[1];
-};
-
-/*
- * Convert pointers between xhat_hme_blk and provider's
- * block (these two blocks are always allocated adjacent to
- * each other).
- */
-#define	XBLK2PROVBLK(xblk)	((void *)(((struct xhat_hme_blk *)(xblk)) + 1))
-#define	PROVBLK2XBLK(pblk)	(((struct xhat_hme_blk *)(pblk)) - 1)
-
-
-
-void	xhat_xblkcache_reclaim(void *);
-
-
-
-#endif /* _ASM */
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _XHAT_SFMMU_H */
--- old/usr/src/uts/sparc/os/syscall.c	2015-05-08 18:10:42.059394530 -0400
+++ new/usr/src/uts/sparc/os/syscall.c	2015-05-08 18:10:42.066304922 -0400
@@ -359,8 +359,6 @@
 
 	t->t_pre_sys = repost = 0;	/* clear pre-syscall processing flag */
 
-	ASSERT(t->t_schedflag & TS_DONT_SWAP);
-
 	syscall_mstate(LMS_USER, LMS_SYSTEM);
 
 	/*
--- old/usr/src/uts/sparc/v9/os/v9dep.c	2015-05-08 18:10:42.294951404 -0400
+++ new/usr/src/uts/sparc/v9/os/v9dep.c	2015-05-08 18:10:42.301945523 -0400
@@ -860,15 +860,6 @@
 	fpp->fpu_fprs = 0;
 }
 
-void
-lwp_swapin(kthread_t *tp)
-{
-	struct machpcb *mpcb = lwptompcb(ttolwp(tp));
-
-	mpcb->mpcb_pa = va_to_pa(mpcb);
-	mpcb->mpcb_wbuf_pa = va_to_pa(mpcb->mpcb_wbuf);
-}
-
 /*
  * Construct the execution environment for the user's signal
  * handler and arrange for control to be given to it on return
--- old/usr/src/uts/sparc/v9/vm/seg_nf.c	2015-05-08 18:10:42.547134614 -0400
+++ new/usr/src/uts/sparc/v9/vm/seg_nf.c	2015-05-08 18:10:42.553964163 -0400
@@ -31,8 +31,6 @@
  * under license from the Regents of the University of California.
  */
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  * VM - segment for non-faulting loads.
  */
@@ -68,53 +66,38 @@
 		    size_t len, uint_t prot);
 static int	segnf_checkprot(struct seg *seg, caddr_t addr,
 		    size_t len, uint_t prot);
-static void	segnf_badop(void);
 static int	segnf_nop(void);
 static int	segnf_getprot(struct seg *seg, caddr_t addr,
 		    size_t len, uint_t *protv);
 static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
 static int	segnf_gettype(struct seg *seg, caddr_t addr);
 static int	segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
-static void	segnf_dump(struct seg *seg);
 static int	segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
 		    struct page ***ppp, enum lock_type type, enum seg_rw rw);
-static int	segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
-		    uint_t szc);
-static int	segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
-static lgrp_mem_policy_info_t	*segnf_getpolicy(struct seg *seg,
-    caddr_t addr);
-
-
-struct seg_ops segnf_ops = {
-	segnf_dup,
-	segnf_unmap,
-	segnf_free,
-	(faultcode_t (*)(struct hat *, struct seg *, caddr_t, size_t,
-	    enum fault_type, enum seg_rw))
-		segnf_nomap,		/* fault */
-	(faultcode_t (*)(struct seg *, caddr_t))
-		segnf_nomap,		/* faulta */
-	segnf_setprot,
-	segnf_checkprot,
-	(int (*)())segnf_badop,		/* kluster */
-	(size_t (*)(struct seg *))NULL,	/* swapout */
-	(int (*)(struct seg *, caddr_t, size_t, int, uint_t))
-		segnf_nop,		/* sync */
-	(size_t (*)(struct seg *, caddr_t, size_t, char *))
-		segnf_nop,		/* incore */
-	(int (*)(struct seg *, caddr_t, size_t, int, int, ulong_t *, size_t))
-		segnf_nop,		/* lockop */
-	segnf_getprot,
-	segnf_getoffset,
-	segnf_gettype,
-	segnf_getvp,
-	(int (*)(struct seg *, caddr_t, size_t, uint_t))
-		segnf_nop,		/* advise */
-	segnf_dump,
-	segnf_pagelock,
-	segnf_setpagesize,
-	segnf_getmemid,
-	segnf_getpolicy,
+
+
+const struct seg_ops segnf_ops = {
+	.dup		= segnf_dup,
+	.unmap		= segnf_unmap,
+	.free		= segnf_free,
+	.fault		= (faultcode_t (*)(struct hat *, struct seg *, caddr_t,
+	    size_t, enum fault_type, enum seg_rw))segnf_nomap,
+	.faulta		= (faultcode_t (*)(struct seg *, caddr_t)) segnf_nomap,
+	.setprot	= segnf_setprot,
+	.checkprot	= segnf_checkprot,
+	.sync		= (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
+		segnf_nop,
+	.incore		= (size_t (*)(struct seg *, caddr_t, size_t, char *))
+		segnf_nop,
+	.lockop		= (int (*)(struct seg *, caddr_t, size_t, int, int,
+	    ulong_t *, size_t))segnf_nop,
+	.getprot	= segnf_getprot,
+	.getoffset	= segnf_getoffset,
+	.gettype	= segnf_gettype,
+	.getvp		= segnf_getvp,
+	.advise		= (int (*)(struct seg *, caddr_t, size_t, uint_t))
+		segnf_nop,
+	.pagelock	= segnf_pagelock,
 };
 
 /*
@@ -406,13 +389,6 @@
 	return ((prot & sprot) == prot ? 0 : EACCES);
 }
 
-static void
-segnf_badop(void)
-{
-	panic("segnf_badop");
-	/*NOTREACHED*/
-}
-
 static int
 segnf_nop(void)
 {
@@ -459,14 +435,6 @@
 	return (0);
 }
 
-/*
- * segnf pages are not dumped, so we just return
- */
-/* ARGSUSED */
-static void
-segnf_dump(struct seg *seg)
-{}
-
 /*ARGSUSED*/
 static int
 segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
@@ -474,25 +442,3 @@
 {
 	return (ENOTSUP);
 }
-
-/*ARGSUSED*/
-static int
-segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
-    uint_t szc)
-{
-	return (ENOTSUP);
-}
-
-/*ARGSUSED*/
-static int
-segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
-{
-	return (ENODEV);
-}
-
-/*ARGSUSED*/
-static lgrp_mem_policy_info_t *
-segnf_getpolicy(struct seg *seg, caddr_t addr)
-{
-	return (NULL);
-}
--- old/usr/src/uts/sun4/io/rootnex.c	2015-05-08 18:10:42.760284269 -0400
+++ new/usr/src/uts/sun4/io/rootnex.c	2015-05-08 18:10:42.767154115 -0400
@@ -719,7 +719,7 @@
     struct hat *hat, struct seg *seg, caddr_t addr,
     struct devpage *dp, pfn_t pfn, uint_t prot, uint_t lock)
 {
-	extern struct seg_ops segdev_ops;
+	extern const struct seg_ops segdev_ops;
 
 	DPRINTF(ROOTNEX_MAP_DEBUG, ("rootnex_map_fault: address <%p> "
 	    "pfn <%lx>", (void *)addr, pfn));
--- old/usr/src/uts/sun4/os/mlsetup.c	2015-05-08 18:10:42.980841172 -0400
+++ new/usr/src/uts/sun4/os/mlsetup.c	2015-05-08 18:10:42.987809513 -0400
@@ -148,7 +148,7 @@
 	/* Can't use va_to_pa here - wait until prom_ initialized */
 	t0.t_stkbase = t0stack;
 	t0.t_pri = maxclsyspri - 3;
-	t0.t_schedflag = TS_LOAD | TS_DONT_SWAP;
+	t0.t_schedflag = 0;
 	t0.t_procp = &p0;
 	t0.t_plockp = &p0lock.pl_lock;
 	t0.t_lwp = &lwp0;
--- old/usr/src/uts/sun4/os/trap.c	2015-05-08 18:10:43.192620341 -0400
+++ new/usr/src/uts/sun4/os/trap.c	2015-05-08 18:10:43.199513195 -0400
@@ -168,13 +168,6 @@
 
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
 
-#ifdef SF_ERRATA_23 /* call causes illegal-insn */
-	ASSERT((curthread->t_schedflag & TS_DONT_SWAP) ||
-	    (type == T_UNIMP_INSTR));
-#else
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-#endif /* SF_ERRATA_23 */
-
 	if (USERMODE(rp->r_tstate) || (type & T_USER)) {
 		/*
 		 * Set lwp_state before trying to acquire any
@@ -1372,8 +1365,6 @@
 
 	CPU_STATS_ADDQ(CPU, sys, trap, 1);
 
-	ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
-
 	if (USERMODE(rp->r_tstate)) {
 		/*
 		 * Set lwp_state before trying to acquire any
--- old/usr/src/uts/sun4u/Makefile.files	2015-05-08 18:10:43.449274047 -0400
+++ new/usr/src/uts/sun4u/Makefile.files	2015-05-08 18:10:43.456114084 -0400
@@ -64,7 +64,6 @@
 CORE_OBJS +=	ppage.o
 CORE_OBJS +=	sfmmu_kdi.o
 CORE_OBJS +=	swtch.o
-CORE_OBJS +=	xhat_sfmmu.o
 
 #
 #	Some objects must be linked at the front of the image (or
@@ -135,7 +134,6 @@
 I2BSC_OBJS	+= i2bsc.o
 GPTWOCFG_OBJS	+= gptwocfg.o
 GPTWO_CPU_OBJS	+= gptwo_cpu.o
-ZULUVM_OBJS  	+= zuluvm.o zulu_asm.o zulu_hat.o zulu_hat_asm.o
 
 JBUSPPM_OBJS	+= jbusppm.o 
 RMC_COMM_OBJS	+= rmc_comm.o rmc_comm_crctab.o rmc_comm_dp.o rmc_comm_drvintf.o
--- old/usr/src/uts/sun4u/Makefile.sun4u	2015-05-08 18:10:43.650410518 -0400
+++ new/usr/src/uts/sun4u/Makefile.sun4u	2015-05-08 18:10:43.657188012 -0400
@@ -428,7 +428,6 @@
 MISC_KMODS	+= sbd
 
 MISC_KMODS	+= opl_cfg
-MISC_KMODS	+= zuluvm
 MISC_KMODS	+= gptwo_cpu gptwocfg
 MISC_KMODS	+= pcie
 
--- old/usr/src/uts/sun4u/io/zuluvm.c	2015-05-08 18:10:43.856278823 -0400
+++ /dev/null	2015-05-08 18:10:43.000000000 -0400
@@ -1,1495 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * zuluvm module
- *
- * Provides services required by the XVR-4000 graphics accelerator (zulu)
- * that are not provided by the ddi. See PSARC 2002/231.
- *
- * Zulu has 2 dma engines with built in MMUs. zuluvm provides TLB miss
- * interrupt support obtaining virtual to physical address translations
- * using the XHAT interface PSARC/2003/517.
- *
- * The module has 3 components. This file, sun4u/vm/zulu_hat.c, and the
- * assembly language routines in sun4u/ml/zulu_asm.s and
- * sun4u/ml/zulu_hat_asm.s.
- *
- * The interrupt handler is a data bearing mondo interrupt handled at TL=1
- * If no translation is found in the zulu hat's tsb, or if the tsb is locked by
- * C code, the handler posts a soft interrupt which wakes up a parked
- * thread belonging to zuludaemon(1M).
- */
-
-#include <sys/conf.h>
-#include <sys/types.h>
-#include <sys/kmem.h>
-#include <sys/debug.h>
-#include <sys/modctl.h>
-#include <sys/autoconf.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/ddi_subrdefs.h>
-#include <sys/intr.h>
-#include <sys/ddi.h>
-#include <sys/sunndi.h>
-#include <sys/proc.h>
-#include <sys/thread.h>
-#include <sys/machsystm.h>
-#include <sys/ivintr.h>
-#include <sys/tnf_probe.h>
-#include <sys/intreg.h>
-#include <sys/atomic.h>
-#include <vm/as.h>
-#include <vm/seg_enum.h>
-#include <vm/faultcode.h>
-#include <sys/dmv.h>
-#include <sys/zulumod.h>
-#include <sys/zulu_hat.h>
-
-#define	ZULUVM_GET_PAGE(val) \
-	(caddr_t)((uintptr_t)(val) & PAGEMASK)
-#define	ZULUVM_GET_AS	curthread->t_procp->p_as
-
-#define	ZULUVM_LOCK   mutex_enter(&(zdev->dev_lck))
-#define	ZULUVM_UNLOCK mutex_exit(&(zdev->dev_lck))
-
-#define	ZULUVM_SET_STATE(_z, b, c) \
-	atomic_cas_32((uint32_t *)&((_z)->zvm.state), c, b)
-#define	ZULUVM_GET_STATE(_z) \
-	(_z)->zvm.state
-#define	ZULUVM_SET_IDLE(_z) \
-	(_z)->zvm.state = ZULUVM_STATE_IDLE;
-
-#define	ZULUVM_INO_MASK ((1<<INO_SIZE)-1)
-#define	ZULUVM_IGN_MASK ((1<<IGN_SIZE)-1)
-#define	ZULUVM_MONDO(_zdev, _n) \
-	((ZULUVM_IGN_MASK & _zdev->agentid) << INO_SIZE) | \
-	(ZULUVM_INO_MASK & (_n))
-
-static void zuluvm_stop(zuluvm_state_t *, int, char *);
-static zuluvm_proc_t *zuluvm_find_proc(zuluvm_state_t *, struct as *);
-static int zuluvm_proc_release(zuluvm_state_t *zdev, zuluvm_proc_t *proc);
-static int zuluvm_get_intr_props(zuluvm_state_t *zdev, dev_info_t *devi);
-static int zuluvm_driver_attach(zuluvm_state_t *);
-static int zuluvm_driver_detach(zuluvm_state_t *);
-static void zuluvm_retarget_intr(void *arg);
-static void zuluvm_do_retarget(zuluvm_state_t *zdev);
-
-extern const unsigned int _mmu_pageshift;
-
-extern int zuluvm_base_pgsize;
-static int zuluvm_pagesizes[ZULUM_MAX_PG_SIZES + 1];
-
-int zuluvm_fast_tlb = 1;
-
-zuluvm_state_t *zuluvm_devtab[ZULUVM_MAX_DEV];
-kmutex_t zuluvm_lck;
-
-#ifdef DEBUG
-int zuluvm_debug_state = 0;
-#endif
-
-unsigned long zuluvm_ctx_locked = 0;
-
-/*
- * Module linkage information for the kernel.
- */
-extern struct mod_ops mod_miscops;
-
-static struct modlmisc modlmisc = {
-	&mod_miscops,
-	"sun4u support " ZULUVM_MOD_VERSION
-};
-
-static struct modlinkage modlinkage = {
-	MODREV_1,
-	(void *)&modlmisc,
-	NULL
-};
-
-int
-_init(void)
-{
-	zuluvm_base_pgsize = (_mmu_pageshift - 13) / 3;
-	if (zulu_hat_init() != 0) {
-		return (ZULUVM_ERROR);
-	}
-	mutex_init(&zuluvm_lck, NULL, MUTEX_DEFAULT, NULL);
-	return (mod_install(&modlinkage));
-}
-
-int
-_fini(void)
-{
-	mutex_destroy(&zuluvm_lck);
-	(void) zulu_hat_destroy();
-	return (mod_remove(&modlinkage));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (mod_info(&modlinkage, modinfop));
-}
-
-/*
- * currently the kernel driver makes the following assumptions:
- * - there is only one TLB miss per zulu device handled at
- *   any given time
- *   ==> we only need local data storage per device, not per DMA
- *   ==> a page fault will block the DMA engine until the fault
- *       is resolved
- *   ==> a pagefault will not trigger a zulu DMA context switch
- *
- * If we want to implement asynnchronous zulu page fault, then we
- * need to keep track of outstanding faults while zulu DMA runs
- * in a different context.
- */
-static int
-zuluvm_write_tte(zuluvm_state_t *zdev, void *arg, caddr_t addr,
-    int t_pfn, int t_perm, int t_size, uint64_t tag,
-    int tlbtype, int *size)
-{
-	int error;
-
-	(void) addr;
-
-	ZULUVM_STATS_MISS(zdev, t_size);
-
-	if (tag == 0) { /* not coming from preload */
-		int state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_WRITE_TTE,
-				ZULUVM_STATE_INTR_PENDING);
-		if (state != ZULUVM_STATE_INTR_PENDING) {
-			zuluvm_stop(zdev, state, "zuluvm_write_tte");
-			return (ZULUVM_MISS_CANCELED);
-		}
-	}
-
-	if (!(tlbtype & ZULUVM_ITLB_FLAG) &&
-	    t_size != zuluvm_base_pgsize &&
-	    t_size != ZULU_TTE4M) {
-		t_size = zuluvm_base_pgsize;
-		TNF_PROBE_2(zuluvm_write_tte_new_pfn, "zuluvm", /* */,
-		    tnf_opaque, t_pfn, t_pfn, tnf_int, pagesize, t_size);
-	}
-	TNF_PROBE_1(zuluvm_write_tte, "zuluvm", /* */,
-	    tnf_opaque, t_pfn, t_pfn);
-	/*
-	 * if the caller is zuluvm_preload, then we need to pass
-	 * back the page size so it can add the right offset.
-	 */
-	if (size)
-		*size = t_size;
-
-	error = zulud_write_tte(zdev, arg, t_size, tag, t_pfn,
-		    t_perm, tlbtype);
-
-	return (error);
-}
-
-static void
-zuluvm_stop(zuluvm_state_t *zdev, int state, char *tag)
-{
-	int ostate = state;
-	while (state != ZULUVM_STATE_STOPPED) {
-		state = ZULUVM_SET_STATE(zdev,
-			    ZULUVM_STATE_STOPPED, state);
-#ifdef DEBUG
-		if (zuluvm_debug_state)
-			cmn_err(CE_NOTE, "zuluvm_stop(%s): (loop) state %d\n",
-			    tag, state);
-#endif
-	}
-	TNF_PROBE_2(zuluvm_stop, "zuluvm", /* */,
-	    tnf_string, tag, tag,
-	    tnf_int, state, ostate);
-	ZULUVM_STATS_CANCEL(zdev);
-}
-
-/*
- * Executed with the context of the parked zulu deamon thread,
- * uses zulu_hat_load to resolve the miss.
- * The tte is loaded and miss done called by the function zuluvm_load_tte
- * which is called from zulu_hat
- *
- * This function is synchronized with the zuluvm_as_free.
- * zuluvm_as_free will block until miss servicing is complete.
- *
- * There is a race condition between as_free and the zulu tlb miss
- * soft interrupt:
- *	- queue zulu interrupt
- *	- process dies, as_free runs
- *	- interrupt gets scheduled and runs as_fault on the
- *	  already freed as.
- * This is solved by keeping track of current zulu dma processes
- * and invalidating them in zuluvm_as_free.
- */
-uint_t
-zuluvm_tlb_handler(caddr_t data)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)data;
-	int	error;
-	int	flag = 0;
-	int	wait = 0;
-	zuluvm_proc_t *proc = NULL;
-	struct zulu_hat	*zhat = NULL;
-	caddr_t	addr;
-	int	tlbtype;
-	void	*arg;
-	int	state, newstate;
-
-	TNF_PROBE_1(zuluvm_tlb_handler_lwp, "zuluvm", /* */,
-	    tnf_opaque, lwp, ttolwp(curthread));
-
-	ZULUVM_LOCK;
-	error   = ZULUVM_GET_TLB_ERRCODE(zdev);
-	addr    = (caddr_t)ZULUVM_GET_TLB_ADDR(zdev);
-	tlbtype = ZULUVM_GET_TLB_TYPE(zdev);
-	arg = zdev->zvm.arg;
-
-	/*
-	 * select the correct dma engine and remember the
-	 * the as_free synchronization flags.
-	 */
-	switch (tlbtype) {
-	case ZULUVM_ITLB1:
-	case ZULUVM_DMA1:
-		proc = zdev->zvm.proc1;
-		flag |= ZULUVM_DO_INTR1;
-		wait |= ZULUVM_WAIT_INTR1;
-		break;
-	case ZULUVM_ITLB2:
-	case ZULUVM_DMA2:
-		proc = zdev->zvm.proc2;
-		flag |= ZULUVM_DO_INTR2;
-		wait |= ZULUVM_WAIT_INTR2;
-		break;
-	}
-
-	state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_INTR_PENDING,
-		    ZULUVM_STATE_INTR_QUEUED);
-	newstate = ZULUVM_GET_STATE(zdev);
-
-	TNF_PROBE_2(zuluvm_tlb_handler_state, "zuluvm", /* */,
-	    tnf_int, oldstate, state,
-	    tnf_int, newstate, newstate);
-#ifdef DEBUG
-	if (zuluvm_debug_state)
-		cmn_err(CE_NOTE, "zuluvm_tlb_handler: state %d\n", state);
-#endif
-	if (state != ZULUVM_STATE_INTR_PENDING &&
-		state != ZULUVM_STATE_INTR_QUEUED) {
-		ZULUVM_UNLOCK;
-
-		zuluvm_stop(zdev, state, "softintr1");
-		zulud_tlb_done(zdev, arg, tlbtype, ZULUVM_MISS_CANCELED);
-		return (1);
-	}
-
-	/*
-	 * block the as_free callback in case it comes in
-	 */
-	zdev->intr_flags |= flag;
-	ZULUVM_UNLOCK;
-
-	mutex_enter(&zdev->proc_lck);
-	/*
-	 * check if this as is still valid
-	 */
-	if (proc == NULL || proc->valid == 0 || proc->zhat == NULL) {
-		mutex_exit(&zdev->proc_lck);
-		/*
-		 * we are on our way out, wake up the as_free
-		 * callback if it is waiting for us
-		 */
-		ZULUVM_LOCK;
-		zdev->intr_flags &= ~flag;
-		if (zdev->intr_flags | wait)
-			cv_broadcast(&zdev->intr_wait);
-		ZULUVM_UNLOCK;
-		state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_IDLE,
-			    ZULUVM_STATE_INTR_PENDING);
-		if (state != ZULUVM_STATE_INTR_PENDING) {
-			zuluvm_stop(zdev, state, "softintr3");
-		}
-		zulud_tlb_done(zdev, arg, tlbtype, ZULUVM_NO_HAT);
-		return (1);
-	}
-	zhat = proc->zhat;
-	mutex_exit(&zdev->proc_lck);
-
-	TNF_PROBE_1(zuluvm_tlb_handler, "zuluvm", /* */,
-	    tnf_opaque, addr, addr);
-
-	switch (error) {
-	case ZULUVM_CTX_LOCKED:
-		/*
-		 * trap handler found that zulu_hat had the lock bit set
-		 * rather than block in the fast trap handler, it punts
-		 * in this rare instance
-		 */
-		++zuluvm_ctx_locked;
-		TNF_PROBE_1(zuluvm_ctx_locked, "zuluvm", /* CSTYLED */,
-			tnf_ulong, zuluvm_ctx_locked, zuluvm_ctx_locked);
-
-		/*FALLTHROUGH*/
-
-	case ZULUVM_TTE_DELAY:
-		/*
-		 * fast tlb handler was skipped, see zuluvm_fast_tlb flag
-		 */
-		/*FALLTHROUGH*/
-
-	case ZULUVM_NO_TTE:
-		/*
-		 * no TSB entry and TTE in the hash
-		 */
-		mutex_enter(&zdev->load_lck);
-		zdev->in_intr = 1;
-		error = zulu_hat_load(zhat,  addr,
-			(tlbtype == ZULUVM_DMA2) ? S_WRITE : S_READ, NULL);
-		zdev->in_intr = 0;
-		mutex_exit(&zdev->load_lck);
-		if (error) {
-
-			error = ZULUVM_NO_MAP;
-		} else {
-			error = ZULUVM_SUCCESS;
-			TNF_PROBE_1(zuluvm_tlb_handler_done, "zuluvm", /* */,
-				    tnf_int, error, error);
-			return (1);
-		}
-
-	default:
-		/*
-		 * error case, fall through and tell zulu driver to abort DMA
-		 */
-		break;
-	}
-
-	if (error != ZULUVM_MISS_CANCELED) {
-		state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_IDLE,
-			    ZULUVM_STATE_WRITE_TTE);
-		newstate = ZULUVM_GET_STATE(zdev);
-		TNF_PROBE_2(zuluvm_tlb_handler_state_done, "zuluvm", /* */,
-		    tnf_int, oldstate, state,
-		    tnf_int, newstate, newstate);
-		if (state != ZULUVM_STATE_WRITE_TTE) {
-			zuluvm_stop(zdev, state, "softintr4");
-		}
-	}
-	/*
-	 * synchronize with as_free callback
-	 * It will set the wait flag, in that case we send
-	 * a wake up.
-	 */
-	ZULUVM_LOCK;
-	zdev->intr_flags &= ~flag;
-	if (zdev->intr_flags | wait)
-		cv_broadcast(&zdev->intr_wait);
-	ZULUVM_UNLOCK;
-
-	TNF_PROBE_1(zuluvm_tlb_handler_done, "zuluvm", /* */,
-	    tnf_int, error, error);
-
-	zulud_tlb_done(zdev, arg, tlbtype, error);
-
-	return (1);
-}
-
-
-void
-zuluvm_load_tte(struct zulu_hat  *zhat, caddr_t addr, uint64_t pfn,
-		int perm, int size)
-{
-	zuluvm_state_t *zdev = zhat->zdev;
-	int		tlbtype = ZULUVM_GET_TLB_TYPE(zdev);
-
-	ASSERT(MUTEX_HELD(&zdev->load_lck));
-	ASSERT(pfn != 0);
-
-	if (zdev->in_intr) {
-		int		error;
-		int		flag = 0;
-		int		wait = 0;
-
-		error = zuluvm_write_tte(zdev, zdev->zvm.arg, addr, pfn,
-					perm, size, 0, tlbtype, NULL);
-
-		if (error != ZULUVM_MISS_CANCELED) {
-			int	state, newstate;
-
-			state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_IDLE,
-				    ZULUVM_STATE_WRITE_TTE);
-			newstate = ZULUVM_GET_STATE(zdev);
-			TNF_PROBE_2(zuluvm_tlb_handler_state_done, "zuluvm",
-				    /* */, tnf_int, oldstate, state,
-				    tnf_int, newstate, newstate);
-			if (state != ZULUVM_STATE_WRITE_TTE) {
-				zuluvm_stop(zdev, state, "softintr4");
-			}
-		}
-		/*
-		 * synchronize with as_free callback
-		 * It will set the wait flag, in that case we send
-		 * a wake up.
-		 */
-		switch (tlbtype) {
-		case ZULUVM_ITLB1:
-		case ZULUVM_DMA1:
-			flag = ZULUVM_DO_INTR1;
-			wait = ZULUVM_WAIT_INTR1;
-			break;
-		case ZULUVM_ITLB2:
-		case ZULUVM_DMA2:
-			flag = ZULUVM_DO_INTR2;
-			wait = ZULUVM_WAIT_INTR2;
-			break;
-		}
-
-		ZULUVM_LOCK;
-		zdev->intr_flags &= ~flag;
-		if (zdev->intr_flags | wait)
-			cv_broadcast(&zdev->intr_wait);
-		ZULUVM_UNLOCK;
-
-		zulud_tlb_done(zdev, zdev->zvm.arg, tlbtype, error);
-	} else {
-		(void) zuluvm_write_tte(zdev, zdev->zvm.arg, addr, pfn,
-					perm, size, (uint64_t)addr |
-					zhat->zulu_ctx, tlbtype, NULL);
-	}
-}
-
-
-
-
-/*
- * This function provides the faulting thread for zulu page faults
- * It is call from the device driver in response to an ioctl issued
- * by a zuludaemon thread.
- * It sits in cv_wait_sig until it gets woken up by a signal or
- * zulu tlb miss soft interrupt.
- */
-int
-zuluvm_park(zuluvm_info_t devp)
-{
-	int rval;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	mutex_enter(&zdev->park_lck);
-	zdev->parking = 1;
-	for (;;) {
-		rval = cv_wait_sig(&zdev->park_cv, &zdev->park_lck);
-		if (rval == 0)
-			break;
-		rval = zuluvm_tlb_handler(devp);
-	}
-	zdev->parking = 0;
-	mutex_exit(&zdev->park_lck);
-	return (rval);
-}
-
-/*
- * zulu soft interrupt handler, just triggers the parked zulu fault
- * thread
- */
-/*ARGSUSED*/
-uint_t
-zuluvm_softintr(caddr_t devp, caddr_t arg2)
-{
-	int tlbtype;
-	void *arg;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	mutex_enter(&zdev->park_lck);
-	if (zdev->parking) {
-		cv_signal(&zdev->park_cv);
-		mutex_exit(&zdev->park_lck);
-		TNF_PROBE_1(zuluvm_fast_intr, "zuluvm", /* */,
-		    tnf_opaque, devp, devp);
-	} else {
-		mutex_exit(&zdev->park_lck);
-		cmn_err(CE_NOTE, "zuluvm: no page fault thread\n");
-		ZULUVM_LOCK;
-		tlbtype = ZULUVM_GET_TLB_TYPE(zdev);
-		arg = zdev->zvm.arg;
-		ZULUVM_UNLOCK;
-		TNF_PROBE_0(zuluvm_fast_intr, "zuluvm", /* */);
-		zuluvm_stop(zdev, ZULUVM_STATE_INTR_QUEUED, "fast_intr");
-		zulud_tlb_done(zdev, arg, tlbtype, ZULUVM_NO_TTE);
-	}
-	return (1);
-}
-
-/* ***** public interface for process mapping events (hat layer) ***** */
-
-/*
- * If the page size matches the Zulu page sizes then just pass
- * it thru. If not then emulate the page demap with demaps of
- * smaller page size.
- */
-/* ARGSUSED */
-void
-zuluvm_demap_page(void *arg, struct hat *hat_ptr, short ctx,
-    caddr_t vaddr, uint_t size)
-{
-	void *ddarg;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)arg;
-
-	if (arg == NULL)
-		return;
-
-	ZULUVM_STATS_DEMAP_PAGE(zdev);
-
-	ddarg = zdev->zvm.arg;
-
-	TNF_PROBE_3(zuluvm_demap_page, "zuluvm", /* */,
-	    tnf_opaque, addr, vaddr,
-	    tnf_int, size, size,
-	    tnf_int, ctx, ctx);
-
-	if (ddarg != NULL) {
-		if (size != zuluvm_base_pgsize &&
-		    size != ZULU_TTE4M) {
-			int i;
-			int cnt = size - zuluvm_base_pgsize;
-			cnt = ZULU_HAT_SZ_SHIFT(cnt);
-			for (i = 0; i < cnt; i++) {
-				uintptr_t addr = (uintptr_t)vaddr |
-				    i << ZULU_HAT_BP_SHIFT;
-				zulud_demap_page(zdev, ddarg,
-						(caddr_t)addr, ctx);
-			}
-		} else {
-			zulud_demap_page(zdev, ddarg, vaddr, ctx);
-		}
-		TNF_PROBE_0(zuluvm_demap_page_done, "zuluvm", /* */);
-	} else {
-		TNF_PROBE_0(zuluvm_demap_page_null_ddarg, "zuluvm", /* */);
-	}
-}
-
-/*
- * An entire context has gone away, just pass it thru
- */
-void
-zuluvm_demap_ctx(void *arg, short ctx)
-{
-	void *ddarg;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)arg;
-
-	if (arg == NULL)
-		return;
-
-	ZULUVM_STATS_DEMAP_CTX(zdev);
-
-	TNF_PROBE_1(zuluvm_demap_ctx, "zuluvm", /* */,
-	    tnf_int, ctx, ctx);
-	ddarg = zdev->zvm.arg;
-
-	if (ddarg != NULL)
-		zulud_demap_ctx(zdev, ddarg, ctx);
-}
-
-static int
-zuluvm_driver_attach(zuluvm_state_t *zdev)
-{
-	int i;
-	mutex_enter(&zuluvm_lck);
-	for (i = 0; i < ZULUVM_MAX_DEV; i++) {
-		if (zuluvm_devtab[i] == NULL) {
-			zuluvm_devtab[i] = zdev;
-			ZULUVM_SET_IDLE(zdev);
-			break;
-		}
-	}
-	mutex_exit(&zuluvm_lck);
-	if (i >= ZULUVM_MAX_DEV)
-		return (ZULUVM_ERROR);
-
-	if (zulu_hat_attach((void *)zdev) != 0) {
-		return (ZULUVM_ERROR);
-	}
-
-	mutex_init(&zdev->dev_lck, NULL, MUTEX_DEFAULT, NULL);
-	mutex_init(&zdev->load_lck, NULL, MUTEX_DEFAULT, NULL);
-	mutex_init(&zdev->proc_lck, NULL, MUTEX_DEFAULT, NULL);
-	mutex_init(&zdev->park_lck, NULL, MUTEX_DEFAULT, NULL);
-	cv_init(&zdev->park_cv, NULL, CV_DEFAULT, NULL);
-	cv_init(&zdev->intr_wait, NULL, CV_DEFAULT, NULL);
-	zdev->parking = 0;
-
-#ifdef ZULUVM_STATS
-	zdev->zvm.cancel	= 0;
-	zdev->zvm.pagefault	= 0;
-	zdev->zvm.no_mapping	= 0;
-	zdev->zvm.preload	= 0;
-	zdev->zvm.migrate	= 0;
-	zdev->zvm.pagesize	= 0;
-	zdev->zvm.tlb_miss[0]	= 0;
-	zdev->zvm.tlb_miss[1]	= 0;
-	zdev->zvm.tlb_miss[2]	= 0;
-	zdev->zvm.tlb_miss[3]	= 0;
-	zdev->zvm.itlb1miss	= 0;
-	zdev->zvm.dtlb1miss	= 0;
-	zdev->zvm.itlb2miss	= 0;
-	zdev->zvm.dtlb2miss	= 0;
-#endif
-	zdev->zvm.pfncnt = 0;
-	for (i = 0; i < 50; i++)
-		zdev->zvm.pfnbuf[i] = 0;
-
-	zdev->zvm.mmu_pa  	= NULL;
-	zdev->zvm.proc1   	= NULL;
-	zdev->zvm.proc2   	= NULL;
-	zdev->procs = NULL;
-	return (ZULUVM_SUCCESS);
-}
-
-static int
-zuluvm_driver_detach(zuluvm_state_t *zdev)
-{
-	int i;
-	cv_destroy(&zdev->intr_wait);
-	cv_destroy(&zdev->park_cv);
-	mutex_destroy(&zdev->park_lck);
-	mutex_destroy(&zdev->proc_lck);
-	mutex_destroy(&zdev->dev_lck);
-	mutex_destroy(&zdev->load_lck);
-	zdev->dops = NULL;
-
-	mutex_enter(&zuluvm_lck);
-	for (i = 0; i < ZULUVM_MAX_DEV; i++) {
-		if (zuluvm_devtab[i] == zdev) {
-			zuluvm_devtab[i] = NULL;
-			break;
-		}
-	}
-	mutex_exit(&zuluvm_lck);
-
-	if (zulu_hat_detach((void *)zdev) == 0) {
-		return (ZULUVM_SUCCESS);
-	} else {
-		return (ZULUVM_ERROR);
-	}
-}
-
-zulud_ops_t *zuluvm_dops = NULL;
-
-/*
- * init the zulu kernel driver (variables, locks, etc)
- */
-int
-zuluvm_init(zulud_ops_t *ops, int **pagesizes)
-{
-	int error = ZULUVM_SUCCESS;
-	int i;
-	int size = zuluvm_base_pgsize; /* MMU_PAGESIZE; */
-
-	if (ops->version != ZULUVM_INTERFACE_VERSION)
-		return (ZULUVM_VERSION_MISMATCH);
-
-	zuluvm_dops = ops;
-	for (i = 0; i < ZULUM_MAX_PG_SIZES && size <= ZULU_TTE4M; i++) {
-		zuluvm_pagesizes[i] = size++;
-	}
-	zuluvm_pagesizes[i] = -1;
-	*pagesizes = zuluvm_pagesizes;
-
-	return (error);
-}
-
-/*
- * cleanup afterwards
- */
-int
-zuluvm_fini(void)
-{
-	zuluvm_dops = NULL;
-	return (ZULUVM_SUCCESS);
-}
-
-/*
- *     allocate a zulu kernel driver instance for this zulu device
- */
-int
-zuluvm_alloc_device(dev_info_t *devi, void *arg, zuluvm_info_t *devp,
-    caddr_t mmu, caddr_t imr)
-{
-	uint64_t intr_num;
-	zuluvm_state_t *zdev;
-	int error = ZULUVM_SUCCESS;
-
-	TNF_PROBE_3(zuluvm_alloc_device, "zuluvm", /* */,
-	    tnf_opaque, arg, arg,
-	    tnf_opaque, mmu, mmu,
-	    tnf_opaque, imr, imr);
-
-	zdev = kmem_zalloc(sizeof (zuluvm_state_t), KM_SLEEP);
-	zdev->dip = devi;
-	zdev->dops = zuluvm_dops;
-	error = zuluvm_driver_attach(zdev);
-	if (error != ZULUVM_SUCCESS) {
-		kmem_free(zdev, sizeof (zuluvm_state_t));
-		return (ZULUVM_NO_DEV);
-	}
-
-	ZULUVM_LOCK;
-	error = zuluvm_get_intr_props(zdev, devi);
-	if (error != ZULUVM_SUCCESS) {
-		ZULUVM_UNLOCK;
-		error = zuluvm_driver_detach(zdev);
-		if (error != ZULUVM_SUCCESS)
-			return (error);
-		kmem_free(zdev, sizeof (zuluvm_state_t));
-		return (ZULUVM_NO_DEV);
-	}
-	zdev->zvm.arg = arg;
-	zdev->zvm.mmu_pa = (uint64_t)va_to_pa((void *)mmu);
-	zdev->imr = (uint64_t *)imr;
-	zdev->zvm.dmv_intr = dmv_add_softintr(zuluvm_dmv_tlbmiss_tl1,
-	    (void *)zdev);
-	zulud_set_itlb_pc(zdev, arg, DMV_MAKE_DMV(zdev->zvm.dmv_intr,
-	    (void *)zdev));
-	zulud_set_dtlb_pc(zdev, arg, DMV_MAKE_DMV(zdev->zvm.dmv_intr,
-	    (void *)zdev));
-	intr_dist_add(zuluvm_retarget_intr, (void *)zdev);
-	zuluvm_do_retarget(zdev);
-	intr_num = add_softintr(ZULUVM_PIL, zuluvm_softintr,
-	    (caddr_t)zdev, SOFTINT_ST);
-	zdev->zvm.intr_num = intr_num;
-	*devp = (caddr_t)zdev;
-	ZULUVM_UNLOCK;
-	TNF_PROBE_1(zuluvm_alloc_device_done, "zuluvm", /* */,
-	    tnf_opaque, devp, *devp);
-	return (ZULUVM_SUCCESS);
-}
-
-/*
- *    free a zulu kernel driver instance
- */
-int
-zuluvm_free_device(zuluvm_info_t devp)
-{
-	int error;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_1(zuluvm_free_device, "zuluvm", /* */,
-	    tnf_opaque, zdev, zdev);
-
-	if (zdev == NULL)
-		return (ZULUVM_NO_DEV);
-	ZULUVM_LOCK;
-	if (zdev->zvm.arg == NULL) {
-		ZULUVM_UNLOCK;
-		TNF_PROBE_1(zuluvm_free_device_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_DEV);
-		return (ZULUVM_NO_DEV);
-	}
-	(void) dmv_rem_intr(zdev->zvm.dmv_intr);
-	(void) rem_softintr(zdev->zvm.intr_num);
-	intr_dist_rem(zuluvm_retarget_intr, (void *)zdev);
-	zdev->zvm.arg = NULL;
-	ZULUVM_UNLOCK;
-	error = zuluvm_driver_detach(zdev);
-	if (error != ZULUVM_SUCCESS)
-		return (error);
-	zdev->dops = NULL;
-	kmem_free(zdev, sizeof (zuluvm_state_t));
-
-	TNF_PROBE_0(zuluvm_free_device_done, "zuluvm", /* */);
-	return (ZULUVM_SUCCESS);
-}
-
-/*
- * find the as in the list of active zulu processes
- * The caller has to hold zdev->proc_lck
- */
-static zuluvm_proc_t *
-zuluvm_find_proc(zuluvm_state_t *zdev, struct as *asp)
-{
-	zuluvm_proc_t *p;
-	TNF_PROBE_2(zuluvm_find_proc, "zuluvm", /* */,
-	    tnf_opaque, zdev, zdev,
-	    tnf_opaque, asp, asp);
-	for (p = zdev->procs; p != NULL; p = p->next) {
-		if (ZULU_HAT2AS(p->zhat) == asp) {
-			TNF_PROBE_1(zuluvm_find_proc_done,
-			    "zuluvm", /* */, tnf_opaque, proc, p);
-			return (p);
-		}
-	}
-	TNF_PROBE_0(zuluvm_find_proc_fail, "zuluvm", /* */);
-	return (NULL);
-}
-
-void
-zuluvm_as_free(struct as *as, void *arg, uint_t events)
-{
-	zuluvm_proc_t *proc = (zuluvm_proc_t *)arg;
-	zuluvm_state_t *zdev = proc->zdev;
-	int wait = 0;
-	int flag = 0;
-	int valid;
-
-	(void) events;
-
-	TNF_PROBE_1(zuluvm_as_free, "zuluvm", /* */,
-	    tnf_opaque, arg, arg);
-
-	(void) as_delete_callback(as, arg);
-	/*
-	 * if this entry is still valid, then we need to sync
-	 * with zuluvm_tlb_handler rountine.
-	 */
-	mutex_enter(&zdev->proc_lck);
-	valid = proc->valid;
-	proc->valid = 0;
-	mutex_exit(&zdev->proc_lck);
-
-	if (valid) {
-		ZULUVM_LOCK;
-		if (proc == zdev->zvm.proc1) {
-			flag |= ZULUVM_WAIT_INTR1;
-			wait |= ZULUVM_DO_INTR1;
-		}
-		if (proc == zdev->zvm.proc2) {
-			flag |= ZULUVM_WAIT_INTR2;
-			wait |= ZULUVM_DO_INTR2;
-		}
-		if (flag) {
-			zdev->intr_flags |= flag;
-			/*
-			 * wait until the tlb miss is resloved
-			 */
-			while (zdev->intr_flags & wait) {
-				cv_wait(&zdev->intr_wait, &zdev->dev_lck);
-			}
-			zdev->intr_flags &= ~flag;
-		}
-		ZULUVM_UNLOCK;
-	}
-
-	if (proc->zhat != NULL) {
-		/*
-		 * prevent any further tlb miss processing for this hat
-		 */
-		zulu_hat_terminate(proc->zhat);
-	}
-
-	/*
-	 * decrement the ref count and do the appropriate
-	 * if it drops to zero.
-	 */
-	mutex_enter(&zdev->proc_lck);
-	(void) zuluvm_proc_release(zdev, proc);
-	mutex_exit(&zdev->proc_lck);
-}
-
-/*
- *	notify zulu vm driver about a new process going to
- *	use zulu DMA. Create a zulu_hat.
- */
-int
-zuluvm_dma_add_proc(zuluvm_info_t devp, uint64_t *cookie)
-{
-	zuluvm_proc_t *proc;
-	int refcnt;
-	struct as *asp = ZULUVM_GET_AS;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_1(zuluvm_dma_add_proc, "zuluvm", /* */,
-	    tnf_opaque, zdev, zdev);
-	mutex_enter(&zdev->proc_lck);
-	proc = zuluvm_find_proc(zdev, asp);
-	if (proc == NULL) {
-		proc = kmem_zalloc(sizeof (zuluvm_proc_t), KM_SLEEP);
-		proc->zhat = zulu_hat_proc_attach(asp, zdev);
-		if (proc->zhat == NULL) {
-			mutex_exit(&zdev->proc_lck);
-			kmem_free(proc, sizeof (zuluvm_proc_t));
-			TNF_PROBE_2(zuluvm_dma_add_proc_done, "zuluvm", /* */,
-			    tnf_int, valid, 0,
-			    tnf_int, error, ZULUVM_ERROR);
-			return (ZULUVM_ERROR);
-		}
-		proc->zdev = zdev;
-		proc->valid = 1;
-		proc->refcnt = 1;
-		proc->next = zdev->procs;
-		if (zdev->procs)
-			zdev->procs->prev = proc;
-		proc->prev = NULL;
-		zdev->procs = proc;
-		proc->refcnt++;
-		(void) as_add_callback(asp, zuluvm_as_free, proc,
-			AS_FREE_EVENT, 0, -1, KM_SLEEP);
-	} else {
-		if (proc->valid == 0) {
-			mutex_exit(&zdev->proc_lck);
-			TNF_PROBE_2(zuluvm_dma_add_proc_done, "zuluvm", /* */,
-			    tnf_int, valid, 0,
-			    tnf_int, error, ZULUVM_ERROR);
-			return (ZULUVM_ERROR);
-		}
-		proc->refcnt++;
-	}
-	refcnt = proc->refcnt;
-	mutex_exit(&zdev->proc_lck);
-	*cookie = (uint64_t)proc;
-	TNF_PROBE_2(zuluvm_dma_add_proc_done, "zuluvm", /* */,
-	    tnf_int, refcnt, refcnt,
-	    tnf_int, error, ZULUVM_SUCCESS);
-	return (ZULUVM_SUCCESS);
-}
-
-void
-zuluvm_proc_hold(zuluvm_state_t *zdev, zuluvm_proc_t *proc)
-{
-	mutex_enter(&zdev->proc_lck);
-	proc->refcnt++;
-	mutex_exit(&zdev->proc_lck);
-}
-
-/*
- * decrement ref count and free data if it drops to zero
- */
-static int
-zuluvm_proc_release(zuluvm_state_t *zdev, zuluvm_proc_t *proc)
-{
-	int refcnt;
-	ASSERT(MUTEX_HELD(&zdev->proc_lck));
-	refcnt = --proc->refcnt;
-	TNF_PROBE_3(zuluvm_proc_release, "zuluvm", /* */,
-	    tnf_opaque, zdev, zdev,
-	    tnf_opaque, proc, proc,
-	    tnf_int, refcnt, refcnt);
-	if (refcnt == 0) {
-		if (proc->next)
-			proc->next->prev = proc->prev;
-		if (proc->prev)
-			proc->prev->next = proc->next;
-		else
-			zdev->procs = proc->next;
-		kmem_free(proc, sizeof (zuluvm_proc_t));
-	}
-	return (refcnt);
-}
-
-/*
- *	this process is not longer using DMA, all entries
- * 	have been removed from the TLB.
- */
-int
-zuluvm_dma_delete_proc(zuluvm_info_t devp, uint64_t cookie)
-{
-	int refcnt;
-	zuluvm_proc_t *proc = (zuluvm_proc_t *)cookie;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_2(zuluvm_dma_delete_proc, "zuluvm", /* */,
-	    tnf_opaque, zdev, zdev,
-	    tnf_opaque, cookie, cookie);
-	mutex_enter(&zdev->proc_lck);
-	if (proc != NULL) {
-		TNF_PROBE_1(zuluvm_dma_delete_proc, "zuluvm", /* */,
-		    tnf_opaque, proc, proc);
-		if (proc->zhat != NULL) {
-			zulu_hat_proc_detach(proc->zhat);
-			proc->zhat = NULL;
-		}
-		refcnt = zuluvm_proc_release(zdev, proc);
-	}
-	mutex_exit(&zdev->proc_lck);
-
-	TNF_PROBE_2(zuluvm_dma_delete_proc_done, "zuluvm", /* */,
-	    tnf_int, refcnt, refcnt,
-	    tnf_int, error, ZULUVM_SUCCESS);
-	return (ZULUVM_SUCCESS);
-}
-
-/*
- * barrier sync for device driver
- * blocks until zuluvm_tlbmiss_tl1 function is done
- */
-void
-zuluvm_fast_tlb_wait(caddr_t devp)
-{
-	int state;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	int cnt = 0;
-
-	do {
-		state = ZULUVM_GET_STATE(zdev);
-		cnt++;
-	} while (state == ZULUVM_STATE_TLB_PENDING);
-	TNF_PROBE_1(zuluvm_fast_tlb_wait, "zuluvm", /* */,
-	    tnf_int, loop_cnt, cnt);
-}
-
-/*
- *     setup DMA handling for this handle
- */
-int
-zuluvm_dma_alloc_ctx(zuluvm_info_t devp, int dma, short *mmuctx,
-    uint64_t *tsbreg)
-{
-	struct as	*asp = ZULUVM_GET_AS;
-	int		error = ZULUVM_NO_DEV;
-	zuluvm_state_t    *zdev = (zuluvm_state_t *)devp;
-	int 		state, newstate;
-
-	if (asp == NULL) {
-		TNF_PROBE_1(zuluvm_dma_alloc_ctx_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_HAT);
-		return (ZULUVM_NO_HAT);
-	}
-
-	*tsbreg = 0;
-	state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_IDLE,
-		    ZULUVM_STATE_STOPPED);
-	newstate = ZULUVM_GET_STATE(zdev);
-	TNF_PROBE_4(zuluvm_dma_alloc_ctx, "zuluvm", /* */,
-	    tnf_opaque, devp, devp,
-	    tnf_int, dma, dma,
-	    tnf_int, oldstate, state,
-	    tnf_int, newstate, newstate);
-#ifdef DEBUG
-	if (zuluvm_debug_state)
-		cmn_err(CE_NOTE, "zuluvm_dma_alloc_ctx: state %d\n", state);
-#endif
-	if (state != ZULUVM_STATE_STOPPED && state != ZULUVM_STATE_IDLE) {
-		while (state != ZULUVM_STATE_IDLE) {
-			state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_IDLE,
-				    ZULUVM_STATE_STOPPED);
-#ifdef DEBUG
-			if (zuluvm_debug_state)
-				cmn_err(CE_NOTE, "zuluvm_dma_alloc_ctx: (loop)"
-				    " state %d\n", state);
-#endif
-			if (state != ZULUVM_STATE_IDLE)
-				delay(1);
-		}
-	}
-
-	if (zdev->zvm.arg != NULL) {
-		struct zulu_hat *zhat;
-		zuluvm_proc_t *proc;
-
-		mutex_enter(&zdev->proc_lck);
-		proc = zuluvm_find_proc(zdev, asp);
-		if (proc != NULL) {
-			zhat = proc->zhat;
-			proc->refcnt++;
-		}
-		mutex_exit(&zdev->proc_lck);
-
-		switch (dma) {
-		case ZULUVM_DMA1:
-			ZULUVM_LOCK;
-			zdev->zvm.proc1 = proc;
-			ZULUVM_UNLOCK;
-			error = ZULUVM_SUCCESS;
-			break;
-		case ZULUVM_DMA2:
-			ZULUVM_LOCK;
-			zdev->zvm.proc2 = proc;
-			ZULUVM_UNLOCK;
-			error = ZULUVM_SUCCESS;
-			break;
-		default:
-			mutex_enter(&zdev->proc_lck);
-			(void) zuluvm_proc_release(zdev, proc);
-			mutex_exit(&zdev->proc_lck);
-		}
-
-		if (error == ZULUVM_SUCCESS) {
-			zulu_hat_validate_ctx(zhat);
-			if (zhat->zulu_ctx >= 0) {
-				*mmuctx = zhat->zulu_ctx;
-			} else {
-				printf("invalid context value: %d\n",
-					zhat->zulu_ctx);
-
-				mutex_enter(&zdev->proc_lck);
-				(void) zuluvm_proc_release(zdev, proc);
-				mutex_exit(&zdev->proc_lck);
-
-				error = ZULUVM_ERROR;
-			}
-		} else {
-			error = ZULUVM_ERROR;
-		}
-	}
-	TNF_PROBE_1(zuluvm_dma_alloc_ctx_done, "zuluvm", /* */,
-	    tnf_int, error, error);
-	return (error);
-}
-
-/*
- * preload TLB
- * this will try to pre-set the zulu tlb, mainly used for dma engine 2,
- * video read-back.
- */
-int
-zuluvm_dma_preload(zuluvm_info_t devp, int dma,
-			int num, zulud_preload_t *list)
-{
-	int i;
-	int error = ZULUVM_SUCCESS;
-	struct zulu_hat *zhat;
-	zuluvm_proc_t *proc = NULL;
-
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_4(zuluvm_dma_preload, "zuluvm", /* */,
-	    tnf_opaque, devp, devp,
-	    tnf_int, dma, dma,
-	    tnf_int, num, num,
-	    tnf_opaque, list, list);
-	ZULUVM_LOCK;
-	switch (dma) {
-	case ZULUVM_DMA1:
-		proc = zdev->zvm.proc1;
-		break;
-	case ZULUVM_DMA2:
-		proc = zdev->zvm.proc2;
-		break;
-	}
-
-	mutex_enter(&zdev->proc_lck);
-	if (proc == NULL || proc->valid == 0 || proc->zhat == NULL) {
-		mutex_exit(&zdev->proc_lck);
-		ZULUVM_UNLOCK;
-		return (ZULUVM_NO_HAT);
-	}
-	mutex_exit(&zdev->proc_lck);
-
-	zhat = proc->zhat;
-	/*
-	 * need to release this to avoid recursive enter in zuluvm_load_tte
-	 * which gets called from zulu_hat_memload()
-	 */
-	ZULUVM_UNLOCK;
-
-	mutex_enter(&zdev->load_lck);
-	for (i = 0; i < num; i++) {
-		int pg_size;
-		int res;
-		int first = 1;
-		caddr_t addr = ZULUVM_GET_PAGE(list[i].addr);
-		int64_t size = (int64_t)list[i].len;
-		while (size > 0) {
-			if (list[i].tlbtype & ~ZULUVM_DMA_MASK) {
-				error = ZULUVM_INVALID_MISS;
-				break;
-			}
-			res = zulu_hat_load(zhat, addr,
-			    (list[i].tlbtype == ZULUVM_DMA2) ? S_WRITE : S_READ,
-			    &pg_size);
-			if ((res != 0) || (pg_size < 0)) {
-				error = ZULUVM_NO_MAP;
-				break;
-			}
-			ZULUVM_STATS_PRELOAD(zdev);
-			TNF_PROBE_2(zuluvm_dma_preload_addr, "zuluvm", /* */,
-			    tnf_opaque, addr, addr,
-			    tnf_opaque, size, size);
-			if (first) {
-				first = 0;
-				size -= ZULU_HAT_PGDIFF(list[i].addr,
-							pg_size);
-			} else {
-				size -= ZULU_HAT_PGSZ(pg_size);
-			}
-			addr += ZULU_HAT_PGSZ(pg_size);
-		}
-	}
-	mutex_exit(&zdev->load_lck);
-	TNF_PROBE_1(zuluvm_dma_preload_done, "zuluvm", /* */,
-	    tnf_int, error, error);
-	return (ZULUVM_SUCCESS);
-}
-
-/*
- * destroy DMA handling for this handle
- */
-int
-zuluvm_dma_free_ctx(zuluvm_info_t devp, int dma)
-{
-	int error = ZULUVM_NO_DEV;
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	int state, newstate;
-
-	state = ZULUVM_SET_STATE(zdev, ZULUVM_STATE_STOPPED,
-		    ZULUVM_STATE_IDLE);
-	newstate = ZULUVM_GET_STATE(zdev);
-	TNF_PROBE_4(zuluvm_dma_free_ctx, "zuluvm", /* */,
-	    tnf_opaque, devp, devp,
-	    tnf_int, dma, dma,
-	    tnf_int, oldstate, state,
-	    tnf_int, newstate, newstate);
-#ifdef DEBUG
-	if (zuluvm_debug_state)
-		cmn_err(CE_NOTE, "zuluvm_dma_free_ctx: state %d\n", state);
-#endif
-	if (state != ZULUVM_STATE_IDLE && state != ZULUVM_STATE_STOPPED) {
-		int doit = 1;
-		while (doit) {
-			switch (state) {
-			case ZULUVM_STATE_CANCELED:
-			case ZULUVM_STATE_STOPPED:
-				doit = 0;
-				break;
-			case ZULUVM_STATE_IDLE:
-				state = ZULUVM_SET_STATE(zdev,
-					    ZULUVM_STATE_STOPPED,
-					    ZULUVM_STATE_IDLE);
-				break;
-			default:
-				state = ZULUVM_SET_STATE(zdev,
-					    ZULUVM_STATE_CANCELED, state);
-			}
-			TNF_PROBE_1(zuluvm_dma_free_ctx, "zuluvm", /* */,
-			    tnf_int, state, state);
-#ifdef DEBUG
-			if (zuluvm_debug_state)
-				cmn_err(CE_NOTE, "zuluvm_dma_free_ctx: (loop1)"
-				    " state %d\n", state);
-#endif
-		}
-	}
-	TNF_PROBE_1(zuluvm_dma_free_ctx, "zuluvm", /* */,
-	    tnf_int, state, state);
-
-	error = ZULUVM_SUCCESS;
-	while (state != ZULUVM_STATE_STOPPED) {
-		state = ZULUVM_GET_STATE(zdev);
-#ifdef DEBUG
-		if (zuluvm_debug_state)
-			cmn_err(CE_NOTE, "zuluvm_dma_free: (loop2) state %d\n",
-			    state);
-#endif
-		if (state != ZULUVM_STATE_STOPPED)
-			delay(1);
-	}
-	ZULUVM_LOCK;
-	if (zdev->zvm.arg != NULL) {
-		zuluvm_proc_t *proc = NULL;
-		switch (dma) {
-		case ZULUVM_DMA1:
-			proc = zdev->zvm.proc1;
-			zdev->zvm.proc1 = NULL;
-			break;
-		case ZULUVM_DMA2:
-			proc = zdev->zvm.proc2;
-			zdev->zvm.proc2 = NULL;
-			break;
-		default:
-			error = ZULUVM_NO_DEV;
-		}
-		ZULUVM_UNLOCK;
-		if (proc) {
-			mutex_enter(&zdev->proc_lck);
-			(void) zuluvm_proc_release(zdev, proc);
-			mutex_exit(&zdev->proc_lck);
-		}
-	} else {
-		ZULUVM_UNLOCK;
-		error = ZULUVM_NO_DEV;
-	}
-	TNF_PROBE_1(zuluvm_dma_free_ctx_done, "zuluvm", /* */,
-	    tnf_int, error, error);
-	return (error);
-}
-
-static void
-zuluvm_do_retarget(zuluvm_state_t *zdev)
-{
-	int i, idx;
-	uint_t cpu;
-	for (i = 0; i < ZULUVM_MAX_INTR; i++) {
-		if (zdev->interrupts[i].ino != -1) {
-			cpu = intr_dist_cpuid();
-			idx = zdev->interrupts[i].offset;
-			if (zdev->imr[idx] & ZULUVM_IMR_V_MASK)
-				zdev->imr[idx] = ZULUVM_IMR_V_MASK |
-				    (cpu<<ZULUVM_IMR_TARGET_SHIFT);
-			else
-				zdev->imr[idx] =
-				    cpu<<ZULUVM_IMR_TARGET_SHIFT;
-		}
-	}
-}
-
-static void
-zuluvm_retarget_intr(void *arg)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)arg;
-	ZULUVM_LOCK;
-	zuluvm_do_retarget(zdev);
-	ZULUVM_UNLOCK;
-}
-
-int
-zuluvm_add_intr(zuluvm_info_t devp, int ino,
-		uint_t (*handler)(caddr_t), caddr_t arg)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	if (devp == NULL) {
-		TNF_PROBE_1(zuluvm_add_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_DEV);
-		return (ZULUVM_NO_DEV);
-	}
-	if (ddi_add_intr(zdev->dip, ino, NULL, NULL, handler, arg)
-		!= DDI_SUCCESS) {
-		TNF_PROBE_1(zuluvm_add_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_ERROR);
-		return (ZULUVM_ERROR);
-	}
-	return (ZULUVM_SUCCESS);
-}
-
-int
-zuluvm_rem_intr(zuluvm_info_t devp, int ino)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-	if (devp == NULL) {
-		TNF_PROBE_1(zuluvm_rem_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_DEV);
-		return (ZULUVM_NO_DEV);
-	}
-	/* remove from distributin list */
-	ZULUVM_LOCK;
-	zdev->imr[zdev->interrupts[ino].offset] &= ~ZULUVM_IMR_V_MASK;
-	ZULUVM_UNLOCK;
-	ddi_remove_intr(zdev->dip, ino, NULL);
-	return (ZULUVM_SUCCESS);
-}
-
-int
-zuluvm_enable_intr(zuluvm_info_t devp, int num)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_2(zuluvm_enable_intr, "zuluvm_intr", /* */,
-	    tnf_opaque, devp, devp,
-	    tnf_int, num, num);
-	if (devp == NULL) {
-		TNF_PROBE_1(zuluvm_enable_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_DEV);
-		return (ZULUVM_NO_DEV);
-	}
-	if (num < 0 || num > ZULUVM_IMR_MAX) {
-		TNF_PROBE_1(zuluvm_enable_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_BAD_IDX);
-		return (ZULUVM_BAD_IDX);
-	}
-	ZULUVM_LOCK;
-	zdev->imr[num] |= ZULUVM_IMR_V_MASK;
-	ZULUVM_UNLOCK;
-	TNF_PROBE_1(zuluvm_enable_intr_done, "zuluvm_intr", /* */,
-	    tnf_int, error, ZULUVM_SUCCESS);
-	return (ZULUVM_SUCCESS);
-}
-
-int
-zuluvm_disable_intr(zuluvm_info_t devp, int num)
-{
-	zuluvm_state_t *zdev = (zuluvm_state_t *)devp;
-
-	TNF_PROBE_2(zuluvm_disable_intr, "zuluvm_intr", /* */,
-	    tnf_opaque, devp, devp,
-	    tnf_int, num, num);
-	if (devp == NULL) {
-		TNF_PROBE_1(zuluvm_disable_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_NO_DEV);
-		return (ZULUVM_NO_DEV);
-	}
-	if (num < 0 || num > ZULUVM_IMR_MAX) {
-		TNF_PROBE_1(zuluvm_disable_intr_done, "zuluvm", /* */,
-		    tnf_int, error, ZULUVM_BAD_IDX);
-		return (ZULUVM_BAD_IDX);
-	}
-	ZULUVM_LOCK;
-	zdev->imr[num] &= ~ZULUVM_IMR_V_MASK;
-	ZULUVM_UNLOCK;
-	TNF_PROBE_1(zuluvm_disable_intr_done, "zuluvm_intr", /* */,
-	    tnf_int, error, ZULUVM_SUCCESS);
-	return (ZULUVM_SUCCESS);
-}
-
-static int
-zuluvm_get_intr_props(zuluvm_state_t *zdev,
-			dev_info_t *devi)
-{
-	int *intr;
-	int i;
-	uint_t nintr;
-
-	zdev->agentid = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
-	    "portid", -1);
-	if (zdev->agentid == -1) {
-		cmn_err(CE_WARN, "%s%d: no portid property",
-		    ddi_get_name(devi),
-		    ddi_get_instance(devi));
-		return (ZULUVM_ERROR);
-	}
-
-	for (i = 0; i < ZULUVM_MAX_INTR; i++) {
-		zdev->interrupts[i].offset = 0;
-		zdev->interrupts[i].ino = -1;
-	}
-
-	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
-	    "interrupts", &intr, &nintr) == DDI_PROP_SUCCESS) {
-
-		if (nintr == 0) {
-			cmn_err(CE_WARN, "%s%d: no interrupts in property",
-			    ddi_get_name(devi),
-			    ddi_get_instance(devi));
-			ddi_prop_free(intr);
-			return (ZULUVM_ERROR);
-		}
-		if (nintr >= ZULUVM_MAX_INTR) {
-			cmn_err(CE_WARN, "%s%d: to many interrupts (%d)",
-			    ddi_get_name(devi),
-			    ddi_get_instance(devi), nintr);
-			ddi_prop_free(intr);
-			return (ZULUVM_ERROR);
-		}
-		for (i = 0; i < nintr; i++) {
-			zdev->interrupts[i].offset = intr[i];
-			zdev->interrupts[i].ino = i;
-		}
-		ddi_prop_free(intr);
-	} else {
-		cmn_err(CE_WARN, "%s%d: no interrupts property",
-		    ddi_get_name(devi),
-		    ddi_get_instance(devi));
-	}
-	return (ZULUVM_SUCCESS);
-}
-
-/* *** enf of zulu *** */
--- old/usr/src/uts/sun4u/ml/zulu_asm.s	2015-05-08 18:10:43.931087349 -0400
+++ /dev/null	2015-05-08 18:10:43.000000000 -0400
@@ -1,325 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#if defined(lint)
-#include <sys/types.h>
-#include <sys/thread.h>
-#else	/* lint */
-#include "assym.h"
-#endif	/* lint */
-
-#include <sys/asi.h>
-#include <sys/sun4asi.h>
-#include <sys/machasi.h>
-#include <sys/asm_linkage.h>
-#include <sys/pte.h>
-#include <sys/mmu.h>
-#include <sys/intreg.h>
-#include <sys/zulumod.h>
-#include <vm/hat_sfmmu.h>
-#include <sys/zulu_hat.h>
-#include <zuluvm_offsets.h>
-
-#ifdef lint
-void
-zuluvm_dmv_tlbmiss_tl1()
-{}
-
-#else	/* lint */
-
-	DGDEF(zuluvm_base_pgsize)
-        .word   0
-
-	ENTRY_NP(zuluvm_dmv_tlbmiss_tl1)
-
-	! g1 - zuluvm_state_t pointer
-	! g2 - IRDR_0
-	mov	UIII_IRDR_1, %g3
-	ldxa	[%g3]ASI_INTR_RECEIVE, %g5
-	stx	%g5, [%g1 + ZULUVM_ASM_TLB_ADDR]
-	mov	UIII_IRDR_6, %g3
-	ldxa	[%g3]ASI_INTR_RECEIVE, %g5
-	stx	%g5, [%g1 + ZULUVM_ASM_TLB_TYPE]
-
-	stxa	%g0, [%g0]ASI_INTR_RECEIVE_STATUS       ! clear the BUSY bit
-	membar	#Sync
-
-	mov	%g1, %g7
-
-	! check the fast tlb miss flag
-	sethi	%hi(zuluvm_fast_tlb), %g6
-	lduw	[%g6 + %lo(zuluvm_fast_tlb)], %g6
-	brz,pn	%g6, send_intr1
-	  mov	ZULUVM_TTE_DELAY, %g1
-#if 1
-	add	%g7, ZULUVM_STATE, %g4
-	mov	ZULUVM_STATE_IDLE, %g1
-	mov	ZULUVM_STATE_TLB_PENDING, %g6
-	casa	[%g4]ASI_N, %g1, %g6
-	cmp 	%g6, %g1
-	be,pt	%icc, 2f
-	  nop
-
-	mov	ZULUVM_STATE_CANCELED, %g1
-	cmp 	%g6, %g1
-	be,pt	%icc, 1f
-	  mov	ZULUVM_STATE_STOPPED, %g1
-	retry
-1:
-	st	%g1, [%g4]
-#ifdef ZULUVM_STATS
-	lduw	[%g7 + ZULUVM_ST_TLBCANCEL], %g3
-	add	%g3, 1, %g3
-	stuw	%g3, [%g7 + ZULUVM_ST_TLBCANCEL]
-#endif
-	retry
-
-2:
-	ldx	[%g7 + ZULUVM_ASM_TLB_TYPE], %g4
-	and	%g4, ZULUVM_DMA_MASK, %g4
-#ifdef ZULUVM_STATS
-	cmp	%g4, ZULUVM_DMA2
-	be,a,pn	%icc, 1f
-	  add	%g7, ZULUVM_ST_DTLB2MISS, %g1
-	cmp     %g4, ZULUVM_ITLB1
-	be,a,pn %icc, 1f
-          add   %g7, ZULUVM_ST_ITLB1MISS, %g1
-	cmp     %g4, ZULUVM_ITLB2
-	be,a,pn %icc, 1f
-          add   %g7, ZULUVM_ST_ITLB2MISS, %g1
-	add	%g7, ZULUVM_ST_DTLB1MISS, %g1
-1:
-	lduw	[%g1], %g3
-	add	%g3, 1, %g3
-	stuw 	%g3, [%g1]
-#endif
-	/*
-	 * lookup the tte in the tsb
-	 * %g1 - vaddr[63:13], ctx[12:0]
-	 * %g2 - our trap level
-	 * %g3 - return address
-	 * %g7 - zulu data pointer (needs to be preserved)
-	 * return:
-	 * %g1 - flags [63..58] and pfn [31..0]
-	 * %g2 - status code if %g1 is null
-	 * %g7 - zulu data pointer
-	 */
-	mov	1, %g2
-	set	zulu_hat_tsb_lookup_tl1, %g3
-	jmpl	%g3, %g3
-	  ldx	[%g7 + ZULUVM_ASM_TLB_ADDR], %g1	! vaddr(tag)
-
-	/*
-	 * did we find a tte ??
-	 * If not, %g2 has the error code
-	 */
-	brgez,a,pt %g1, send_intr
-	mov	%g2, %g1
-
-	set	zulu_tsb_hit, %g6
-	ldx	[%g6], %g3
-	add	%g3, 1, %g3
-	stx	%g3, [%g6]
-
-	/*
-	 * get flags and pfn
-	 */
-	sllx    %g1, 32, %g6
-	srlx	%g6, 32, %g6			! %g6 pfn
-	srlx    %g1, 59, %g3
-	and 	%g3, 0x7, %g2			! %g2 page size
-	srlx    %g3, 3, %g4
-	and	%g4, 1, %g4			! %g4 write perm
-	mov     %g6, %g1 
-
-	/*
-	 * check if this is a dtlb2 miss(no itlb, pgsz != 8k)
-	 * and if the current dtlb2 pgsz != tte pgsz
-	 */
-	ldx	[%g7 + ZULUVM_ASM_TLB_TYPE], %g3
-	and	%g3, 0x1, %g3
-	brnz,pt %g3, 3f				! not 0 => itlb => handles
-	  nop
-
-	! check page size, base page size is always handled by dtlb1, so we
-	! only need to check against dtlb2
-	sethi   %hi(zuluvm_base_pgsize), %g3
-        lduw    [%g3 + %lo(zuluvm_base_pgsize)], %g3
-	cmp	%g2, %g3
-	be,pt	%icc, 2f
-	cmp	%g2, ZULU_TTE4M
-	be,pt 	%icc, 2f			! TTE4M => dtlb2 => ok!
-	  nop
-
-#ifdef ZULUVM_STATS
-	lduw	[%g7 + ZULUVM_ST_PAGESIZE], %g3
-	add	%g3, 1, %g3
-	stuw	%g3, [%g7 + ZULUVM_ST_PAGESIZE]
-	add	%g7, ZULUVM_ST_MISS, %g3
-	sll	%g2, 2, %g5
-	add	%g5, %g3, %g5
-	lduw	[%g5], %g3
-	add	%g3, 1, %g3
-	stuw	%g3, [%g5]
-#endif
-	! set tte size to ZULUVM_BASE_PGSZ
-	sethi   %hi(zuluvm_base_pgsize), %g3
-        lduw    [%g3 + %lo(zuluvm_base_pgsize)], %g3
-	ba,pt	%icc, 3f
-	  mov	%g3, %g2
-2:
-
-#ifdef ZULUVM_STATS
-	add	%g7, ZULUVM_ST_MISS, %g3
-	sll	%g2, 2, %g5
-	add	%g3, %g5, %g5
-	lduw	[%g5], %g3
-	add	%g3, 1, %g3
-	stuw	%g3, [%g5]
-#endif
-
-	! we maintain data on the last pfns for the last 12 pfns that we
-	! processed
-3:
-        lduw    [%g7 + ZULUVM_PFNCNT], %g5
-        add     %g5, 4, %g3
-        cmp     %g3, 48
-        be,a,pn %icc, 1f
-          mov   %g0, %g3
- 
-1:                           
-        stuw    %g3, [%g7 + ZULUVM_PFNCNT]
-        sllx    %g5, 3, %g5
-        add     %g7, ZULUVM_PFNBUF, %g3
-        add     %g3, %g5, %g3
-        stx     %g1, [%g3]
-        stx     %g2, [%g3 + 8]
-        stx     %g4, [%g3 + 16]
-	ldx     [%g7 + ZULUVM_ASM_TLB_TYPE], %g5
-	stx     %g5, [%g3 + 24]
-
-	ldx	[%g7 + ZULUVM_ASM_TLB_TYPE], %g3
-	and	%g3, 0x3, %g3			! tlbtype
-	ldx	[%g7 + ZULUVM_ARG], %g6
-
-	! write tte to zulu mmu
-	! %g1 pfn
-	! %g2 tte size
-	! %g3 tlbtype
-	! %g4 tte wrperm
-	! %g6 zulu device driver arg
-	! %g7 devtab pointer
-
-	sllx	%g1, ZULUVM_ZFB_MMU_TLB_D_PA_SHIFT, %g1
-	mov	0x1, %g5
-	sllx	%g5, 63, %g5			! ZFB_MMU_TLB_D_V_MASK
-	or	%g1, %g5, %g1
-	or	%g1, ZULUVM_ZFB_MMU_TLB_D_C_MASK, %g1
-	sllx	%g2, ZULUVM_ZFB_MMU_TLB_D_SZ_SHIFT, %g2
-
-	brz,pt	%g4, 3f				! write perm ??
-	  or	%g2, %g1, %g1
-
-	or	%g1, ZULUVM_ZFB_MMU_TLB_D_W_MASK, %g1
-3:
-	! at this point %g1 is ready to be written to the corresponding
-	! data_in register, let's see which if it was itlb or dtlb...
-	and	%g3, ZULUVM_ITLB_FLAG, %g3
-						! assumption is that data miss
-	brz,pt	%g3, 4f				! is more likely than instr miss
-	  ldx	[%g7 + ZULUVM_PAMMU], %g2	! physical addr of zulu mmu regs
-
-	! instruction miss
-	mov     ZULUVM_ZFB_MMU_TLB_CR_IMISS_MASK, %g5
-        add     %g2, ZULUVM_ITLB_DATA_IN, %g4
-	!stxa  %g1, [%g4]ASI_IO
-	ba,pt	%xcc, 5f
-	  stxa  %g1, [%g4]ASI_IO
-	  !ldxa    [%g4]ASI_IO, %g4
-4:
-	! data miss
-	mov     ZULUVM_ZFB_MMU_TLB_CR_DMISS_MASK, %g5
-	add     %g2, ZULUVM_DTLB_DATA_IN, %g4
-	stxa    %g1, [%g4]ASI_IO
-	!ldxa    [%g4]ASI_IO, %g4
-5:
-	add     %g7, ZULUVM_STATE, %g4
-        mov     ZULUVM_STATE_TLB_PENDING, %g6
-        mov     ZULUVM_STATE_IDLE, %g1
-        casa	[%g4]ASI_N, %g6, %g1
-        cmp     %g6, %g1
-        bne,a,pn %icc, stopped
-          mov	ZULUVM_STATE_STOPPED, %g3
-
-	ldx	[%g7 + ZULUVM_PAMMU], %g2
-	add     %g2, ZULUVM_TLB_CONTROL, %g2
-	stxa    %g5, [%g2]ASI_IO
-	!ldxa	[%g2]ASI_IO, %g3
-	retry
-
-send_intr:	
-	add     %g7, ZULUVM_STATE, %g4
-	mov     ZULUVM_STATE_INTR_QUEUED, %g5
-	mov     ZULUVM_STATE_TLB_PENDING, %g3
-	casa    [%g4]ASI_N, %g3, %g5
-	cmp     %g3, %g5
-        be,pt  %icc, deliver_intr
-        mov     ZULUVM_STATE_STOPPED, %g3
-	ba,pt	%icc, stopped
-	  nop
-#endif
-
-send_intr1:
-	add	%g7, ZULUVM_STATE, %g4
-	mov     ZULUVM_STATE_IDLE, %g3
-	mov 	ZULUVM_STATE_INTR_QUEUED, %g5
-	casa	[%g4]ASI_N, %g3, %g5
-        cmp     %g3, %g5
-        be,pt  %icc, deliver_intr
-        mov	ZULUVM_STATE_STOPPED, %g3
-stopped:
-	st	%g3, [%g4]
-#ifdef ZULUVM_STATS
-	lduw	[%g7 + ZULUVM_ST_TLBCANCEL], %g3
-	add	%g3, 1, %g3
-	stuw	%g3, [%g7 + ZULUVM_ST_TLBCANCEL]
-#endif
-	retry 
-
-deliver_intr:
-	stx     %g1, [%g7 + ZULUVM_ASM_TLB_ERRCODE]     ! set the error field
-        stx     %g6, [%g7 + ZULUVM_ASM_TLB_TTE] ! deliver tte in data_0
-                                                ! %g6 is invalid if error != SUCCESS
-	! setsoftint_tl1(uint64_t inum, uint64_t dummy)
-	set     setsoftint_tl1, %g5
-        jmp     %g5
-        ldx     [%g7 + ZULUVM_INTRNUM], %g1
-
-	SET_SIZE(zuluvm_dmv_tlbmiss_tl1)
-
-#endif	/* lint */
-
--- old/usr/src/uts/sun4u/ml/zulu_hat_asm.s	2015-05-08 18:10:44.002189736 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,314 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#if defined(lint)
-#include <sys/types.h>
-#include <sys/thread.h>
-#else	/* lint */
-#include "assym.h"
-#endif	/* lint */
-
-#include <sys/asi.h>
-#include <sys/machasi.h>
-#include <sys/asm_linkage.h>
-#include <zuluvm_offsets.h>
-#include <sys/zulu_hat.h>
-#include <sys/zuluvm.h>
-
-/*
- * function to look up ttes in zulu_hat TSB.
- *
- * zulu_hat_tsb_lookup_tl1 is called from the zuluvm dmv interrupt handler
- * so we can only use the global registers.
- *
- * zulu_hat_tsb_lookup_tl0 is called from TL=0 
- */
-#ifdef lint
-
-/* ARGSUSED */
-uint64_t
-zulu_hat_tsb_lookup_tl1(caddr_t vaddr)
-{
-	return (0);
-}
-
-/* ARGSUSED */
-uint64_t
-zulu_hat_tsb_lookup_tl0(struct zulu_hat *zhat, caddr_t vaddr)
-{
-	return (0);
-}
-
-#else	/* lint */
-
-	/*
-	 * %g1 - vaddr | ctx
-	 * %g3 - return address
-	 * Must preserve %g7 for caller
-	 *
-	 * returns:
-	 * %g1 - pfn and flags
-	 * %g2 - zuluvm error code if %g1 is null
-	 */
-	ENTRY_NP(zulu_hat_tsb_lookup_tl1)
-	set	ZULU_CTX_MASK, %g4
-	and	%g1, %g4, %g4
-
-	! we're at trap level 1, (TL=1)
-	! if the context is already locked by another
-	! thread, punt to the TL=0 code
-	! it's not safe to spinloop now.
-
-	set	zulu_ctx_tab, %g6
-	sllx	%g4, 3, %g5
-#ifdef DEBUG
-	mov	%g5, %g2	! remember ctx * 8
-#endif
-	add	%g5, %g6, %g6
-
-	ldx	[%g6], %g4
-	andcc	%g4, 1, %g0
-	bne,a,pn %icc, ctx_busy
-	  mov	ZULUVM_CTX_LOCKED, %g2
-	
-	! now do a compare and swap and make sure it's still not locked
-	or	%g4, 1, %g5
-	casxa	[%g6]ASI_N, %g4, %g5
-	cmp	%g4, %g5
-	bne,a,pn %icc, ctx_busy
-	  mov	ZULUVM_CTX_LOCKED, %g2
-
-	brz,a,pn %g4, zulu_hat_tsb_exit
-	  mov	%g0, %g1
-
-	! we have the lock now proceed
-
-	! set lsb of g3 to indicate that we need to unlock the context
-	! before returning
-	ba,pt	%xcc, zulu_hat_tsb_lookup
-	  or	%g3, 1, %g3
-
-ctx_busy:
-	mov	%g0, %g1
-	jmpl	%g3+8, %g0
-	nop
-
-
-	/*
-	 * zulu_hat_tsb_lookup_tl0 jumps here
-	 *
-	 * %g1 vaddr | ctx
-	 * %g3 return address | unlock flag (bit zero)
-	 * %g4 has the zulu hat ptr (locked)
-	 */
-zulu_hat_tsb_lookup:
-	mov	%g1, %g2
-	mov     %g4, %g1
-	  
-	add	%g1, ZULU_HAT_TSB_SZ, %g5
-	lduh	[%g5], %g5		! tsb size
-	sub	%g5, 1, %g5
-
-	srlx    %g2, 22,  %g4		! 4m page hash
-	and     %g5, %g4, %g4           ! hash index
-	sllx    %g4, 4, %g4
-	add     %g1, ZULU_HAT_TSB, %g5
-	ldx     [%g5], %g5
-	add     %g5, %g4, %g4           ! ptr to struct zulu_tte
-	ldx     [%g4], %g5              ! get the tag
-
-	set	(0x1ff << 13), %g6
-	andn	%g5, %g6, %g5
-	andn    %g2, %g6, %g6
-	cmp     %g5, %g6
-	bne,pn  %xcc, zulu_hat_tsb_try_512k
-          nop
-
-	ldx     [%g4 + 8], %g4          ! flags and pfn 
-	brgez,pn %g4, zulu_hat_tsb_try_512k ! check if entry is valid
-	  nop
-
-	sllx	%g4, 2, %g5
-	srlx	%g5, 61, %g5		! tte size
-	cmp	%g5, ZULU_TTE4M
-	be,pn   %xcc, zulu_hat_tsb_found
-	  nop
-
-zulu_hat_tsb_try_512k:
-	add     %g1, ZULU_HAT_TSB_SZ, %g5
-        lduh    [%g5], %g5              ! tsb size
-        sub     %g5, 1, %g5
-
-	srlx    %g2, 19, %g4           ! 4m page hash
-        and     %g5, %g4, %g4           ! hash index
-        sllx    %g4, 4, %g4
-        add     %g1, ZULU_HAT_TSB, %g5
-        ldx     [%g5], %g5
-        add     %g5, %g4, %g4           ! ptr to struct zulu_tte
-        ldx     [%g4], %g5              ! get the tag
-	
-	set     (0x3f << 13), %g6
-        andn    %g5, %g6, %g5
-        andn    %g2, %g6, %g6
-        cmp     %g5, %g6
-        bne,pn  %xcc, zulu_hat_tsb_try_64k
-          nop
- 
-        ldx     [%g4 + 8], %g4          ! flags and pfn
-        brgez,pn %g4, zulu_hat_tsb_try_64k ! check if entry is valid
-          nop
- 
-        sllx    %g4, 2, %g5
-        srlx    %g5, 61, %g5            ! tte size
-        cmp     %g5, ZULU_TTE512K 
-        be,pn   %xcc, zulu_hat_tsb_found
-          nop
-
-zulu_hat_tsb_try_64k:
-	add     %g1, ZULU_HAT_TSB_SZ, %g5
-        lduh    [%g5], %g5              ! tsb size
-        sub     %g5, 1, %g5
- 
-        srlx    %g2, 16, %g4           ! 4m page hash
-        and     %g5, %g4, %g4           ! hash index
-        sllx    %g4, 4, %g4
-        add     %g1, ZULU_HAT_TSB, %g5
-        ldx     [%g5], %g5
-        add     %g5, %g4, %g4           ! ptr to struct zulu_tte
-        ldx     [%g4], %g5              ! get the tag
-
-	set     (0x7 << 13), %g6
-        andn    %g5, %g6, %g5
-        andn    %g2, %g6, %g6
-        cmp     %g5, %g6
-        bne,pn  %xcc, zulu_hat_tsb_try_8k
-          nop
- 
-        ldx     [%g4 + 8], %g4          ! flags and pfn
-        brgez,pn %g4, zulu_hat_tsb_try_8k ! check if entry is valid
-          nop
- 
-        sllx    %g4, 2, %g5
-        srlx    %g5, 61, %g5            ! tte size
-        cmp     %g5, ZULU_TTE64K
-        be,pn   %xcc, zulu_hat_tsb_found
-          nop 
-
-zulu_hat_tsb_try_8k:
-	add     %g1, ZULU_HAT_TSB_SZ, %g5
-	lduh    [%g5], %g5              ! tsb size
-	sub     %g5, 1, %g5
-
-	srlx	%g2, 13, %g4		! calc hash
-	and	%g5, %g4, %g4		! hash index
-	sllx	%g4, 4, %g4
-	add	%g1, ZULU_HAT_TSB, %g5
-	ldx	[%g5], %g5		! tsb ptr
-	add	%g5, %g4, %g4		! ptr to struct tte
-	ldx	[%g4], %g5		! get the tag
-	cmp	%g5, %g2
-	bne,pn	%xcc, zulu_hat_tsb_exit
-	  mov	%g0, %g1
-
-	ldx	[%g4 + 8], %g4		! flags and pfn
-	brgez,pn %g4, zulu_hat_tsb_exit	! check if entry is valid
-	  mov   %g0, %g1
-
-	sllx    %g4, 2, %g5
-        srlx    %g5, 61, %g5            ! tte size
-	brnz,pn	%g5, zulu_hat_tsb_exit
-	  mov   %g0, %g1
-
-zulu_hat_tsb_found:
-	! expect the tte size in %g5
-	mulx	%g5, 3, %g5
-	mov	1, %g1
-	sllx	%g1, %g5, %g1
-	sub	%g1, 1, %g1
-	andn	%g4, %g1, %g4
-	srlx	%g2, 13, %g5
-	and	%g1, %g5, %g5
-	or	%g5, %g4, %g4
-	mov   	%g4, %g1
-
-	! now fall through to exit
-
-zulu_hat_tsb_exit:
-	! if bit zero of %g3 is set, we're at TL=1 and need to unlock
-	! the context here
-	andcc	%g3, 1, %g0
-	be,pn	%xcc, after_unlock
-	  nop
-
-	! clear the context unlock flag
-	andn	%g3, 1, %g3
-
-	set     ZULU_CTX_MASK, %g6
-	and     %g2, %g6, %g6           ! ctx num
-
-	sllx	%g6, 3, %g6
-	set	zulu_ctx_tab, %g5
-	add	%g6, %g5, %g5		! %g5 = &zulu_ctx_tab[ctx_num]
-	ldx	[%g5], %g6
-	andn	%g6, 1, %g6
-	stx	%g6, [%g5]
-
-after_unlock:
-
-	! set the status code to ZULUVM_NO_TTE in case we are running at TL=1
-	! and no tte was found.
-	!
-	! note: caller doesn't examine %g2 unless flags and pfn are null
-	jmpl    %g3 + 0x8, %g0
-	  mov  	ZULUVM_NO_TTE, %g2
-
-
-
-
-	SET_SIZE(zulu_hat_tsb_lookup_tl1)
-
-	/*
-	 * %o0 - zulu hat ptr (already locked)
-	 * %o1 - vaddr
-	 */
-	ENTRY_NP(zulu_hat_tsb_lookup_tl0)
-	mov	%o0, %g4
-
-	set	zulu_hat_tsb_lookup, %g3
-
-	! note bit zero of g3 is zero which tells zulu_hat_tsb_lookup
-	! to not unlock tsb before returning
-
-	jmpl	%g3, %g3
-	  mov	%o1, %g1
-
-	retl
-	  mov   %g1, %o0
-	SET_SIZE(zulu_hat_tsb_lookup_tl0)
-
-#endif	/* lint */
--- old/usr/src/uts/sun4u/serengeti/sys/sgfrutypes.h	2015-05-08 18:10:44.075705028 -0400
+++ new/usr/src/uts/sun4u/serengeti/sys/sgfrutypes.h	2015-05-08 18:10:44.082499685 -0400
@@ -73,12 +73,6 @@
 #define	SG_HPU_TYPE_WIB_BOARD_ID		"SB"
 #define	SG_HPU_TYPE_WIB_BOARD_SHORTNAME		"WIB"
 
-#define	SG_HPU_TYPE_ZULU_BOARD			(0x203)
-#define	SG_HPU_TYPE_ZULU_BOARD_STR		"Zulu Board"
-#define	SG_HPU_TYPE_ZULU_BOARD_ID		"SB"
-#define	SG_HPU_TYPE_ZULU_BOARD_SHORTNAME	"GPX"
-
-
 #define	SG_HPU_TYPE_REPEATER_BOARD			(0x301)
 #define	SG_HPU_TYPE_REPEATER_BOARD_STR			"Repeater Board"
 #define	SG_HPU_TYPE_REPEATER_BOARD_ID			"RP"
--- old/usr/src/uts/sun4u/sys/zulu_hat.h	2015-05-08 18:10:44.282254171 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,214 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	__ZULU_HAT_INCL__
-#define	__ZULU_HAT_INCL__
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#define	ZULU_TTE8K		0
-#define	ZULU_TTE64K		1
-#define	ZULU_TTE512K		2
-#define	ZULU_TTE4M		3
-#define	ZULUM_MAX_PG_SIZES	4
-
-#define	ZULU_CTX_MASK		0x1fff
-
-#ifndef _ASM
-
-#include <sys/types.h>
-#include <sys/atomic.h>
-#include <vm/xhat.h>
-#include <sys/avl.h>
-
-
-#define	ZULU_HAT_BP_SHIFT		13
-#define	ZULU_HAT_SZ_SHIFT(sz)		((sz) * 3)
-#define	ZULU_HAT_NUM_PGS(sz)		(1<<ZULU_HAT_SZ_SHIFT(sz))
-#define	ZULU_HAT_PGSHIFT(s)		(ZULU_HAT_BP_SHIFT + \
-					ZULU_HAT_SZ_SHIFT(s))
-#define	ZULU_HAT_PGSZ(s)		((uint64_t)1<<ZULU_HAT_PGSHIFT(s))
-#define	ZULU_HAT_PGOFFSET(s)		(ZULU_HAT_PGSZ(s) - 1)
-#define	ZULU_HAT_PGMASK(s)		(~ZULU_HAT_PGOFFSET((uint64_t)s))
-#define	ZULU_HAT_PGADDR(a, s)		((uintptr_t)(a) & ZULU_HAT_PGMASK(s))
-#define	ZULU_HAT_PGADDROFF(a, s)	((uintptr_t)(a) & ZULU_HAT_PGOFFSET(s))
-#define	ZULU_HAT_PGDIFF(a, s)		(ZULU_HAT_PGSZ(s) - \
-					ZULU_HAT_PGADDROFF(a, s))
-
-#define	ZULU_HAT_PFN_MASK(sz)		((1 << ZULU_HAT_SZ_SHIFT(sz)) - 1)
-#define	ZULU_HAT_ADJ_PFN(ttep, vaddr) \
-	((ttep->zulu_tte_pfn & ~ZULU_HAT_PFN_MASK(ttep->zulu_tte_size)) | \
-	(((uintptr_t)vaddr >> ZULU_HAT_BP_SHIFT) & \
-	ZULU_HAT_PFN_MASK(ttep->zulu_tte_size)))
-
-/*
- * zulu_ctx_tab is an array of pointers to zulu hat structures.
- * since the addresses are 8 byte aligned we use bit 0 as a lock flag.
- * This will synchronize TL1 access to the tsb and the mappings.
- */
-
-#define	ZULU_CTX_LOCK	0x1
-
-#define	ZULU_CTX_LOCK_INIT(c)		zulu_ctx_tab[c] = NULL
-#define	ZULU_CTX_IS_FREE(c)		(zulu_ctx_tab[c] == NULL)
-#define	ZULU_CTX_SET_HAT(c, h) 		zulu_ctx_tab[c] = h
-
-#define	ZULU_CTX_GET_HAT(c)	(struct zulu_hat *)((uint64_t) \
-				    zulu_ctx_tab[c] & ~ZULU_CTX_LOCK)
-
-struct zulu_tag {
-	uint64_t	zulu_tag_page:51;	/* [63:13] vpage */
-};
-
-struct zulu_tte {
-	union {
-		struct zulu_tag zulu_tte_tag;
-		uint64_t 	zulu_tte_addr;
-	} un;
-	uint_t	zulu_tte_valid  :1;
-	uint_t	zulu_tte_perm   :1;
-	uint_t	zulu_tte_size   :3;
-	uint_t	zulu_tte_locked :1;
-	uint_t	zulu_tte_pfn;
-};
-
-/*
- * zulu hat stores its list of translation in a hash table.
- * TODO: size this table. 256 buckets may be too small.
- */
-#define	ZULU_HASH_TBL_NUM  0x100
-#define	ZULU_HASH_TBL_MASK (ZULU_HASH_TBL_NUM - 1)
-#define	ZULU_HASH_TBL_SHIFT(_s) (ZULU_HAT_BP_SHIFT + (3 * _s))
-#define	ZULU_HASH_TBL_SZ  (ZULU_HASH_TBL_NUM * sizeof (struct zulu_hat_blk *))
-#define	ZULU_MAP_HASH_VAL(_v, _s) (((_v) >> ZULU_HASH_TBL_SHIFT(_s)) & \
-							ZULU_HASH_TBL_MASK)
-#define	ZULU_MAP_HASH_HEAD(_zh, _v, _s) \
-		(_zh->hash_tbl[ZULU_MAP_HASH_VAL(_v, _s)])
-
-/*
- *
- * TODO: need finalize the number of entries in the TSB
- * 32K tsb entries caused us to never get a tsb miss that didn't cause
- * a page fault.
- *
- * Reducing TSB_NUM to 512 entries caused tsb_miss > tsb_hit
- * in a yoyo run.
- */
-#define	ZULU_TSB_NUM		4096
-#define	ZULU_TSB_SZ		(ZULU_TSB_NUM * sizeof (struct zulu_tte))
-#define	ZULU_TSB_HASH(a, ts, s)	(((uintptr_t)(a) >> ZULU_HAT_PGSHIFT(ts)) & \
-					(s-1))
-
-#define	ZULU_VADDR(tag)		(tag & ~ZULU_CTX_MASK)
-#define	ZULU_TTE_TO_PAGE(a)	a.un.zulu_tte_tag.zulu_tag_page
-
-
-struct zulu_hat_blk {
-	struct zulu_hat_blk	*zulu_hash_next;
-	struct zulu_hat_blk	*zulu_hash_prev;
-	struct zulu_shadow_blk  *zulu_shadow_blk;
-	struct zulu_tte		zulu_hat_blk_tte;
-};
-
-#define	zulu_hat_blk_vaddr	zulu_hat_blk_tte.un.zulu_tte_addr
-#define	zulu_hat_blk_pfn	zulu_hat_blk_tte.zulu_tte_pfn
-#define	zulu_hat_blk_page	ZULU_TTE_TO_PAGE(zulu_hat_blk_tte)
-#define	zulu_hat_blk_perm	zulu_hat_blk_tte.zulu_tte_perm
-#define	zulu_hat_blk_size	zulu_hat_blk_tte.zulu_tte_size
-#define	zulu_hat_blk_valid	zulu_hat_blk_tte.zulu_tte_valid
-
-/*
- * for fast lookups by address, len we use an avl list to shadow occupied
- * 4Mb regions that have mappings.
- */
-#define	ZULU_SHADOW_BLK_RANGE 0x400000
-#define	ZULU_SHADOW_BLK_MASK (~(ZULU_SHADOW_BLK_RANGE - 1))
-
-struct zulu_shadow_blk {
-	avl_node_t	link;		/* must be at beginning of struct */
-	uint64_t	ivaddr;		/* base address of this node */
-	uint64_t	ref_count;
-	uint64_t	min_addr;
-	uint64_t	max_addr;
-};
-#define	ZULU_SHADOW_BLK_LINK_OFFSET (0)
-
-struct zulu_hat {
-	struct xhat		zulu_xhat;
-	kmutex_t		lock;
-	avl_tree_t		shadow_tree;
-	char			magic;	    /* =42 to mark our data for mdb */
-	unsigned		in_fault  : 1;
-	unsigned		freed	  : 1;
-	unsigned		map8k	  : 1;
-	unsigned		map64k	  : 1;
-	unsigned		map512k	  : 1;
-	unsigned		map4m	  : 1;
-	short			zulu_ctx;
-	unsigned short		zulu_tsb_size;	/* TODO why not a constant? */
-	struct zulu_hat_blk	**hash_tbl;
-	struct zulu_tte 	*zulu_tsb;
-	struct zulu_shadow_blk	*sblk_last;	/* last sblk looked up */
-	uint64_t		fault_ivaddr_last; /* last translation loaded */
-	caddr_t			vaddr_max;
-	hrtime_t		last_used;
-	void			*zdev;
-};
-
-#define	ZULU_HAT2AS(h)	((h)->zulu_xhat.xhat_as)
-
-/*
- * Assembly language function for TSB lookups
- */
-uint64_t zulu_hat_tsb_lookup_tl0(struct zulu_hat *zhat, caddr_t vaddr);
-
-/*
- * zuluvm's interface to zulu_hat
- */
-
-int zulu_hat_load(struct zulu_hat *zhat, caddr_t vaddr, enum seg_rw rw, int *);
-
-int zulu_hat_init();
-int zulu_hat_destroy();
-int zulu_hat_attach(void *arg);
-int zulu_hat_detach(void *arg);
-struct zulu_hat *zulu_hat_proc_attach(struct as *as, void *zdev);
-void zulu_hat_proc_detach(struct zulu_hat *zhat);
-
-void zulu_hat_validate_ctx(struct zulu_hat *zhat);
-void zulu_hat_terminate(struct zulu_hat *zhat);
-
-#endif /* _ASM */
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* __ZULU_HAT_INCL__ */
--- old/usr/src/uts/sun4u/sys/zulumod.h	2015-05-08 18:10:44.353498233 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,262 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_ZULUMOD_H
-#define	_ZULUMOD_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-#include <sys/int_const.h>
-#include <sys/zuluvm.h>
-
-#ifndef _ASM
-
-#include <sys/zulu_hat.h>
-#include <sys/sysmacros.h>
-
-#define	ZULUVM_VERSION_STR(a)	#a
-#define	ZULUVM_VERSION(a)	ZULUVM_VERSION_STR(a)
-#define	ZULUVM_MOD_VERSION \
-	ZULUVM_VERSION(XHAT_PROVIDER_VERSION) "." \
-	ZULUVM_VERSION(ZULUVM_INTERFACE_VERSION)
-
-#define	ZULUDCHKFUNC(_p1, _p2, _p3) \
-	((_p1) != NULL && (_p1)->_p2 != NULL) ? \
-	(_p1)->_p2 _p3 : ZULUVM_NO_SUPPORT
-#define	ZULUDCHKPROC(_p1, _p2, _p3) \
-	if ((_p1) != NULL && (_p1)->_p2 != NULL) (_p1)->_p2 _p3
-
-#define	zulud_set_itlb_pc(_devp, _a, _b) \
-	ZULUDCHKPROC((_devp)->dops, set_itlb_pc, (_a, _b))
-#define	zulud_set_dtlb_pc(_devp, _a, _b) \
-	ZULUDCHKPROC((_devp)->dops, set_dtlb_pc, (_a, _b))
-#define	zulud_write_tte(_devp, _a, _b, _c, _d, _e, _f) \
-	ZULUDCHKFUNC((_devp)->dops, write_tte, (_a, _b, _c, _d, _e, _f))
-#define	zulud_tlb_done(_devp, _a, _b, _c) \
-	ZULUDCHKPROC((_devp)->dops, tlb_done, (_a, _b, _c))
-#define	zulud_demap_page(_devp, _a, _b, _c) \
-	ZULUDCHKPROC((_devp)->dops, demap_page, (_a, _b, _c))
-#define	zulud_demap_ctx(_devp, _a, _b) \
-	ZULUDCHKPROC((_devp)->dops, demap_ctx, (_a, _b))
-
-#endif
-
-#define	ZULUVM_DATA0_IDX	0
-#define	ZULUVM_DATA1_IDX	1
-#define	ZULUVM_DATA2_IDX	2
-#define	ZULUVM_DATA3_IDX	3
-#define	ZULUVM_DATA4_IDX	4
-#define	ZULUVM_DATA5_IDX	5
-#define	ZULUVM_DATA6_IDX	6
-#define	ZULUVM_DATA7_IDX	7
-
-#define	ZULUVM_IDX2FLAG(i)	(1 << (7 - i))
-#define	ZULUVM_DATA0_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA0_IDX)
-#define	ZULUVM_DATA1_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA1_IDX)
-#define	ZULUVM_DATA2_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA2_IDX)
-#define	ZULUVM_DATA3_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA3_IDX)
-#define	ZULUVM_DATA4_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA4_IDX)
-#define	ZULUVM_DATA5_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA5_IDX)
-#define	ZULUVM_DATA6_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA6_IDX)
-#define	ZULUVM_DATA7_FLAG	ZULUVM_IDX2FLAG(ZULUVM_DATA7_IDX)
-
-#define	ZULUVM_TLB_ADDR_IDX	ZULUVM_DATA0_IDX
-#define	ZULUVM_TLB_TYPE_IDX	ZULUVM_DATA1_IDX
-#define	ZULUVM_TLB_TTE_IDX	ZULUVM_DATA2_IDX
-#define	ZULUVM_TLB_ERRCODE_IDX	ZULUVM_DATA3_IDX
-
-#define	ZULUVM_DATA_FLAGS	(ZULUVM_DATA1_FLAG | \
-				ZULUVM_DATA6_FLAG)
-
-#define	ZULUVM_GET_TLB_TTE(devp) \
-		(devp)->zvm.idata[ZULUVM_TLB_TTE_IDX]
-#define	ZULUVM_GET_TLB_ADDR(devp) \
-		(devp)->zvm.idata[ZULUVM_TLB_ADDR_IDX]
-#define	ZULUVM_GET_TLB_TYPE(devp) (ZULUVM_DMA_MASK & \
-		(devp)->zvm.idata[ZULUVM_TLB_TYPE_IDX])
-#define	ZULUVM_GET_TLB_ERRCODE(devp) (int)(0xffffffff & \
-		(devp)->zvm.idata[ZULUVM_TLB_ERRCODE_IDX])
-
-#define	ZULUVM_MAX_DEV		2
-#define	ZULUVM_PIL		PIL_2
-#define	ZULUVM_NUM_PGSZS	4
-
-#define	ZULUVM_STATE_IDLE		0
-#define	ZULUVM_STATE_STOPPED		1
-#define	ZULUVM_STATE_CANCELED		2
-#define	ZULUVM_STATE_TLB_PENDING	3
-#define	ZULUVM_STATE_INTR_QUEUED	4
-#define	ZULUVM_STATE_INTR_PENDING	5
-#define	ZULUVM_STATE_WRITE_TTE		6
-
-#ifndef _ASM
-
-typedef struct {
-	uint64_t	idata[4];	/* mondo pkt copy area */
-	void		*arg;		/* arg for device calls */
-	uint64_t	mmu_pa;		/* phy. addr of MMU regs */
-	struct zuluvm_proc *proc1;
-	struct zuluvm_proc *proc2;
-	volatile uint32_t state;	/* state of tlb miss handling */
-	uint64_t	intr_num;	/* our soft intr number */
-	short		dmv_intr;	/* dmv interrupt handle */
-#ifdef ZULUVM_STATS
-	int 		cancel;
-	int		tlb_miss[ZULUVM_NUM_PGSZS];
-	int		pagefault;
-	int		no_mapping;
-	int		preload;
-	int		migrate;
-	int		pagesize;
-	int		itlb1miss;
-	int		dtlb1miss;
-	int		itlb2miss;
-	int		dtlb2miss;
-	int		demap_page;
-	int		demap_ctx;
-#endif
-	uint64_t	pfnbuf[50];
-	int		pfncnt;
-} zuluvm_miss_t;
-
-#ifdef ZULUVM_STATS
-#define	ZULUVM_STATS_MISS(devp, sz)	(devp)->zvm.tlb_miss[sz]++
-#define	ZULUVM_STATS_PAGEFAULT(devp)	(devp)->zvm.pagefault++
-#define	ZULUVM_STATS_NOMAP(devp)	(devp)->zvm.no_mapping++
-#define	ZULUVM_STATS_PRELOAD(devp)	(devp)->zvm.preload++
-#define	ZULUVM_STATS_MIGRATE(devp)	(devp)->zvm.migrate++
-#define	ZULUVM_STATS_PAGEZISE(devp)	(devp)->zvm.pagesize++
-#define	ZULUVM_STATS_CANCEL(devp)	(devp)->zvm.cancel++
-#define	ZULUVM_STATS_DEMAP_PAGE(devp)	(devp)->zvm.demap_page++
-#define	ZULUVM_STATS_DEMAP_CTX(devp)	(devp)->zvm.demap_ctx++
-#else
-#define	ZULUVM_STATS_MISS(devp, sz)
-#define	ZULUVM_STATS_PAGEFAULT(devp)
-#define	ZULUVM_STATS_NOMAP(devp)
-#define	ZULUVM_STATS_PRELOAD(devp)
-#define	ZULUVM_STATS_MIGRATE(devp)
-#define	ZULUVM_STATS_PAGEZISE(devp)
-#define	ZULUVM_STATS_CANCEL(devp)
-#define	ZULUVM_STATS_DEMAP_PAGE(devp)
-#define	ZULUVM_STATS_DEMAP_CTX(devp)
-#endif
-
-#define	ZULUVM_MAX_INTR 32
-
-typedef struct {
-	short offset;
-	short ino;
-} zuluvm_intr_t;
-
-/*
- * This structure contains per device data.
- * It is protected by dev_lck.
- */
-typedef struct {
-	zuluvm_miss_t		zvm;		/* tlb miss state */
-	volatile uint64_t	*imr;		/* intr mapping regs */
-	struct zuluvm_proc 	*procs; 	/* protected by proc_lck */
-	dev_info_t		*dip;		/* device driver instance */
-	zulud_ops_t		*dops;		/* device drv operations */
-	kmutex_t		load_lck;	/* protects in_intr */
-	kmutex_t		dev_lck;	/* protects this struct */
-	kmutex_t 		proc_lck;	/* protects active procs */
-	kcondvar_t 		intr_wait;	/* sync for as_free */
-	int			intr_flags;
-	int			in_intr;
-	kmutex_t		park_lck;	/* page fault thread */
-	kcondvar_t		park_cv;
-	int			parking;
-	int			agentid;	/* zulu's agent id */
-	zuluvm_intr_t		interrupts[ZULUVM_MAX_INTR];
-} zuluvm_state_t;
-
-#define	ZULUVM_INTR_OFFSET	offsetof(zuluvm_state_t, interrupts)
-#define	ZULUVM_INTR2INO(addr)	(((zuluvm_intr_t *)(addr))->ino)
-#define	ZULUVM_INTR2ZDEV(addr) \
-	(zuluvm_state_t *)((caddr_t)addr - (ZULUVM_INTR2INO(addr) * \
-	sizeof (zuluvm_intr_t)) - ZULUVM_INTR_OFFSET)
-
-typedef struct zuluvm_proc {
-	struct zulu_hat	*zhat;
-	zuluvm_state_t  *zdev;  /* back ptr to dev instance */
-	unsigned short	refcnt;	/* keep this until ref == 0 */
-	short		valid;	/* if valid is 0 then don't use */
-	struct zuluvm_proc *next;
-	struct zuluvm_proc *prev;
-} zuluvm_proc_t;
-
-#define	ZULUVM_DO_INTR1		INT32_C(1)
-#define	ZULUVM_WAIT_INTR1	INT32_C(2)
-#define	ZULUVM_DO_INTR2		INT32_C(4)
-#define	ZULUVM_WAIT_INTR2	INT32_C(8)
-
-int zuluvm_change_state(uint32_t *state_pa, int new, int assume);
-void zuluvm_demap_page(void *, struct hat *, short, caddr_t, uint_t);
-void zuluvm_demap_ctx(void *, short);
-void zuluvm_dmv_tlbmiss_tl1(void);
-void zuluvm_load_tte(struct zulu_hat *zhat, caddr_t addr, uint64_t pfn,
-		int perm, int size);
-
-
-#endif
-
-/*
- * The following defines are copied from the ZFB and ZULU
- * workspaces. We re-define them here since we can't have
- * a dependency onto files outside our consolidation
- */
-#define	ZULUVM_IMR_V_MASK	UINT64_C(0x0000000080000000)
-#define	ZULUVM_IMR_TARGET_SHIFT INT32_C(26)
-#define	ZULUVM_IMR_MAX		INT32_C(0x3f)
-
-#define	ZULUVM_ZFB_MMU_TLB_D_V_MASK	  0x8000000000000000
-#define	ZULUVM_ZFB_MMU_TLB_D_PA_SHIFT	  0xD	/* 13 bits */
-#define	ZULUVM_ZFB_MMU_TLB_D_C_MASK	  0x20
-#define	ZULUVM_ZFB_MMU_TLB_D_SZ_SHIFT	  0x3D	/* 61 */
-#define	ZULUVM_ZFB_MMU_TLB_D_SZ_MASK	  0x6000000000000000
-#define	ZULUVM_ZFB_MMU_TLB_D_W_MASK	  0x2
-#define	ZULUVM_ZFB_MMU_TLB_CR_IMISS_MASK  0x2
-#define	ZULUVM_ZFB_MMU_TLB_CR_DMISS_MASK  0x1
-#define	ZULUVM_ZFB_MMU_DTLB_PAGE_SZ_2_MASK  0xc /* DTLB2 Page size */
-#define	ZULUVM_ZFB_MMU_DTLB_PAGE_SZ_2_SHIFT 2
-#define	ZULUVM_DTLB_PAGE_SZ	0x8
-#define	ZULUVM_ITLB_DATA_IN	0x18
-#define	ZULUVM_DTLB_DATA_IN	0x28
-#define	ZULUVM_TLB_CONTROL	0
-#define	ZULUVM_ITLB_MISS_ICR	0x0
-#define	ZULUVM_DTLB_MISS_ICR	0x8
-#define	ZULUVM_DMA1_TSB_BASE	0x50
-#define	ZULUVM_DMA2_TSB_BASE	0x68
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _ZULUMOD_H */
--- old/usr/src/uts/sun4u/sys/zuluvm.h	2015-05-08 18:10:44.425059234 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,121 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	__ZULUVM_INCL__
-#define	__ZULUVM_INCL__
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-/* zulud interface */
-
-#ifndef _ASM
-
-#include <sys/dditypes.h>
-
-typedef struct {
-	caddr_t	addr;
-	size_t  len;
-	int	tlbtype;
-} zulud_preload_t;
-
-typedef struct {
-	int version;
-	int (*set_itlb_pc)(void *handle, uint64_t mondo);
-	int (*set_dtlb_pc)(void *handle, uint64_t mondo);
-	int (*set_suspendAck_pc)(void *handle, uint64_t mondo);
-	int (*write_tte)(void *handle, int ttesize, uint64_t tag,
-	    pfn_t pfn, int permission, int tlbtype);
-	int (*tlb_done)(void *handle, int tlbtype, int status);
-	int (*demap_page)(void *handle, caddr_t vaddr, short ctx);
-	int (*demap_ctx)(void *handle, short ctx);
-	int (*dma_suspend_ack)(void *handle);
-	int (*set_tsb)(void *handle, int tlbtype, uint64_t tsbreg);
-} zulud_ops_t;
-
-#endif
-
-#define	ZULUVM_SUCCESS		0
-#define	ZULUVM_ERROR		1
-#define	ZULUVM_NO_TTE		2
-#define	ZULUVM_INVALID_MISS	3
-#define	ZULUVM_NO_DEV		4
-#define	ZULUVM_NO_HAT		5
-#define	ZULUVM_NO_MAP		6
-#define	ZULUVM_VERSION_MISMATCH	7
-#define	ZULUVM_TTE_DELAY	8
-#define	ZULUVM_MISS_CANCELED	9
-#define	ZULUVM_BAD_IDX		10
-#define	ZULUVM_WATCH_POINT	11
-#define	ZULUVM_NO_SUPPORT	12
-#define	ZULUVM_CTX_LOCKED	13
-
-#define	ZULUVM_ITLB_FLAG	0x1
-#define	ZULUVM_DMA_FLAG		0x2
-#define	ZULUVM_DMA_MASK		0x3
-
-#define	ZULUVM_DMA1	0
-#define	ZULUVM_DMA2	ZULUVM_DMA_FLAG
-#define	ZULUVM_ITLB1	ZULUVM_ITLB_FLAG
-#define	ZULUVM_ITLB2	(ZULUVM_ITLB_FLAG | ZULUVM_DMA_FLAG)
-#define	ZULUVM_INVAL	0x4
-
-#ifndef _ASM
-
-/* zuluvm interface */
-
-#define	ZULUVM_INTERFACE_VERSION	1 /* inc with every intf change */
-
-typedef void * zuluvm_info_t;
-int zuluvm_init(zulud_ops_t *ops, int **pagesizes);
-int zuluvm_fini(void);
-int zuluvm_alloc_device(dev_info_t *devi, void *arg, zuluvm_info_t *devp,
-    caddr_t mmu, caddr_t imr);
-int zuluvm_free_device(zuluvm_info_t devp);
-int zuluvm_dma_add_proc(zuluvm_info_t devp, uint64_t *cookie);
-int zuluvm_dma_delete_proc(zuluvm_info_t devp, uint64_t cookie);
-int zuluvm_dma_alloc_ctx(zuluvm_info_t devp, int dma, short *ctx,
-    uint64_t *tsb);
-int zuluvm_dma_preload(zuluvm_info_t devp, int dma, int num,
-    zulud_preload_t *list);
-int zuluvm_dma_free_ctx(zuluvm_info_t devp, int dma);
-int zuluvm_add_intr(zuluvm_info_t devp, int ino, uint_t (*handler)(caddr_t),
-    caddr_t arg);
-int zuluvm_rem_intr(zuluvm_info_t devp, int ino);
-int zuluvm_enable_intr(zuluvm_info_t devp, int num);
-int zuluvm_disable_intr(zuluvm_info_t devp, int num);
-int zuluvm_park(zuluvm_info_t devp);
-
-#endif
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* __ZULUVM_INCL__ */
--- old/usr/src/uts/sun4u/vm/mach_kpm.c	2015-05-08 18:10:44.496648660 -0400
+++ new/usr/src/uts/sun4u/vm/mach_kpm.c	2015-05-08 18:10:44.503468871 -0400
@@ -1684,8 +1684,6 @@
 		if (IS_PAHME(sfhmep))
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhmep);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 		tmphat = hblktosfmmu(hmeblkp);
 		sfmmu_copytte(&sfhmep->hme_tte, &tte);
 		ASSERT(TTE_IS_VALID(&tte));
@@ -1709,8 +1707,6 @@
 		if (IS_PAHME(sfhmep))
 			continue;
 		hmeblkp = sfmmu_hmetohblk(sfhmep);
-		if (hmeblkp->hblk_xhat_bit)
-			continue;
 		(void) sfmmu_pageunload(pp, sfhmep, TTE8K);
 	}
 
--- old/usr/src/uts/sun4u/vm/zulu_hat.c	2015-05-08 18:10:44.756694088 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,1469 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/mman.h>
-#include <sys/sunddi.h>
-#include <sys/tnf_probe.h>
-#include <vm/hat_sfmmu.h>
-#include <vm/as.h>
-#include <vm/xhat.h>
-#include <vm/xhat_sfmmu.h>
-#include <sys/zulu_hat.h>
-#include <sys/zulumod.h>
-
-/*
- * This file contains the implementation of zulu_hat: an XHAT provider
- * to support the MMU for the XVR-4000 graphics accelerator (code name zulu).
- *
- * The zulu hat is linked into the kernel misc module zuluvm.
- * zuluvm provides services that the zulu device driver module requires
- * that are not part of the standard ddi. See PSARC 2002/231.
- *
- * The zulu driver is delivered by the graphics consolidation.
- * zuluvm is in ON workspace.
- *
- * There are two types of interfaces provided by zulu_hat
- *   1.	The set of functions and data structures used by zuluvm to obtain
- * 	tte entries for the zulu MMU and to manage the association between
- *	user process's address spaces and zulu graphics contexts.
- *
- *   2.	The entry points required for an XHAT provider: zulu_hat_ops
- */
-
-/*
- * zulu_ctx_tab contains an array of pointers to the zulu_hats.
- *
- * During zulu graphics context switch, the zulu MMU's current context register
- * is set to the index of the process's zulu hat's location in the array
- * zulu_ctx_tab.
- *
- * This allows the TL=1 TLB miss handler to quickly find the zulu hat and
- * lookup a tte in the zulu hat's TSB.
- *
- * To synchronize with the trap handler we use bit zero of
- * the pointer as a lock bit. See the function zulu_ctx_tsb_lock_enter().
- *
- * If the trap handler finds the ctx locked it doesn't wait, it
- * posts a soft interrupt which is handled at TL=0.
- */
-
-#define		ZULU_HAT_MAX_CTX 32
-struct zulu_hat *zulu_ctx_tab[ZULU_HAT_MAX_CTX];
-
-/*
- * To avoid searching through the whole zulu_ctx_tab for a free slot,
- * we maintain the value of zulu_ctx_search_start.
- *
- * This value is a guess as to where a free slot in the context table might be.
- * All slots < zulu_ctx_search_start are definitely occupied.
- */
-static int zulu_ctx_search_start = 0;
-
-
-/*
- * this mutex protects the zulu_ctx_tab and zulu_ctx_search_start
- */
-static kmutex_t	zulu_ctx_lock;
-
-
-uint64_t	zulu_tsb_hit = 0;	/* assembly code increments this */
-static uint64_t	zulu_tsb_miss = 0;
-static uint64_t	zulu_as_fault = 0;
-
-/*
- * The zulu device has two zulu data mmus.
- * We use the base pagesize for one of them and the and 4M for the other.
- */
-extern int zuluvm_base_pgsize;
-
-
-
-/*
- * call zuluvm to remove translations for a page
- */
-static void
-zulu_hat_demap_page(struct zulu_hat *zhat, caddr_t vaddr, int size)
-{
-	if (zhat->zulu_ctx < 0) {
-		/* context has been stolen, so page is already demapped */
-		return;
-	}
-	zuluvm_demap_page(zhat->zdev, NULL, zhat->zulu_ctx, vaddr, size);
-}
-
-static void
-zulu_hat_demap_ctx(void *zdev, int zulu_ctx)
-{
-	if (zulu_ctx < 0) {
-		/* context has been stolen */
-		return;
-	}
-	zuluvm_demap_ctx(zdev, zulu_ctx);
-}
-
-
-/*
- * steal the least recently used context slot.
- */
-static int
-zulu_hat_steal_ctx()
-{
-	int		ctx;
-	hrtime_t	delta = INT64_MAX;
-	struct zulu_hat *zhat_oldest = NULL;
-
-	ASSERT(mutex_owned(&zulu_ctx_lock));
-
-	for (ctx = 0; ctx < ZULU_HAT_MAX_CTX; ctx++) {
-		struct zulu_hat *zhat = ZULU_CTX_GET_HAT(ctx);
-
-		/*
-		 * we shouldn't be here unless all slots are occupied
-		 */
-		ASSERT(zhat != NULL);
-
-		TNF_PROBE_3(steal_ctx_loop, "zulu_hat", /* CSTYLED */,
-		    tnf_int, ctx, ctx,
-		    tnf_long, last_used, zhat->last_used,
-		    tnf_long, oldest, delta);
-
-		if (zhat->last_used <  delta) {
-			zhat_oldest = zhat;
-			delta  = zhat->last_used;
-		}
-	}
-
-	ASSERT(zhat_oldest != NULL);
-
-	mutex_enter(&zhat_oldest->lock);
-
-	/* Nobody should have the tsb lock bit set here */
-	ASSERT(((uint64_t)zulu_ctx_tab[zhat_oldest->zulu_ctx] & ZULU_CTX_LOCK)
-	    == 0);
-
-	ctx = zhat_oldest->zulu_ctx;
-	zhat_oldest->zulu_ctx = -1;
-
-	ZULU_CTX_SET_HAT(ctx, NULL);
-
-	zulu_hat_demap_ctx(zhat_oldest->zdev, ctx);
-
-	mutex_exit(&zhat_oldest->lock);
-
-	TNF_PROBE_1(zulu_hat_steal_ctx, "zulu_hat", /* CSTYLED */,
-		tnf_int, ctx, ctx);
-
-	return (ctx);
-}
-
-/*
- * find a slot in the context table for a zulu_hat
- */
-static void
-zulu_hat_ctx_alloc(struct zulu_hat *zhat)
-{
-	int 		ctx;
-
-	mutex_enter(&zulu_ctx_lock);
-
-	for (ctx = zulu_ctx_search_start; ctx < ZULU_HAT_MAX_CTX; ctx++) {
-		if (ZULU_CTX_IS_FREE(ctx)) {
-			zulu_ctx_search_start = ctx + 1;
-			break;
-		}
-	}
-
-	if (ctx == ZULU_HAT_MAX_CTX) {
-		/* table is full need to steal an entry */
-		zulu_ctx_search_start = ZULU_HAT_MAX_CTX;
-		ctx = zulu_hat_steal_ctx();
-	}
-
-	mutex_enter(&zhat->lock);
-
-	ZULU_CTX_SET_HAT(ctx, zhat);
-	zhat->zulu_ctx = ctx;
-
-	mutex_exit(&zhat->lock);
-
-	mutex_exit(&zulu_ctx_lock);
-
-	TNF_PROBE_2(zulu_hat_ctx_alloc, "zulu_hat", /* CSTYLED */,
-		tnf_opaque, zhat, zhat, tnf_int, ctx, ctx);
-}
-
-/*
- * zulu_hat_validate_ctx: Called before the graphics context associated
- * with a given zulu hat becomes the current zulu graphics context.
- * Make sure that the hat has a slot in zulu_ctx_tab.
- */
-void
-zulu_hat_validate_ctx(struct zulu_hat *zhat)
-{
-	if (zhat->zulu_ctx < 0)  {
-		zulu_hat_ctx_alloc(zhat);
-	}
-	zhat->last_used = gethrtime();
-}
-
-
-static void
-zulu_hat_ctx_free(struct zulu_hat *zhat)
-{
-	TNF_PROBE_1(zulu_hat_ctx_free, "zulu_hat", /* CSTYLED */,
-		tnf_int, ctx, zhat->zulu_ctx);
-
-	mutex_enter(&zulu_ctx_lock);
-
-	mutex_enter(&zhat->lock);
-	if (zhat->zulu_ctx >= 0) {
-		ZULU_CTX_SET_HAT(zhat->zulu_ctx, NULL);
-
-		if (zulu_ctx_search_start > zhat->zulu_ctx) {
-			zulu_ctx_search_start = zhat->zulu_ctx;
-		}
-	}
-	mutex_exit(&zhat->lock);
-	mutex_exit(&zulu_ctx_lock);
-}
-
-/*
- * Lock the zulu tsb for a given zulu_hat.
- *
- * We're just protecting against the TLB trap handler here. Other operations
- * on the zulu_hat require entering the zhat's lock.
- */
-static void
-zulu_ctx_tsb_lock_enter(struct zulu_hat *zhat)
-{
-	uint64_t	lck;
-	uint64_t    	*plck;
-
-	ASSERT(mutex_owned(&zhat->lock));
-
-	if (zhat->zulu_ctx < 0) {
-		return;
-	}
-	plck = (uint64_t *)&zulu_ctx_tab[zhat->zulu_ctx];
-
-	for (; ; ) {
-		lck = *plck;
-		if (!(lck & ZULU_CTX_LOCK)) {
-			uint64_t old_lck, new_lck;
-
-			new_lck = lck | ZULU_CTX_LOCK;
-
-			old_lck = atomic_cas_64(plck, lck, new_lck);
-
-			if (old_lck == lck) {
-				/*
-				 * success
-				 */
-				break;
-			}
-		}
-	}
-}
-
-static void
-zulu_ctx_tsb_lock_exit(struct zulu_hat *zhat)
-{
-	uint64_t	lck;
-	int		zulu_ctx = zhat->zulu_ctx;
-
-	if (zulu_ctx < 0) {
-		return;
-	}
-	lck = (uint64_t)zulu_ctx_tab[zulu_ctx];
-	ASSERT(lck & ZULU_CTX_LOCK);
-	lck &= ~ZULU_CTX_LOCK;
-	zulu_ctx_tab[zulu_ctx] = (struct zulu_hat *)lck;
-}
-
-/*
- * Each zulu hat has a "shadow tree" which is a table of 4MB address regions
- * for which the zhat has mappings.
- *
- * This table is maintained in an avl tree.
- * Nodes in the tree are called shadow blocks (or sblks)
- *
- * This data structure allows unload operations by (address, range) to be
- * much more efficent.
- *
- * We get called a lot for address ranges that have never been supplied
- * to zulu.
- */
-
-/*
- * compare the base address of two nodes in the shadow tree
- */
-static int
-zulu_shadow_tree_compare(const void *a, const void *b)
-{
-	struct zulu_shadow_blk *zba = (struct zulu_shadow_blk *)a;
-	struct zulu_shadow_blk *zbb = (struct zulu_shadow_blk *)b;
-	uint64_t		addr_a = zba->ivaddr;
-	uint64_t		addr_b = zbb->ivaddr;
-
-	TNF_PROBE_2(zulu_shadow_tree_compare, "zulu_shadow_tree", /* CSTYLED */,
-		tnf_opaque, addr_a, addr_a, tnf_opaque, addr_b, addr_b);
-
-	if (addr_a < addr_b) {
-		return (-1);
-	} else if (addr_a > addr_b) {
-		return (1);
-	} else {
-		return (0);
-	}
-}
-
-/*
- * lookup the entry in the shadow tree for a given virtual address
- */
-static struct zulu_shadow_blk *
-zulu_shadow_tree_lookup(struct zulu_hat *zhat, uint64_t ivaddr,
-	avl_index_t *where)
-{
-	struct zulu_shadow_blk proto;
-	struct zulu_shadow_blk *sblk;
-
-	proto.ivaddr = ivaddr & ZULU_SHADOW_BLK_MASK;
-
-	/*
-	 * pages typically fault in in order so we cache the last shadow
-	 * block that was referenced so we usually get to reduce calls to
-	 * avl_find.
-	 */
-	if ((zhat->sblk_last != NULL) &&
-	    (proto.ivaddr == zhat->sblk_last->ivaddr)) {
-		sblk = zhat->sblk_last;
-	} else {
-		sblk = (struct zulu_shadow_blk *)avl_find(&zhat->shadow_tree,
-		    &proto, where);
-		zhat->sblk_last = sblk;
-	}
-
-	TNF_PROBE_2(zulu_shadow_tree_lookup, "zulu_shadow_tree", /* CSTYLED */,
-	    tnf_opaque, ivaddr, proto.ivaddr,
-	    tnf_opaque, where, where ? *where : ~0);
-
-	return (sblk);
-}
-
-/*
- * insert a sblk into the shadow tree for a given zblk.
- * If a sblk already exists, just increment it's refcount.
- */
-static void
-zulu_shadow_tree_insert(struct zulu_hat *zhat, struct zulu_hat_blk *zblk)
-{
-	avl_index_t		where;
-	struct zulu_shadow_blk 	*sblk  = NULL;
-	uint64_t		ivaddr;
-	uint64_t		end;
-
-	ivaddr = zblk->zulu_hat_blk_vaddr & ZULU_SHADOW_BLK_MASK;
-
-	end = zblk->zulu_hat_blk_vaddr + ZULU_HAT_PGSZ(zblk->zulu_hat_blk_size);
-
-	sblk = zulu_shadow_tree_lookup(zhat, ivaddr, &where);
-	if (sblk != NULL) {
-		sblk->ref_count++;
-
-		end = zblk->zulu_hat_blk_vaddr +
-		    ZULU_HAT_PGSZ(zblk->zulu_hat_blk_size);
-		if (zblk->zulu_hat_blk_vaddr < sblk->min_addr) {
-			sblk->min_addr = zblk->zulu_hat_blk_vaddr;
-		}
-		/*
-		 * a blk can set both the minimum and maximum when it
-		 * is the first zblk added to a previously emptied sblk
-		 */
-		if (end > sblk->max_addr) {
-			sblk->max_addr = end;
-		}
-	} else {
-		sblk = kmem_zalloc(sizeof (*sblk), KM_SLEEP);
-		sblk->ref_count = 1;
-		sblk->ivaddr = ivaddr;
-		sblk->min_addr = zblk->zulu_hat_blk_vaddr;
-		sblk->max_addr = end;
-		zhat->sblk_last = sblk;
-
-		avl_insert(&zhat->shadow_tree, sblk, where);
-	}
-	zblk->zulu_shadow_blk = sblk;
-	TNF_PROBE_2(zulu_shadow_tree_insert, "zulu_shadow_tree", /* CSTYLED */,
-	    tnf_opaque, vaddr, ivaddr,
-	    tnf_opaque, ref_count, sblk->ref_count);
-}
-
-/*
- * decrement the ref_count for the sblk that corresponds to a given zblk.
- * When the ref_count goes to zero remove the sblk from the tree and free it.
- */
-
-static void
-zulu_shadow_tree_delete(struct zulu_hat *zhat, struct zulu_hat_blk *zblk)
-{
-	struct zulu_shadow_blk 	*sblk;
-
-	ASSERT(zblk->zulu_shadow_blk != NULL);
-
-	sblk = zblk->zulu_shadow_blk;
-
-	TNF_PROBE_2(zulu_shadow_tree_delete, "zulu_shadow_tree", /* CSTYLED */,
-	    tnf_opaque, vaddr, sblk->ivaddr,
-	    tnf_opaque, ref_count, sblk->ref_count-1);
-
-	if (--sblk->ref_count == 0) {
-		if (zhat->sblk_last == sblk) {
-			zhat->sblk_last = NULL;
-		}
-		sblk->min_addr = sblk->ivaddr + ZULU_SHADOW_BLK_RANGE;
-		sblk->max_addr = sblk->ivaddr;
-	} else {
-		/*
-		 * Update the high and low water marks for this sblk.
-		 * These are estimates, because we don't know if the previous
-		 * or next region are actually occupied, but we can tell
-		 * whether the previous values have become invalid.
-		 *
-		 * In the most often applied case a segment is being
-		 * unloaded, and the min_addr will be kept up to date as
-		 * the zblks are deleted in order.
-		 */
-		uint64_t end = zblk->zulu_hat_blk_vaddr +
-		    ZULU_HAT_PGSZ(zblk->zulu_hat_blk_size);
-
-		if (zblk->zulu_hat_blk_vaddr == sblk->min_addr) {
-			sblk->min_addr = end;
-		}
-		if (end == sblk->max_addr) {
-			sblk->max_addr = zblk->zulu_hat_blk_vaddr;
-		}
-	}
-
-	zblk->zulu_shadow_blk = NULL;
-}
-
-static void
-zulu_shadow_tree_destroy(struct zulu_hat *zhat)
-{
-	struct zulu_shadow_blk *sblk;
-	void	*cookie = NULL;
-
-	while ((sblk = (struct zulu_shadow_blk *)avl_destroy_nodes(
-	    &zhat->shadow_tree, &cookie)) != NULL) {
-		TNF_PROBE_2(shadow_tree_destroy, "zulu_hat", /* CSTYLED */,
-		    tnf_opaque, vaddr, sblk->ivaddr,
-		    tnf_opaque, ref_count, sblk->ref_count);
-		kmem_free(sblk, sizeof (*sblk));
-	}
-	avl_destroy(&zhat->shadow_tree);
-}
-
-/*
- * zulu_hat_insert_map:
- *
- * Add a zulu_hat_blk to the a zhat's mappings list.
- *
- * Several data stuctures are used
- *	tsb: for simple fast lookups by the trap handler
- *	hash table: for efficent lookups by address, range
- *	An shadow tree of 4MB ranges with mappings for unloading big regions.
- */
-static void
-zulu_hat_insert_map(struct zulu_hat *zhat, struct zulu_hat_blk *zblk)
-{
-	int tsb_hash;
-
-	tsb_hash = ZULU_TSB_HASH(zblk->zulu_hat_blk_vaddr,
-	    zblk->zulu_hat_blk_size, zhat->zulu_tsb_size);
-
-	TNF_PROBE_3(zulu_hat_insert_map, "zulu_hat", /* CSTYLED */,
-	    tnf_opaque, zblkp, zblk,
-	    tnf_opaque, vaddr, zblk->zulu_hat_blk_vaddr,
-	    tnf_opaque, hash, tsb_hash);
-
-	ASSERT(tsb_hash < zhat->zulu_tsb_size);
-
-	zulu_shadow_tree_insert(zhat, zblk);
-
-	/*
-	 * The hash table is an array of buckets. Each bucket is the
-	 * head of a linked list of mappings who's address hashess to the bucket
-	 * New entries go to the head of the list.
-	 */
-	zblk->zulu_hash_prev = NULL;
-	zblk->zulu_hash_next = ZULU_MAP_HASH_HEAD(zhat,
-	    zblk->zulu_hat_blk_vaddr, zblk->zulu_hat_blk_size);
-	if (zblk->zulu_hash_next) {
-		zblk->zulu_hash_next->zulu_hash_prev = zblk;
-	}
-	ZULU_MAP_HASH_HEAD(zhat, zblk->zulu_hat_blk_vaddr,
-	    zblk->zulu_hat_blk_size) = zblk;
-
-	zulu_ctx_tsb_lock_enter(zhat);
-	zhat->zulu_tsb[tsb_hash] = zblk->zulu_hat_blk_tte;
-	zulu_ctx_tsb_lock_exit(zhat);
-}
-
-/*
- * remove a block from a zhat
- */
-static void
-zulu_hat_remove_map(struct zulu_hat *zhat, struct zulu_hat_blk *zblk)
-{
-	int tsb_hash = ZULU_TSB_HASH(zblk->zulu_hat_blk_vaddr,
-	    zblk->zulu_hat_blk_size, zhat->zulu_tsb_size);
-
-	TNF_PROBE_2(zulu_hat_remove_map, "zulu_hat", /* CSTYLED */,
-	    tnf_opaque, vaddr, zblk->zulu_hat_blk_vaddr,
-	    tnf_opaque, hash, tsb_hash);
-
-	ASSERT(tsb_hash < zhat->zulu_tsb_size);
-	ASSERT(mutex_owned(&zhat->lock));
-
-	zulu_shadow_tree_delete(zhat, zblk);
-
-	/*
-	 * first remove zblk from hash table
-	 */
-	if (zblk->zulu_hash_prev) {
-		zblk->zulu_hash_prev->zulu_hash_next = zblk->zulu_hash_next;
-	} else {
-		ZULU_MAP_HASH_HEAD(zhat, zblk->zulu_hat_blk_vaddr,
-		    zblk->zulu_hat_blk_size) = NULL;
-	}
-	if (zblk->zulu_hash_next) {
-		zblk->zulu_hash_next->zulu_hash_prev = zblk->zulu_hash_prev;
-	}
-	zblk->zulu_hash_next = NULL;
-	zblk->zulu_hash_prev = NULL;
-
-	/*
-	 * then remove the tsb entry
-	 */
-	zulu_ctx_tsb_lock_enter(zhat);
-	if (zhat->zulu_tsb[tsb_hash].un.zulu_tte_addr ==
-	    zblk->zulu_hat_blk_vaddr) {
-		zhat->zulu_tsb[tsb_hash].zulu_tte_valid = 0;
-	}
-	zulu_ctx_tsb_lock_exit(zhat);
-}
-
-/*
- * look for a mapping to a given vaddr and page size
- */
-static struct zulu_hat_blk *
-zulu_lookup_map_bysize(struct zulu_hat *zhat, caddr_t vaddr, int page_sz)
-{
-	struct  	zulu_hat_blk *zblkp;
-	uint64_t	ivaddr = (uint64_t)vaddr;
-	int		blks_checked = 0;
-
-	ASSERT(mutex_owned(&zhat->lock));
-
-	for (zblkp = ZULU_MAP_HASH_HEAD(zhat, ivaddr, page_sz); zblkp != NULL;
-	    zblkp = zblkp->zulu_hash_next) {
-		uint64_t	size;
-		uint64_t	iaddr;
-
-		blks_checked++;
-
-		size = ZULU_HAT_PGSZ(zblkp->zulu_hat_blk_size);
-		iaddr = ZULU_VADDR((uint64_t)zblkp->zulu_hat_blk_vaddr);
-
-		if (iaddr <= ivaddr && (iaddr + size) > ivaddr) {
-			int tsb_hash;
-
-			tsb_hash = ZULU_TSB_HASH(zblkp->zulu_hat_blk_vaddr,
-			    zblkp->zulu_hat_blk_size,
-			    zhat->zulu_tsb_size);
-			ASSERT(tsb_hash < zhat->zulu_tsb_size);
-
-			zulu_ctx_tsb_lock_enter(zhat);
-			zhat->zulu_tsb[tsb_hash] = zblkp->zulu_hat_blk_tte;
-			zulu_ctx_tsb_lock_exit(zhat);
-			break;
-		}
-
-	}
-
-	TNF_PROBE_3(zulu_hat_lookup_map_bysz, "zulu_hat", /* CSTYLED */,
-	    tnf_opaque, zblkp, zblkp,
-	    tnf_int, blks_checked, blks_checked,
-	    tnf_int, page_sz, page_sz);
-
-	return (zblkp);
-}
-
-/*
- * Lookup a zblk for a given virtual address.
- */
-static struct zulu_hat_blk *
-zulu_lookup_map(struct zulu_hat *zhat, caddr_t vaddr)
-{
-	struct  	zulu_hat_blk *zblkp = NULL;
-
-	/*
-	 * if the hat is using 4M pages, look first for a 4M page
-	 */
-	if (zhat->map4m) {
-		zblkp = zulu_lookup_map_bysize(zhat, vaddr, ZULU_TTE4M);
-		if (zblkp != NULL) {
-			return (zblkp);
-		}
-	}
-	/*
-	 * Otherwise look for a 8k page
-	 * Note: if base pagesize gets increased to 64K remove this test
-	 */
-	if (zhat->map8k) {
-		zblkp = zulu_lookup_map_bysize(zhat, vaddr, ZULU_TTE8K);
-		if (zblkp != NULL) {
-			return (zblkp);
-		}
-	}
-	/*
-	 * only if the page isn't found in the sizes that match the zulu mmus
-	 * look for the inefficient 64K or 512K page sizes
-	 */
-	if (zhat->map64k) {
-		zblkp = zulu_lookup_map_bysize(zhat, vaddr, ZULU_TTE64K);
-		if (zblkp != NULL) {
-			return (zblkp);
-		}
-	}
-	if (zhat->map512k) {
-		zblkp = zulu_lookup_map_bysize(zhat, vaddr, ZULU_TTE512K);
-	}
-
-	return (zblkp);
-}
-
-/*
- * zulu_hat_load: Load translation for given vaddr
- */
-int
-zulu_hat_load(struct zulu_hat *zhat, caddr_t vaddr,
-		enum seg_rw rw, int *ppg_size)
-{
-	faultcode_t 		as_err;
-	struct zulu_hat_blk 	*zblkp;
-	int			rval;
-	uint64_t 		flags_pfn;
-	struct zulu_tte		tte;
-
-	TNF_PROBE_2(zulu_hat_load, "zulu_hat", /* CSTYLED */,
-	    tnf_int, zulu_ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, vaddr);
-
-	mutex_enter(&zhat->lock);
-	ASSERT(zhat->zulu_ctx >= 0);
-	/*
-	 * lookup in our tsb first
-	 */
-	zulu_ctx_tsb_lock_enter(zhat);
-	flags_pfn = zulu_hat_tsb_lookup_tl0(zhat, vaddr);
-	zulu_ctx_tsb_lock_exit(zhat);
-
-	if (flags_pfn) {
-		uint64_t *p = (uint64_t *)&tte;
-
-		p++; 			/* ignore the tag */
-		*p = flags_pfn;		/* load the flags */
-
-		zuluvm_load_tte(zhat, vaddr, flags_pfn, tte.zulu_tte_perm,
-		    tte.zulu_tte_size);
-		if (ppg_size != NULL) {
-			*ppg_size = tte.zulu_tte_size;
-		}
-
-		zulu_tsb_hit++;
-		mutex_exit(&zhat->lock);
-		return (0);
-	}
-
-	zulu_tsb_miss++;
-
-	zblkp = zulu_lookup_map(zhat, vaddr);
-	if (zblkp) {
-		tte = zblkp->zulu_hat_blk_tte;
-		tte.zulu_tte_pfn = ZULU_HAT_ADJ_PFN((&tte), vaddr);
-		zuluvm_load_tte(zhat, vaddr,  tte.zulu_tte_pfn,
-		    tte.zulu_tte_perm, tte.zulu_tte_size);
-		if (ppg_size != NULL) {
-			*ppg_size = tte.zulu_tte_size;
-		}
-		mutex_exit(&zhat->lock);
-		return (0);
-	}
-
-	/*
-	 * Set a flag indicating that we're processing a fault.
-	 * See comments in zulu_hat_unload_region.
-	 */
-	zhat->in_fault = 1;
-	mutex_exit(&zhat->lock);
-
-	zulu_as_fault++;
-	TNF_PROBE_0(calling_as_fault, "zulu_hat", /* CSTYLED */);
-
-	as_err = as_fault((struct hat *)zhat, zhat->zulu_xhat.xhat_as,
-	    (caddr_t)(ZULU_VADDR((uint64_t)vaddr) & PAGEMASK),
-	    PAGESIZE, F_INVAL, rw);
-
-	mutex_enter(&zhat->lock);
-	zhat->in_fault = 0;
-	if (ppg_size != NULL) {
-		/*
-		 * caller wants to know the page size (used by preload)
-		 */
-		zblkp = zulu_lookup_map(zhat, vaddr);
-		if (zblkp != NULL) {
-			*ppg_size = zblkp->zulu_hat_blk_size;
-		} else {
-			*ppg_size = -1;
-		}
-	}
-	mutex_exit(&zhat->lock);
-
-	TNF_PROBE_1(as_fault_returned, "zulu_hat", /* CSTYLED */,
-		tnf_int, as_err, as_err);
-
-	if (as_err != 0) {
-		printf("as_fault returned %d\n", as_err);
-		rval = as_err;
-	} else if (zhat->freed) {
-		rval = -1;
-	} else {
-		rval = 0;
-	}
-
-	return (rval);
-}
-
-static struct xhat *
-zulu_hat_alloc(void *arg)
-{
-	struct zulu_hat *zhat = kmem_zalloc(sizeof (struct zulu_hat), KM_SLEEP);
-
-	(void) arg;
-
-	zulu_hat_ctx_alloc(zhat);
-
-	mutex_init(&zhat->lock, NULL, MUTEX_DEFAULT, NULL);
-
-	zhat->zulu_tsb = kmem_zalloc(ZULU_TSB_SZ, KM_SLEEP);
-	zhat->zulu_tsb_size = ZULU_TSB_NUM;
-	zhat->hash_tbl = kmem_zalloc(ZULU_HASH_TBL_SZ, KM_SLEEP);
-	avl_create(&zhat->shadow_tree, zulu_shadow_tree_compare,
-	    sizeof (zhat->shadow_tree), ZULU_SHADOW_BLK_LINK_OFFSET);
-	/*
-	 * The zulu hat has a few opaque data structs embedded in it.
-	 * This tag makes finding the our data easier with a debugger.
-	 */
-	zhat->magic = 0x42;
-
-	zhat->freed = 0;
-	TNF_PROBE_1(zulu_hat_alloc, "zulu_hat", /* CSTYLED */,
-		tnf_int, zulu_ctx, zhat->zulu_ctx);
-	return ((struct xhat *)zhat);
-}
-
-static void
-zulu_hat_free(struct xhat *xhat)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-
-	TNF_PROBE_1(zulu_hat_free, "zulu_hat", /* CSTYLED */,
-		tnf_int, zulu_ctx, zhat->zulu_ctx);
-
-	zulu_shadow_tree_destroy(zhat);
-	kmem_free(zhat->hash_tbl, ZULU_HASH_TBL_SZ);
-	kmem_free(zhat->zulu_tsb, ZULU_TSB_SZ);
-	mutex_destroy(&zhat->lock);
-	kmem_free(xhat, sizeof (struct zulu_hat));
-}
-
-static void
-zulu_hat_free_start(struct xhat *xhat)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-
-	TNF_PROBE_1(zulu_hat_free_start, "zulu_hat", /* CSTYLED */,
-		tnf_int, zulu_ctx, zhat->zulu_ctx);
-	(void) xhat;
-}
-
-/*
- * zulu_hat_memload: This is the callback where the vm system gives us our
- * translations
- */
-static void
-zulu_do_hat_memload(struct xhat *xhat, caddr_t vaddr, struct page *page,
-    uint_t attr, uint_t flags, int use_pszc)
-{
-	void *blk;
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-	struct zulu_hat_blk *zblk;
-	pfn_t pfn;
-
-	TNF_PROBE_4(zulu_hat_memload, "zulu_hat", /* CSTYLED */,
-	    tnf_int, zulu_ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, vaddr, tnf_opaque, attr, attr,
-	    tnf_opaque, flags, flags);
-
-	/*
-	 * keep track of the highest address that this zhat has had
-	 * a mapping for.
-	 * We use this in unload to avoid searching for regions that
-	 * we've never seen.
-	 *
-	 * This is particularly useful avoiding repeated searches for
-	 * for the process's mappings to the zulu hardware. These mappings
-	 * are explicitly unloaded at each graphics context switch..
-	 *
-	 * This takes advantage of the fact that the device addresses
-	 * are always above than the heap where most DMA data is stored.
-	 */
-	if (vaddr > zhat->vaddr_max) {
-		zhat->vaddr_max = vaddr;
-	}
-
-	pfn = xhat_insert_xhatblk(page, xhat, &blk);
-	zblk = (struct zulu_hat_blk *)blk;
-	zblk->zulu_hat_blk_vaddr = (uintptr_t)vaddr;
-	zblk->zulu_hat_blk_pfn = (uint_t)pfn;
-	/*
-	 * The perm bit is actually in the tte which gets copied to the TSB
-	 */
-	zblk->zulu_hat_blk_perm = (attr & PROT_WRITE) ? 1 : 0;
-	zblk->zulu_hat_blk_size = use_pszc ? page->p_szc : 0;
-	zblk->zulu_hat_blk_valid = 1;
-
-	switch (zblk->zulu_hat_blk_size) {
-	case	ZULU_TTE8K:
-		zhat->map8k = 1;
-		break;
-	case	ZULU_TTE64K:
-		zhat->map64k = 1;
-		break;
-	case	ZULU_TTE512K:
-		zhat->map512k = 1;
-		break;
-	case	ZULU_TTE4M:
-		zhat->map4m = 1;
-		break;
-	default:
-		panic("zulu_hat illegal page size\n");
-	}
-
-	mutex_enter(&zhat->lock);
-
-	zulu_hat_insert_map(zhat, zblk);
-	if (!zhat->freed) {
-		zuluvm_load_tte(zhat, vaddr, zblk->zulu_hat_blk_pfn,
-		    zblk->zulu_hat_blk_perm, zblk->zulu_hat_blk_size);
-	}
-	zhat->fault_ivaddr_last =
-	    ZULU_VADDR((uint64_t)zblk->zulu_hat_blk_vaddr);
-
-	mutex_exit(&zhat->lock);
-}
-
-static void
-zulu_hat_memload(struct xhat *xhat, caddr_t vaddr, struct page *page,
-    uint_t attr, uint_t flags)
-{
-	zulu_do_hat_memload(xhat, vaddr, page, attr, flags, 0);
-}
-
-static void
-zulu_hat_devload(struct xhat *xhat, caddr_t vaddr, size_t size, pfn_t pfn,
-	uint_t attr, int flags)
-{
-	struct page *pp = page_numtopp_nolock(pfn);
-	(void) size;
-	zulu_do_hat_memload(xhat, vaddr, pp, attr, (uint_t)flags, 1);
-}
-
-static void
-zulu_hat_memload_array(struct xhat *xhat, caddr_t addr, size_t len,
-    struct page **gen_pps, uint_t attr, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-
-	TNF_PROBE_3(zulu_hat_memload_array, "zulu_hat", /* CSTYLED */,
-	    tnf_int, zulu_ctx, zhat->zulu_ctx,
-	    tnf_opaque, addr, addr,
-	    tnf_opaque, len, len);
-
-	for (; len > 0; len -= ZULU_HAT_PGSZ((*gen_pps)->p_szc),
-	    gen_pps += ZULU_HAT_NUM_PGS((*gen_pps)->p_szc)) {
-		zulu_do_hat_memload(xhat, addr, *gen_pps, attr, flags, 1);
-
-		addr += ZULU_HAT_PGSZ((*gen_pps)->p_szc);
-	}
-}
-
-static void
-free_zblks(struct zulu_hat_blk *free_list)
-{
-	struct zulu_hat_blk *zblkp;
-	struct zulu_hat_blk *next;
-
-	for (zblkp = free_list; zblkp != NULL; zblkp = next) {
-		next = zblkp->zulu_hash_next;
-		(void) xhat_delete_xhatblk((struct xhat_hme_blk *)zblkp, 0);
-	}
-}
-
-static void
-add_to_free_list(struct zulu_hat_blk **pfree_list, struct zulu_hat_blk *zblk)
-{
-	zblk->zulu_hash_next = *pfree_list;
-	*pfree_list = zblk;
-}
-
-static void
-zulu_hat_unload_region(struct zulu_hat *zhat, uint64_t ivaddr, size_t size,
-		struct zulu_shadow_blk *sblk, struct zulu_hat_blk **pfree_list)
-{
-	uint64_t	end = ivaddr + size;
-	int		found = 0;
-
-	TNF_PROBE_2(zulu_hat_unload_region, "zulu_hat", /* CSTYLED */,
-		tnf_opaque, vaddr, ivaddr, tnf_opaque, size, size);
-
-	/*
-	 * check address against the low and highwater marks for mappings
-	 * in this sblk
-	 */
-	if (ivaddr < sblk->min_addr) {
-		ivaddr = sblk->min_addr;
-		TNF_PROBE_1(zulu_hat_unload_skip, "zulu_hat", /* CSTYLED */,
-			tnf_opaque, ivaddr, ivaddr);
-	}
-	if (end > sblk->max_addr) {
-		end = sblk->max_addr;
-		TNF_PROBE_1(zulu_hat_unload_reg_skip, "zulu_hat", /* CSTYLED */,
-			tnf_opaque, end, end);
-	}
-	/*
-	 * REMIND: It's not safe to touch the sblk after we enter this loop
-	 * because it may get deleted.
-	 */
-
-	while (ivaddr < end) {
-		uint64_t iaddr;
-		size_t  pg_sz;
-		struct zulu_hat_blk *zblkp;
-
-		zblkp = zulu_lookup_map(zhat, (caddr_t)ivaddr);
-		if (zblkp == NULL) {
-			ivaddr += PAGESIZE;
-			continue;
-		}
-
-		iaddr = ZULU_VADDR((uint64_t)zblkp->zulu_hat_blk_vaddr);
-		pg_sz = ZULU_HAT_PGSZ(zblkp->zulu_hat_blk_size);
-
-		found++;
-
-		zulu_hat_remove_map(zhat, zblkp);
-		/*
-		 * skip demap page if as_free has already been entered
-		 * zuluvm demapped the context already
-		 */
-		if (!zhat->freed) {
-			if ((zhat->in_fault) &&
-			    (iaddr == zhat->fault_ivaddr_last)) {
-				/*
-				 * We're being called from within as_fault to
-				 * unload the last translation we loaded.
-				 *
-				 * This is probably due to watchpoint handling.
-				 * Delay the demap for a millisecond
-				 * to allow zulu to make some progress.
-				 */
-				drv_usecwait(1000);
-				zhat->fault_ivaddr_last = 0;
-			}
-			zulu_hat_demap_page(zhat, (caddr_t)iaddr,
-			    zblkp->zulu_hat_blk_size);
-		}
-
-		add_to_free_list(pfree_list, zblkp);
-
-		if ((iaddr + pg_sz) >= end) {
-			break;
-		}
-
-		ivaddr += pg_sz;
-	}
-	TNF_PROBE_1(zulu_hat_unload_region_done, "zulu_hat", /* CSTYLED */,
-		tnf_opaque, found, found);
-}
-
-static void
-zulu_hat_unload(struct xhat *xhat, caddr_t vaddr, size_t size, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-	uint64_t	ivaddr;
-	uint64_t	end;
-	int		found = 0;
-	struct zulu_hat_blk *free_list = NULL;
-
-	(void) flags;
-
-	TNF_PROBE_4(zulu_hat_unload, "zulu_hat", /* CSTYLED */,
-	    tnf_int, zulu_ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, vaddr,
-	    tnf_opaque, vaddr_max, zhat->vaddr_max,
-	    tnf_opaque, size, size);
-
-	mutex_enter(&zhat->lock);
-
-	/*
-	 * The following test prevents us from searching for the user's
-	 * mappings to the zulu device registers. Those mappings get unloaded
-	 * every time a graphics context switch away from a given context
-	 * occurs.
-	 *
-	 * Since the heap is located at smaller virtual addresses than the
-	 * registers, this simple test avoids quite a bit of useless work.
-	 */
-	if (vaddr > zhat->vaddr_max) {
-		/*
-		 * all existing mappings have lower addresses than vaddr
-		 * no need to search further.
-		 */
-		mutex_exit(&zhat->lock);
-		return;
-	}
-
-	ivaddr = (uint64_t)vaddr;
-	end = ivaddr + size;
-
-	do {
-		struct zulu_shadow_blk *sblk;
-
-		sblk = zulu_shadow_tree_lookup(zhat, ivaddr, NULL);
-		if (sblk != NULL) {
-			uint64_t 	sblk_end;
-			size_t		region_size;
-
-			found++;
-
-			sblk_end = (ivaddr + ZULU_SHADOW_BLK_RANGE) &
-			    ZULU_SHADOW_BLK_MASK;
-
-			if (sblk_end < end) {
-				region_size = sblk_end - ivaddr;
-			} else {
-				region_size = end - ivaddr;
-			}
-			zulu_hat_unload_region(zhat, ivaddr, region_size, sblk,
-			    &free_list);
-
-		}
-		ivaddr += ZULU_SHADOW_BLK_RANGE;
-	} while (ivaddr < end);
-
-	mutex_exit(&zhat->lock);
-
-	free_zblks(free_list);
-
-	TNF_PROBE_1(zulu_hat_unload_done, "zulu_hat", /* CSTYLED */,
-		tnf_int, found, found);
-}
-
-static void
-zulu_hat_unload_callback(struct xhat *xhat, caddr_t vaddr, size_t size,
-	uint_t flags, hat_callback_t *pcb)
-{
-	(void) size;
-	(void) pcb;
-	zulu_hat_unload(xhat, vaddr, size, flags);
-}
-
-
-/*
- * unload one page
- */
-static int
-zulu_hat_pageunload(struct xhat *xhat, struct page *pp, uint_t flags,
-    void *xblk)
-{
-	struct zulu_hat_blk *zblk = (struct zulu_hat_blk *)xblk;
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-	int	do_delete;
-
-	(void) pp;
-	(void) flags;
-
-	TNF_PROBE_3(zulu_hat_pageunload, "zulu_hat", /* CSTYLED */,
-	    tnf_int, zulu_ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, zblk->zulu_hat_blk_vaddr,
-	    tnf_int, pg_size, zblk->zulu_hat_blk_size);
-
-	mutex_enter(&zhat->lock);
-	if (zblk->zulu_shadow_blk != NULL) {
-
-		do_delete = 1;
-
-		zulu_hat_remove_map(zhat, zblk);
-
-		/*
-		 * now that the entry is removed from the TSB, remove the
-		 * translation from the zulu hardware.
-		 *
-		 * Skip the demap if this as is in the process of being freed.
-		 * The zuluvm as callback has demapped the whole context.
-		 */
-		if (!zhat->freed) {
-			zulu_hat_demap_page(zhat,
-			    (caddr_t)(uintptr_t)(zblk->zulu_hat_blk_page <<
-			    ZULU_HAT_BP_SHIFT),
-			    zblk->zulu_hat_blk_size);
-		}
-	} else {
-		/*
-		 * This block has already been removed from the zulu_hat,
-		 * it's on a free list waiting for our thread to release
-		 * a mutex so it can be freed
-		 */
-		do_delete = 0;
-
-		TNF_PROBE_0(zulu_hat_pageunload_skip, "zulu_hat",
-		    /* CSTYLED */);
-	}
-	mutex_exit(&zhat->lock);
-
-	if (do_delete) {
-		(void) xhat_delete_xhatblk(xblk, 1);
-	}
-
-	return (0);
-}
-
-static void
-zulu_hat_swapout(struct xhat *xhat)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-	struct zulu_hat_blk *zblk;
-	struct zulu_hat_blk *free_list = NULL;
-	int	i;
-	int	nblks = 0;
-
-	TNF_PROBE_1(zulu_hat_swapout, "zulu_hat", /* CSTYLED */,
-		tnf_int, zulu_ctx, zhat->zulu_ctx);
-
-	mutex_enter(&zhat->lock);
-
-	/*
-	 * real swapout calls are rare so we don't do anything in
-	 * particular to optimize them.
-	 *
-	 * Just loop over all buckets in the hash table and free each
-	 * zblk.
-	 */
-	for (i = 0; i < ZULU_HASH_TBL_NUM; i++) {
-		struct zulu_hat_blk *next;
-		for (zblk = zhat->hash_tbl[i]; zblk != NULL; zblk = next) {
-			next = zblk->zulu_hash_next;
-			zulu_hat_remove_map(zhat, zblk);
-			add_to_free_list(&free_list, zblk);
-			nblks++;
-		}
-	}
-
-	/*
-	 * remove all mappings for this context from zulu hardware.
-	 */
-	zulu_hat_demap_ctx(zhat->zdev, zhat->zulu_ctx);
-
-	mutex_exit(&zhat->lock);
-
-	free_zblks(free_list);
-
-	TNF_PROBE_1(zulu_hat_swapout_done, "zulu_hat", /* CSTYLED */,
-		tnf_int, nblks, nblks);
-}
-
-
-static void
-zulu_hat_unshare(struct xhat *xhat, caddr_t vaddr, size_t size)
-{
-	TNF_PROBE_0(zulu_hat_unshare, "zulu_hat", /* CSTYLED */);
-
-	zulu_hat_unload(xhat, vaddr, size, 0);
-}
-
-/*
- * Functions to manage changes in protections for mappings.
- *
- * These are rarely called in normal operation so for now just unload
- * the region.
- * If the mapping is still needed, it will fault in later with the new
- * attrributes.
- */
-typedef enum {
-	ZULU_HAT_CHGATTR,
-	ZULU_HAT_SETATTR,
-	ZULU_HAT_CLRATTR
-} zulu_hat_prot_op;
-
-static void
-zulu_hat_update_attr(struct xhat *xhat, caddr_t vaddr, size_t size,
-	uint_t flags, zulu_hat_prot_op op)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-
-	TNF_PROBE_5(zulu_hat_changeprot, "zulu_hat", /* CSTYLED */,
-	    tnf_int, ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, vaddr, tnf_opaque, size, size,
-	    tnf_uint, flags, flags, tnf_int, op, op);
-
-	zulu_hat_unload(xhat, vaddr, size, 0);
-}
-
-static void
-zulu_hat_chgprot(struct xhat *xhat, caddr_t vaddr, size_t size, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-#ifdef DEBUG
-	printf("zulu_hat_chgprot: ctx: %d addr: %lx, size: %lx flags: %x\n",
-	    zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
-#endif
-	zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_CHGATTR);
-}
-
-
-static void
-zulu_hat_setattr(struct xhat *xhat, caddr_t vaddr, size_t size, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-#ifdef DEBUG
-	printf("zulu_hat_setattr: ctx: %d addr: %lx, size: %lx flags: %x\n",
-	    zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
-#endif
-	zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_SETATTR);
-}
-
-static void
-zulu_hat_clrattr(struct xhat *xhat, caddr_t vaddr, size_t size, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-#ifdef DEBUG
-	printf("zulu_hat_clrattr: ctx: %d addr: %lx, size: %lx flags: %x\n",
-	    zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
-#endif
-	zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_CLRATTR);
-}
-
-static void
-zulu_hat_chgattr(struct xhat *xhat, caddr_t vaddr, size_t size, uint_t flags)
-{
-	struct zulu_hat *zhat = (struct zulu_hat *)xhat;
-	TNF_PROBE_3(zulu_hat_chgattr, "zulu_hat", /* CSTYLED */,
-	    tnf_int, ctx, zhat->zulu_ctx,
-	    tnf_opaque, vaddr, vaddr,
-	    tnf_opaque, flags, flags);
-#ifdef DEBUG
-	printf("zulu_hat_chgattr: ctx: %d addr: %lx, size: %lx flags: %x\n",
-	    zhat->zulu_ctx, (uint64_t)vaddr, size, flags);
-#endif
-	zulu_hat_update_attr(xhat, vaddr, size, flags, ZULU_HAT_CHGATTR);
-}
-
-
-struct xhat_ops zulu_hat_ops = {
-	zulu_hat_alloc,		/* xhat_alloc */
-	zulu_hat_free,		/* xhat_free */
-	zulu_hat_free_start,	/* xhat_free_start */
-	NULL,			/* xhat_free_end */
-	NULL,			/* xhat_dup */
-	NULL,			/* xhat_swapin */
-	zulu_hat_swapout,	/* xhat_swapout */
-	zulu_hat_memload,	/* xhat_memload */
-	zulu_hat_memload_array,	/* xhat_memload_array */
-	zulu_hat_devload,	/* xhat_devload */
-	zulu_hat_unload,	/* xhat_unload */
-	zulu_hat_unload_callback, /* xhat_unload_callback */
-	zulu_hat_setattr,	/* xhat_setattr */
-	zulu_hat_clrattr,	/* xhat_clrattr */
-	zulu_hat_chgattr,	/* xhat_chgattr */
-	zulu_hat_unshare,	/* xhat_unshare */
-	zulu_hat_chgprot,	/* xhat_chgprot */
-	zulu_hat_pageunload,	/* xhat_pageunload */
-};
-
-xblk_cache_t zulu_xblk_cache = {
-    NULL,
-    NULL,
-    NULL,
-    xhat_xblkcache_reclaim
-};
-
-xhat_provider_t zulu_hat_provider = {
-	XHAT_PROVIDER_VERSION,
-	0,
-	NULL,
-	NULL,
-	"zulu_hat_provider",
-	&zulu_xblk_cache,
-	&zulu_hat_ops,
-	sizeof (struct zulu_hat_blk) + sizeof (struct xhat_hme_blk)
-};
-
-/*
- * The following functions are the entry points that zuluvm uses.
- */
-
-/*
- * initialize this module. Called from zuluvm's _init function
- */
-int
-zulu_hat_init()
-{
-	int 	c;
-	int	rval;
-	mutex_init(&zulu_ctx_lock, NULL, MUTEX_DEFAULT, NULL);
-
-	for (c = 0; c < ZULU_HAT_MAX_CTX; c++) {
-		ZULU_CTX_LOCK_INIT(c);
-	}
-	zulu_ctx_search_start = 0;
-	rval = xhat_provider_register(&zulu_hat_provider);
-	if (rval != 0) {
-		mutex_destroy(&zulu_ctx_lock);
-	}
-	return (rval);
-}
-
-/*
- * un-initialize this module. Called from zuluvm's _fini function
- */
-int
-zulu_hat_destroy()
-{
-	if (xhat_provider_unregister(&zulu_hat_provider) != 0) {
-		return (-1);
-	}
-	mutex_destroy(&zulu_ctx_lock);
-	return (0);
-}
-
-int
-zulu_hat_attach(void *arg)
-{
-	(void) arg;
-	return (0);
-}
-
-int
-zulu_hat_detach(void *arg)
-{
-	(void) arg;
-	return (0);
-}
-
-/*
- * create a zulu hat for this address space.
- */
-struct zulu_hat *
-zulu_hat_proc_attach(struct as *as, void *zdev)
-{
-	struct zulu_hat *zhat;
-	int		xhat_rval;
-
-	xhat_rval = xhat_attach_xhat(&zulu_hat_provider, as,
-	    (struct xhat **)&zhat, NULL);
-	if ((xhat_rval == 0) && (zhat != NULL)) {
-		mutex_enter(&zhat->lock);
-		ZULU_HAT2AS(zhat) = as;
-		zhat->zdev = zdev;
-		mutex_exit(&zhat->lock);
-	}
-
-	TNF_PROBE_3(zulu_hat_proc_attach, "zulu_hat", /* CSTYLED */,
-	    tnf_int, xhat_rval, xhat_rval, tnf_opaque, as, as,
-	    tnf_opaque, zhat, zhat);
-
-	return (zhat);
-}
-
-void
-zulu_hat_proc_detach(struct zulu_hat *zhat)
-{
-	struct  as *as = ZULU_HAT2AS(zhat);
-
-	zulu_hat_ctx_free(zhat);
-
-	(void) xhat_detach_xhat(&zulu_hat_provider, ZULU_HAT2AS(zhat));
-
-	TNF_PROBE_1(zulu_hat_proc_detach, "zulu_hat", /* CSTYLED */,
-			tnf_opaque, as, as);
-}
-
-/*
- * zulu_hat_terminate
- *
- * Disables any further TLB miss processing for this hat
- * Called by zuluvm's as_free callback. The primary purpose of this
- * function is to cause any pending zulu DMA to abort quickly.
- */
-void
-zulu_hat_terminate(struct zulu_hat *zhat)
-{
-	int	ctx = zhat->zulu_ctx;
-
-	TNF_PROBE_1(zulu_hat_terminate, "zulu_hat", /* CSTYLED */,
-		tnf_int, ctx, ctx);
-
-	mutex_enter(&zhat->lock);
-
-	zhat->freed = 1;
-
-	zulu_ctx_tsb_lock_enter(zhat);
-	/*
-	 * zap the tsb
-	 */
-	bzero(zhat->zulu_tsb, ZULU_TSB_SZ);
-	zulu_ctx_tsb_lock_exit(zhat);
-
-	zulu_hat_demap_ctx(zhat->zdev, zhat->zulu_ctx);
-
-	mutex_exit(&zhat->lock);
-
-	TNF_PROBE_0(zulu_hat_terminate_done, "zulu_hat", /* CSTYLED */);
-}
--- old/usr/src/uts/sun4u/zuluvm/Makefile	2015-05-08 18:10:44.834275325 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,133 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of the zulunvm
-#	mics module
-#
-#	sun4u implementation architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= zuluvm
-OBJECTS		= $(ZULUVM_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(ZULUVM_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MISC_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/sun4u/Makefile.sun4u
-
-#
-#	Override defaults to build a unique, local modstubs.o.
-#
-MODSTUBS_DIR	 = .
-$(MODSTUBS_O)	:= AS_CPPFLAGS += -DZULU_MISC_MODULE
-
-CLEANFILES	+= $(MODSTUBS_O)
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-ZULUVM_OFFSETS		= $(UTSBASE)/sun4u/zuluvm/zuluvm_offsets.in
-ZULUVM_OFFSETS_H	= $(OBJS_DIR)/zuluvm_offsets.h
-
-ZULUVM_STATS = -DZULUVM_STATS
-
-#
-# We turn off tnf probes for opt builds.
-# 
-PROBE_FLAGS_OBJ64 = -DNPROBE
-
-#
-# lint pass one enforcement
-#
-CFLAGS += $(CCVERBOSE) $(ZULUVM_STATS) $(PROBE_FLAGS_$(BUILD_TYPE))
-ASFLAGS += $(ZULUVM_STATS)
-LINTFLAGS += -I$(OBJS_DIR)
-
-#
-# For now, disable these lint checks; maintainers should endeavor
-# to investigate and remove these for maximum lint coverage.
-# Please do not carry these forward to new Makefiles.
-#
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS) lint64
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-# Special rules for generating assym.h for inclusion in assembly files
-#
-#$(DSF_DIR)/$(OBJS_DIR)/assym.h: FRC
-#	@cd $(DSF_DIR); $(MAKE) all.targ
-#
-AS_INC_PATH	+= -I$(OBJS_DIR)
-
-ZULUVM_DEPS	+= zulu_hat_asm.o zulu_asm.o zulu_asm.ln zulu_hat_asm.ln
-
-CLEANFILES	+= $(ZULUVM_OFFSETS_H) $(ZULUVM_OFFSETS_OUT)
-
-$(ZULUVM_DEPS:%=$(OBJS_DIR)/%):	$(ZULUVM_OFFSETS_H)
-
-$(ZULUVM_OFFSETS_H): $(ZULUVM_OFFSETS)
-	$(OFFSETS_CREATE) <$(ZULUVM_OFFSETS) >$@
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/sun4u/Makefile.targ
--- old/usr/src/uts/sun4u/zuluvm/zuluvm_offsets.in	2015-05-08 18:10:44.905152819 -0400
+++ /dev/null	2015-05-08 18:10:44.000000000 -0400
@@ -1,77 +0,0 @@
-\
-\ Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
-\ Use is subject to license terms.
-\
-\ CDDL HEADER START
-\
-\ The contents of this file are subject to the terms of the
-\ Common Development and Distribution License, Version 1.0 only
-\ (the "License").  You may not use this file except in compliance
-\ with the License.
-\
-\ You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-\ or http://www.opensolaris.org/os/licensing.
-\ See the License for the specific language governing permissions
-\ and limitations under the License.
-\
-\ When distributing Covered Code, include this CDDL HEADER in each
-\ file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-\ If applicable, add the following below this CDDL HEADER, with the
-\ fields enclosed by brackets "[]" replaced with your own identifying
-\ information: Portions Copyright [yyyy] [name of copyright owner]
-\
-\ CDDL HEADER END
-\
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/types.h>
-#include <sys/sunddi.h>
-#include <sys/zulumod.h>
-#include <sys/zulu_hat.h>
-
-zulu_hat
-	zulu_tsb	ZULU_HAT_TSB
-	zulu_tsb_size	ZULU_HAT_TSB_SZ
-	zulu_ctx	ZULU_HAT_CTX
-
-#ifdef ZULUVM_STATS
-zuluvm_miss_t
-	idata		ZULUVM_IDATA
-	arg		ZULUVM_ARG
-	mmu_pa		ZULUVM_PAMMU
-	state		ZULUVM_STATE
-	intr_num	ZULUVM_INTRNUM
-	cancel		ZULUVM_ST_TLBCANCEL
-	tlb_miss	ZULUVM_ST_MISS
-	pagefault	ZULUVM_ST_PGFAULT
-	no_mapping	ZULUVM_ST_NOMAP	
-	preload		ZULUVM_ST_PRELOAD
-	migrate		ZULUVM_ST_MIGRATE
-	pagesize	ZULUVM_ST_PAGESIZE
-	itlb1miss	ZULUVM_ST_ITLB1MISS
-	dtlb1miss	ZULUVM_ST_DTLB1MISS
-	itlb2miss	ZULUVM_ST_ITLB2MISS
-	dtlb2miss	ZULUVM_ST_DTLB2MISS
-	demap_page	ZULUVM_ST_DEMAP_PAGE
-	demap_ctx	ZULUVM_ST_DEMAP_CTX
-	pfnbuf		ZULUVM_PFNBUF
-	pfncnt		ZULUVM_PFNCNT
-
-#else
-
-zuluvm_miss_t
-	idata		ZULUVM_IDATA
-	arg		ZULUVM_ARG
-	mmu_pa		ZULUVM_PAMMU
-	state		ZULUVM_STATE
-	intr_num	ZULUVM_INTRNUM
-	pfnbuf		ZULUVM_PFNBUF
-	pfncnt		ZULUVM_PFNCNT
-#endif
-
-\#define ZULUVM_OFFSET(a) (ZULUVM_IDATA + ((a) * ZULUVM_IDATA_INCR))
-\#define ZULUVM_ASM_TLB_TTE	ZULUVM_OFFSET(ZULUVM_TLB_TTE_IDX)
-\#define ZULUVM_ASM_TLB_ADDR	ZULUVM_OFFSET(ZULUVM_TLB_ADDR_IDX)
-\#define ZULUVM_ASM_TLB_TYPE	ZULUVM_OFFSET(ZULUVM_TLB_TYPE_IDX)
-\#define ZULUVM_ASM_TLB_ERRCODE	ZULUVM_OFFSET(ZULUVM_TLB_ERRCODE_IDX)
--- old/usr/src/uts/sun4v/Makefile.files	2015-05-08 18:10:44.976376901 -0400
+++ new/usr/src/uts/sun4v/Makefile.files	2015-05-08 18:10:44.983112351 -0400
@@ -81,7 +81,6 @@
 CORE_OBJS +=	suspend.o
 CORE_OBJS +=	swtch.o
 CORE_OBJS +=	wdt.o
-CORE_OBJS +=	xhat_sfmmu.o
 
 CORE_OBJS +=	mdesc_diff.o
 CORE_OBJS +=	mdesc_findname.o
