--- 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);
