--- old/usr/src/cmd/devfsadm/i386/Makefile	Fri Aug 10 23:19:08 2018
+++ new/usr/src/cmd/devfsadm/i386/Makefile	Fri Aug 10 23:19:08 2018
@@ -18,6 +18,7 @@
 #
 # CDDL HEADER END
 #
+
 #
 # Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
 #
@@ -24,10 +25,7 @@
 
 LINK_OBJS_i386 = \
 	drm_link_i386.o \
-	misc_link_i386.o \
-	xen_link.o
+	misc_link_i386.o
 
-xen_link.o xen_link.ln xen_link.po := CPPFLAGS += -I$(UTSBASE)/i86xpv
-
 include ../Makefile.com
 
--- old/usr/src/cmd/devfsadm/i386/xen_link.c	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:09 2018
@@ -1,111 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <regex.h>
-#include <devfsadm.h>
-#include <stdio.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <sys/privcmd_impl.h>
-#include <sys/domcaps_impl.h>
-#include <sys/balloon.h>
-
-/*
- * Handle miscellaneous children of xendev
- */
-static int devxen(di_minor_t, di_node_t);
-static int xdt(di_minor_t minor, di_node_t node);
-
-static devfsadm_create_t xen_cbt[] = {
-	{ "xendev", DDI_PSEUDO, "xenbus",
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
-	},
-	{ "xendev", DDI_PSEUDO, PRIVCMD_DRIVER_NAME,
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
-	},
-	{ "xendev", DDI_PSEUDO, "evtchn",
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
-	},
-	{ "xendev", DDI_PSEUDO, DOMCAPS_DRIVER_NAME,
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
-	},
-	{ "xendev", DDI_PSEUDO, BALLOON_DRIVER_NAME,
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, devxen,
-	},
-	{ "pseudo", DDI_PSEUDO, "xdt",
-	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, xdt
-	},
-};
-
-DEVFSADM_CREATE_INIT_V0(xen_cbt);
-
-static devfsadm_remove_t xen_remove_cbt[] = {
-	{ "xendev", "^" "xen/xenbus" "$", RM_ALWAYS | RM_PRE | RM_HOT,
-	    ILEVEL_0, devfsadm_rm_all
-	},
-	{ "xendev", "^" PRIVCMD_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
-	    ILEVEL_0, devfsadm_rm_all
-	},
-	{ "xendev", "^" "xen/evtchn" "$", RM_ALWAYS | RM_PRE | RM_HOT,
-	    ILEVEL_0, devfsadm_rm_all
-	},
-	{ "xendev", "^" DOMCAPS_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
-	    ILEVEL_0, devfsadm_rm_all
-	},
-	{ "xendev", "^" BALLOON_PATHNAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
-	    ILEVEL_0, devfsadm_rm_all
-	},
-};
-
-DEVFSADM_REMOVE_INIT_V0(xen_remove_cbt);
-
-/*
- * /dev/xen/<foo>	->	/devices/xendev/<whatever>:<foo>
- */
-static int
-devxen(di_minor_t minor, di_node_t node)
-{
-	char buf[256];
-
-	(void) snprintf(buf, sizeof (buf), "xen/%s", di_minor_name(minor));
-	(void) devfsadm_mklink(buf, node, minor, 0);
-
-	return (DEVFSADM_CONTINUE);
-}
-
-static int
-xdt(di_minor_t minor, di_node_t node)
-{
-	char *mname = di_minor_name(minor);
-	char path[MAXPATHLEN];
-
-	(void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
-	(void) devfsadm_mklink(path, node, minor, 0);
-
-	return (DEVFSADM_CONTINUE);
-}
--- old/usr/src/cmd/dtrace/test/tst/Makefile	Fri Aug 10 23:19:09 2018
+++ new/usr/src/cmd/dtrace/test/tst/Makefile	Fri Aug 10 23:19:09 2018
@@ -23,11 +23,10 @@
 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-#ident	"%Z%%M%	%I%	%E% SMI"
 
 include $(SRC)/Makefile.master
 
-SUBDIRS= common $(MACH:i386=i386 i86xpv)
+SUBDIRS= common $(MACH)
 include ../Makefile.subdirs
 
 dstyle := TARGET += dstyle
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/Makefile	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:09 2018
@@ -1,29 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-include ../Makefile.com
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.basic.ksh	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:09 2018
@@ -1,77 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# ASSERTION: Make sure that we can map in and read the Xen trace buffers.
-#
-
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
-
-#
-# Do not fail the test in a domU
-#
-if [ ! -c /dev/xen/privcmd ]; then
-	exit 0
-fi
-
-dtrace=$1
-
-script()
-{
-	$dtrace -qs /dev/stdin <<EOF
-	xdt:sched::on-cpu
-	/arg0 == 0/
-	{
-		self->on++;
-	}
-
-	xdt:sched::off-cpu
-	/arg0 == 0 && self->on/
-	{
-		self->off++;
-	}
-
-	xdt:sched::off-cpu
-	/self->on > 50 && self->off > 50/
-	{
-		exit(0);
-	}
-
-	profile:::tick-1sec
-	/n++ > 10/
-	{
-		exit(1);
-	}
-EOF
-}
-
-script
-status=$?
-
-exit $status
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.hvmenable.ksh	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:09 2018
@@ -1,64 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-#
-# ASSERTION: HVM probes should enable successfully.
-#
-
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
-
-#
-# Do not fail the test in a domU
-#
-if [ ! -c /dev/xen/privcmd ]; then
-	exit 0
-fi
-
-dtrace=$1
-
-script()
-{
-	$dtrace -qs /dev/stdin <<EOF
-	dtrace:::BEGIN
-	{
-		exit(0);
-	}
-
-	xdt:hvm::vmentry,
-	xdt:hvm::vmexit
-	{}
-EOF
-}
-
-script
-status=$?
-
-exit $status
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.memenable.ksh	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:09 2018
@@ -1,65 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-#
-# ASSERTION: Mem probes should enable successfully.
-#
-
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
-
-#
-# Do not fail the test in a domU
-#
-if [ ! -c /dev/xen/privcmd ]; then
-	exit 0
-fi
-
-dtrace=$1
-
-script()
-{
-	$dtrace -qs /dev/stdin <<EOF
-	dtrace:::BEGIN
-	{
-		exit(0);
-	}
-
-	xdt:mem::page-grant-map,
-	xdt:mem::page-grant-unmap,
-	xdt:mem::page-grant-transfer
-	{}
-EOF
-}
-
-script
-status=$?
-
-exit $status
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedargs.ksh	Fri Aug 10 23:19:09 2018
+++ /dev/null	Fri Aug 10 23:19:10 2018
@@ -1,121 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# ASSERTION: Sched probe arguments should be valid. 
-#
-
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
-
-#
-# do not fail test in a domU
-#
-if [ ! -c /dev/xen/privcmd ]; then
-	exit 0
-fi
-
-dtrace=$1
-outf=/tmp/sched.args.$$
-
-script()
-{
-	$dtrace -c '/usr/bin/sleep 10' -o $outf -qs /dev/stdin <<EOF
-	xdt:sched::off-cpu,
-	xdt:sched::on-cpu,
-	xdt:sched::block,
-	xdt:sched::sleep,
-	xdt:sched::wake,
-	xdt:sched::yield
-	{
-		/* print domid vcpu pcpu probename */
-		printf("%d %d %d %s\n", arg0, arg1, \`xdt_curpcpu, probename);
-	}
-EOF
-}
-
-validate()
-{
-	/usr/bin/nawk '
-	BEGIN {
-		while (("/usr/sbin/xm vcpu-list" | getline)) {
-			if ($1 != "Name") {
-				domid = $2
-				vcpu = $3
-
-				vcpumap[domid, vcpu] = 1
-
-				split($7, affinity, ",")
-				for (i in affinity) {
-					if (split(affinity[i], p, "-") > 1) {
-						for (pcpu = p[1]; pcpu <= p[2];\
-						    pcpu++) {
-							cpumap[domid, vcpu,
-							    pcpu] = 1
-						}
-					} else {
-						cpumap[domid, vcpu,
-						    affinity[i]] = 1
-					}
-				}
-			}
-		}
-	}
-
-	/^$/ { next }
-
-	/wake/ {
-		if (vcpumap[$1, $2]) {
-			next
-		} else {
-			print "error: " $0
-			exit 1
-		}
-	}
-
-	{
-		if (cpumap[$1, $2, "any"] || cpumap[$1, $2, $3]) {
-			next
-		} else {
-			print "error: " $0
-			exit 1
-		}
-	}
-	' $outf
-}
-
-script
-status=$?
-
-if [ $status == 0 ]; then
-	validate
-	status=$?
-fi
-
-rm $outf
-exit $status
--- old/usr/src/cmd/dtrace/test/tst/i86xpv/xdt/tst.schedenable.ksh	Fri Aug 10 23:19:10 2018
+++ /dev/null	Fri Aug 10 23:19:10 2018
@@ -1,74 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-#
-# ASSERTION: Sched probes should enable successfully.
-#
-
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
-
-#
-# do not fail test in a domU
-#
-if [ ! -c /dev/xen/privcmd ]; then
-	exit 0
-fi
-
-dtrace=$1
-
-script()
-{
-	$dtrace -qs /dev/stdin <<EOF
-	dtrace:::BEGIN
-	{
-		exit(0);
-	}
-
-	xdt:sched::off-cpu,
-	xdt:sched::on-cpu,
-	xdt:sched::idle-off-cpu,
-	xdt:sched::idle-on-cpu,
-	xdt:sched::block,
-	xdt:sched::sleep,
-	xdt:sched::wake,
-	xdt:sched::yield,
-	xdt:sched::shutdown-poweroff,
-	xdt:sched::shutdown-reboot,
-	xdt:sched::shutdown-suspend,
-	xdt:sched::shutdown-crash
-	{}
-EOF
-}
-
-script
-status=$?
-
-exit $status
--- old/usr/src/cmd/mdb/Makefile	Fri Aug 10 23:19:10 2018
+++ new/usr/src/cmd/mdb/Makefile	Fri Aug 10 23:19:10 2018
@@ -32,7 +32,7 @@
 i386_MACHDIR = intel
 
 sparc_SUBDIRS = sparc sun4u sun4v
-i386_SUBDIRS = intel i86pc i86xpv
+i386_SUBDIRS = intel i86pc
 
 MACHDIR = $($(MACH)_MACHDIR)
 SUBDIRS = tools $($(MACH)_SUBDIRS) demo
--- old/usr/src/cmd/mdb/common/modules/genunix/memory.c	Fri Aug 10 23:19:10 2018
+++ new/usr/src/cmd/mdb/common/modules/genunix/memory.c	Fri Aug 10 23:19:10 2018
@@ -41,9 +41,6 @@
 #include <vm/seg_map.h>
 #include <vm/seg_vn.h>
 #include <vm/seg_hole.h>
-#if defined(__i386) || defined(__amd64)
-#include <sys/balloon_impl.h>
-#endif
 
 #include "avl.h"
 #include "memory.h"
@@ -509,10 +506,6 @@
 	vn_htable_t ht;
 	struct vnode *kvps;
 	uintptr_t vn_size = 0;
-#if defined(__i386) || defined(__amd64)
-	bln_stats_t bln_stats;
-	ssize_t bln_size;
-#endif
 
 	bzero(&stats, sizeof (memstat_t));
 
@@ -631,29 +624,10 @@
 	else
 		freemem = 0;
 
-#if defined(__i386) || defined(__amd64)
-	/* Are we running under Xen?  If so, get balloon memory usage. */
-	if ((bln_size = mdb_readvar(&bln_stats, "bln_stats")) != -1) {
-		if (freemem > bln_stats.bln_hv_pages)
-			freemem -= bln_stats.bln_hv_pages;
-		else
-			freemem = 0;
-	}
-#endif
-
 	mdb_printf("Free (freelist)  %16lu  %16llu  %3lu%%\n", freemem,
 	    (uint64_t)freemem * PAGESIZE / (1024 * 1024),
 	    MS_PCT_TOTAL(freemem));
 
-#if defined(__i386) || defined(__amd64)
-	if (bln_size != -1) {
-		mdb_printf("Balloon          %16lu  %16llu  %3lu%%\n",
-		    bln_stats.bln_hv_pages,
-		    (uint64_t)bln_stats.bln_hv_pages * PAGESIZE / (1024 * 1024),
-		    MS_PCT_TOTAL(bln_stats.bln_hv_pages));
-	}
-#endif
-
 	mdb_printf("\nTotal            %16lu  %16lu\n",
 	    physmem,
 	    (uint64_t)physmem * PAGESIZE / (1024 * 1024));
--- old/usr/src/cmd/mdb/i86xpv/Makefile	Fri Aug 10 23:19:10 2018
+++ /dev/null	Fri Aug 10 23:19:10 2018
@@ -1,28 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-
-SUBDIRS = modules
-include ../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/Makefile.i86xpv	Fri Aug 10 23:19:10 2018
+++ /dev/null	Fri Aug 10 23:19:10 2018
@@ -1,47 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-
-ROOTMOD = $(ROOT)/usr/platform/i86xpv/lib/mdb/$(MDBTGT)$(MACHMODDIR)
-ROOTKMOD = $(ROOT)/platform/i86xpv/kernel/kmdb$(MACHMODDIR)
-
-$(ROOT)/usr/platform/i86xpv/lib/mdb:
-	$(INS.dir)
-
-$(ROOT)/usr/platform/i86xpv/lib/mdb/$(MDBTGT): $(ROOT)/usr/platform/i86xpv/lib/mdb
-	$(INS.dir)
-
-$(ROOT)/usr/platform/i86xpv/lib/mdb/$(MDBTGT)/amd64: \
-    $(ROOT)/usr/platform/i86xpv/lib/mdb/$(MDBTGT)
-	$(INS.dir)
-
-$(ROOT)/platform/i86xpv/kernel:
-	$(INS.dir)
-
-$(ROOT)/platform/i86xpv/kernel/kmdb: $(ROOT)/platform/i86xpv/kernel
-	$(INS.dir)
-
-$(ROOT)/platform/i86xpv/kernel/kmdb/amd64: $(ROOT)/platform/i86xpv/kernel/kmdb
-	$(INS.dir)
--- old/usr/src/cmd/mdb/i86xpv/modules/Makefile	Fri Aug 10 23:19:10 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,29 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-
-SUBDIRS = unix xpv xpv_psm xpv_uppc
-include ../../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/modules/unix/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,28 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-$(BUILD64)SUBDIRS += 	$(MACH64)
-include ../../../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,53 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-
-MODULE = unix.so
-MDBTGT = kvm
-
-MODSRCS = unix.c i86mmu.c
-MODASMSRCS = unix_sup.s
-
-include ../../../../../Makefile.cmd
-include ../../../../../Makefile.cmd.64
-include ../../../../intel/Makefile.amd64
-include ../../../Makefile.i86xpv
-include ../../../../Makefile.module
-
-MODSRCS_DIR = ../../../../i86pc/modules/unix/
-
-CPPFLAGS += -DMP -D_MACHDEP -D__xpv
-CPPFLAGS += -I../../../../common
-CPPFLAGS += -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/uts/i86xpv
-CPPFLAGS += -I$(SRC)/uts/i86pc
-CPPFLAGS += -I$(SRC)/uts/intel
-
-CERRWARN += -_gcc=-Wno-char-subscripts
-CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
-
-CERRWARN += -_gcc=-Wno-unused-function
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,28 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-$(BUILD64)SUBDIRS += 	$(MACH64)
-include ../../../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv/amd64/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,47 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#ident	"%Z%%M%	%I%	%E% SMI"
-
-MODULE = xpv.so
-MODULE_BUILD_TYPE = mdb
-MDBTGT = kvm
-
-MODSRCS = xpv.c
-
-include ../../../../../Makefile.cmd
-include ../../../../../Makefile.cmd.64
-include ../../../../intel/Makefile.amd64
-include ../../../Makefile.i86xpv
-include ../../../../Makefile.module
-
-MODSRCS_DIR = ../../../../i86pc/modules/common
-
-CPPFLAGS += -DMP -D_MACHDEP -D__xpv -D_MDB -D__x86_64__
-CPPFLAGS += -I../../../../common
-CPPFLAGS += -I../../../../i86pc/modules/common
-CPPFLAGS += -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/uts/i86xpv
-CPPFLAGS += -I$(SRC)/uts/i86pc
-CPPFLAGS += -I$(SRC)/uts/intel
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv/xpv.c	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,288 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Copyright (c) 2012 by Delphix. All rights reserved.
- */
-
-#include <mdb/mdb_modapi.h>
-#include <mdb/mdb_ks.h>
-#include <mdb/mdb_ctf.h>
-#include <mdb/mdb_gelf.h>
-#include <mdb/mdb_target_impl.h>
-#include <mdb/mdb_kvm.h>
-#include <mdb/mdb.h>
-#include <xen/public/xen.h>
-#include <xen/public/arch-x86/xen.h>
-#include <errno.h>
-
-static mdb_ctf_id_t domain_type;
-
-/*
- * Some constants found in the non-public sched.h header file
- */
-#define	MAX_EVTCHNS		NR_EVENT_CHANNELS
-#define	EVTCHNS_PER_BUCKET	128
-#define	NR_EVTCHN_BUCKETS	(MAX_EVTCHNS / EVTCHNS_PER_BUCKET)
-
-/*
- * "struct domain" is an internal Xen structure.  Rather than trying to
- * keep the mdb source in sync with Xen, we use CTF to extract the
- * interesting bits from the binary, and stash them in the structure
- * defined below.
- */
-typedef struct mdb_xpv_domain {
-	short		domain_id;
-	int		tot_pages;
-	int		max_pages;
-	int		xenheap_pages;
-	ulong_t		domain_flags;
-	char		is_hvm;
-	struct vcpu	*vcpu[MAX_VIRT_CPUS];
-	struct evtchn	*evtchn[NR_EVTCHN_BUCKETS];
-	struct domain	*next_in_list;
-} mdb_xpv_domain_t;
-
-static uintptr_t
-get_dom0_addr()
-{
-	GElf_Sym sym;
-	uintptr_t addr;
-
-	if ((mdb_lookup_by_obj(MDB_TGT_OBJ_EVERY, "dom0", &sym)) == 1) {
-		mdb_warn("can't find symbol 'dom0'");
-		return (0);
-	}
-
-	if (sym.st_size != sizeof (uintptr_t)) {
-		mdb_printf("Symbol 'dom0' found, but with the wrong size\n");
-		return (0);
-	}
-
-	if (mdb_vread(&addr, sym.st_size, sym.st_value) == -1) {
-		mdb_warn("can't read data for symbol 'dom0'");
-		return (0);
-	}
-
-	return (addr);
-}
-
-typedef struct domain_walk {
-	uint_t dw_step;
-} domain_walk_t;
-
-int
-domain_walk_init(mdb_walk_state_t *wsp)
-{
-	domain_walk_t *dwp;
-
-	if (wsp->walk_addr == NULL)
-		if ((wsp->walk_addr = get_dom0_addr()) == NULL)
-			return (WALK_ERR);
-
-	dwp = mdb_alloc(sizeof (domain_walk_t), UM_SLEEP);
-	dwp->dw_step = FALSE;
-	wsp->walk_data = dwp;
-	return (WALK_NEXT);
-}
-
-int
-domain_walk_step(mdb_walk_state_t *wsp)
-{
-	domain_walk_t *dwp = (domain_walk_t *)wsp->walk_data;
-	mdb_xpv_domain_t dom;
-	int status;
-
-	if (wsp->walk_addr == NULL)
-		return (WALK_DONE);
-
-	status = wsp->walk_callback(wsp->walk_addr, (void *)wsp->walk_addr,
-	    wsp->walk_cbdata);
-
-	if (mdb_ctf_vread(&dom, "struct domain", "mdb_xpv_domain_t",
-	    wsp->walk_addr, 0) != 0)
-		return (WALK_ERR);
-	wsp->walk_addr = (uintptr_t)dom.next_in_list;
-
-	dwp->dw_step = TRUE;
-	return (status);
-}
-
-void
-domain_walk_fini(mdb_walk_state_t *wsp)
-{
-	domain_walk_t *dwp = (domain_walk_t *)wsp->walk_data;
-
-	mdb_free(dwp, sizeof (domain_walk_t));
-}
-
-typedef struct vcpu_walk {
-	uint_t vw_count;
-	uint_t vw_step;
-} vcpu_walk_t;
-
-int
-vcpu_walk_init(mdb_walk_state_t *wsp)
-{
-	vcpu_walk_t *vwp;
-	uintptr_t off;
-
-	if (wsp->walk_addr == NULL)
-		if ((wsp->walk_addr = get_dom0_addr()) == NULL)
-			return (WALK_ERR);
-
-	if (mdb_ctf_offsetof(domain_type, "vcpu", &off)) {
-		mdb_warn("can't find per-domain vcpu information");
-		return (WALK_ERR);
-	}
-
-	wsp->walk_addr = wsp->walk_addr + (off / NBBY);
-	vwp = mdb_alloc(sizeof (vcpu_walk_t), UM_SLEEP);
-	vwp->vw_step = FALSE;
-	vwp->vw_count = 0;
-	wsp->walk_data = vwp;
-	return (WALK_NEXT);
-}
-
-int
-vcpu_walk_step(mdb_walk_state_t *wsp)
-{
-	vcpu_walk_t *vwp = (vcpu_walk_t *)wsp->walk_data;
-	uintptr_t vcpu_ptr;
-	int status;
-
-	if (vwp->vw_count++ >= MAX_VIRT_CPUS)
-		return (WALK_DONE);
-	if ((wsp->walk_addr == NULL) ||
-	    (mdb_vread(&vcpu_ptr, sizeof (uintptr_t), wsp->walk_addr) == -1) ||
-	    (vcpu_ptr == 0))
-		return (WALK_DONE);
-
-	status = wsp->walk_callback(vcpu_ptr, (void *)vcpu_ptr,
-	    wsp->walk_cbdata);
-
-	wsp->walk_addr = wsp->walk_addr + sizeof (uintptr_t);
-	vwp->vw_step = TRUE;
-	return (status);
-}
-
-void
-vcpu_walk_fini(mdb_walk_state_t *wsp)
-{
-	vcpu_walk_t *vwp = (vcpu_walk_t *)wsp->walk_data;
-
-	mdb_free(vwp, sizeof (vcpu_walk_t));
-}
-
-int
-domain(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
-	mdb_xpv_domain_t dom;
-	uintptr_t off, vcpu_addr, evtchn_addr;
-
-	if (!mdb_ctf_type_valid(domain_type)) {
-		mdb_warn("Can't parse Xen domain info.\n");
-		return (DCMD_ERR);
-	}
-
-	if (!(flags & DCMD_ADDRSPEC)) {
-		if (mdb_walk_dcmd("domain", "domain", argc, argv) == -1) {
-			mdb_warn("can't walk domains");
-			return (DCMD_ERR);
-		}
-		return (DCMD_OK);
-	}
-
-	if (DCMD_HDRSPEC(flags))
-		mdb_printf("%?s %3s %8s %8s %8s %3s %?s %?s\n",
-		    "ADDR", "ID", "TPAGES", "MPAGES", "FLAGS", "HVM",
-		    "VCPU", "EVTCHN");
-
-	if (mdb_ctf_vread(&dom, "struct domain", "mdb_xpv_domain_t", addr,
-	    0) != 0)
-		return (DCMD_ERR);
-
-	if (mdb_ctf_offsetof(domain_type, "vcpu", &off)) {
-		mdb_warn("can't find per-domain vcpu information");
-		return (DCMD_ERR);
-	}
-	vcpu_addr = addr + (off / NBBY);
-	if (mdb_ctf_offsetof(domain_type, "evtchn", &off)) {
-		mdb_warn("can't find per-domain event channel information");
-		return (DCMD_ERR);
-	}
-	evtchn_addr = addr + (off / NBBY);
-	mdb_printf("%?lx %3d %8x %8x %8x %3d %?lx %?lx\n",
-	    addr, dom.domain_id, dom.tot_pages, dom.max_pages, dom.domain_flags,
-	    dom.is_hvm, vcpu_addr, evtchn_addr);
-
-	return (DCMD_OK);
-}
-
-static const mdb_dcmd_t dcmds[] = {
-	{ "domain", ":", "display Xen domain info", domain },
-	{ NULL }
-};
-
-static const mdb_walker_t walkers[] = {
-	{ "domain", "walk list of Xen domains",
-		domain_walk_init, domain_walk_step, domain_walk_fini },
-	{ "vcpu", "walk a Xen domain's vcpus",
-		vcpu_walk_init, vcpu_walk_step, vcpu_walk_fini },
-	{ NULL }
-};
-
-static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
-
-typedef struct mdb_xpv_panic_info {
-	int pi_version;
-} mdb_xpv_panic_info_t;
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
-	uintptr_t pip;
-	mdb_xpv_panic_info_t pi;
-
-	if (mdb_readsym(&pip, sizeof (pip), "xpv_panic_info") == -1) {
-		mdb_warn("failed to read xpv panic_info pointer");
-		return (NULL);
-	}
-	if (mdb_ctf_vread(&pi, "struct panic_info", "mdb_xpv_panic_info_t",
-	    pip, 0) == -1)
-		return (NULL);
-
-	if (pi.pi_version != PANIC_INFO_VERSION) {
-		mdb_warn("unrecognized hypervisor panic format");
-		return (NULL);
-	}
-
-	if (mdb_ctf_lookup_by_name("struct domain", &domain_type) != 0) {
-		mdb_warn("Can't parse Xen domain info: "
-		    "'struct domain' not found.\n");
-		mdb_ctf_type_invalidate(&domain_type);
-	}
-
-	return (&modinfo);
-}
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_psm/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,28 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-$(BUILD64)SUBDIRS += 	$(MACH64)
-include ../../../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_psm/amd64/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,48 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-
-MODULE = xpv_psm.so
-MDBTGT = kvm
-
-MODSRCS = xpv_psm.c intr_common.c
-
-include ../../../../../Makefile.cmd
-include ../../../../../Makefile.cmd.64
-include ../../../../intel/Makefile.amd64
-include ../../../Makefile.i86xpv
-include ../../../../Makefile.module
-
-MODSRCS_DIR = ../../../../i86pc/modules/common
-
-CPPFLAGS += -DMP -D_MACHDEP -D__xen
-CPPFLAGS += -I../../../../common
-CPPFLAGS += -I../../../../i86pc/modules/common
-CPPFLAGS += -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/uts/i86xpv
-CPPFLAGS += -I$(SRC)/uts/i86pc
-CPPFLAGS += -I$(SRC)/uts/intel
-
-CERRWARN += -_gcc=-Wno-unused-function
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_psm/xpv_psm.c	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,536 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Copyright (c) 2013 by Delphix. All rights reserved.
- */
-
-#include <mdb/mdb_modapi.h>
-#include <mdb/mdb_ks.h>
-#include <mdb/mdb_ctf.h>
-#include <sys/evtchn_impl.h>
-#include <errno.h>
-#include <sys/xc_levels.h>
-
-#include "intr_common.h"
-
-typedef struct mdb_shared_info {
-	unsigned long evtchn_pending[sizeof (unsigned long) * NBBY];
-	unsigned long evtchn_mask[sizeof (unsigned long) * NBBY];
-} mdb_shared_info_t;
-
-static mdb_shared_info_t shared_info;
-static int have_shared_info;
-static uintptr_t evtchn_cpus_addr;
-static struct av_head avec_tbl[NR_IRQS];
-static irq_info_t irq_tbl[NR_IRQS];
-static mec_info_t ipi_tbl[MAXIPL];
-static mec_info_t virq_tbl[NR_VIRQS];
-static short evtchn_tbl[NR_EVENT_CHANNELS];
-static apic_irq_t *apic_irq_tbl[APIC_MAX_VECTOR+1];
-static char level_tbl[APIC_MAX_VECTOR+1];
-
-static int
-update_tables(void)
-{
-	GElf_Sym sym;
-	uintptr_t shared_info_addr;
-
-	if (mdb_readvar(&irq_tbl, "irq_info") == -1) {
-		mdb_warn("failed to read irq_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&ipi_tbl, "ipi_info") == -1) {
-		mdb_warn("failed to read ipi_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&avec_tbl, "autovect") == -1) {
-		mdb_warn("failed to read autovect");
-		return (0);
-	}
-
-	if (mdb_readvar(&irq_tbl, "irq_info") == -1) {
-		mdb_warn("failed to read irq_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&ipi_tbl, "ipi_info") == -1) {
-		mdb_warn("failed to read ipi_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&virq_tbl, "virq_info") == -1) {
-		mdb_warn("failed to read virq_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&evtchn_tbl, "evtchn_to_irq") == -1) {
-		mdb_warn("failed to read evtchn_to_irq");
-		return (0);
-	}
-
-	if (mdb_readvar(&apic_irq_tbl, "apic_irq_table") == -1) {
-		mdb_warn("failed to read apic_irq_table");
-		return (0);
-	}
-
-	if (mdb_readvar(&level_tbl, "apic_level_intr") == -1) {
-		mdb_warn("failed to read apic_level_intr");
-		return (0);
-	}
-
-	if (mdb_lookup_by_name("evtchn_cpus", &sym) == -1) {
-		mdb_warn("failed to lookup evtchn_cpus");
-		return (0);
-	}
-
-	evtchn_cpus_addr = sym.st_value;
-
-	if (mdb_readvar(&shared_info_addr, "HYPERVISOR_shared_info") == -1) {
-		mdb_warn("failed to read HYPERVISOR_shared_info");
-		return (0);
-	}
-
-	/*
-	 * It's normal for this to fail with a domain dump.
-	 */
-	if (mdb_ctf_vread(&shared_info, "shared_info_t", "mdb_shared_info_t",
-	    shared_info_addr, MDB_CTF_VREAD_QUIET) != -1)
-		have_shared_info = 1;
-
-	return (1);
-}
-
-static const char *
-virq_type(int irq)
-{
-	int i;
-
-	for (i = 0; i < NR_VIRQS; i++) {
-		if (virq_tbl[i].mi_irq == irq)
-			break;
-	}
-
-	switch (i) {
-	case VIRQ_TIMER:
-		return ("virq:timer");
-	case VIRQ_DEBUG:
-		return ("virq:debug");
-	case VIRQ_CONSOLE:
-		return ("virq:console");
-	case VIRQ_DOM_EXC:
-		return ("virq:dom exc");
-	case VIRQ_DEBUGGER:
-		return ("virq:debugger");
-	case VIRQ_MCA:
-		return ("virq:mca");
-	default:
-		break;
-	}
-
-	return ("virq:?");
-}
-
-static const char *
-irq_type(int irq, int extended)
-{
-	switch (irq_tbl[irq].ii_type) {
-	case IRQT_UNBOUND:
-		return ("unset");
-	case IRQT_PIRQ:
-		return ("pirq");
-	case IRQT_VIRQ:
-		if (extended)
-			return (virq_type(irq));
-		return ("virq");
-	case IRQT_IPI:
-		return ("ipi");
-	case IRQT_EVTCHN:
-		return ("evtchn");
-	case IRQT_DEV_EVTCHN:
-		return ("device");
-	}
-
-	return ("?");
-}
-
-/*
- * We need a non-trivial IPL lookup as the CPU poke's IRQ doesn't have ii_ipl
- * set -- see evtchn.h.
- */
-static int
-irq_ipl(int irq)
-{
-	int i;
-
-	if (irq_tbl[irq].ii_u2.ipl != 0)
-		return (irq_tbl[irq].ii_u2.ipl);
-
-	for (i = 0; i < MAXIPL; i++) {
-		if (ipi_tbl[i].mi_irq == irq) {
-			return (i);
-		}
-	}
-
-	return (0);
-}
-
-static void
-print_cpu(irq_info_t *irqp, int evtchn)
-{
-	size_t cpuset_size = BT_BITOUL(NCPU) * sizeof (ulong_t);
-	int cpu;
-
-	if (irqp != NULL) {
-		switch (irqp->ii_type) {
-		case IRQT_VIRQ:
-		case IRQT_IPI:
-			mdb_printf("all ");
-			return;
-
-		case IRQT_DEV_EVTCHN:
-			mdb_printf("0   ");
-			return;
-
-		default:
-			break;
-		}
-	}
-
-	if (evtchn >= NR_EVENT_CHANNELS || evtchn == 0) {
-		mdb_printf("-   ");
-		return;
-	}
-
-	cpu = mdb_cpuset_find(evtchn_cpus_addr +
-	    (cpuset_size * evtchn));
-
-	/*
-	 * XXPV: we should verify this against the CPU's mask and show
-	 * something if they don't match.
-	 */
-	mdb_printf("%-4d", cpu);
-}
-
-static void
-print_isr(int i)
-{
-	if (avec_tbl[i].avh_link != NULL) {
-		struct autovec avhp;
-
-		(void) mdb_vread(&avhp, sizeof (struct autovec),
-		    (uintptr_t)avec_tbl[i].avh_link);
-
-		interrupt_print_isr((uintptr_t)avhp.av_vector,
-		    (uintptr_t)avhp.av_intarg1, (uintptr_t)avhp.av_dip);
-	} else if (irq_ipl(i) == XC_CPUPOKE_PIL) {
-		mdb_printf("poke_cpu");
-	}
-}
-
-static int
-evtchn_masked(int i)
-{
-	return (!!TEST_EVTCHN_BIT(i, &shared_info.evtchn_mask[0]));
-}
-
-static int
-evtchn_pending(int i)
-{
-	return (!!TEST_EVTCHN_BIT(i, &shared_info.evtchn_pending[0]));
-}
-
-typedef struct mdb_xpv_psm_autovec {
-	dev_info_t *av_dip;
-} mdb_xpv_psm_autovec_t;
-
-static void
-print_bus(int irq)
-{
-	char parent[7];
-	uintptr_t dip_addr;
-	struct dev_info	dev_info;
-	mdb_xpv_psm_autovec_t avhp;
-
-	if (mdb_ctf_vread(&avhp, "struct autovec", "mdb_xpv_psm_autovec_t",
-	    (uintptr_t)avec_tbl[irq].avh_link, MDB_CTF_VREAD_QUIET) == -1)
-		goto fail;
-
-	dip_addr = (uintptr_t)avhp.av_dip;
-
-	if (dip_addr == NULL)
-		goto fail;
-
-	/*
-	 * Sigh.  As a result of the perennial confusion of how you do opaque
-	 * handles, dev_info_t has a funny old type, which means we can't use
-	 * mdb_ctf_vread() here.
-	 */
-
-	if (mdb_vread(&dev_info, sizeof (struct dev_info), dip_addr) == -1)
-		goto fail;
-
-	dip_addr = (uintptr_t)dev_info.devi_parent;
-
-	if (mdb_vread(&dev_info, sizeof (struct dev_info), dip_addr) == -1)
-		goto fail;
-
-	if (mdb_readstr(parent, 7, (uintptr_t)dev_info.devi_node_name) == -1)
-		goto fail;
-
-	mdb_printf("%-6s ", parent);
-	return;
-
-fail:
-	mdb_printf("-      ");
-}
-
-static void
-ec_interrupt_dump(int i)
-{
-	irq_info_t *irqp = &irq_tbl[i];
-	char evtchn[8];
-
-	if (irqp->ii_type == IRQT_UNBOUND)
-		return;
-
-	if (option_flags & INTR_DISPLAY_INTRSTAT) {
-		print_cpu(irqp, irqp->ii_u.evtchn);
-		print_isr(i);
-		mdb_printf("\n");
-		return;
-	}
-
-	switch (irqp->ii_type) {
-	case IRQT_EVTCHN:
-	case IRQT_VIRQ:
-		if (irqp->ii_u.index == VIRQ_TIMER) {
-			strcpy(evtchn, "T");
-		} else {
-			mdb_snprintf(evtchn, sizeof (evtchn), "%-7d",
-			    irqp->ii_u.evtchn);
-		}
-		break;
-	case IRQT_IPI:
-		strcpy(evtchn, "I");
-		break;
-	case IRQT_DEV_EVTCHN:
-		strcpy(evtchn, "D");
-		break;
-	}
-
-	/* IRQ */
-	mdb_printf("%3d  ", i);
-	/* Vector */
-	mdb_printf("-    ");
-	/* Evtchn */
-	mdb_printf("%-7s", evtchn);
-	/* IPL */
-	mdb_printf("%-4d", irq_ipl(i));
-	/* Bus */
-	print_bus(i);
-	/* Trigger */
-	mdb_printf("%-4s", "Edg");
-	/* Type */
-	mdb_printf("%-7s", irq_type(i, 0));
-	/* CPU */
-	print_cpu(irqp, irqp->ii_u.evtchn);
-	/* Share */
-	mdb_printf("-     ");
-	/* APIC/INT# */
-	mdb_printf("-         ");
-
-	print_isr(i);
-
-	mdb_printf("\n");
-}
-
-/* ARGSUSED */
-static int
-interrupts_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
-	int i;
-
-	option_flags = 0;
-	if (mdb_getopts(argc, argv,
-	    'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
-	    'i', MDB_OPT_SETBITS, INTR_DISPLAY_INTRSTAT, &option_flags,
-	    NULL) != argc)
-		return (DCMD_USAGE);
-
-	if (!update_tables())
-		return (DCMD_ERR);
-
-	if (option_flags & INTR_DISPLAY_INTRSTAT) {
-		mdb_printf("%<u>CPU ");
-	} else {
-		mdb_printf("%<u>IRQ  Vect Evtchn IPL Bus    Trg Type   "
-		    "CPU Share APIC/INT# ");
-	}
-	mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
-	    "Driver Name(s)" : "ISR(s)");
-
-	for (i = 0; i < NR_IRQS; i++) {
-		if (irq_tbl[i].ii_type == IRQT_PIRQ) {
-			apic_irq_t airq;
-
-			if (irq_tbl[i].ii_u.evtchn == 0)
-				continue;
-
-			if (mdb_vread(&airq, sizeof (apic_irq_t),
-			    (uintptr_t)apic_irq_tbl[i]) == -1)
-				continue;
-
-			apic_interrupt_dump(&airq, &avec_tbl[i], i,
-			    &irq_tbl[i].ii_u.evtchn, level_tbl[i]);
-			continue;
-		}
-
-		ec_interrupt_dump(i);
-	}
-
-	return (DCMD_OK);
-}
-
-static void
-evtchn_dump(int i)
-{
-	int irq = evtchn_tbl[i];
-
-	if (irq == INVALID_IRQ) {
-		mdb_printf("%-14s%-7d%-4s%-4s", "unassigned", i, "-", "-");
-		print_cpu(NULL, i);
-		if (have_shared_info) {
-			mdb_printf("%-7d", evtchn_masked(i));
-			mdb_printf("%-8d", evtchn_pending(i));
-		}
-		mdb_printf("\n");
-		return;
-	}
-
-	/* Type */
-	mdb_printf("%-14s", irq_type(irq, 1));
-	/* Evtchn */
-	mdb_printf("%-7d", i);
-	/* IRQ */
-	mdb_printf("%-4d", irq);
-	/* IPL */
-	mdb_printf("%-4d", irq_ipl(irq));
-	/* CPU */
-	print_cpu(NULL, i);
-	if (have_shared_info) {
-		/* Masked/Pending */
-		mdb_printf("%-7d", evtchn_masked(i));
-		mdb_printf("%-8d", evtchn_pending(i));
-	}
-	/* ISR */
-	print_isr(irq);
-
-	mdb_printf("\n");
-}
-
-/* ARGSUSED */
-static int
-evtchns_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
-	int i;
-
-	option_flags = 0;
-	if (mdb_getopts(argc, argv,
-	    'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
-	    NULL) != argc)
-		return (DCMD_USAGE);
-
-	if (!update_tables())
-		return (DCMD_ERR);
-
-	if (flags & DCMD_ADDRSPEC) {
-		/*
-		 * Note: we allow the invalid evtchn 0, as it can help catch if
-		 * we incorrectly try to configure it.
-		 */
-		if ((int)addr >= NR_EVENT_CHANNELS) {
-			mdb_warn("Invalid event channel %d.\n", (int)addr);
-			return (DCMD_ERR);
-		}
-	}
-
-	mdb_printf("%<u>Type          Evtchn IRQ IPL CPU ");
-	if (have_shared_info)
-		mdb_printf("Masked Pending ");
-
-	mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
-	    "Driver Name(s)" : "ISR(s)");
-
-	if (flags & DCMD_ADDRSPEC) {
-		evtchn_dump((int)addr);
-		return (DCMD_OK);
-	}
-
-	for (i = 0; i < NR_EVENT_CHANNELS; i++) {
-		if (evtchn_tbl[i] == INVALID_IRQ)
-			continue;
-
-		evtchn_dump(i);
-	}
-
-	return (DCMD_OK);
-}
-
-static void
-evtchns_help(void)
-{
-	mdb_printf("Print valid event channels\n"
-	    "If %<u>addr%</u> is given, interpret it as an evtchn to print "
-	    "details of.\n"
-	    "By default, only interrupt service routine names are printed.\n\n"
-	    "Switches:\n"
-	    "  -d   instead of ISR, print <driver_name><instance#>\n");
-}
-
-static const mdb_dcmd_t dcmds[] = {
-	{ "interrupts", "?[-di]", "print interrupts", interrupts_dump,
-	    interrupt_help },
-	{ "evtchns", "?[-d]", "print event channels", evtchns_dump,
-	    evtchns_help },
-	{ "softint", "?[-d]", "print soft interrupts", soft_interrupt_dump,
-	    soft_interrupt_help},
-	{ NULL }
-};
-
-static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, NULL };
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
-	GElf_Sym sym;
-
-	if (mdb_lookup_by_name("gld_intr", &sym) != -1)
-		if (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
-			gld_intr_addr = (uintptr_t)sym.st_value;
-
-	return (&modinfo);
-}
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_uppc/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,28 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-$(BUILD64)SUBDIRS += 	$(MACH64)
-include ../../../Makefile.subdirs
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_uppc/amd64/Makefile	Fri Aug 10 23:19:11 2018
+++ /dev/null	Fri Aug 10 23:19:11 2018
@@ -1,48 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-
-MODULE = xpv_uppc.so
-MDBTGT = kvm
-
-MODSRCS = xpv_uppc.c intr_common.c
-
-include ../../../../../Makefile.cmd
-include ../../../../../Makefile.cmd.64
-include ../../../../intel/Makefile.amd64
-include ../../../Makefile.i86xpv
-include ../../../../Makefile.module
-
-MODSRCS_DIR = ../../../../i86pc/modules/common
-
-CPPFLAGS += -DMP -D_MACHDEP -D__xen
-CPPFLAGS += -I../../../../common
-CPPFLAGS += -I../../../../i86pc/modules/common
-CPPFLAGS += -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/uts/i86xpv
-CPPFLAGS += -I$(SRC)/uts/i86pc
-CPPFLAGS += -I$(SRC)/uts/intel
-
-CERRWARN += -_gcc=-Wno-unused-function
--- old/usr/src/cmd/mdb/i86xpv/modules/xpv_uppc/xpv_uppc.c	Fri Aug 10 23:19:12 2018
+++ /dev/null	Fri Aug 10 23:19:12 2018
@@ -1,496 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Copyright (c) 2013 by Delphix. All rights reserved.
- */
-
-#include <mdb/mdb_modapi.h>
-#include <mdb/mdb_ks.h>
-#include <mdb/mdb_ctf.h>
-#include <sys/evtchn_impl.h>
-
-#include "intr_common.h"
-
-typedef struct mdb_shared_info {
-	unsigned long evtchn_pending[sizeof (unsigned long) * NBBY];
-	unsigned long evtchn_mask[sizeof (unsigned long) * NBBY];
-} mdb_shared_info_t;
-
-static mdb_shared_info_t	shared_info;
-static struct av_head	avec_tbl[NR_IRQS];
-static uint16_t		shared_tbl[MAX_ISA_IRQ + 1];
-static irq_info_t	irq_tbl[NR_IRQS];
-static mec_info_t	virq_tbl[NR_VIRQS];
-static short		evtchn_tbl[NR_EVENT_CHANNELS];
-
-static int
-update_tables(void)
-{
-	uintptr_t shared_info_addr;
-
-	if (mdb_readvar(&irq_tbl, "irq_info") == -1) {
-		mdb_warn("failed to read irq_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&virq_tbl, "virq_info") == -1) {
-		mdb_warn("failed to read virq_info");
-		return (0);
-	}
-
-	if (mdb_readvar(&evtchn_tbl, "evtchn_to_irq") == -1) {
-		mdb_warn("failed to read evtchn_to_irq");
-		return (0);
-	}
-
-	if (mdb_readvar(&avec_tbl, "autovect") == -1) {
-		mdb_warn("failed to read autovect");
-		return (0);
-	}
-
-	if (mdb_readvar(&shared_tbl, "xen_uppc_irq_shared_table") == -1) {
-		mdb_warn("failed to read xen_uppc_irq_shared_table");
-		return (0);
-	}
-
-	if (mdb_readvar(&shared_info_addr, "HYPERVISOR_shared_info") == -1) {
-		mdb_warn("failed to read HYPERVISOR_shared_info");
-		return (0);
-	}
-
-	if (mdb_ctf_vread(&shared_info, "shared_info_t", "mdb_shared_info_t",
-	    shared_info_addr, 0) == -1)
-		return (0);
-
-	return (1);
-}
-
-
-static char *
-interrupt_print_bus(uintptr_t dip_addr)
-{
-	char		bind_name[MAXPATHLEN + 1];
-	struct dev_info	dev_info;
-
-	if (mdb_vread(&dev_info, sizeof (dev_info), dip_addr) == -1) {
-		mdb_warn("failed to read child dip");
-		return ("-");
-	}
-
-	while (dev_info.devi_parent != 0) {
-		if (mdb_vread(&dev_info, sizeof (dev_info),
-		    (uintptr_t)dev_info.devi_parent) == -1)
-			break;
-
-		(void) mdb_readstr(bind_name, sizeof (bind_name),
-		    (uintptr_t)dev_info.devi_binding_name);
-		if (strcmp(bind_name, "isa") == 0)
-			return ("ISA");
-		else if (strcmp(bind_name, "pci") == 0 ||
-		    strcmp(bind_name, "npe") == 0)
-			return ("PCI");
-	}
-	return ("-");
-}
-
-static const char *
-virq_type(int irq)
-{
-	int i;
-
-	for (i = 0; i < NR_VIRQS; i++) {
-		if (virq_tbl[i].mi_irq == irq)
-			break;
-	}
-
-	switch (i) {
-	case VIRQ_TIMER:
-		return ("virq:timer");
-	case VIRQ_DEBUG:
-		return ("virq:debug");
-	case VIRQ_CONSOLE:
-		return ("virq:console");
-	case VIRQ_DOM_EXC:
-		return ("virq:dom exc");
-	case VIRQ_DEBUGGER:
-		return ("virq:debugger");
-	default:
-		break;
-	}
-
-	return ("virq:?");
-}
-
-static const char *
-irq_type(int irq, int extended)
-{
-	switch (irq_tbl[irq].ii_type) {
-	case IRQT_UNBOUND:
-		return ("unset");
-	case IRQT_PIRQ:
-		return ("pirq");
-	case IRQT_VIRQ:
-		if (extended)
-			return (virq_type(irq));
-		return ("virq");
-	case IRQT_IPI:
-		return ("ipi");
-	case IRQT_EVTCHN:
-		return ("evtchn");
-	case IRQT_DEV_EVTCHN:
-		return ("device");
-	}
-
-	return ("?");
-}
-
-static void
-print_isr(int i)
-{
-	struct autovec avhp;
-
-	if (avec_tbl[i].avh_link == NULL)
-		return;
-
-	(void) mdb_vread(&avhp, sizeof (struct autovec),
-	    (uintptr_t)avec_tbl[i].avh_link);
-
-	interrupt_print_isr((uintptr_t)avhp.av_vector,
-	    (uintptr_t)avhp.av_intarg1, (uintptr_t)avhp.av_dip);
-
-	while (avhp.av_link != NULL &&
-	    mdb_vread(&avhp, sizeof (struct autovec),
-	    (uintptr_t)avhp.av_link) != -1) {
-		mdb_printf(", ");
-		interrupt_print_isr((uintptr_t)avhp.av_vector,
-		    (uintptr_t)avhp.av_intarg1, (uintptr_t)avhp.av_dip);
-	}
-}
-
-static int
-evtchn_masked(int i)
-{
-	return (TEST_EVTCHN_BIT(i, &shared_info.evtchn_mask[0]) != 0);
-}
-
-static int
-evtchn_pending(int i)
-{
-	return (TEST_EVTCHN_BIT(i, &shared_info.evtchn_pending[0]) != 0);
-}
-
-static void
-pic_interrupt_dump(int i, struct autovec *avhp, int evtchn)
-{
-	if (option_flags & INTR_DISPLAY_INTRSTAT) {
-		mdb_printf("%-3d ", 0);
-		print_isr(i);
-		mdb_printf("\n");
-		return;
-	}
-
-	mdb_printf("%-3d  0x%2x %-6d %6d/%-2d  %-3s %-6s %-5d ",
-	    i, i + PIC_VECTBASE, evtchn, avec_tbl[i].avh_lo_pri,
-	    avec_tbl[i].avh_hi_pri, avhp->av_dip ?
-	    interrupt_print_bus((uintptr_t)avhp->av_dip) : "-",
-	    irq_type(i, 0), shared_tbl[i]);
-
-	print_isr(i);
-
-	mdb_printf("\n");
-}
-
-static void
-ec_interrupt_dump(int i)
-{
-	irq_info_t *irqp = &irq_tbl[i];
-	struct autovec avhp;
-	char evtchn[8];
-
-	if (irqp->ii_type == IRQT_UNBOUND)
-		return;
-
-	if (option_flags & INTR_DISPLAY_INTRSTAT) {
-		mdb_printf("%-3d ", 0);
-		print_isr(i);
-		mdb_printf("\n");
-		return;
-	}
-
-
-	memset(&avhp, 0, sizeof (avhp));
-	if (avec_tbl[i].avh_link != NULL)
-		(void) mdb_vread(&avhp, sizeof (struct autovec),
-		    (uintptr_t)avec_tbl[i].avh_link);
-
-	switch (irqp->ii_type) {
-	case IRQT_EVTCHN:
-	case IRQT_VIRQ:
-		if (irqp->ii_u.index == VIRQ_TIMER) {
-			strcpy(evtchn, "T");
-		} else {
-			mdb_snprintf(evtchn, sizeof (evtchn), "%-7d",
-			    irqp->ii_u.evtchn);
-		}
-		break;
-	case IRQT_IPI:
-		strcpy(evtchn, "I");
-		break;
-	case IRQT_DEV_EVTCHN:
-		strcpy(evtchn, "D");
-		break;
-	}
-
-	/* IRQ */
-	mdb_printf("%3d  ", i);
-	/* Vector */
-	mdb_printf("-    ");
-	/* Evtchn */
-	mdb_printf("%-7s", evtchn);
-	/* IPL */
-	mdb_printf("%6d/%-2d  ", irq_tbl[i].ii_u2.ipl, irq_tbl[i].ii_u2.ipl);
-	/* Bus */
-	mdb_printf("%-3s ", avhp.av_dip
-	    ? interrupt_print_bus((uintptr_t)avhp.av_dip) : "-");
-	/* Type */
-	mdb_printf("%-6s ", irq_type(i, 0));
-	/* Share */
-	mdb_printf("-     ");
-
-	print_isr(i);
-
-	mdb_printf("\n");
-}
-
-/*
- * uppc_interrupt_dump:
- *	Dump uppc(7d) interrupt information.
- */
-/* ARGSUSED */
-int
-xen_uppc_interrupt_dump(uintptr_t addr, uint_t flags, int argc,
-    const mdb_arg_t *argv)
-{
-	int		i;
-	boolean_t	found = B_FALSE;
-	struct autovec	avhp;
-
-	option_flags = 0;
-	if (mdb_getopts(argc, argv,
-	    'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
-	    'i', MDB_OPT_SETBITS, INTR_DISPLAY_INTRSTAT, &option_flags,
-	    NULL) != argc)
-		return (DCMD_USAGE);
-
-	if (!update_tables())
-		return (DCMD_ERR);
-
-	/*
-	 * By default, on all x86 systems ::interrupts from xen_uppc(7d) gets
-	 * loaded first. For APIC systems the ::interrupts from xpv_psm(7d)
-	 * ought to be executed. Confusion stems as both modules export the
-	 * same dcmd.
-	 */
-	for (i = 0; i < MAX_ISA_IRQ + 1; i++)
-		if (shared_tbl[i]) {
-			found = B_TRUE;
-			break;
-		}
-
-	if (found == B_FALSE) {
-		if (mdb_lookup_by_obj("xpv_psm", "apic_irq_table",
-		    NULL) == 0) {
-			return (mdb_call_dcmd("xpv_psm`interrupts",
-			    addr, flags, argc, argv));
-		}
-	}
-
-	/* Print the header first */
-	if (option_flags & INTR_DISPLAY_INTRSTAT)
-		mdb_printf("%<u>CPU ");
-	else
-		mdb_printf("%<u>IRQ  Vect Evtchn IPL(lo/hi) Bus Type   Share ");
-	mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
-	    "Driver Name(s)" : "ISR(s)");
-
-	for (i = 0; i < NR_IRQS; i++) {
-		if (irq_tbl[i].ii_type == IRQT_PIRQ) {
-			if (irq_tbl[i].ii_u.evtchn == 0)
-				continue;
-
-			/* Read the entry, if invalid continue */
-			if (mdb_vread(&avhp, sizeof (struct autovec),
-			    (uintptr_t)avec_tbl[i].avh_link) == -1)
-				continue;
-
-			pic_interrupt_dump(i, &avhp, irq_tbl[i].ii_u.evtchn);
-			continue;
-		}
-
-		ec_interrupt_dump(i);
-	}
-
-	return (DCMD_OK);
-}
-
-
-static void
-evtchn_dump(int i)
-{
-	int irq = evtchn_tbl[i];
-
-	if (irq == INVALID_IRQ) {
-		mdb_printf("%-14s%-7d%-4s%-7s", "unassigned", i, "-", "-");
-		mdb_printf("%-4d", 0);
-		mdb_printf("%-7d", evtchn_masked(i));
-		mdb_printf("%-8d", evtchn_pending(i));
-		mdb_printf("\n");
-		return;
-	}
-
-	/* Type */
-	mdb_printf("%-14s", irq_type(irq, 1));
-	/* Evtchn */
-	mdb_printf("%-7d", i);
-	/* IRQ */
-	mdb_printf("%-4d", irq);
-	/* IPL */
-	mdb_printf("%6d/%-2d  ", irq_tbl[irq].ii_u2.ipl,
-	    irq_tbl[irq].ii_u2.ipl);
-	/* CPU */
-	mdb_printf("%-4d", 0);
-	/* Masked/Pending */
-	mdb_printf("%-7d", evtchn_masked(i));
-	mdb_printf("%-8d", evtchn_pending(i));
-	/* ISR */
-	print_isr(irq);
-
-	mdb_printf("\n");
-}
-
-/* ARGSUSED */
-static int
-evtchns_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
-	int		i;
-	boolean_t	found = B_FALSE;
-
-	option_flags = 0;
-	if (mdb_getopts(argc, argv,
-	    'd', MDB_OPT_SETBITS, INTR_DISPLAY_DRVR_INST, &option_flags,
-	    NULL) != argc)
-		return (DCMD_USAGE);
-
-	if (!update_tables())
-		return (DCMD_ERR);
-
-	/*
-	 * By default, on all x86 systems ::evtchns from xen_uppc(7d) gets
-	 * loaded first. For APIC systems the ::evtchns from xpv_psm(7d)
-	 * ought to be executed. Confusion stems as both modules export the
-	 * same dcmd.
-	 */
-	for (i = 0; i < MAX_ISA_IRQ + 1; i++)
-		if (shared_tbl[i]) {
-			found = B_TRUE;
-			break;
-		}
-
-	if (found == B_FALSE) {
-		if (mdb_lookup_by_obj("xpv_psm", "apic_irq_table",
-		    NULL) == 0) {
-			return (mdb_call_dcmd("xpv_psm`evtchns",
-			    addr, flags, argc, argv));
-		}
-	}
-
-	if (flags & DCMD_ADDRSPEC) {
-		/*
-		 * Note: we allow the invalid evtchn 0, as it can help catch if
-		 * we incorrectly try to configure it.
-		 */
-		if ((int)addr >= NR_EVENT_CHANNELS) {
-			mdb_warn("Invalid event channel %d.\n", (int)addr);
-			return (DCMD_ERR);
-		}
-	}
-
-	mdb_printf("%<u>Type          Evtchn IRQ IPL(lo/hi) CPU "
-	    "Masked Pending ");
-	mdb_printf("%s %</u>\n", option_flags & INTR_DISPLAY_DRVR_INST ?
-	    "Driver Name(s)" : "ISR(s)");
-
-	if (flags & DCMD_ADDRSPEC) {
-		evtchn_dump((int)addr);
-		return (DCMD_OK);
-	}
-
-	for (i = 0; i < NR_EVENT_CHANNELS; i++) {
-		if (evtchn_tbl[i] == INVALID_IRQ)
-			continue;
-
-		evtchn_dump(i);
-	}
-
-	return (DCMD_OK);
-}
-
-static void
-evtchns_help(void)
-{
-	mdb_printf("Print valid event channels\n"
-	    "If %<u>addr%</u> is given, interpret it as an evtchn to print "
-	    "details of.\n"
-	    "By default, only interrupt service routine names are printed.\n\n"
-	    "Switches:\n"
-	    "  -d   instead of ISR, print <driver_name><instance#>\n");
-}
-
-/*
- * MDB module linkage information:
- */
-static const mdb_dcmd_t dcmds[] = {
-	{ "interrupts", "?[-di]", "print interrupts", xen_uppc_interrupt_dump,
-	    interrupt_help},
-	{ "evtchns", "?[-d]", "print event channels", evtchns_dump,
-	    evtchns_help },
-	{ "softint", "?[-d]", "print soft interrupts", soft_interrupt_dump,
-	    soft_interrupt_help},
-	{ NULL }
-};
-
-static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, NULL };
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
-	GElf_Sym	sym;
-
-	if (mdb_lookup_by_name("gld_intr", &sym) != -1)
-		if (GELF_ST_TYPE(sym.st_info) == STT_FUNC)
-			gld_intr_addr = (uintptr_t)sym.st_value;
-
-	return (&modinfo);
-}
--- old/usr/src/cmd/mdb/intel/modules/Makefile	Fri Aug 10 23:19:12 2018
+++ new/usr/src/cmd/mdb/intel/modules/Makefile	Fri Aug 10 23:19:12 2018
@@ -18,14 +18,16 @@
 #
 # CDDL HEADER END
 #
+
 #
 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 # Use is subject to license terms.
 #
-SUBDIRS = mdb_kb \
-	i40e \
-	generic_cpu \
+
+SUBDIRS= \
 	amd_opteron \
+	generic_cpu \
+	i40e \
 	sata \
 	xhci
 
--- old/usr/src/cmd/mdb/intel/modules/mdb_kb/Makefile	Fri Aug 10 23:19:12 2018
+++ /dev/null	Fri Aug 10 23:19:12 2018
@@ -1,28 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-$(BUILD64)SUBDIRS += 	$(MACH64)
-include ../../../Makefile.subdirs
--- old/usr/src/cmd/mdb/intel/modules/mdb_kb/amd64/Makefile	Fri Aug 10 23:19:12 2018
+++ /dev/null	Fri Aug 10 23:19:12 2018
@@ -1,46 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-MODULE = mdb_kb.so
-MDBTGT = kvm
-MODULE_BUILD_TYPE = mdb
-
-MODSRCS = mdb_kb.c
-
-include ../../../../../Makefile.cmd
-include ../../../../../Makefile.cmd.64
-include ../../../../intel/Makefile.amd64
-include ../../../../Makefile.module
-
-CSTD=	$(CSTD_GNU99)
-C99LMODE=	-Xc99=%all
-
-CPPFLAGS += -DMP -D_MACHDEP -D_MDB -D__xpv
-CPPFLAGS += -U_KERNEL -D_KMEMUSER
-CPPFLAGS += -I../../../../common
-CPPFLAGS += -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/uts/i86pc
-CPPFLAGS += -I$(SRC)/uts/i86xpv
-CPPFLAGS += -I$(SRC)/uts/intel
--- old/usr/src/cmd/mdb/intel/modules/mdb_kb/mdb_kb.c	Fri Aug 10 23:19:12 2018
+++ /dev/null	Fri Aug 10 23:19:12 2018
@@ -1,1607 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * KVM backend for hypervisor domain dumps.  We don't use libkvm for
- * such dumps, since they do not have a namelist file or the typical
- * dump structures we expect to aid bootstrapping.  Instead, we
- * bootstrap based upon a debug_info structure at a known VA, using the
- * guest's own page tables to resolve to physical addresses, and
- * construct the namelist in a manner similar to ksyms_snapshot().
- *
- * Note that there are two formats understood by this module: the older,
- * ad hoc format, which we call 'core' within this file, and an
- * ELF-based format, known as 'elf'.
- *
- * We only support the older format generated on Solaris dom0: before we
- * fixed it, core dump files were broken whenever a PFN didn't map a
- * real MFN (!).
- */
-
-#include <strings.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <gelf.h>
-#include <errno.h>
-
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/debug_info.h>
-#include <sys/xen_mmu.h>
-#include <sys/elf.h>
-#include <sys/machelf.h>
-#include <sys/modctl.h>
-#include <sys/kobj.h>
-#include <sys/kobj_impl.h>
-#include <sys/sysmacros.h>
-#include <sys/privmregs.h>
-#include <vm/as.h>
-
-#include <mdb/mdb_io.h>
-#include <mdb/mdb_kb.h>
-#include <mdb/mdb_target_impl.h>
-
-#include <xen/public/xen.h>
-#include <xen/public/version.h>
-#include <xen/public/elfnote.h>
-
-#define	XKB_SHDR_NULL 0
-#define	XKB_SHDR_SYMTAB 1
-#define	XKB_SHDR_STRTAB 2
-#define	XKB_SHDR_SHSTRTAB 3
-#define	XKB_SHDR_NUM 4
-
-#define	XKB_WALK_LOCAL 0x1
-#define	XKB_WALK_GLOBAL 0x2
-#define	XKB_WALK_STR 0x4
-#define	XKB_WALK_ALL (XKB_WALK_LOCAL | XKB_WALK_GLOBAL | XKB_WALK_STR)
-
-#if defined(__i386)
-#define	DEBUG_INFO 0xf4bff000
-#define	DEBUG_INFO_HVM 0xfe7ff000
-#elif defined(__amd64)
-#define	DEBUG_INFO 0xfffffffffb7ff000
-#define	DEBUG_INFO_HVM 0xfffffffffb7ff000
-#endif
-
-#define	PAGE_SIZE 0x1000
-#define	PAGE_SHIFT 12
-#define	PAGE_OFFSET(a) ((a) & (PAGE_SIZE - 1))
-#define	PAGE_MASK(a) ((a) & ~(PAGE_SIZE - 1))
-#define	PAGE_ALIGNED(a) (((a) & (PAGE_SIZE -1)) == 0)
-#define	PT_PADDR_LGPG 0x000fffffffffe000ull
-#define	PT_PADDR 0x000ffffffffff000ull
-#define	PT_VALID 0x1
-#define	PT_PAGESIZE 0x080
-#define	PTE_IS_LGPG(p, l) ((l) > 0 && ((p) & PT_PAGESIZE))
-
-#define	XC_CORE_MAGIC 0xF00FEBED
-#define	XC_CORE_MAGIC_HVM 0xF00FEBEE
-
-#define	VGCF_HVM_GUEST (1<<1)
-
-typedef struct xc_core_header {
-	unsigned int xch_magic;
-	unsigned int xch_nr_vcpus;
-	unsigned int xch_nr_pages;
-	unsigned int xch_ctxt_offset;
-	unsigned int xch_index_offset;
-	unsigned int xch_pages_offset;
-} xc_core_header_t;
-
-struct xc_elf_header {
-	uint64_t xeh_magic;
-	uint64_t xeh_nr_vcpus;
-	uint64_t xeh_nr_pages;
-	uint64_t xeh_page_size;
-};
-
-struct xc_elf_version {
-	uint64_t xev_major;
-	uint64_t xev_minor;
-	xen_extraversion_t xev_extra;
-	xen_compile_info_t xev_compile_info;
-	xen_capabilities_info_t xev_capabilities;
-	xen_changeset_info_t xev_changeset;
-	xen_platform_parameters_t xev_platform_parameters;
-	uint64_t xev_pagesize;
-};
-
-/*
- * Either an old-style (3.0.4) core format, or the ELF format.
- */
-typedef enum {
-	XKB_FORMAT_UNKNOWN = 0,
-	XKB_FORMAT_CORE = 1,
-	XKB_FORMAT_ELF = 2
-} xkb_type_t;
-
-typedef struct mfn_map {
-	mfn_t mm_mfn;
-	char *mm_map;
-} mfn_map_t;
-
-typedef struct mmu_info {
-	size_t mi_max;
-	size_t mi_shift[4];
-	size_t mi_ptes;
-	size_t mi_ptesize;
-} mmu_info_t;
-
-typedef struct xkb_core {
-	xc_core_header_t xc_hdr;
-	void *xc_p2m_buf;
-} xkb_core_t;
-
-typedef struct xkb_elf {
-	mdb_gelf_file_t *xe_gelf;
-	size_t *xe_off;
-	struct xc_elf_header xe_hdr;
-	struct xc_elf_version xe_version;
-} xkb_elf_t;
-
-typedef struct xkb {
-	char *xkb_path;
-	int xkb_fd;
-	int xkb_is_hvm;
-
-	xkb_type_t xkb_type;
-	xkb_core_t xkb_core;
-	xkb_elf_t xkb_elf;
-
-	size_t xkb_nr_vcpus;
-	size_t xkb_nr_pages;
-	size_t xkb_pages_off;
-	xen_pfn_t xkb_max_pfn;
-	mfn_t xkb_max_mfn;
-	int xkb_is_pae;
-
-	mmu_info_t xkb_mmu;
-	debug_info_t xkb_info;
-
-	void *xkb_vcpu_data;
-	size_t xkb_vcpu_data_sz;
-	struct vcpu_guest_context **xkb_vcpus;
-
-	char *xkb_pages;
-	mfn_t *xkb_p2m;
-	xen_pfn_t *xkb_m2p;
-	mfn_map_t xkb_pt_map[4];
-	mfn_map_t xkb_map;
-
-	char *xkb_namelist;
-	size_t xkb_namesize;
-} xkb_t;
-
-static const char xkb_shstrtab[] = "\0.symtab\0.strtab\0.shstrtab\0";
-
-typedef struct xkb_namelist {
-	Ehdr	kh_elf_hdr;
-	Phdr	kh_text_phdr;
-	Phdr	kh_data_phdr;
-	Shdr	kh_shdr[XKB_SHDR_NUM];
-	char	shstrings[sizeof (xkb_shstrtab)];
-} xkb_namelist_t;
-
-static int xkb_build_ksyms(xkb_t *);
-static offset_t xkb_mfn_to_offset(xkb_t *, mfn_t);
-static mfn_t xkb_va_to_mfn(xkb_t *, uintptr_t, mfn_t);
-static ssize_t xkb_read(xkb_t *, uintptr_t, void *, size_t);
-static int xkb_read_word(xkb_t *, uintptr_t, uintptr_t *);
-static char *xkb_map_mfn(xkb_t *, mfn_t, mfn_map_t *);
-static int xkb_close(xkb_t *);
-
-/*
- * Jump through the hoops we need to to correctly identify a core file
- * of either the old or new format.
- */
-int
-xkb_identify(const char *file, int *longmode)
-{
-	xc_core_header_t header;
-	mdb_gelf_file_t *gf = NULL;
-	mdb_gelf_sect_t *sect = NULL;
-	mdb_io_t *io = NULL;
-	char *notes = NULL;
-	char *pos;
-	int ret = 0;
-	size_t sz;
-	int fd;
-
-	if ((fd = open64(file, O_RDONLY)) == -1)
-		return (-1);
-
-	if (pread64(fd, &header, sizeof (header), 0) != sizeof (header)) {
-		(void) close(fd);
-		return (0);
-	}
-
-	(void) close(fd);
-
-	if (header.xch_magic == XC_CORE_MAGIC) {
-		*longmode = 0;
-
-		/*
-		 * Indeed.
-		 */
-		sz = header.xch_index_offset - header.xch_ctxt_offset;
-#ifdef _LP64
-		if (sizeof (struct vcpu_guest_context) *
-		    header.xch_nr_vcpus == sz)
-			*longmode = 1;
-#else
-		if (sizeof (struct vcpu_guest_context) *
-		    header.xch_nr_vcpus != sz)
-			*longmode = 1;
-#endif /* _LP64 */
-
-		return (1);
-	}
-
-	if ((io = mdb_fdio_create_path(NULL, file, O_RDONLY, 0)) == NULL)
-		return (-1);
-
-	if ((gf = mdb_gelf_create(io, ET_NONE, GF_FILE)) == NULL)
-		goto out;
-
-	if ((sect = mdb_gelf_sect_by_name(gf, ".note.Xen")) == NULL)
-		goto out;
-
-	if ((notes = mdb_gelf_sect_load(gf, sect)) == NULL)
-		goto out;
-
-	for (pos = notes; pos < notes + sect->gs_shdr.sh_size; ) {
-		struct xc_elf_version *vers;
-		/* LINTED - alignment */
-		Elf64_Nhdr *nhdr = (Elf64_Nhdr *)pos;
-		char *desc;
-		char *name;
-
-		name = pos + sizeof (*nhdr);
-		desc = (char *)P2ROUNDUP((uintptr_t)name + nhdr->n_namesz, 4);
-
-		pos = desc + nhdr->n_descsz;
-
-		if (nhdr->n_type != XEN_ELFNOTE_DUMPCORE_XEN_VERSION)
-			continue;
-
-		/*
-		 * The contents of this struct differ between 32 and 64
-		 * bit; however, not until past the 'xev_capabilities'
-		 * member, so we can just about get away with this.
-		 */
-
-		/* LINTED - alignment */
-		vers = (struct xc_elf_version *)desc;
-
-		if (strstr(vers->xev_capabilities, "x86_64")) {
-			/*
-			 * 64-bit hypervisor, but it can still be
-			 * a 32-bit domain core. 32-bit domain cores
-			 * are also dumped in Elf64 format, but they
-			 * have e_machine set to EM_386, not EM_AMD64.
-			 */
-			if (gf->gf_ehdr.e_machine == EM_386)
-				*longmode = 0;
-			else
-				*longmode = 1;
-		} else if (strstr(vers->xev_capabilities, "x86_32") ||
-		    strstr(vers->xev_capabilities, "x86_32p")) {
-			/*
-			 * 32-bit hypervisor, can only be a 32-bit core.
-			 */
-			*longmode = 0;
-		} else {
-			mdb_warn("couldn't derive word size of dump; "
-			    "assuming 64-bit");
-			*longmode = 1;
-		}
-	}
-
-	ret = 1;
-
-out:
-	if (gf != NULL)
-		mdb_gelf_destroy(gf);
-	else if (io != NULL)
-		mdb_io_destroy(io);
-	return (ret);
-}
-
-static void *
-xkb_fail(xkb_t *xkb, const char *msg, ...)
-{
-	va_list args;
-
-	va_start(args, msg);
-	if (xkb != NULL)
-		(void) fprintf(stderr, "%s: ", xkb->xkb_path);
-	(void) vfprintf(stderr, msg, args);
-	(void) fprintf(stderr, "\n");
-	va_end(args);
-	if (xkb != NULL)
-		(void) xkb_close(xkb);
-
-	errno = ENOEXEC;
-
-	return (NULL);
-}
-
-static int
-xkb_build_m2p(xkb_t *xkb)
-{
-	size_t i;
-
-	for (i = 0; i <= xkb->xkb_max_pfn; i++) {
-		if (xkb->xkb_p2m[i] != MFN_INVALID &&
-		    xkb->xkb_p2m[i] > xkb->xkb_max_mfn)
-			xkb->xkb_max_mfn = xkb->xkb_p2m[i];
-	}
-
-	xkb->xkb_m2p = mdb_alloc((xkb->xkb_max_mfn + 1) * sizeof (xen_pfn_t),
-	    UM_SLEEP);
-
-	for (i = 0; i <= xkb->xkb_max_mfn; i++)
-		xkb->xkb_m2p[i] = PFN_INVALID;
-
-	for (i = 0; i <= xkb->xkb_max_pfn; i++) {
-		if (xkb->xkb_p2m[i] != MFN_INVALID)
-			xkb->xkb_m2p[xkb->xkb_p2m[i]] = i;
-	}
-
-	return (1);
-}
-
-/*
- * With FORMAT_CORE, we can use the table in the dump file directly.
- * Just to make things fun, they've not page-aligned the p2m table.
- */
-static int
-xkb_map_p2m(xkb_t *xkb)
-{
-	offset_t off;
-	size_t size;
-	xkb_core_t *xc = &xkb->xkb_core;
-	size_t count = xkb->xkb_nr_pages;
-	size_t boff = xc->xc_hdr.xch_index_offset;
-
-	size = (sizeof (mfn_t) * count) + (PAGE_SIZE * 2);
-	size = PAGE_MASK(size);
-	off = PAGE_MASK(boff);
-
-	/* LINTED - alignment */
-	xc->xc_p2m_buf = (mfn_t *)mmap(NULL, size, PROT_READ,
-	    MAP_SHARED, xkb->xkb_fd, off);
-
-	if (xc->xc_p2m_buf == (xen_pfn_t *)MAP_FAILED) {
-		(void) xkb_fail(xkb, "cannot map p2m table");
-		return (0);
-	}
-
-	/* LINTED - alignment */
-	xkb->xkb_p2m = (mfn_t *)((char *)xc->xc_p2m_buf +
-	    PAGE_OFFSET(boff));
-
-	return (1);
-}
-
-/*
- * With FORMAT_ELF, we have a set of <pfn,mfn> pairs, which we convert
- * into a linear array indexed by pfn for convenience.  We also need to
- * track the mapping between mfn and the offset in the file: a pfn with
- * no mfn will not appear in the core file.
- */
-static int
-xkb_build_p2m(xkb_t *xkb)
-{
-	xkb_elf_t *xe = &xkb->xkb_elf;
-	mdb_gelf_sect_t *sect;
-	size_t size;
-	size_t i;
-
-	struct elf_p2m {
-		uint64_t pfn;
-		uint64_t gmfn;
-	} *p2m;
-
-	sect = mdb_gelf_sect_by_name(xe->xe_gelf, ".xen_p2m");
-
-	if (sect == NULL) {
-		(void) xkb_fail(xkb, "cannot find section .xen_p2m");
-		return (0);
-	}
-
-	if ((p2m = mdb_gelf_sect_load(xe->xe_gelf, sect)) == NULL) {
-		(void) xkb_fail(xkb, "couldn't read .xen_p2m");
-		return (0);
-	}
-
-	for (i = 0; i < xkb->xkb_nr_pages; i++) {
-		if (p2m[i].pfn > xkb->xkb_max_pfn)
-			xkb->xkb_max_pfn = p2m[i].pfn;
-	}
-
-	size = sizeof (xen_pfn_t) * (xkb->xkb_max_pfn + 1);
-	xkb->xkb_p2m = mdb_alloc(size, UM_SLEEP);
-	size = sizeof (size_t) * (xkb->xkb_max_pfn + 1);
-	xe->xe_off = mdb_alloc(size, UM_SLEEP);
-
-	for (i = 0; i <= xkb->xkb_max_pfn; i++) {
-		xkb->xkb_p2m[i] = PFN_INVALID;
-		xe->xe_off[i] = (size_t)-1;
-	}
-
-	for (i = 0; i < xkb->xkb_nr_pages; i++) {
-		xkb->xkb_p2m[p2m[i].pfn] = p2m[i].gmfn;
-		xe->xe_off[p2m[i].pfn] = i;
-	}
-
-	return (1);
-}
-
-/*
- * For HVM images, we don't have the corresponding MFN list; the table
- * is just a mapping from page index in the dump to the corresponding
- * PFN.  To simplify the other code, we'll pretend that these PFNs are
- * really MFNs as well, by populating xkb_p2m.
- */
-static int
-xkb_build_fake_p2m(xkb_t *xkb)
-{
-	xkb_elf_t *xe = &xkb->xkb_elf;
-	mdb_gelf_sect_t *sect;
-	size_t size;
-	size_t i;
-
-	uint64_t *p2pfn;
-
-	sect = mdb_gelf_sect_by_name(xe->xe_gelf, ".xen_pfn");
-
-	if (sect == NULL) {
-		(void) xkb_fail(xkb, "cannot find section .xen_pfn");
-		return (0);
-	}
-
-	if ((p2pfn = mdb_gelf_sect_load(xe->xe_gelf, sect)) == NULL) {
-		(void) xkb_fail(xkb, "couldn't read .xen_pfn");
-		return (0);
-	}
-
-	for (i = 0; i < xkb->xkb_nr_pages; i++) {
-		if (p2pfn[i] != PFN_INVALID && p2pfn[i] > xkb->xkb_max_pfn)
-			xkb->xkb_max_pfn = p2pfn[i];
-	}
-
-	size = sizeof (xen_pfn_t) * (xkb->xkb_max_pfn + 1);
-	xkb->xkb_p2m = mdb_alloc(size, UM_SLEEP);
-
-	size = sizeof (size_t) * (xkb->xkb_max_pfn + 1);
-	xe->xe_off = mdb_alloc(size, UM_SLEEP);
-
-	for (i = 0; i <= xkb->xkb_max_pfn; i++) {
-		xkb->xkb_p2m[i] = PFN_INVALID;
-		xe->xe_off[i] = (size_t)-1;
-	}
-
-	for (i = 0; i < xkb->xkb_nr_pages; i++) {
-		if (p2pfn[i] == PFN_INVALID)
-			continue;
-		xkb->xkb_p2m[p2pfn[i]] = p2pfn[i];
-		xe->xe_off[p2pfn[i]] = i;
-	}
-
-	return (1);
-}
-
-/*
- * Return the MFN of the top-level page table for the given as.
- */
-static mfn_t
-xkb_as_to_mfn(xkb_t *xkb, struct as *as)
-{
-	uintptr_t asp = (uintptr_t)as;
-	uintptr_t hatp;
-	uintptr_t htablep;
-	uintptr_t pfn;
-
-	if (!xkb_read_word(xkb, asp + offsetof(struct as, a_hat), &hatp))
-		return (MFN_INVALID);
-	if (!xkb_read_word(xkb, hatp + xkb->xkb_info.di_hat_htable_off,
-	    &htablep))
-		return (MFN_INVALID);
-	if (!xkb_read_word(xkb, htablep + xkb->xkb_info.di_ht_pfn_off,
-	    &pfn))
-		return (MFN_INVALID);
-
-	if (pfn > xkb->xkb_max_pfn)
-		return (MFN_INVALID);
-
-	return (xkb->xkb_p2m[pfn]);
-}
-
-static mfn_t
-xkb_cr3_to_pfn(xkb_t *xkb)
-{
-	uint64_t cr3 = xkb->xkb_vcpus[0]->ctrlreg[3];
-	if (xkb->xkb_is_hvm)
-		return (cr3 >> PAGE_SHIFT);
-	return (xen_cr3_to_pfn(cr3));
-}
-
-static ssize_t
-xkb_read_helper(xkb_t *xkb, struct as *as, int phys, uint64_t addr,
-    void *buf, size_t size)
-{
-	size_t left = size;
-	int windowed = (xkb->xkb_pages == NULL);
-	mfn_t tlmfn = xkb_cr3_to_pfn(xkb);
-
-	if (as != NULL && (tlmfn = xkb_as_to_mfn(xkb, as)) == MFN_INVALID)
-		return (-1);
-
-	while (left) {
-		uint64_t pos = addr + (size - left);
-		char *outpos = (char *)buf + (size - left);
-		size_t pageoff = PAGE_OFFSET(pos);
-		size_t sz = MIN(left, PAGE_SIZE - pageoff);
-		mfn_t mfn;
-
-		if (!phys) {
-			mfn = xkb_va_to_mfn(xkb, pos, tlmfn);
-			if (mfn == MFN_INVALID)
-				return (-1);
-		} else {
-			xen_pfn_t pfn = pos >> PAGE_SHIFT;
-			if (pfn > xkb->xkb_max_pfn)
-				return (-1);
-			mfn = xkb->xkb_p2m[pfn];
-			if (mfn == MFN_INVALID)
-				return (-1);
-		}
-
-		/*
-		 * If we're windowed then pread() is much faster.
-		 */
-		if (windowed) {
-			offset_t off = xkb_mfn_to_offset(xkb, mfn);
-			int ret;
-
-			if (off == ~1ULL)
-				return (-1);
-
-			off += pageoff;
-
-			ret = pread64(xkb->xkb_fd, outpos, sz, off);
-			if (ret == -1)
-				return (-1);
-			if (ret != sz)
-				return ((size - left) + ret);
-
-			left -= ret;
-		} else {
-			if (xkb_map_mfn(xkb, mfn, &xkb->xkb_map) == NULL)
-				return (-1);
-
-			bcopy(xkb->xkb_map.mm_map + pageoff, outpos, sz);
-
-			left -= sz;
-		}
-	}
-
-	return (size);
-}
-
-static ssize_t
-xkb_pread(xkb_t *xkb, uint64_t addr, void *buf, size_t size)
-{
-	return (xkb_read_helper(xkb, NULL, 1, addr, buf, size));
-}
-
-static ssize_t
-xkb_aread(xkb_t *xkb, uintptr_t addr, void *buf, size_t size, struct as *as)
-{
-	return (xkb_read_helper(xkb, as, 0, addr, buf, size));
-}
-
-static ssize_t
-xkb_read(xkb_t *xkb, uintptr_t addr, void *buf, size_t size)
-{
-	return (xkb_aread(xkb, addr, buf, size, NULL));
-}
-
-static int
-xkb_read_word(xkb_t *xkb, uintptr_t addr, uintptr_t *buf)
-{
-	if (xkb_read(xkb, addr, buf, sizeof (uintptr_t)) !=
-	    sizeof (uintptr_t))
-		return (0);
-	return (1);
-}
-
-static char *
-xkb_readstr(xkb_t *xkb, uintptr_t addr)
-{
-	char *str = mdb_alloc(1024, UM_SLEEP);
-	size_t i;
-
-	for (i = 0; i < 1024; i++) {
-		if (xkb_read(xkb, addr + i, &str[i], 1) != 1) {
-			mdb_free(str, 1024);
-			return (NULL);
-		}
-
-		if (str[i] == '\0')
-			break;
-	}
-
-	if (i == 1024) {
-		mdb_free(str, 1024);
-		return (NULL);
-	}
-
-	return (str);
-}
-
-static offset_t
-xkb_pfn_to_off(xkb_t *xkb, xen_pfn_t pfn)
-{
-	if (pfn == PFN_INVALID || pfn > xkb->xkb_max_pfn)
-		return (-1ULL);
-
-	if (xkb->xkb_type == XKB_FORMAT_CORE)
-		return (PAGE_SIZE * pfn);
-
-	return (PAGE_SIZE * (xkb->xkb_elf.xe_off[pfn]));
-}
-
-static offset_t
-xkb_mfn_to_offset(xkb_t *xkb, mfn_t mfn)
-{
-	xen_pfn_t pfn;
-
-	if (mfn > xkb->xkb_max_mfn)
-		return (-1ULL);
-
-	pfn = xkb->xkb_m2p[mfn];
-
-	if (pfn == PFN_INVALID)
-		return (-1ULL);
-
-	return (xkb->xkb_pages_off + xkb_pfn_to_off(xkb, pfn));
-}
-
-static char *
-xkb_map_mfn(xkb_t *xkb, mfn_t mfn, mfn_map_t *mm)
-{
-	int windowed = (xkb->xkb_pages == NULL);
-	offset_t off;
-
-	if (mm->mm_mfn == mfn)
-		return (mm->mm_map);
-
-	mm->mm_mfn = mfn;
-
-	if (windowed) {
-		if (mm->mm_map != (char *)MAP_FAILED) {
-			(void) munmap(mm->mm_map, PAGE_SIZE);
-			mm->mm_map = (void *)MAP_FAILED;
-		}
-
-		if ((off = xkb_mfn_to_offset(xkb, mfn)) == (-1ULL))
-			return (NULL);
-
-		mm->mm_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED,
-		    xkb->xkb_fd, off);
-
-		if (mm->mm_map == (char *)MAP_FAILED)
-			return (NULL);
-	} else {
-		xen_pfn_t pfn;
-
-		mm->mm_map = NULL;
-
-		if (mfn > xkb->xkb_max_mfn)
-			return (NULL);
-
-		pfn = xkb->xkb_m2p[mfn];
-
-		if (pfn == PFN_INVALID)
-			return (NULL);
-
-		mm->mm_map = xkb->xkb_pages + xkb_pfn_to_off(xkb, pfn);
-	}
-
-	return (mm->mm_map);
-}
-
-static uint64_t
-xkb_get_pte(mmu_info_t *mmu, char *ptep)
-{
-	uint64_t pte = 0;
-
-	if (mmu->mi_ptesize == 8) {
-		/* LINTED - alignment */
-		pte = *((uint64_t *)ptep);
-	} else {
-		/* LINTED - alignment */
-		pte = *((uint32_t *)ptep);
-	}
-
-	return (pte);
-}
-
-static mfn_t
-xkb_pte_to_base_mfn(uint64_t pte, size_t level)
-{
-	if (PTE_IS_LGPG(pte, level)) {
-		pte &= PT_PADDR_LGPG;
-	} else {
-		pte &= PT_PADDR;
-	}
-
-	return (pte >> PAGE_SHIFT);
-}
-
-/*
- * Resolve the given VA into an MFN, using the provided mfn as a top-level page
- * table.
- */
-static mfn_t
-xkb_va_to_mfn(xkb_t *xkb, uintptr_t va, mfn_t mfn)
-{
-	mmu_info_t *mmu = &xkb->xkb_mmu;
-	uint64_t pte;
-	size_t level;
-
-	for (level = mmu->mi_max; ; --level) {
-		size_t entry;
-
-		if (xkb_map_mfn(xkb, mfn, &xkb->xkb_pt_map[level]) == NULL)
-			return (MFN_INVALID);
-
-		entry = (va >> mmu->mi_shift[level]) & (mmu->mi_ptes - 1);
-
-		pte = xkb_get_pte(mmu, (char *)xkb->xkb_pt_map[level].mm_map +
-		    entry * mmu->mi_ptesize);
-
-		if ((mfn = xkb_pte_to_base_mfn(pte, level)) == MFN_INVALID)
-			return (MFN_INVALID);
-
-		if (level == 0)
-			break;
-
-		/*
-		 * Currently 'mfn' refers to the base MFN of the
-		 * large-page mapping.  Add on the 4K-sized index into
-		 * the large-page mapping to get the right MFN within
-		 * the mapping.
-		 */
-		if (PTE_IS_LGPG(pte, level)) {
-			mfn += (va & ((1 << mmu->mi_shift[level]) - 1)) >>
-			    PAGE_SHIFT;
-			break;
-		}
-	}
-
-	return (mfn);
-}
-
-static int
-xkb_read_module(xkb_t *xkb, uintptr_t modulep, struct module *module,
-    uintptr_t *sym_addr, uintptr_t *sym_count, uintptr_t *str_addr)
-{
-	if (xkb_read(xkb, modulep, module, sizeof (struct module)) !=
-	    sizeof (struct module))
-		return (0);
-
-	if (!xkb_read_word(xkb, (uintptr_t)module->symhdr +
-	    offsetof(Shdr, sh_addr), sym_addr))
-		return (0);
-
-	if (!xkb_read_word(xkb, (uintptr_t)module->strhdr +
-	    offsetof(Shdr, sh_addr), str_addr))
-		return (0);
-
-	if (!xkb_read_word(xkb, (uintptr_t)module->symhdr +
-	    offsetof(Shdr, sh_size), sym_count))
-		return (0);
-	*sym_count /= sizeof (Sym);
-
-	return (1);
-}
-
-static int
-xkb_read_modsyms(xkb_t *xkb, char **buf, size_t *sizes, int types,
-    uintptr_t sym_addr, uintptr_t str_addr, uintptr_t sym_count)
-{
-	size_t i;
-
-	for (i = 0; i < sym_count; i++) {
-		Sym sym;
-		char *name;
-		size_t sz;
-		int type = XKB_WALK_GLOBAL;
-
-		if (xkb_read(xkb, sym_addr + i * sizeof (sym), &sym,
-		    sizeof (sym)) != sizeof (sym))
-			return (0);
-
-		if (GELF_ST_BIND(sym.st_info) == STB_LOCAL)
-			type = XKB_WALK_LOCAL;
-
-		name = xkb_readstr(xkb, str_addr + sym.st_name);
-
-		sym.st_shndx = SHN_ABS;
-		sym.st_name = sizes[XKB_WALK_STR];
-
-		sizes[type] += sizeof (sym);
-		sz = strlen(name) + 1;
-		sizes[XKB_WALK_STR] += sz;
-
-		if (buf != NULL) {
-			if (types & type) {
-				bcopy(&sym, *buf, sizeof (sym));
-				*buf += sizeof (sym);
-			}
-			if (types & XKB_WALK_STR) {
-				bcopy(name, *buf, sz);
-				*buf += sz;
-			}
-		}
-
-		mdb_free(name, 1024);
-	}
-
-	return (1);
-}
-
-static int
-xkb_walk_syms(xkb_t *xkb, uintptr_t modhead, char **buf,
-    size_t *sizes, int types)
-{
-	uintptr_t modctl = modhead;
-	uintptr_t modulep;
-	struct module module;
-	uintptr_t sym_count;
-	uintptr_t sym_addr;
-	uintptr_t str_addr;
-	size_t max_iter = 500;
-
-	bzero(sizes, sizeof (*sizes) * (XKB_WALK_STR + 1));
-
-	/*
-	 * empty first symbol
-	 */
-	sizes[XKB_WALK_LOCAL] += sizeof (Sym);
-	sizes[XKB_WALK_STR] += 1;
-
-	if (buf != NULL) {
-		if (types & XKB_WALK_LOCAL) {
-			Sym tmp;
-			bzero(&tmp, sizeof (tmp));
-			bcopy(&tmp, *buf, sizeof (tmp));
-			*buf += sizeof (tmp);
-		}
-		if (types & XKB_WALK_STR) {
-			**buf = '\0';
-			(*buf)++;
-		}
-	}
-
-	for (;;) {
-		if (!xkb_read_word(xkb,
-		    modctl + offsetof(struct modctl, mod_mp), &modulep))
-			return (0);
-
-		if (modulep == NULL)
-			goto next;
-
-		if (!xkb_read_module(xkb, modulep, &module, &sym_addr,
-		    &sym_count, &str_addr))
-			return (0);
-
-		if ((module.flags & KOBJ_NOKSYMS))
-			goto next;
-
-		if (!xkb_read_modsyms(xkb, buf, sizes, types, sym_addr,
-		    str_addr, sym_count))
-			return (0);
-
-next:
-		if (!xkb_read_word(xkb,
-		    modctl + offsetof(struct modctl, mod_next), &modctl))
-			return (0);
-
-		if (modctl == modhead)
-			break;
-		/*
-		 * Try and prevent us looping forever if we have a broken list.
-		 */
-		if (--max_iter == 0)
-			break;
-	}
-
-	return (1);
-}
-
-/*
- * Userspace equivalent of ksyms_snapshot().  Since we don't have a namelist
- * file for hypervisor images, we fabricate one here using code similar
- * to that of /dev/ksyms.
- */
-static int
-xkb_build_ksyms(xkb_t *xkb)
-{
-	debug_info_t *info = &xkb->xkb_info;
-	size_t sizes[XKB_WALK_STR + 1];
-	xkb_namelist_t *hdr;
-	char *buf;
-	struct modctl modules;
-	uintptr_t module;
-	Shdr *shp;
-
-	if (xkb_read(xkb, info->di_modules, &modules,
-	    sizeof (struct modctl)) != sizeof (struct modctl))
-		return (0);
-
-	module = (uintptr_t)modules.mod_mp;
-
-	if (!xkb_walk_syms(xkb, info->di_modules, NULL, sizes,
-	    XKB_WALK_LOCAL | XKB_WALK_GLOBAL | XKB_WALK_STR))
-		return (0);
-
-	xkb->xkb_namesize = sizeof (xkb_namelist_t);
-	xkb->xkb_namesize += sizes[XKB_WALK_LOCAL];
-	xkb->xkb_namesize += sizes[XKB_WALK_GLOBAL];
-	xkb->xkb_namesize += sizes[XKB_WALK_STR];
-
-	if ((xkb->xkb_namelist = mdb_zalloc(xkb->xkb_namesize, UM_SLEEP))
-	    == NULL)
-		return (0);
-
-	/* LINTED - alignment */
-	hdr = (xkb_namelist_t *)xkb->xkb_namelist;
-
-	if (xkb_read(xkb, module + offsetof(struct module, hdr),
-	    &hdr->kh_elf_hdr, sizeof (Ehdr)) != sizeof (Ehdr))
-		return (0);
-
-	hdr->kh_elf_hdr.e_phoff = offsetof(xkb_namelist_t, kh_text_phdr);
-	hdr->kh_elf_hdr.e_shoff = offsetof(xkb_namelist_t, kh_shdr);
-	hdr->kh_elf_hdr.e_phnum = 2;
-	hdr->kh_elf_hdr.e_shnum = XKB_SHDR_NUM;
-	hdr->kh_elf_hdr.e_shstrndx = XKB_SHDR_SHSTRTAB;
-
-	hdr->kh_text_phdr.p_type = PT_LOAD;
-	hdr->kh_text_phdr.p_vaddr = (Addr)info->di_s_text;
-	hdr->kh_text_phdr.p_memsz = (Word)(info->di_e_text - info->di_s_text);
-	hdr->kh_text_phdr.p_flags = PF_R | PF_X;
-
-	hdr->kh_data_phdr.p_type = PT_LOAD;
-	hdr->kh_data_phdr.p_vaddr = (Addr)info->di_s_data;
-	hdr->kh_data_phdr.p_memsz = (Word)(info->di_e_data - info->di_s_data);
-	hdr->kh_data_phdr.p_flags = PF_R | PF_W | PF_X;
-
-	shp = &hdr->kh_shdr[XKB_SHDR_SYMTAB];
-	shp->sh_name = 1;	/* xkb_shstrtab[1] = ".symtab" */
-	shp->sh_type = SHT_SYMTAB;
-	shp->sh_offset = sizeof (xkb_namelist_t);
-	shp->sh_size = sizes[XKB_WALK_LOCAL] + sizes[XKB_WALK_GLOBAL];
-	shp->sh_link = XKB_SHDR_STRTAB;
-	shp->sh_info = sizes[XKB_WALK_LOCAL] / sizeof (Sym);
-	shp->sh_addralign = sizeof (Addr);
-	shp->sh_entsize = sizeof (Sym);
-	shp->sh_addr = (Addr)(xkb->xkb_namelist + shp->sh_offset);
-
-
-	shp = &hdr->kh_shdr[XKB_SHDR_STRTAB];
-	shp->sh_name = 9;	/* xkb_shstrtab[9] = ".strtab" */
-	shp->sh_type = SHT_STRTAB;
-	shp->sh_offset = sizeof (xkb_namelist_t) +
-	    sizes[XKB_WALK_LOCAL] + sizes[XKB_WALK_GLOBAL];
-	shp->sh_size = sizes[XKB_WALK_STR];
-	shp->sh_addralign = 1;
-	shp->sh_addr = (Addr)(xkb->xkb_namelist + shp->sh_offset);
-
-
-	shp = &hdr->kh_shdr[XKB_SHDR_SHSTRTAB];
-	shp->sh_name = 17;	/* xkb_shstrtab[17] = ".shstrtab" */
-	shp->sh_type = SHT_STRTAB;
-	shp->sh_offset = offsetof(xkb_namelist_t, shstrings);
-	shp->sh_size = sizeof (xkb_shstrtab);
-	shp->sh_addralign = 1;
-	shp->sh_addr = (Addr)(xkb->xkb_namelist + shp->sh_offset);
-
-	bcopy(xkb_shstrtab, hdr->shstrings, sizeof (xkb_shstrtab));
-
-	buf = xkb->xkb_namelist + sizeof (xkb_namelist_t);
-
-	if (!xkb_walk_syms(xkb, info->di_modules, &buf, sizes,
-	    XKB_WALK_LOCAL))
-		return (0);
-	if (!xkb_walk_syms(xkb, info->di_modules, &buf, sizes,
-	    XKB_WALK_GLOBAL))
-		return (0);
-	if (!xkb_walk_syms(xkb, info->di_modules, &buf, sizes,
-	    XKB_WALK_STR))
-		return (0);
-
-	return (1);
-}
-
-static xkb_t *
-xkb_open_core(xkb_t *xkb)
-{
-	xkb_core_t *xc = &xkb->xkb_core;
-	size_t sz;
-	int i;
-	struct vcpu_guest_context *vcp;
-
-	xkb->xkb_type = XKB_FORMAT_CORE;
-
-	if ((xkb->xkb_fd = open64(xkb->xkb_path, O_RDONLY)) == -1)
-		return (xkb_fail(xkb, "cannot open %s", xkb->xkb_path));
-
-	if (pread64(xkb->xkb_fd, &xc->xc_hdr, sizeof (xc->xc_hdr), 0) !=
-	    sizeof (xc->xc_hdr))
-		return (xkb_fail(xkb, "invalid dump file"));
-
-	if (xc->xc_hdr.xch_magic == XC_CORE_MAGIC_HVM)
-		return (xkb_fail(xkb, "cannot process HVM images"));
-
-	if (xc->xc_hdr.xch_magic != XC_CORE_MAGIC) {
-		return (xkb_fail(xkb, "invalid magic %d",
-		    xc->xc_hdr.xch_magic));
-	}
-
-	/*
-	 * With FORMAT_CORE, all pages are in the dump (non-existing
-	 * ones are zeroed out).
-	 */
-	xkb->xkb_nr_pages = xc->xc_hdr.xch_nr_pages;
-	xkb->xkb_pages_off = xc->xc_hdr.xch_pages_offset;
-	xkb->xkb_max_pfn = xc->xc_hdr.xch_nr_pages - 1;
-	xkb->xkb_nr_vcpus = xc->xc_hdr.xch_nr_vcpus;
-
-	sz = xkb->xkb_nr_vcpus * sizeof (struct vcpu_guest_context);
-	xkb->xkb_vcpu_data_sz = sz;
-	xkb->xkb_vcpu_data = mdb_alloc(sz, UM_SLEEP);
-
-	if (pread64(xkb->xkb_fd, xkb->xkb_vcpu_data, sz,
-	    xc->xc_hdr.xch_ctxt_offset) != sz)
-		return (xkb_fail(xkb, "cannot read VCPU contexts"));
-
-	sz = xkb->xkb_nr_vcpus * sizeof (struct vcpu_guest_context *);
-	xkb->xkb_vcpus = mdb_alloc(sz, UM_SLEEP);
-
-	vcp = xkb->xkb_vcpu_data;
-	for (i = 0; i < xkb->xkb_nr_vcpus; i++)
-		xkb->xkb_vcpus[i] = &vcp[i];
-
-	/*
-	 * Try to map all the data pages. If we can't, fall back to the
-	 * window/pread() approach, which is significantly slower.
-	 */
-	xkb->xkb_pages = mmap(NULL, PAGE_SIZE * xkb->xkb_nr_pages,
-	    PROT_READ, MAP_SHARED, xkb->xkb_fd, xc->xc_hdr.xch_pages_offset);
-
-	if (xkb->xkb_pages == (char *)MAP_FAILED)
-		xkb->xkb_pages = NULL;
-
-	/*
-	 * We'd like to adapt for correctness' sake, but we have no way of
-	 * detecting a PAE guest, since cr4 writes are disallowed.
-	 */
-	xkb->xkb_is_pae = 1;
-
-	if (!xkb_map_p2m(xkb))
-		return (NULL);
-
-	return (xkb);
-}
-
-static xkb_t *
-xkb_open_elf(xkb_t *xkb)
-{
-	xkb_elf_t *xe = &xkb->xkb_elf;
-	mdb_gelf_sect_t *sect;
-	char *notes;
-	char *pos;
-	mdb_io_t *io;
-	size_t sz;
-	int i;
-	void *dp;
-
-	if ((io = mdb_fdio_create_path(NULL, xkb->xkb_path,
-	    O_RDONLY, 0)) == NULL)
-		return (xkb_fail(xkb, "failed to open"));
-
-	xe->xe_gelf = mdb_gelf_create(io, ET_NONE, GF_FILE);
-
-	if (xe->xe_gelf == NULL) {
-		mdb_io_destroy(io);
-		return (xkb);
-	}
-
-	xkb->xkb_fd = mdb_fdio_fileno(io);
-
-	sect = mdb_gelf_sect_by_name(xe->xe_gelf, ".note.Xen");
-
-	if (sect == NULL)
-		return (xkb);
-
-	if ((notes = mdb_gelf_sect_load(xe->xe_gelf, sect)) == NULL)
-		return (xkb);
-
-	/*
-	 * Now we know this is indeed a hypervisor core dump, even if
-	 * it's corrupted.
-	 */
-	xkb->xkb_type = XKB_FORMAT_ELF;
-
-	for (pos = notes; pos < notes + sect->gs_shdr.sh_size; ) {
-		/* LINTED - alignment */
-		Elf64_Nhdr *nhdr = (Elf64_Nhdr *)pos;
-		uint64_t vers;
-		char *desc;
-		char *name;
-
-		name = pos + sizeof (*nhdr);
-		desc = (char *)P2ROUNDUP((uintptr_t)name + nhdr->n_namesz, 4);
-
-		pos = desc + nhdr->n_descsz;
-
-		switch (nhdr->n_type) {
-		case XEN_ELFNOTE_DUMPCORE_NONE:
-			break;
-
-		case XEN_ELFNOTE_DUMPCORE_HEADER:
-			if (nhdr->n_descsz != sizeof (struct xc_elf_header)) {
-				return (xkb_fail(xkb, "invalid ELF note "
-				    "XEN_ELFNOTE_DUMPCORE_HEADER\n"));
-			}
-
-			bcopy(desc, &xe->xe_hdr,
-			    sizeof (struct xc_elf_header));
-			break;
-
-		case XEN_ELFNOTE_DUMPCORE_XEN_VERSION:
-			if (nhdr->n_descsz < sizeof (struct xc_elf_version)) {
-				return (xkb_fail(xkb, "invalid ELF note "
-				    "XEN_ELFNOTE_DUMPCORE_XEN_VERSION\n"));
-			}
-
-			bcopy(desc, &xe->xe_version,
-			    sizeof (struct xc_elf_version));
-			break;
-
-		case XEN_ELFNOTE_DUMPCORE_FORMAT_VERSION:
-			/* LINTED - alignment */
-			vers = *((uint64_t *)desc);
-			if ((vers >> 32) != 0) {
-				return (xkb_fail(xkb, "unknown major "
-				    "version %d (expected 0)\n",
-				    (int)(vers >> 32)));
-			}
-
-			if ((vers & 0xffffffff) != 1) {
-				mdb_warn("unexpected dump minor number "
-				    "version %d (expected 1)\n",
-				    (int)(vers & 0xffffffff));
-			}
-			break;
-
-		default:
-			mdb_warn("unknown ELF note %d(%s)\n",
-			    nhdr->n_type, name);
-			break;
-		}
-	}
-
-	xkb->xkb_is_hvm = xe->xe_hdr.xeh_magic == XC_CORE_MAGIC_HVM;
-
-	if (xe->xe_hdr.xeh_magic != XC_CORE_MAGIC &&
-	    xe->xe_hdr.xeh_magic != XC_CORE_MAGIC_HVM) {
-		return (xkb_fail(xkb, "invalid magic %d",
-		    xe->xe_hdr.xeh_magic));
-	}
-
-	xkb->xkb_nr_pages = xe->xe_hdr.xeh_nr_pages;
-	xkb->xkb_is_pae = (strstr(xe->xe_version.xev_capabilities,
-	    "x86_32p") != NULL);
-
-	sect = mdb_gelf_sect_by_name(xe->xe_gelf, ".xen_prstatus");
-
-	if (sect == NULL)
-		return (xkb_fail(xkb, "cannot find section .xen_prstatus"));
-
-	if (sect->gs_shdr.sh_entsize < sizeof (vcpu_guest_context_t))
-		return (xkb_fail(xkb, "invalid section .xen_prstatus"));
-
-	xkb->xkb_nr_vcpus = sect->gs_shdr.sh_size / sect->gs_shdr.sh_entsize;
-
-	xkb->xkb_vcpu_data = mdb_gelf_sect_load(xe->xe_gelf, sect);
-	if (xkb->xkb_vcpu_data == NULL)
-		return (xkb_fail(xkb, "cannot load section .xen_prstatus"));
-	xkb->xkb_vcpu_data_sz = sect->gs_shdr.sh_size;
-
-	/*
-	 * The vcpu_guest_context structures saved in the core file
-	 * are actually unions of the 64-bit and 32-bit versions.
-	 * Don't rely on the entry size to match the size of
-	 * the structure, but set up an array of pointers.
-	 */
-	sz = xkb->xkb_nr_vcpus * sizeof (struct vcpu_guest_context *);
-	xkb->xkb_vcpus = mdb_alloc(sz, UM_SLEEP);
-	for (i = 0; i < xkb->xkb_nr_vcpus; i++) {
-		dp = ((char *)xkb->xkb_vcpu_data +
-		    i * sect->gs_shdr.sh_entsize);
-		xkb->xkb_vcpus[i] = dp;
-	}
-
-	sect = mdb_gelf_sect_by_name(xe->xe_gelf, ".xen_pages");
-
-	if (sect == NULL)
-		return (xkb_fail(xkb, "cannot find section .xen_pages"));
-
-	if (!PAGE_ALIGNED(sect->gs_shdr.sh_offset))
-		return (xkb_fail(xkb, ".xen_pages is not page aligned"));
-
-	if (sect->gs_shdr.sh_entsize != PAGE_SIZE)
-		return (xkb_fail(xkb, "invalid section .xen_pages"));
-
-	xkb->xkb_pages_off = sect->gs_shdr.sh_offset;
-
-	/*
-	 * Try to map all the data pages. If we can't, fall back to the
-	 * window/pread() approach, which is significantly slower.
-	 */
-	xkb->xkb_pages = mmap(NULL, PAGE_SIZE * xkb->xkb_nr_pages,
-	    PROT_READ, MAP_SHARED, xkb->xkb_fd, xkb->xkb_pages_off);
-
-	if (xkb->xkb_pages == (char *)MAP_FAILED)
-		xkb->xkb_pages = NULL;
-
-	if (xkb->xkb_is_hvm) {
-		if (!xkb_build_fake_p2m(xkb))
-			return (NULL);
-	} else {
-		if (!xkb_build_p2m(xkb))
-			return (NULL);
-	}
-
-	return (xkb);
-}
-
-static void
-xkb_init_mmu(xkb_t *xkb)
-{
-#if defined(__amd64)
-	xkb->xkb_mmu.mi_max = 3;
-	xkb->xkb_mmu.mi_shift[0] = 12;
-	xkb->xkb_mmu.mi_shift[1] = 21;
-	xkb->xkb_mmu.mi_shift[2] = 30;
-	xkb->xkb_mmu.mi_shift[3] = 39;
-	xkb->xkb_mmu.mi_ptes = 512;
-	xkb->xkb_mmu.mi_ptesize = 8;
-#elif defined(__i386)
-	if (xkb->xkb_is_pae) {
-		xkb->xkb_mmu.mi_max = 2;
-		xkb->xkb_mmu.mi_shift[0] = 12;
-		xkb->xkb_mmu.mi_shift[1] = 21;
-		xkb->xkb_mmu.mi_shift[2] = 30;
-		xkb->xkb_mmu.mi_ptes = 512;
-		xkb->xkb_mmu.mi_ptesize = 8;
-	} else {
-		xkb->xkb_mmu.mi_max = 1;
-		xkb->xkb_mmu.mi_shift[0] = 12;
-		xkb->xkb_mmu.mi_shift[1] = 22;
-		xkb->xkb_mmu.mi_ptes = 1024;
-		xkb->xkb_mmu.mi_ptesize = 4;
-	}
-#endif
-}
-
-/*ARGSUSED*/
-xkb_t *
-xkb_open(const char *namelist, const char *corefile, const char *swapfile,
-    int flag, const char *err)
-{
-	uintptr_t debug_info = DEBUG_INFO;
-	struct stat64 corestat;
-	xkb_t *xkb = NULL;
-	size_t i;
-
-	if (stat64(corefile, &corestat) == -1)
-		return (xkb_fail(xkb, "cannot stat %s", corefile));
-
-	if (flag != O_RDONLY)
-		return (xkb_fail(xkb, "invalid open flags"));
-
-	xkb = mdb_zalloc(sizeof (*xkb), UM_SLEEP);
-
-	for (i = 0; i < 4; i++) {
-		xkb->xkb_pt_map[i].mm_mfn = MFN_INVALID;
-		xkb->xkb_pt_map[i].mm_map = (char *)MAP_FAILED;
-	}
-
-	xkb->xkb_type = XKB_FORMAT_UNKNOWN;
-	xkb->xkb_map.mm_mfn = MFN_INVALID;
-	xkb->xkb_map.mm_map = (char *)MAP_FAILED;
-	xkb->xkb_core.xc_p2m_buf = (char *)MAP_FAILED;
-	xkb->xkb_fd = -1;
-
-	xkb->xkb_path = strdup(corefile);
-
-	if ((xkb = xkb_open_elf(xkb)) == NULL)
-		return (NULL);
-
-	if (xkb->xkb_type == XKB_FORMAT_UNKNOWN) {
-		if (!xkb_open_core(xkb))
-			return (NULL);
-	}
-
-	xkb_init_mmu(xkb);
-
-	if (!xkb_build_m2p(xkb))
-		return (NULL);
-
-	if (xkb->xkb_is_hvm)
-		debug_info = DEBUG_INFO_HVM;
-
-	if (xkb_read(xkb, debug_info, &xkb->xkb_info,
-	    sizeof (xkb->xkb_info)) != sizeof (xkb->xkb_info))
-		return (xkb_fail(xkb, "cannot read debug_info"));
-
-	if (xkb->xkb_info.di_magic != DEBUG_INFO_MAGIC) {
-		return (xkb_fail(xkb, "invalid debug info magic %d",
-		    xkb->xkb_info.di_magic));
-	}
-
-	if (xkb->xkb_info.di_version != DEBUG_INFO_VERSION) {
-		return (xkb_fail(xkb, "unknown debug info version %d",
-		    xkb->xkb_info.di_version));
-	}
-
-	if (!xkb_build_ksyms(xkb))
-		return (xkb_fail(xkb, "cannot construct namelist"));
-
-	return (xkb);
-}
-
-int
-xkb_close(xkb_t *xkb)
-{
-	size_t i, sz;
-
-	if (xkb == NULL)
-		return (0);
-
-	if (xkb->xkb_m2p != NULL) {
-		mdb_free(xkb->xkb_m2p,
-		    (xkb->xkb_max_mfn + 1) * sizeof (xen_pfn_t));
-	}
-
-	if (xkb->xkb_pages != NULL) {
-		(void) munmap((void *)xkb->xkb_pages,
-		    PAGE_SIZE * xkb->xkb_nr_pages);
-	} else {
-		for (i = 0; i < 4; i++) {
-			char *addr = xkb->xkb_pt_map[i].mm_map;
-			if (addr != (char *)MAP_FAILED)
-				(void) munmap((void *)addr, PAGE_SIZE);
-		}
-		if (xkb->xkb_map.mm_map != (char *)MAP_FAILED) {
-			(void) munmap((void *)xkb->xkb_map.mm_map,
-			    PAGE_SIZE);
-		}
-	}
-
-	if (xkb->xkb_namelist != NULL)
-		mdb_free(xkb->xkb_namelist, xkb->xkb_namesize);
-
-	if (xkb->xkb_type == XKB_FORMAT_ELF) {
-		xkb_elf_t *xe = &xkb->xkb_elf;
-
-		if (xe->xe_gelf != NULL)
-			mdb_gelf_destroy(xe->xe_gelf);
-
-		sz = sizeof (xen_pfn_t) * (xkb->xkb_max_pfn + 1);
-
-		if (xkb->xkb_p2m != NULL)
-			mdb_free(xkb->xkb_p2m, sz);
-
-		sz = sizeof (size_t) * (xkb->xkb_max_pfn + 1);
-
-		if (xe->xe_off != NULL)
-			mdb_free(xe->xe_off, sz);
-
-	} else if (xkb->xkb_type == XKB_FORMAT_CORE) {
-		xkb_core_t *xc = &xkb->xkb_core;
-
-		if (xkb->xkb_fd != -1)
-			(void) close(xkb->xkb_fd);
-
-		sz = (xkb->xkb_nr_pages * sizeof (mfn_t)) + (PAGE_SIZE * 2);
-		sz = PAGE_MASK(sz);
-
-		if (xc->xc_p2m_buf != (xen_pfn_t *)MAP_FAILED)
-			(void) munmap(xc->xc_p2m_buf, sz);
-
-		if (xkb->xkb_vcpu_data != NULL)
-			mdb_free(xkb->xkb_vcpu_data, xkb->xkb_vcpu_data_sz);
-	}
-
-	if (xkb->xkb_vcpus != NULL) {
-		sz = sizeof (struct vcpu_guest_context *) *
-		    xkb->xkb_nr_vcpus;
-		mdb_free(xkb->xkb_vcpus, sz);
-	}
-
-	free(xkb->xkb_path);
-
-	mdb_free(xkb, sizeof (*xkb));
-	return (0);
-}
-
-/*ARGSUSED*/
-static mdb_io_t *
-xkb_sym_io(xkb_t *xkb, const char *symfile)
-{
-	mdb_io_t *io = mdb_memio_create(xkb->xkb_namelist, xkb->xkb_namesize);
-
-	if (io == NULL)
-		mdb_warn("failed to create namelist from %s", xkb->xkb_path);
-
-	return (io);
-}
-
-uint64_t
-xkb_vtop(xkb_t *xkb, struct as *as, uintptr_t addr)
-{
-	mfn_t tlmfn = xkb_cr3_to_pfn(xkb);
-	mfn_t mfn;
-
-	if (as != NULL && (tlmfn = xkb_as_to_mfn(xkb, as)) == MFN_INVALID)
-		return (-1ULL);
-
-	mfn = xkb_va_to_mfn(xkb, addr, tlmfn);
-
-	if (mfn == MFN_INVALID || mfn > xkb->xkb_max_mfn)
-		return (-1ULL);
-
-	return (((uint64_t)xkb->xkb_m2p[mfn] << PAGE_SHIFT)
-	    | PAGE_OFFSET(addr));
-}
-
-static int
-xkb_getmregs(xkb_t *xkb, uint_t cpu, struct privmregs *mregs)
-{
-	struct vcpu_guest_context *vcpu;
-	struct cpu_user_regs *ur;
-	struct regs *regs;
-
-	if (cpu >= xkb->xkb_nr_vcpus) {
-		errno = EINVAL;
-		return (-1);
-	}
-
-	bzero(mregs, sizeof (*mregs));
-
-	vcpu = xkb->xkb_vcpus[cpu];
-	ur = &vcpu->user_regs;
-	regs = &mregs->pm_gregs;
-
-	regs->r_ss = ur->ss;
-	regs->r_cs = ur->cs;
-	regs->r_ds = ur->ds;
-	regs->r_es = ur->es;
-	regs->r_fs = ur->fs;
-	regs->r_gs = ur->gs;
-	regs->r_trapno = ur->entry_vector;
-	regs->r_err = ur->error_code;
-#ifdef __amd64
-	regs->r_savfp = ur->rbp;
-	regs->r_savpc = ur->rip;
-	regs->r_rdi = ur->rdi;
-	regs->r_rsi = ur->rsi;
-	regs->r_rdx = ur->rdx;
-	regs->r_rcx = ur->rcx;
-	regs->r_r8 = ur->r8;
-	regs->r_r9 = ur->r9;
-	regs->r_rax = ur->rax;
-	regs->r_rbx = ur->rbx;
-	regs->r_rbp = ur->rbp;
-	regs->r_r10 = ur->r10;
-	regs->r_r11 = ur->r11;
-	regs->r_r12 = ur->r12;
-	regs->r_r13 = ur->r13;
-	regs->r_r14 = ur->r14;
-	regs->r_r15 = ur->r15;
-	regs->r_rip = ur->rip;
-	regs->r_rfl = ur->rflags;
-	regs->r_rsp = ur->rsp;
-#else
-	regs->r_savfp = ur->ebp;
-	regs->r_savpc = ur->eip;
-	regs->r_edi = ur->edi;
-	regs->r_esi = ur->esi;
-	regs->r_ebp = ur->ebp;
-	regs->r_esp = ur->esp;
-	regs->r_ebx = ur->ebx;
-	regs->r_edx = ur->edx;
-	regs->r_ecx = ur->ecx;
-	regs->r_eax = ur->eax;
-	regs->r_eip = ur->eip;
-	regs->r_efl = ur->eflags;
-	regs->r_uesp = 0;
-#endif
-
-	bcopy(&vcpu->ctrlreg, &mregs->pm_cr, 8 * sizeof (ulong_t));
-	bcopy(&vcpu->debugreg, &mregs->pm_dr, 8 * sizeof (ulong_t));
-
-	mregs->pm_flags = PM_GREGS | PM_CRREGS | PM_DRREGS;
-
-	return (0);
-}
-
-static mdb_kb_ops_t xpv_kb_ops = {
-	.kb_open = (void *(*)())xkb_open,
-	.kb_close = (int (*)())xkb_close,
-	.kb_sym_io = (mdb_io_t *(*)())xkb_sym_io,
-	.kb_kread = (ssize_t (*)())xkb_read,
-	.kb_kwrite = (ssize_t (*)())mdb_tgt_notsup,
-	.kb_aread = (ssize_t (*)())xkb_aread,
-	.kb_awrite = (ssize_t (*)())mdb_tgt_notsup,
-	.kb_pread = (ssize_t (*)())xkb_pread,
-	.kb_pwrite = (ssize_t (*)())mdb_tgt_notsup,
-	.kb_vtop = (uint64_t (*)())xkb_vtop,
-	.kb_getmregs = (int (*)())xkb_getmregs
-};
-
-mdb_kb_ops_t *
-mdb_kb_ops(void)
-{
-	return (&xpv_kb_ops);
-}
-
-static const mdb_dcmd_t dcmds[] = { NULL, };
-static const mdb_walker_t walkers[] = { NULL, };
-static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
-	return (&modinfo);
-}
-
-void
-_mdb_fini(void)
-{
-}
--- old/usr/src/pkg/manifests/SUNWcs.mf	Fri Aug 10 23:19:12 2018
+++ new/usr/src/pkg/manifests/SUNWcs.mf	Fri Aug 10 23:19:12 2018
@@ -23,7 +23,7 @@
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 # Copyright (c) 2013 Gary Mills
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
-# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2018 Nexenta Systems, Inc.
 # Copyright 2017 Toomas Soome <tsoome@me.com>
 #
 
@@ -920,7 +920,6 @@
 file path=usr/lib/devfsadm/linkmod/SUNW_smp_link.so group=sys
 file path=usr/lib/devfsadm/linkmod/SUNW_tape_link.so group=sys
 file path=usr/lib/devfsadm/linkmod/SUNW_usb_link.so group=sys
-$(i386_ONLY)file path=usr/lib/devfsadm/linkmod/SUNW_xen_link.so group=sys
 file path=usr/lib/diffh mode=0555
 file path=usr/lib/expreserve mode=0555
 file path=usr/lib/exrecover mode=0555
@@ -1575,14 +1574,6 @@
 hardlink path=usr/sbin/share target=../../usr/sbin/sharemgr
 hardlink path=usr/sbin/tapes target=./devfsadm
 hardlink path=usr/sbin/unshare target=../../usr/sbin/sharemgr
-legacy pkg=SUNWcsr \
-    desc="core software for a specific instruction-set architecture" \
-    name="Core Solaris, (Root)"
-legacy pkg=SUNWcsu \
-    desc="core software for a specific instruction-set architecture" \
-    name="Core Solaris, (Usr)"
-legacy pkg=SUNWftpr desc="FTP Server Configuration Files" \
-    name="FTP Server, (Root)"
 license cr_ATT license=cr_ATT
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/developer-debug-mdb.mf	Fri Aug 10 23:19:13 2018
+++ new/usr/src/pkg/manifests/developer-debug-mdb.mf	Fri Aug 10 23:19:13 2018
@@ -38,11 +38,6 @@
     variant.opensolaris.zone=global
 $(i386_ONLY)dir path=platform/i86pc/kernel/kmdb group=sys
 $(i386_ONLY)dir path=platform/i86pc/kernel/kmdb/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv group=sys variant.opensolaris.zone=global
-$(i386_ONLY)dir path=platform/i86xpv/kernel group=sys \
-    variant.opensolaris.zone=global
-$(i386_ONLY)dir path=platform/i86xpv/kernel/kmdb group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/kmdb/$(ARCH64) group=sys
 $(sparc_ONLY)dir path=platform/sun4u group=sys variant.opensolaris.zone=global
 $(sparc_ONLY)dir path=platform/sun4u/kernel group=sys \
     variant.opensolaris.zone=global
@@ -73,11 +68,6 @@
 $(i386_ONLY)dir path=usr/platform/i86pc/lib/mdb group=sys
 $(i386_ONLY)dir path=usr/platform/i86pc/lib/mdb/kvm group=sys
 $(i386_ONLY)dir path=usr/platform/i86pc/lib/mdb/kvm/$(ARCH64) group=sys
-$(i386_ONLY)dir path=usr/platform/i86xpv group=sys
-$(i386_ONLY)dir path=usr/platform/i86xpv/lib
-$(i386_ONLY)dir path=usr/platform/i86xpv/lib/mdb group=sys
-$(i386_ONLY)dir path=usr/platform/i86xpv/lib/mdb/kvm group=sys
-$(i386_ONLY)dir path=usr/platform/i86xpv/lib/mdb/kvm/$(ARCH64) group=sys
 $(sparc_ONLY)dir path=usr/platform/sun4u group=sys
 $(sparc_ONLY)dir path=usr/platform/sun4u/lib
 $(sparc_ONLY)dir path=usr/platform/sun4u/lib/mdb group=sys
@@ -137,12 +127,6 @@
     mode=0555
 $(i386_ONLY)file path=platform/i86pc/kernel/kmdb/$(ARCH64)/uppc group=sys \
     mode=0555
-$(i386_ONLY)file path=platform/i86xpv/kernel/kmdb/$(ARCH64)/unix group=sys \
-    mode=0555
-$(i386_ONLY)file path=platform/i86xpv/kernel/kmdb/$(ARCH64)/xpv_psm group=sys \
-    mode=0555
-$(i386_ONLY)file path=platform/i86xpv/kernel/kmdb/$(ARCH64)/xpv_uppc group=sys \
-    mode=0555
 $(sparc_ONLY)file path=platform/sun4u/kernel/kmdb/$(ARCH64)/oplhwd group=sys \
     mode=0555
 $(sparc_ONLY)file path=platform/sun4u/kernel/kmdb/$(ARCH64)/sgenv group=sys \
@@ -182,7 +166,6 @@
 file path=usr/lib/mdb/kvm/$(ARCH64)/lofs.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/logindmux.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/mac.so group=sys mode=0555
-$(i386_ONLY)file path=usr/lib/mdb/kvm/$(ARCH64)/mdb_kb.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/mdb_ks.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/mm.so group=sys mode=0555
 file path=usr/lib/mdb/kvm/$(ARCH64)/mpt.so group=sys mode=0555
@@ -242,14 +225,6 @@
     group=sys mode=0555
 $(i386_ONLY)file path=usr/platform/i86pc/lib/mdb/kvm/$(ARCH64)/uppc.so \
     group=sys mode=0555
-$(i386_ONLY)file path=usr/platform/i86xpv/lib/mdb/kvm/$(ARCH64)/unix.so \
-    group=sys mode=0555
-$(i386_ONLY)file path=usr/platform/i86xpv/lib/mdb/kvm/$(ARCH64)/xpv.so \
-    group=sys mode=0555
-$(i386_ONLY)file path=usr/platform/i86xpv/lib/mdb/kvm/$(ARCH64)/xpv_psm.so \
-    group=sys mode=0555
-$(i386_ONLY)file path=usr/platform/i86xpv/lib/mdb/kvm/$(ARCH64)/xpv_uppc.so \
-    group=sys mode=0555
 $(sparc_ONLY)file path=usr/platform/sun4u/lib/mdb/kvm/$(ARCH64)/oplhwd.so \
     group=sys mode=0555
 $(sparc_ONLY)file path=usr/platform/sun4u/lib/mdb/kvm/$(ARCH64)/sgenv.so \
@@ -275,9 +250,6 @@
 hardlink path=usr/bin/$(ARCH64)/adb target=../../../usr/bin/$(ARCH64)/mdb
 hardlink path=usr/bin/adb target=../../usr/lib/isaexec
 hardlink path=usr/bin/mdb target=../../usr/lib/isaexec
-legacy pkg=SUNWmdb desc="Modular Debugger (MDB)" name="Modular Debugger"
-legacy pkg=SUNWmdbr desc="Modular Debugger (MDB) (Root)" \
-    name="Modular Debugger (Root)"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 license usr/src/common/bzip2/LICENSE license=usr/src/common/bzip2/LICENSE
--- old/usr/src/pkg/manifests/driver-i86pc-ioat.mf	Fri Aug 10 23:19:13 2018
+++ new/usr/src/pkg/manifests/driver-i86pc-ioat.mf	Fri Aug 10 23:19:13 2018
@@ -43,10 +43,6 @@
 dir path=platform/i86pc/kernel group=sys
 dir path=platform/i86pc/kernel/drv group=sys
 dir path=platform/i86pc/kernel/drv/$(ARCH64) group=sys
-dir path=platform/i86xpv group=sys
-dir path=platform/i86xpv/kernel group=sys
-dir path=platform/i86xpv/kernel/drv group=sys
-dir path=platform/i86xpv/kernel/drv/$(ARCH64) group=sys
 driver name=ioat \
     alias=pciex8086,1a38 \
     alias=pciex8086,360b \
@@ -54,8 +50,5 @@
 file path=kernel/misc/$(ARCH64)/dcopy group=sys mode=0755
 file path=platform/i86pc/kernel/drv/$(ARCH64)/ioat group=sys
 file path=platform/i86pc/kernel/drv/ioat.conf group=sys
-file path=platform/i86xpv/kernel/drv/$(ARCH64)/ioat group=sys
-file path=platform/i86xpv/kernel/drv/ioat.conf group=sys
-legacy pkg=SUNWdcopy desc="Sun dcopy DMA drivers" name="Sun dcopy DMA drivers"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/driver-storage-ata.mf	Fri Aug 10 23:19:13 2018
+++ new/usr/src/pkg/manifests/driver-storage-ata.mf	Fri Aug 10 23:19:13 2018
@@ -43,10 +43,6 @@
 dir path=platform/i86pc/kernel group=sys
 dir path=platform/i86pc/kernel/drv group=sys
 dir path=platform/i86pc/kernel/drv/$(ARCH64) group=sys
-dir path=platform/i86xpv group=sys
-dir path=platform/i86xpv/kernel group=sys
-dir path=platform/i86xpv/kernel/drv group=sys
-dir path=platform/i86xpv/kernel/drv/$(ARCH64) group=sys
 dir path=usr/share/man
 dir path=usr/share/man/man7d
 driver name=ata alias=ide class=dada class=scsi
@@ -56,10 +52,6 @@
     original_name=SUNWpsdir:kernel/drv/ata.conf preserve=true
 file path=platform/i86pc/kernel/drv/$(ARCH64)/pci-ide group=sys
 file path=platform/i86pc/kernel/drv/pci-ide.conf group=sys
-file path=platform/i86xpv/kernel/drv/$(ARCH64)/pci-ide group=sys
-file path=platform/i86xpv/kernel/drv/pci-ide.conf group=sys
 file path=usr/share/man/man7d/ata.7d
-legacy pkg=SUNWpsdir desc="Platform Support, ISA Bus Device Drivers, (Root)" \
-    name="Platform Support, ISA Bus Device Drivers, (Root)"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/driver-x11-xsvc.mf	Fri Aug 10 23:19:13 2018
+++ new/usr/src/pkg/manifests/driver-x11-xsvc.mf	Fri Aug 10 23:19:13 2018
@@ -39,16 +39,8 @@
 dir path=platform/i86pc/kernel group=sys
 dir path=platform/i86pc/kernel/drv group=sys
 dir path=platform/i86pc/kernel/drv/$(ARCH64) group=sys
-dir path=platform/i86xpv group=sys
-dir path=platform/i86xpv/kernel group=sys
-dir path=platform/i86xpv/kernel/drv group=sys
-dir path=platform/i86xpv/kernel/drv/$(ARCH64) group=sys
 driver name=xsvc devlink=type=ddi_pseudo;name=xsvc\t\M0
 file path=platform/i86pc/kernel/drv/$(ARCH64)/xsvc group=sys
 file path=platform/i86pc/kernel/drv/xsvc.conf group=sys
-file path=platform/i86xpv/kernel/drv/$(ARCH64)/xsvc group=sys
-file path=platform/i86xpv/kernel/drv/xsvc.conf group=sys
-legacy pkg=SUNWxsvc desc="Sun Xserver pseudo driver" \
-    name="Sun Xserver pseudo driver" version=11.11.0,REV=2009.11.11
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/driver-xvm-pv.mf	Fri Aug 10 23:19:14 2018
+++ new/usr/src/pkg/manifests/driver-xvm-pv.mf	Fri Aug 10 23:19:14 2018
@@ -53,7 +53,5 @@
 file path=platform/$(ARCH32)hvm/kernel/drv/xpvd.conf group=sys
 file path=platform/$(ARCH32)hvm/kernel/misc/$(ARCH64)/hvm_bootstrap group=sys \
     mode=0755
-legacy pkg=SUNWxvmpv desc="xVM Paravirtualized Drivers" \
-    name="xVM Paravirtualized Drivers"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/system-dtrace-tests.mf	Fri Aug 10 23:19:14 2018
+++ new/usr/src/pkg/manifests/system-dtrace-tests.mf	Fri Aug 10 23:19:14 2018
@@ -127,8 +127,6 @@
 dir path=opt/SUNWdtrt/tst/common/ustack
 dir path=opt/SUNWdtrt/tst/common/vars
 dir path=opt/SUNWdtrt/tst/common/version
-$(i386_ONLY)dir path=opt/SUNWdtrt/tst/i86xpv
-$(i386_ONLY)dir path=opt/SUNWdtrt/tst/i86xpv/xdt
 file path=opt/SUNWdtrt/README mode=0444
 file path=opt/SUNWdtrt/bin/$(ARCH32)/chkargs mode=0555
 file path=opt/SUNWdtrt/bin/$(ARCH64)/chkargs mode=0555
@@ -2129,15 +2127,6 @@
 file path=opt/SUNWdtrt/tst/common/vars/tst.uid.d mode=0444
 file path=opt/SUNWdtrt/tst/common/vars/tst.walltimestamp.d mode=0444
 file path=opt/SUNWdtrt/tst/common/version/tst.1.0.d mode=0444
-$(i386_ONLY)file path=opt/SUNWdtrt/tst/i86xpv/xdt/tst.basic.ksh mode=0444
-$(i386_ONLY)file path=opt/SUNWdtrt/tst/i86xpv/xdt/tst.hvmenable.ksh mode=0444
-$(i386_ONLY)file path=opt/SUNWdtrt/tst/i86xpv/xdt/tst.memenable.ksh mode=0444
-$(i386_ONLY)file path=opt/SUNWdtrt/tst/i86xpv/xdt/tst.schedargs.ksh mode=0444
-$(i386_ONLY)file path=opt/SUNWdtrt/tst/i86xpv/xdt/tst.schedenable.ksh \
-    mode=0444
-legacy pkg=SUNWdtrt category=internal \
-    desc="DTrace Test Suite Internal Distribution" \
-    hotline="Contact the DTrace discussion forum" name="DTrace Test Suite"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 depend fmri=runtime/java type=require
--- old/usr/src/pkg/manifests/system-header.mf	Fri Aug 10 23:19:14 2018
+++ new/usr/src/pkg/manifests/system-header.mf	Fri Aug 10 23:19:14 2018
@@ -161,10 +161,6 @@
 $(i386_ONLY)dir path=usr/platform/i86pc/include
 $(i386_ONLY)dir path=usr/platform/i86pc/include/sys
 $(i386_ONLY)dir path=usr/platform/i86pc/include/vm
-$(i386_ONLY)dir path=usr/platform/i86xpv group=sys
-$(i386_ONLY)dir path=usr/platform/i86xpv/include
-$(i386_ONLY)dir path=usr/platform/i86xpv/include/sys
-$(i386_ONLY)dir path=usr/platform/i86xpv/include/vm
 $(sparc_ONLY)dir path=usr/platform/sun4u group=sys
 $(sparc_ONLY)dir path=usr/platform/sun4u/include
 $(sparc_ONLY)dir path=usr/platform/sun4u/include/sys
@@ -185,7 +181,6 @@
 dir path=usr/share/src group=sys
 dir path=usr/share/src/uts
 $(i386_ONLY)dir path=usr/share/src/uts/i86pc
-$(i386_ONLY)dir path=usr/share/src/uts/i86xpv
 $(sparc_ONLY)dir path=usr/share/src/uts/sun4u
 $(sparc_ONLY)dir path=usr/share/src/uts/sun4v
 dir path=usr/xpg4
@@ -1700,11 +1695,6 @@
 $(i386_ONLY)file path=usr/platform/i86pc/include/vm/hment.h
 $(i386_ONLY)file path=usr/platform/i86pc/include/vm/htable.h
 $(i386_ONLY)file path=usr/platform/i86pc/include/vm/kboot_mmu.h
-$(i386_ONLY)file path=usr/platform/i86xpv/include/sys/balloon.h
-$(i386_ONLY)file path=usr/platform/i86xpv/include/sys/machprivregs.h
-$(i386_ONLY)file path=usr/platform/i86xpv/include/sys/xen_mmu.h
-$(i386_ONLY)file path=usr/platform/i86xpv/include/sys/xpv_impl.h
-$(i386_ONLY)file path=usr/platform/i86xpv/include/vm/seg_mf.h
 $(sparc_ONLY)file path=usr/platform/sun4u/include/sys/ac.h
 $(sparc_ONLY)file path=usr/platform/sun4u/include/sys/async.h
 $(sparc_ONLY)file path=usr/platform/sun4u/include/sys/cheetahregs.h
@@ -2106,10 +2096,6 @@
     target=../../../../platform/i86pc/include/sys
 $(i386_ONLY)link path=usr/share/src/uts/i86pc/vm \
     target=../../../../platform/i86pc/include/vm
-$(i386_ONLY)link path=usr/share/src/uts/i86xpv/sys \
-    target=../../../../platform/i86xpv/include/sys
-$(i386_ONLY)link path=usr/share/src/uts/i86xpv/vm \
-    target=../../../../platform/i86xpv/include/vm
 $(sparc_ONLY)link path=usr/share/src/uts/sun4u/sys \
     target=../../../../platform/sun4u/include/sys
 $(sparc_ONLY)link path=usr/share/src/uts/sun4u/vm \
--- old/usr/src/pkg/manifests/system-kernel-dtrace-providers-xdt.mf	Fri Aug 10 23:19:15 2018
+++ new/usr/src/pkg/manifests/system-kernel-dtrace-providers-xdt.mf	Fri Aug 10 23:19:15 2018
@@ -23,29 +23,6 @@
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 #
 
-#
-# The default for payload-bearing actions in this package is to appear in the
-# global zone only.  See the include file for greater detail, as well as
-# information about overriding the defaults.
-#
-<include global_zone_only_component>
 set name=pkg.fmri value=pkg:/system/kernel/dtrace/providers/xdt@$(PKGVERS)
-set name=pkg.description \
-    value="DTrace provider for tracing events in the xVM hypervisor"
-set name=pkg.summary value="xVM Hypervisor Dynamic Tracing (DTrace) Provider"
-set name=info.classification \
-    value=org.opensolaris.category.2008:Development/System
+set name=pkg.obsolete value=true
 set name=variant.arch value=i386
-dir path=platform group=sys
-dir path=platform/i86xpv group=sys
-dir path=platform/i86xpv/kernel group=sys
-dir path=platform/i86xpv/kernel/drv group=sys
-dir path=platform/i86xpv/kernel/drv/$(ARCH64) group=sys
-driver name=xdt
-file path=platform/i86xpv/kernel/drv/$(ARCH64)/xdt group=sys
-file path=platform/i86xpv/kernel/drv/xdt.conf group=sys
-legacy pkg=SUNWxdt \
-    desc="DTrace provider for tracing events in the xVM hypervisor" \
-    name="xVM Hypervisor Dynamic Tracing (DTrace) Provider"
-license cr_Sun license=cr_Sun
-license lic_CDDL license=lic_CDDL
--- old/usr/src/pkg/manifests/system-kernel-platform.mf	Fri Aug 10 23:19:15 2018
+++ new/usr/src/pkg/manifests/system-kernel-platform.mf	Fri Aug 10 23:19:15 2018
@@ -21,7 +21,7 @@
 
 #
 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2018 Nexenta Systems, Inc.
 # Copyright 2014 Gary Mills
 #
 
@@ -310,21 +310,6 @@
 $(i386_ONLY)dir path=platform/i86pc/kernel/misc group=sys
 $(i386_ONLY)dir path=platform/i86pc/kernel/misc/$(ARCH64) group=sys
 $(i386_ONLY)dir path=platform/i86pc/ucode group=sys
-$(i386_ONLY)dir path=platform/i86xpv group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/cpu group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/cpu/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/dacf group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/dacf/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/drv group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/drv/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/mach group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/mach/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/misc group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/misc/$(ARCH64) group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/tod group=sys
-$(i386_ONLY)dir path=platform/i86xpv/kernel/tod/$(ARCH64) group=sys
 $(sparc_ONLY)dir path=platform/sun4u group=sys
 $(sparc_ONLY)dir path=platform/sun4u-us3 group=sys
 $(sparc_ONLY)dir path=platform/sun4u-us3/kernel group=sys
@@ -539,18 +524,9 @@
     alias=SUNW,virtual-devices
 $(sparc_ONLY)driver name=xcalppm alias=ebus-ppm
 $(sparc_ONLY)driver name=xcalwd
-$(i386_ONLY)driver name=xdb
 $(i386_ONLY)driver name=xdf
-$(i386_ONLY)driver name=xenbus perms="* 0666 root sys"
-$(i386_ONLY)driver name=xencons
-$(i386_ONLY)driver name=xnbe alias=xnb,ioemu
-$(i386_ONLY)driver name=xnbo \
-    alias=xnb \
-    alias=xnb,SUNW_mac
-$(i386_ONLY)driver name=xnbu alias=xnb,netfront
 $(i386_ONLY)driver name=xnf
 $(i386_ONLY)driver name=xpvd
-$(i386_ONLY)driver name=xpvtap perms="* 0666 root sys"
 $(sparc_ONLY)driver name=zs perms="[a-z] 0666 root sys" \
     perms="[a-z],cu 0600 uucp uucp"
 $(sparc_ONLY)driver name=zsh perms="* 0666 root sys"
@@ -853,52 +829,6 @@
 $(i386_ONLY)file path=platform/i86pc/ucode/intel-ucode.txt group=sys mode=0444 \
     original_name=SUNWcakr:platform/i86pc/ucode/intel-ucode.txt preserve=true \
     reboot-needed=true
-$(i386_ONLY)file path=platform/i86xpv/kernel/$(ARCH64)/unix group=sys \
-    mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/cpu/$(ARCH64)/cpu.generic \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/cpu/$(ARCH64)/cpu_ms.AuthenticAMD \
-    group=sys mode=0755
-$(i386_ONLY)file \
-    path=platform/i86xpv/kernel/cpu/$(ARCH64)/cpu_ms.AuthenticAMD.15 \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/cpu/$(ARCH64)/cpu_ms.GenuineIntel \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/dacf/$(ARCH64)/consconfig_dacf \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/balloon group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/domcaps group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/evtchn group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/isa group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/npe group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/pci group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/pit_beep group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/privcmd group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/rootnex group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xdb group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xdf group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xenbus group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xencons group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xnbe group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xnbo group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xnbu group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xnf group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xpvd group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/$(ARCH64)/xpvtap group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/pit_beep.conf group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/drv/xencons.conf group=sys
-$(i386_ONLY)file path=platform/i86xpv/kernel/mach/$(ARCH64)/xpv_psm group=sys \
-    mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/mach/$(ARCH64)/xpv_uppc group=sys \
-    mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/misc/$(ARCH64)/gfx_private \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/misc/$(ARCH64)/xnb group=sys \
-    mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/misc/$(ARCH64)/xpv_autoconfig \
-    group=sys mode=0755
-$(i386_ONLY)file path=platform/i86xpv/kernel/tod/$(ARCH64)/xpvtod group=sys \
-    mode=0755
 $(sparc_ONLY)file path=platform/sun4u-us3/kernel/crypto/$(ARCH64)/aes \
     group=sys mode=0755
 $(sparc_ONLY)file path=platform/sun4u/bootlst group=sys reboot-needed=true
@@ -1130,9 +1060,6 @@
 $(sparc_ONLY)legacy pkg=SUNWcakrnt2000.v arch=$(ARCH).sun4v \
     desc="driver software for the Netra-T2000 hardware platform" \
     name="Platform Specific Drivers for Netra-T2000, (Root)"
-$(i386_ONLY)legacy pkg=SUNWcakrx.i arch=$(ARCH).i86pc \
-    desc="core kernel software for the i86xpv virtual hardware platform" \
-    name="Core Kernel Architecture i86xpv, (Root)"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 license usr/src/cmd/mdb/common/libstand/THIRDPARTYLICENSE \
--- old/usr/src/pkg/manifests/system-library-processor.mf	Fri Aug 10 23:19:15 2018
+++ new/usr/src/pkg/manifests/system-library-processor.mf	Fri Aug 10 23:19:15 2018
@@ -54,7 +54,6 @@
 $(sparc_ONLY)dir path=platform/SUNW,Ultra-30 group=sys
 $(sparc_ONLY)dir path=platform/SUNW,Ultra-60 group=sys
 $(i386_ONLY)dir path=platform/i86pc group=sys
-$(i386_ONLY)dir path=platform/i86xpv group=sys
 $(sparc_ONLY)dir path=platform/sun4u group=sys
 $(sparc_ONLY)dir path=platform/sun4u/lib
 $(sparc_ONLY)dir path=platform/sun4u/lib/$(ARCH64)
@@ -107,9 +106,6 @@
 $(sparc_ONLY)legacy pkg=SUNWcart200.v arch=$(ARCH).sun4v \
     desc="core software for a specific hardware platform group" \
     name="Core Architecture, sun4v-based platforms (Root)"
-$(i386_ONLY)legacy pkg=SUNWcarx.i arch=$(ARCH).i86pc \
-    desc="core software for the i86xpv virtual hardware platform" \
-    name="Core Architecture i86xpv, (Root)"
 license cr_Sun license=cr_Sun
 license lic_CDDL license=lic_CDDL
 $(sparc_ONLY)link path=platform/SUNW,Netra-210 target=SUNW,Sun-Fire-V240
--- old/usr/src/uts/Makefile	Fri Aug 10 23:19:16 2018
+++ new/usr/src/uts/Makefile	Fri Aug 10 23:19:16 2018
@@ -37,7 +37,7 @@
 #
 sparc_ARCHITECTURES = sun4v sun4u sparc
 
-i386_ARCHITECTURES = i86pc i86xpv intel
+i386_ARCHITECTURES = i86pc intel
 
 #
 # For i386 all architectures can be compiled in parallel.
@@ -174,7 +174,7 @@
 		common/sys
 
 sparc_HDRDIRS= sun/sys
-i386_HDRDIRS= i86pc/vm i86xpv/vm
+i386_HDRDIRS= i86pc/vm
 
 HDRDIRS= $(COMMON_HDRDIRS) $($(MACH)_HDRDIRS)
 install_h check: $(HDRDIRS) $($(MACH)_ARCHITECTURES)
--- old/usr/src/uts/common/xen/dtrace/xdt.c	Fri Aug 10 23:19:16 2018
+++ /dev/null	Fri Aug 10 23:19:15 2018
@@ -1,2182 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Xen event provider for DTrace
- *
- * NOTE: This provider is PRIVATE. It is intended as a short-term solution and
- * may disappear or be re-implemented at anytime.
- *
- * This provider isn't suitable as a general-purpose solution for a number of
- * reasons. First and foremost, we rely on the Xen tracing mechanism and don't
- * have any way to gather data other than that collected by the Xen trace
- * buffers. Further, it does not fit into the DTrace model (see "Interacting
- * with DTrace" below.)
- *
- *
- * Tracing in Xen
- * --------------
- *
- * Xen implements a tracing facility for generating and collecting execution
- * event traces from the hypervisor. When tracing is enabled, compiled in
- * probes record events in contiguous per-CPU trace buffers.
- *
- *               +---------+
- * +------+      |         |
- * | CPUn |----> | BUFFERn |
- * +------+      |         |
- *               +---------+- tbuf.va + (tbuf.size * n)
- *               :         :
- *               +---------+
- * +------+      |         |
- * | CPU1 |----> | BUFFER1 |
- * +------+      |         |
- *               +---------+- tbuf.va + tbuf.size
- * +------+      |         |
- * | CPU0 |----> | BUFFER0 |
- * +------+      |         |
- *               +---------+- tbuf.va
- *
- * Each CPU buffer consists of a metadata header followed by the trace records.
- * The metadata consists of a producer/consumer pair of pointers into the buffer
- * that point to the next record to be written and the next record to be read
- * respectively.
- *
- * A trace record can be in one of two forms, depending on if the TSC is
- * included. The record header indicates whether or not the TSC field is
- * present.
- *
- * 1. Trace record without TSC:
- * +------------------------------------------------------------+
- * | HEADER(uint32_t) |            DATA FIELDS                  |
- * +------------------------------------------------------------+
- *
- * 2. Trace record with TSC:
- * +--------------------------------------------------------------------------+
- * | HEADER(uint32_t) | TSC(uint64_t) |              DATA FIELDS              |
- * +--------------------------------------------------------------------------+
- *
- * Where,
- *
- * HEADER bit field:
- * +--------------------------------------------------------------------------+
- * | C |  NDATA  |                        EVENT                               |
- * +--------------------------------------------------------------------------+
- *  31  30     28 27                                                         0
- *
- * EVENT: Event ID.
- * NDATA: Number of populated data fields.
- *     C: TSC included.
- *
- * DATA FIELDS:
- * +--------------------------------------------------------------------------+
- * | D1(uint32_t) | D2(uint32_t) | D3(uint32_t) |     . . .    | D7(uint32_t) |
- * +--------------------------------------------------------------------------+
- *
- *
- * Interacting with DTrace
- * -----------------------
- *
- * Every xdt_poll_nsec nano-seconds we poll the trace buffers for data and feed
- * each entry into dtrace_probe() with the corresponding probe ID for the event.
- * As a result of this periodic collection implementation probe firings are
- * asynchronous. This is the only sensible way to implement this form of
- * provider, but because of its asynchronous nature asking things like
- * "current CPU" and, more importantly, arbitrary questions about the context
- * surrounding the probe firing are not meaningful. So, consumers should not
- * attempt to infer anything beyond what is supplied via the probe arguments.
- */
-
-#include <sys/xpv_user.h>
-
-#include <sys/types.h>
-#include <sys/sysmacros.h>
-#include <sys/modctl.h>
-#include <sys/sunddi.h>
-#include <sys/ddi.h>
-#include <sys/conf.h>
-#include <sys/devops.h>
-#include <sys/stat.h>
-#include <sys/cmn_err.h>
-#include <sys/dtrace.h>
-#include <sys/sdt.h>
-#include <sys/cyclic.h>
-#include <vm/seg_kmem.h>
-#include <vm/hat_i86.h>
-
-#include <sys/hypervisor.h>
-#include <xen/public/trace.h>
-#include <xen/public/sched.h>
-
-#define	XDT_POLL_DEFAULT	100000000	/* default poll interval (ns) */
-#define	XDT_POLL_MIN		10000000	/* min poll interval (ns) */
-#define	XDT_TBUF_RETRY		50		/* tbuf disable retry count */
-
-/*
- * The domid must match IDLE_DOMAIN_ID in xen.hg/xen/include/xen/sched.h
- * in the xVM gate.
- */
-#define	IS_IDLE_DOM(domid)	(domid == 0x7FFFU)
-
-/* Macros to extract the domid and cpuid from a HVM trace data field */
-#define	HVM_DOMID(d)		(d >> 16)
-#define	HVM_VCPUID(d)		(d & 0xFFFF)
-
-/* Flags for shadow page table events */
-#define	SH_GUEST_32	0x000
-#define	SH_GUEST_PAE	0x100
-#define	SH_GUEST_64	0x200
-
-#define	XDT_PROBE5(event, arg0, arg1, arg2, arg3, arg4) {		\
-	dtrace_id_t id = xdt_probemap[event];				\
-	if (id)								\
-		dtrace_probe(id, arg0, arg1, arg2, arg3, arg4);		\
-}									\
-
-#define	XDT_PROBE4(event, arg0, arg1, arg2, arg3) \
-	XDT_PROBE5(event, arg0, arg1, arg2, arg3, 0)
-
-#define	XDT_PROBE3(event, arg0, arg1, arg2) \
-	XDT_PROBE5(event, arg0, arg1, arg2, 0, 0)
-
-#define	XDT_PROBE2(event, arg0, arg1) \
-	XDT_PROBE5(event, arg0, arg1, 0, 0, 0)
-
-#define	XDT_PROBE1(event, arg0) \
-	XDT_PROBE5(event, arg0, 0, 0, 0, 0)
-
-#define	XDT_PROBE0(event) \
-	XDT_PROBE5(event, 0, 0, 0, 0, 0)
-
-/* Probe classes */
-#define	XDT_SCHED			0
-#define	XDT_MEM				1
-#define	XDT_HVM				2
-#define	XDT_GEN				3
-#define	XDT_PV				4
-#define	XDT_SHADOW			5
-#define	XDT_PM				6
-#define	XDT_NCLASSES			7
-
-/* Probe events */
-#define	XDT_EVT_INVALID			(-(int)1)
-#define	XDT_SCHED_OFF_CPU		0
-#define	XDT_SCHED_ON_CPU		1
-#define	XDT_SCHED_IDLE_OFF_CPU		2
-#define	XDT_SCHED_IDLE_ON_CPU		3
-#define	XDT_SCHED_BLOCK			4
-#define	XDT_SCHED_SLEEP			5
-#define	XDT_SCHED_WAKE			6
-#define	XDT_SCHED_YIELD			7
-#define	XDT_SCHED_SHUTDOWN_POWEROFF	8
-#define	XDT_SCHED_SHUTDOWN_REBOOT	9
-#define	XDT_SCHED_SHUTDOWN_SUSPEND	10
-#define	XDT_SCHED_SHUTDOWN_CRASH	11
-#define	XDT_MEM_PAGE_GRANT_MAP		12
-#define	XDT_MEM_PAGE_GRANT_UNMAP	13
-#define	XDT_MEM_PAGE_GRANT_TRANSFER	14
-#define	XDT_HVM_VMENTRY			15
-#define	XDT_HVM_VMEXIT			16
-#define	XDT_TRC_LOST_RECORDS		17
-#define	XDT_SCHED_ADD_VCPU		18
-#define	XDT_SCHED_REM_VCPU		19	/* unused */
-#define	XDT_SCHED_CTL			20	/* unused */
-#define	XDT_SCHED_ADJDOM		21
-#define	XDT_SCHED_S_TIMER_FN		22	/* unused */
-#define	XDT_SCHED_T_TIMER_FN		23	/* unused */
-#define	XDT_SCHED_DOM_TIMER_FN		24	/* unused */
-#define	XDT_PV_HYPERCALL		25
-#define	XDT_PV_TRAP			26
-#define	XDT_PV_PAGE_FAULT		27
-#define	XDT_PV_FORCED_INVALID_OP	28
-#define	XDT_PV_EMULATE_PRIVOP		29
-#define	XDT_PV_EMULATE_4GB		30	/* unused (32-bit HV only ) */
-#define	XDT_PV_MATH_STATE_RESTORE	31
-#define	XDT_PV_PAGING_FIXUP		32
-#define	XDT_PV_DT_MAPPING_FAULT		33
-#define	XDT_PV_PTWR_EMULATION		34
-#define	XDT_HVM_PF_XEN			35
-#define	XDT_HVM_PF_INJECT		36
-#define	XDT_HVM_EXC_INJECT		37
-#define	XDT_HVM_VIRQ_INJECT		38
-#define	XDT_HVM_VIRQ_REINJECT		39
-#define	XDT_HVM_IO_READ			40	/* unused */
-#define	XDT_HVM_IO_WRITE		41	/* unused */
-#define	XDT_HVM_CR_READ			42
-#define	XDT_HVM_CR_WRITE		43
-#define	XDT_HVM_DR_READ			44	/* unused */
-#define	XDT_HVM_DR_WRITE		45	/* unused */
-#define	XDT_HVM_MSR_READ		46
-#define	XDT_HVM_MSR_WRITE		47
-#define	XDT_HVM_CPUID			48
-#define	XDT_HVM_INTR			49
-#define	XDT_HVM_INTR_WINDOW		50
-#define	XDT_HVM_NMI			51
-#define	XDT_HVM_SMI			52
-#define	XDT_HVM_VMMCALL			53
-#define	XDT_HVM_HLT			54
-#define	XDT_HVM_INVLPG			55
-#define	XDT_HVM_MCE			56
-#define	XDT_HVM_IOPORT_READ		57
-#define	XDT_HVM_IOPORT_WRITE		58
-#define	XDT_HVM_CLTS			59
-#define	XDT_HVM_LMSW			60
-#define	XDT_HVM_IOMEM_READ		61
-#define	XDT_HVM_IOMEM_WRITE		62
-#define	XDT_SHADOW_NOT_SHADOW			63
-#define	XDT_SHADOW_FAST_PROPAGATE		64
-#define	XDT_SHADOW_FAST_MMIO			65
-#define	XDT_SHADOW_FALSE_FAST_PATH		66
-#define	XDT_SHADOW_MMIO				67
-#define	XDT_SHADOW_FIXUP			68
-#define	XDT_SHADOW_DOMF_DYING			69
-#define	XDT_SHADOW_EMULATE			70
-#define	XDT_SHADOW_EMULATE_UNSHADOW_USER	71
-#define	XDT_SHADOW_EMULATE_UNSHADOW_EVTINJ	72
-#define	XDT_SHADOW_EMULATE_UNSHADOW_UNHANDLED	73
-#define	XDT_SHADOW_WRMAP_BF			74
-#define	XDT_SHADOW_PREALLOC_UNPIN		75
-#define	XDT_SHADOW_RESYNC_FULL			76
-#define	XDT_SHADOW_RESYNC_ONLY			77
-#define	XDT_PM_FREQ_CHANGE		78
-#define	XDT_PM_IDLE_ENTRY		79
-#define	XDT_PM_IDLE_EXIT		80
-#define	XDT_SCHED_RUNSTATE_CHANGE	81
-#define	XDT_SCHED_CONTINUE_RUNNING	82
-#define	XDT_NEVENTS			83
-
-typedef struct {
-	const char	*pr_mod;	/* probe module */
-	const char	*pr_name;	/* probe name */
-	int		evt_id;		/* event id */
-	uint_t		class;		/* probe class */
-} xdt_probe_t;
-
-typedef struct {
-	uint32_t	trc_mask;	/* trace mask */
-	uint32_t	cnt;		/* num enabled probes in class */
-} xdt_classinfo_t;
-
-typedef struct {
-	ulong_t prev_domid;		/* previous dom executed */
-	ulong_t prev_vcpuid;		/* previous vcpu executed */
-	ulong_t prev_ctime;		/* time spent on cpu */
-	ulong_t next_domid;		/* next dom to be scheduled */
-	ulong_t next_vcpuid;		/* next vcpu to be scheduled */
-	ulong_t next_wtime;		/* time spent waiting to get on cpu */
-	ulong_t next_ts;		/* allocated time slice */
-	ulong_t cur_domid;		/* current dom */
-	ulong_t cur_vcpuid;		/* current vcpuid */
-	int curinfo_valid;		/* info is valid */
-} xdt_schedinfo_t;
-
-static struct {
-	uint_t cnt;			/* total num of trace buffers */
-	size_t size;			/* size of each cpu buffer */
-	mfn_t start_mfn;		/* starting mfn of buffers */
-	caddr_t va;			/* va buffers are mapped into */
-
-	/* per-cpu buffers */
-	struct t_buf **meta;		/* buffer metadata */
-	struct t_rec **data;		/* buffer data records */
-
-	/* statistics */
-	uint64_t stat_dropped_recs;	/* records dropped */
-	uint64_t stat_spurious_cpu;	/* recs with garbage cpuids */
-	uint64_t stat_spurious_switch;	/* inconsistent vcpu switches */
-	uint64_t stat_unknown_shutdown;	/* unknown shutdown code */
-	uint64_t stat_unknown_recs;	/* unknown records */
-} tbuf;
-
-static size_t tbuf_data_size;
-
-static char *xdt_stats[] = {
-	"dropped_recs",
-};
-
-/*
- * Tunable variables
- *
- * The following may be tuned by adding a line to /etc/system that
- * includes both the name of the module ("xdt") and the name of the variable.
- * For example:
- *     set xdt:xdt_tbuf_pages = 40
- */
-uint_t xdt_tbuf_pages = 20;			/* pages to alloc per-cpu buf */
-
-/*
- * The following may be tuned by adding a line to
- * /platform/i86xpv/kernel/drv/xdt.conf.
- * For example:
- *     xdt_poll_nsec = 200000000;
- */
-static hrtime_t xdt_poll_nsec;			/* trace buffer poll interval */
-
-/*
- * Another tunable variable: the maximum number of records to process
- * in one scan. If it is 0 (e.g. not set in /etc/system), it will
- * be set to ncpu * (bufsize / max_rec_size).
- *
- * Having an upper limit avoids a situation where the scan would loop
- * endlessly in case the hypervisor adds records quicker than we
- * can process them. It's better to drop records than to loop, obviously.
- */
-uint_t xdt_max_recs = 0;
-
-/*
- * Internal variables
- */
-static dev_info_t *xdt_devi;
-static dtrace_provider_id_t xdt_id;
-static uint_t xdt_ncpus;			/* total number of phys CPUs */
-static uint32_t cur_trace_mask;			/* current trace mask */
-static xdt_schedinfo_t *xdt_cpu_schedinfo;	/* per-cpu sched info */
-dtrace_id_t xdt_probemap[XDT_NEVENTS];		/* map of enabled probes */
-dtrace_id_t xdt_prid[XDT_NEVENTS];		/* IDs of registered events */
-static cyclic_id_t xdt_cyclic = CYCLIC_NONE;
-static kstat_t *xdt_kstats;
-static xdt_classinfo_t xdt_classinfo[XDT_NCLASSES];
-
-/*
- * These provide context when probes fire. They can be accessed
- * from xdt dtrace probe (as `xdt_curdom, etc). It's ok for these
- * to be global, and not per-cpu, as probes are run strictly in sequence
- * as the trace buffers are
- */
-uint_t xdt_curdom, xdt_curvcpu, xdt_curpcpu;
-uint64_t xdt_timestamp;
-
-static xdt_probe_t xdt_probe[] = {
-	/* Sched probes */
-	{ "sched", "off-cpu", XDT_SCHED_OFF_CPU, XDT_SCHED },
-	{ "sched", "on-cpu", XDT_SCHED_ON_CPU, XDT_SCHED },
-	{ "sched", "idle-off-cpu", XDT_SCHED_IDLE_OFF_CPU, XDT_SCHED },
-	{ "sched", "idle-on-cpu", XDT_SCHED_IDLE_ON_CPU, XDT_SCHED },
-	{ "sched", "block", XDT_SCHED_BLOCK, XDT_SCHED },
-	{ "sched", "sleep", XDT_SCHED_SLEEP, XDT_SCHED },
-	{ "sched", "wake", XDT_SCHED_WAKE, XDT_SCHED },
-	{ "sched", "yield", XDT_SCHED_YIELD, XDT_SCHED },
-	{ "sched", "shutdown-poweroff", XDT_SCHED_SHUTDOWN_POWEROFF,
-		XDT_SCHED },
-	{ "sched", "shutdown-reboot", XDT_SCHED_SHUTDOWN_REBOOT, XDT_SCHED },
-	{ "sched", "shutdown-suspend", XDT_SCHED_SHUTDOWN_SUSPEND, XDT_SCHED },
-	{ "sched", "shutdown-crash", XDT_SCHED_SHUTDOWN_CRASH, XDT_SCHED },
-	{ "sched", "add", XDT_SCHED_ADD_VCPU, XDT_SCHED },
-	{ "sched", "runstate-change", XDT_SCHED_RUNSTATE_CHANGE, XDT_SCHED },
-	{ "sched", "continue-running", XDT_SCHED_CONTINUE_RUNNING, XDT_SCHED },
-
-	/* Memory probes */
-	{ "mem", "page-grant-map", XDT_MEM_PAGE_GRANT_MAP, XDT_MEM },
-	{ "mem", "page-grant-unmap", XDT_MEM_PAGE_GRANT_UNMAP, XDT_MEM },
-	{ "mem", "page-grant-transfer", XDT_MEM_PAGE_GRANT_TRANSFER, XDT_MEM },
-
-	{"pv", "hypercall", XDT_PV_HYPERCALL, XDT_PV },
-	{"pv", "trap", XDT_PV_TRAP, XDT_PV },
-	{"pv", "page-fault", XDT_PV_PAGE_FAULT, XDT_PV },
-	{"pv", "forced-invalid-op", XDT_PV_FORCED_INVALID_OP, XDT_PV },
-	{"pv", "emulate-priv-op", XDT_PV_EMULATE_PRIVOP, XDT_PV },
-	{"pv", "math-state-restore", XDT_PV_MATH_STATE_RESTORE, XDT_PV },
-	{"pv", "paging-fixup", XDT_PV_PAGING_FIXUP, XDT_PV },
-	{"pv", "dt-mapping-fault", XDT_PV_DT_MAPPING_FAULT, XDT_PV },
-	{"pv", "pte-write-emul", XDT_PV_PTWR_EMULATION, XDT_PV },
-
-	/* HVM probes */
-	{ "hvm", "vmentry", XDT_HVM_VMENTRY, XDT_HVM },
-	{ "hvm", "vmexit", XDT_HVM_VMEXIT, XDT_HVM },
-	{ "hvm", "pagefault-xen", XDT_HVM_PF_XEN, XDT_HVM },
-	{ "hvm", "pagefault-inject", XDT_HVM_PF_INJECT, XDT_HVM },
-	{ "hvm", "exception-inject", XDT_HVM_EXC_INJECT, XDT_HVM },
-	{ "hvm", "virq-inject", XDT_HVM_VIRQ_INJECT, XDT_HVM },
-	{ "hvm", "cr-read", XDT_HVM_CR_READ, XDT_HVM },
-	{ "hvm", "cr-write", XDT_HVM_CR_WRITE, XDT_HVM },
-	{ "hvm", "msr-read", XDT_HVM_MSR_READ, XDT_HVM },
-	{ "hvm", "msr-write", XDT_HVM_MSR_WRITE, XDT_HVM },
-	{ "hvm", "cpuid", XDT_HVM_CPUID, XDT_HVM },
-	{ "hvm", "intr", XDT_HVM_INTR, XDT_HVM },
-	{ "hvm", "intr-window", XDT_HVM_INTR_WINDOW, XDT_HVM },
-	{ "hvm", "nmi", XDT_HVM_NMI, XDT_HVM },
-	{ "hvm", "smi", XDT_HVM_SMI, XDT_HVM },
-	{ "hvm", "vmmcall", XDT_HVM_VMMCALL, XDT_HVM },
-	{ "hvm", "hlt", XDT_HVM_HLT, XDT_HVM },
-	{ "hvm", "invlpg", XDT_HVM_INVLPG, XDT_HVM },
-	{ "hvm", "mce", XDT_HVM_MCE, XDT_HVM },
-	{ "hvm", "pio-read", XDT_HVM_IOPORT_READ, XDT_HVM },
-	{ "hvm", "pio-write", XDT_HVM_IOPORT_WRITE, XDT_HVM },
-	{ "hvm", "mmio-read", XDT_HVM_IOMEM_READ, XDT_HVM },
-	{ "hvm", "mmio-write", XDT_HVM_IOMEM_WRITE, XDT_HVM },
-	{ "hvm", "clts", XDT_HVM_CLTS, XDT_HVM },
-	{ "hvm", "lmsw", XDT_HVM_LMSW, XDT_HVM },
-
-	{ "shadow", "fault-not-shadow", XDT_SHADOW_NOT_SHADOW, XDT_SHADOW },
-	{ "shadow", "fast-propagate", XDT_SHADOW_FAST_PROPAGATE, XDT_SHADOW },
-	{ "shadow", "fast-mmio", XDT_SHADOW_FAST_MMIO, XDT_SHADOW },
-	{ "shadow", "false-fast-path", XDT_SHADOW_FALSE_FAST_PATH,
-	    XDT_SHADOW },
-	{ "shadow", "mmio", XDT_SHADOW_MMIO, XDT_SHADOW },
-	{ "shadow", "fixup", XDT_SHADOW_FIXUP, XDT_SHADOW },
-	{ "shadow", "domf-dying", XDT_SHADOW_DOMF_DYING, XDT_SHADOW },
-	{ "shadow", "emulate", XDT_SHADOW_EMULATE, XDT_SHADOW },
-	{ "shadow", "emulate-unshadow-user", XDT_SHADOW_EMULATE_UNSHADOW_USER,
-	    XDT_SHADOW },
-	{ "shadow", "emulate-unshadow-evtinj",
-	    XDT_SHADOW_EMULATE_UNSHADOW_EVTINJ, XDT_SHADOW },
-	{ "shadow", "emulate-unshadow-unhandled",
-	    XDT_SHADOW_EMULATE_UNSHADOW_UNHANDLED, XDT_SHADOW },
-	{ "shadow", "wrmap-bf", XDT_SHADOW_WRMAP_BF, XDT_SHADOW },
-	{ "shadow", "prealloc-unpin", XDT_SHADOW_PREALLOC_UNPIN, XDT_SHADOW },
-	{ "shadow", "resync-full", XDT_SHADOW_RESYNC_FULL, XDT_SHADOW },
-	{ "shadow", "resync-only", XDT_SHADOW_RESYNC_ONLY, XDT_SHADOW },
-
-	{ "pm", "freq-change", XDT_PM_FREQ_CHANGE, XDT_PM },
-	{ "pm", "idle-entry", XDT_PM_IDLE_ENTRY, XDT_PM },
-	{ "pm", "idle-exit", XDT_PM_IDLE_EXIT, XDT_PM },
-
-	/* Trace buffer related probes */
-	{ "trace", "records-lost", XDT_TRC_LOST_RECORDS, XDT_GEN },
-
-	{ NULL }
-};
-
-static inline uint32_t
-xdt_nr_active_probes()
-{
-	int i;
-	uint32_t tot = 0;
-
-	for (i = 0; i < XDT_NCLASSES; i++)
-		tot += xdt_classinfo[i].cnt;
-
-	return (tot);
-}
-
-static void
-xdt_init_trace_masks(void)
-{
-	xdt_classinfo[XDT_SCHED].trc_mask = TRC_SCHED;
-	xdt_classinfo[XDT_MEM].trc_mask = TRC_MEM;
-	xdt_classinfo[XDT_HVM].trc_mask = TRC_HVM;
-	xdt_classinfo[XDT_GEN].trc_mask = TRC_GEN;
-	xdt_classinfo[XDT_PV].trc_mask = TRC_PV;
-	xdt_classinfo[XDT_SHADOW].trc_mask = TRC_SHADOW;
-	xdt_classinfo[XDT_PM].trc_mask = TRC_PM;
-}
-
-static int
-xdt_kstat_update(kstat_t *ksp, int flag)
-{
-	kstat_named_t *knp;
-
-	if (flag != KSTAT_READ)
-		return (EACCES);
-
-	knp = ksp->ks_data;
-
-	/*
-	 * Assignment order should match that of the names in
-	 * xdt_stats.
-	 */
-	(knp++)->value.ui64 = tbuf.stat_dropped_recs;
-
-	return (0);
-}
-
-static void
-xdt_kstat_init(void)
-{
-	int nstats = sizeof (xdt_stats) / sizeof (xdt_stats[0]);
-	char **cp = xdt_stats;
-	kstat_named_t *knp;
-
-	if ((xdt_kstats = kstat_create("xdt", 0, "trace_statistics", "misc",
-	    KSTAT_TYPE_NAMED, nstats, 0)) == NULL)
-		return;
-
-	xdt_kstats->ks_update = xdt_kstat_update;
-
-	knp = xdt_kstats->ks_data;
-	while (nstats > 0) {
-		kstat_named_init(knp, *cp, KSTAT_DATA_UINT64);
-		knp++;
-		cp++;
-		nstats--;
-	}
-
-	kstat_install(xdt_kstats);
-}
-
-static int
-xdt_sysctl_tbuf(xen_sysctl_tbuf_op_t *tbuf_op)
-{
-	xen_sysctl_t op;
-	int xerr;
-
-	op.cmd = XEN_SYSCTL_tbuf_op;
-	op.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
-	op.u.tbuf_op = *tbuf_op;
-
-	if ((xerr = HYPERVISOR_sysctl(&op)) != 0)
-		return (xen_xlate_errcode(xerr));
-
-	*tbuf_op = op.u.tbuf_op;
-	return (0);
-}
-
-static int
-xdt_map_trace_buffers(mfn_t mfn, caddr_t va, size_t len)
-{
-	x86pte_t pte;
-	caddr_t const sva = va;
-	caddr_t const eva = va + len;
-	int xerr;
-
-	ASSERT(mfn != MFN_INVALID);
-	ASSERT(va != NULL);
-	ASSERT(IS_PAGEALIGNED(len));
-
-	for (; va < eva; va += MMU_PAGESIZE) {
-		/*
-		 * Ask the HAT to load a throwaway mapping to page zero, then
-		 * overwrite it with the hypervisor mapping. It gets removed
-		 * later via hat_unload().
-		 */
-		hat_devload(kas.a_hat, va, MMU_PAGESIZE, (pfn_t)0,
-		    PROT_READ | HAT_UNORDERED_OK,
-		    HAT_LOAD_NOCONSIST | HAT_LOAD);
-
-		pte = mmu_ptob((x86pte_t)mfn) | PT_VALID | PT_USER
-		    | PT_FOREIGN | PT_WRITABLE;
-
-		xerr = HYPERVISOR_update_va_mapping_otherdomain((ulong_t)va,
-		    pte, UVMF_INVLPG | UVMF_LOCAL, DOMID_XEN);
-
-		if (xerr != 0) {
-			/* unmap pages loaded so far */
-			size_t ulen = (uintptr_t)(va + MMU_PAGESIZE) -
-			    (uintptr_t)sva;
-			hat_unload(kas.a_hat, sva, ulen, HAT_UNLOAD_UNMAP);
-			return (xen_xlate_errcode(xerr));
-		}
-
-		mfn++;
-	}
-
-	return (0);
-}
-
-static int
-xdt_attach_trace_buffers(void)
-{
-	xen_sysctl_tbuf_op_t tbuf_op;
-	size_t len;
-	int err;
-	uint_t i;
-
-	/*
-	 * Xen does not support trace buffer re-sizing. If the buffers
-	 * have already been allocated we just use them as is.
-	 */
-	tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
-	if ((err = xdt_sysctl_tbuf(&tbuf_op)) != 0)
-		return (err);
-
-	if (tbuf_op.size == 0) {
-		/* set trace buffer size */
-		tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_size;
-		tbuf_op.size = xdt_tbuf_pages;
-		(void) xdt_sysctl_tbuf(&tbuf_op);
-
-		/* get trace buffer info */
-		tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
-		if ((err = xdt_sysctl_tbuf(&tbuf_op)) != 0)
-			return (err);
-
-		if (tbuf_op.size == 0) {
-			cmn_err(CE_NOTE, "Couldn't allocate trace buffers.");
-			return (ENOBUFS);
-		}
-	}
-
-	tbuf.size = tbuf_op.size;
-	tbuf.start_mfn = (mfn_t)tbuf_op.buffer_mfn;
-	tbuf.cnt = xdt_ncpus;
-
-	ASSERT(tbuf.start_mfn != MFN_INVALID);
-	ASSERT(tbuf.cnt > 0);
-
-	len = tbuf.size * tbuf.cnt;
-	tbuf.va = vmem_alloc(heap_arena, len, VM_SLEEP);
-
-	if ((err = xdt_map_trace_buffers(tbuf.start_mfn, tbuf.va, len)) != 0) {
-		vmem_free(heap_arena, tbuf.va, len);
-		tbuf.va = NULL;
-		return (err);
-	}
-
-	tbuf.meta = (struct t_buf **)kmem_alloc(tbuf.cnt * sizeof (*tbuf.meta),
-	    KM_SLEEP);
-	tbuf.data = (struct t_rec **)kmem_alloc(tbuf.cnt * sizeof (*tbuf.data),
-	    KM_SLEEP);
-
-	for (i = 0; i < tbuf.cnt; i++) {
-		void *cpu_buf = (void *)(tbuf.va + (tbuf.size * i));
-		tbuf.meta[i] = cpu_buf;
-		tbuf.data[i] = (struct t_rec *)((uintptr_t)cpu_buf +
-		    sizeof (struct t_buf));
-
-		/* throw away stale trace records */
-		tbuf.meta[i]->cons = tbuf.meta[i]->prod;
-	}
-
-	tbuf_data_size = tbuf.size - sizeof (struct t_buf);
-	if (xdt_max_recs == 0)
-		xdt_max_recs = (xdt_ncpus * tbuf_data_size)
-		    / sizeof (struct t_rec);
-
-	return (0);
-}
-
-static void
-xdt_detach_trace_buffers(void)
-{
-	size_t len = tbuf.size * tbuf.cnt;
-
-	ASSERT(tbuf.va != NULL);
-
-	hat_unload(kas.a_hat, tbuf.va, len,
-	    HAT_UNLOAD_UNMAP | HAT_UNLOAD_UNLOCK);
-	vmem_free(heap_arena, tbuf.va, len);
-	kmem_free(tbuf.meta, tbuf.cnt * sizeof (*tbuf.meta));
-	kmem_free(tbuf.data, tbuf.cnt * sizeof (*tbuf.data));
-}
-
-static void
-xdt_update_sched_context(uint_t cpuid, uint_t dom, uint_t vcpu)
-{
-	xdt_schedinfo_t *sp = &xdt_cpu_schedinfo[cpuid];
-
-	sp->cur_domid = dom;
-	sp->cur_vcpuid = vcpu;
-	sp->curinfo_valid = 1;
-}
-
-static void
-xdt_update_domain_context(uint_t dom, uint_t vcpu)
-{
-	xdt_curdom = dom;
-	xdt_curvcpu = vcpu;
-}
-
-static size_t
-xdt_process_rec(uint_t cpuid, struct t_rec *rec)
-{
-	xdt_schedinfo_t *sp = &xdt_cpu_schedinfo[cpuid];
-	uint_t dom, vcpu;
-	int eid;
-	uint32_t *data;
-	uint64_t tsc, addr64, rip64, val64, pte64;
-	size_t rec_size;
-
-	ASSERT(rec != NULL);
-	ASSERT(xdt_ncpus == xpv_nr_phys_cpus());
-
-	if (cpuid >= xdt_ncpus) {
-		tbuf.stat_spurious_cpu++;
-		goto done;
-	}
-
-	/*
-	 * If our current state isn't valid, and if this is not
-	 * an event that will update our state, skip it.
-	 */
-
-	if (!sp->curinfo_valid &&
-	    rec->event != TRC_SCHED_SWITCH &&
-	    rec->event != TRC_LOST_RECORDS)
-		goto done;
-
-	if (rec->cycles_included) {
-		data = rec->u.cycles.extra_u32;
-		tsc = (((uint64_t)rec->u.cycles.cycles_hi) << 32)
-		    | rec->u.cycles.cycles_lo;
-	} else {
-		data = rec->u.nocycles.extra_u32;
-		tsc = 0;
-	}
-
-	xdt_timestamp = tsc;
-
-	switch (rec->event) {
-	/*
-	 * Sched probes
-	 */
-	case TRC_SCHED_SWITCH_INFPREV:
-		/*
-		 * Info on vCPU being de-scheduled
-		 *
-		 * data[0] = prev domid
-		 * data[1] = time spent on pcpu
-		 */
-		sp->prev_domid = data[0];
-		sp->prev_ctime = data[1];
-		break;
-
-	case TRC_SCHED_SWITCH_INFNEXT:
-		/*
-		 * Info on next vCPU to be scheduled
-		 *
-		 * data[0] = next domid
-		 * data[1] = time spent waiting to get on cpu
-		 * data[2] = time slice
-		 */
-		sp->next_domid = data[0];
-		sp->next_wtime = data[1];
-		sp->next_ts = data[2];
-		break;
-
-	case TRC_SCHED_SWITCH:
-		/*
-		 * vCPU switch
-		 *
-		 * data[0] = prev domid
-		 * data[1] = prev vcpuid
-		 * data[2] = next domid
-		 * data[3] = next vcpuid
-		 */
-
-		/*
-		 * Provide valid context for this probe if there
-		 * wasn't one.
-		 */
-		if (!sp->curinfo_valid)
-			xdt_update_domain_context(data[0], data[1]);
-
-		xdt_update_sched_context(cpuid, data[0], data[1]);
-
-		if (data[0] != sp->prev_domid &&
-		    data[2] != sp->next_domid) {
-			/* prev and next info don't match doms being sched'd */
-			tbuf.stat_spurious_switch++;
-			goto switchdone;
-		}
-
-		sp->prev_vcpuid = data[1];
-		sp->next_vcpuid = data[3];
-
-		XDT_PROBE3(IS_IDLE_DOM(sp->prev_domid)?
-		    XDT_SCHED_IDLE_OFF_CPU:XDT_SCHED_OFF_CPU,
-		    sp->prev_domid, sp->prev_vcpuid, sp->prev_ctime);
-
-		XDT_PROBE4(IS_IDLE_DOM(sp->next_domid)?
-		    XDT_SCHED_IDLE_ON_CPU:XDT_SCHED_ON_CPU,
-		    sp->next_domid, sp->next_vcpuid, sp->next_wtime,
-		    sp->next_ts);
-switchdone:
-		xdt_update_sched_context(cpuid, data[2], data[3]);
-		xdt_update_domain_context(data[2], data[3]);
-
-		break;
-
-	case TRC_SCHED_BLOCK:
-		/*
-		 * vCPU blocked
-		 *
-		 * data[0] = domid
-		 * data[1] = vcpuid
-		 */
-		XDT_PROBE2(XDT_SCHED_BLOCK, data[0], data[1]);
-		break;
-
-	case TRC_SCHED_SLEEP:
-		/*
-		 * Put vCPU to sleep
-		 *
-		 * data[0] = domid
-		 * data[1] = vcpuid
-		 */
-		XDT_PROBE2(XDT_SCHED_SLEEP, data[0], data[1]);
-		break;
-
-	case TRC_SCHED_WAKE:
-		/*
-		 * Wake up vCPU
-		 *
-		 * data[0] = domid
-		 * data[1] = vcpuid
-		 */
-		XDT_PROBE2(XDT_SCHED_WAKE, data[0], data[1]);
-		break;
-
-	case TRC_SCHED_YIELD:
-		/*
-		 * vCPU yielded
-		 *
-		 * data[0] = domid
-		 * data[1] = vcpuid
-		 */
-		XDT_PROBE2(XDT_SCHED_YIELD, data[0], data[1]);
-		break;
-
-	case TRC_SCHED_SHUTDOWN:
-		/*
-		 * Guest shutting down
-		 *
-		 * data[0] = domid
-		 * data[1] = initiating vcpu
-		 * data[2] = shutdown code
-		 */
-		switch (data[2]) {
-		case SHUTDOWN_poweroff:
-			eid = XDT_SCHED_SHUTDOWN_POWEROFF;
-			break;
-		case SHUTDOWN_reboot:
-			eid = XDT_SCHED_SHUTDOWN_REBOOT;
-			break;
-		case SHUTDOWN_suspend:
-			eid = XDT_SCHED_SHUTDOWN_SUSPEND;
-			break;
-		case SHUTDOWN_crash:
-			eid = XDT_SCHED_SHUTDOWN_CRASH;
-			break;
-		default:
-			tbuf.stat_unknown_shutdown++;
-			goto done;
-		}
-
-		XDT_PROBE2(eid, data[0], data[1]);
-		break;
-
-	case TRC_SCHED_DOM_REM:
-	case TRC_SCHED_CTL:
-	case TRC_SCHED_S_TIMER_FN:
-	case TRC_SCHED_T_TIMER_FN:
-	case TRC_SCHED_DOM_TIMER_FN:
-		/* unused */
-		break;
-	case TRC_SCHED_DOM_ADD:
-		/*
-		 * Add vcpu to a guest.
-		 *
-		 * data[0] = domid
-		 * data[1] = vcpu
-		 */
-		XDT_PROBE2(XDT_SCHED_ADD_VCPU, data[0], data[1]);
-		break;
-	case TRC_SCHED_ADJDOM:
-		/*
-		 * Scheduling parameters for a guest
-		 * were modified.
-		 *
-		 * data[0] = domid;
-		 */
-		XDT_PROBE1(XDT_SCHED_ADJDOM, data[1]);
-		break;
-	case TRC_SCHED_RUNSTATE_CHANGE:
-		/*
-		 * Runstate change for a VCPU.
-		 *
-		 * data[0] = (domain << 16) | vcpu;
-		 * data[1] = oldstate;
-		 * data[2] = newstate;
-		 */
-		XDT_PROBE4(XDT_SCHED_RUNSTATE_CHANGE, data[0] >> 16,
-		    data[0] & 0xffff, data[1], data[2]);
-		break;
-	case TRC_SCHED_CONTINUE_RUNNING:
-		/*
-		 * VCPU is back on a physical CPU that it previously
-		 * was also running this VCPU.
-		 *
-		 * data[0] = (domain << 16) | vcpu;
-		 */
-		XDT_PROBE2(XDT_SCHED_CONTINUE_RUNNING, data[0] >> 16,
-		    data[0] & 0xffff);
-		break;
-	/*
-	 * Mem probes
-	 */
-	case TRC_MEM_PAGE_GRANT_MAP:
-		/*
-		 * Guest mapped page grant
-		 *
-		 * data[0] = target domid
-		 */
-		XDT_PROBE1(XDT_MEM_PAGE_GRANT_MAP, data[0]);
-		break;
-
-	case TRC_MEM_PAGE_GRANT_UNMAP:
-		/*
-		 * Guest unmapped page grant
-		 *
-		 * data[0] = target domid
-		 */
-		XDT_PROBE1(XDT_MEM_PAGE_GRANT_UNMAP, data[0]);
-		break;
-
-	case TRC_MEM_PAGE_GRANT_TRANSFER:
-		/*
-		 * Page grant is being transferred
-		 *
-		 * data[0] = target domid
-		 */
-		XDT_PROBE1(XDT_MEM_PAGE_GRANT_TRANSFER, data[0]);
-		break;
-
-	/*
-	 * Probes for PV domains.
-	 */
-	case TRC_PV_HYPERCALL:
-		/*
-		 * Hypercall from a 32-bit PV domain.
-		 *
-		 * data[0] = eip
-		 * data[1] = eax
-		 */
-		XDT_PROBE2(XDT_PV_HYPERCALL, data[0], data[1]);
-		break;
-	case TRC_PV_HYPERCALL | TRC_64_FLAG:
-		/*
-		 * Hypercall from a 64-bit PV domain.
-		 *
-		 * data[0] = rip(0:31)
-		 * data[1] = rip(32:63)
-		 * data[2] = eax;
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[0];
-		XDT_PROBE2(XDT_PV_HYPERCALL, rip64, data[2]);
-		break;
-	case TRC_PV_TRAP:
-		/*
-		 * Trap in a 32-bit PV domain.
-		 *
-		 * data[0] = eip
-		 * data[1] = trapnr | (error_code_valid << 15)
-		 * 	| (error_code << 16);
-		 */
-		XDT_PROBE4(XDT_PV_TRAP, data[0], data[1] & 0x7fff,
-		    (data[1] >> 15) & 1, data[1] >> 16);
-		break;
-	case TRC_PV_TRAP | TRC_64_FLAG:
-		/*
-		 * Trap in a 64-bit PV domain.
-		 *
-		 * data[0] = rip(0:31)
-		 * data[1] = rip(32:63)
-		 * data[2] = trapnr | (error_code_valid << 15)
-		 * 	| (error_code << 16);
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[2];
-		XDT_PROBE4(XDT_PV_TRAP, rip64, data[2] & 0x7fff,
-		    (data[2] >> 15) & 1, data[2] >> 16);
-		break;
-	case TRC_PV_PAGE_FAULT:
-		/*
-		 * Page fault in a 32-bit PV domain.
-		 *
-		 * data[0] = eip
-		 * data[1] = vaddr
-		 * data[2] = error code
-		 */
-		XDT_PROBE3(XDT_PV_PAGE_FAULT, data[0], data[1], data[2]);
-		break;
-	case TRC_PV_PAGE_FAULT | TRC_64_FLAG:
-		/*
-		 * Page fault in a 32-bit PV domain.
-		 *
-		 * data[0] = rip(0:31)
-		 * data[1] = rip(31:63)
-		 * data[2] = vaddr(0:31)
-		 * data[3] = vaddr(31:63)
-		 * data[4] = error code
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[0];
-		addr64 = (((uint64_t)data[3]) << 32) | data[2];
-		XDT_PROBE3(XDT_PV_PAGE_FAULT, rip64, addr64, data[4]);
-		break;
-	case TRC_PV_FORCED_INVALID_OP:
-		/*
-		 * Hypervisor emulated a forced invalid op (ud2)
-		 * in a 32-bit PV domain.
-		 *
-		 * data[1] = eip
-		 */
-		XDT_PROBE1(XDT_PV_FORCED_INVALID_OP, data[1]);
-		break;
-	case TRC_PV_FORCED_INVALID_OP | TRC_64_FLAG:
-		/*
-		 * Hypervisor emulated a forced invalid op (ud2)
-		 * in a 64-bit PV domain.
-		 *
-		 * data[1] = rip(0:31)
-		 * data[2] = rip(31:63)
-		 *
-		 */
-		rip64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE1(XDT_PV_FORCED_INVALID_OP, rip64);
-		break;
-	case TRC_PV_EMULATE_PRIVOP:
-		/*
-		 * Hypervisor emulated a privileged operation
-		 * in a 32-bit PV domain.
-		 *
-		 * data[0] = eip
-		 */
-		XDT_PROBE1(XDT_PV_EMULATE_PRIVOP, data[0]);
-		break;
-	case TRC_PV_EMULATE_PRIVOP | TRC_64_FLAG:
-		/*
-		 * Hypervisor emulated a privileged operation
-		 * in a 64-bit PV domain.
-		 *
-		 * data[0] = rip(0:31)
-		 * data[1] = rip(31:63)
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[0];
-		XDT_PROBE1(XDT_PV_EMULATE_PRIVOP, rip64);
-		break;
-	case TRC_PV_EMULATE_4GB:
-		/* unused, 32-bit hypervisor only */
-		break;
-	case TRC_PV_MATH_STATE_RESTORE:
-		/*
-		 * Hypervisor restores math state after FP DNA trap.
-		 *
-		 * No arguments.
-		 */
-		XDT_PROBE0(XDT_PV_MATH_STATE_RESTORE);
-		break;
-	case TRC_PV_PAGING_FIXUP:
-		/*
-		 * Hypervisor fixed up a page fault (e.g. it was
-		 * a side-effect of hypervisor guest page table
-		 * bookkeeping, and not propagated to the guest).
-		 *
-		 * data[0] = eip
-		 * data[1] = vaddr
-		 */
-		XDT_PROBE2(XDT_PV_PAGING_FIXUP, data[0], data[2]);
-		break;
-	case TRC_PV_PAGING_FIXUP | TRC_64_FLAG:
-		/*
-		 * Hypervisor fixed up a page fault (e.g. it was
-		 * a side-effect of hypervisor guest page table
-		 * bookkeeping, and not propagated to the guest).
-		 *
-		 * data[0] = eip(0:31)
-		 * data[1] = eip(31:63)
-		 * data[2] = vaddr(0:31)
-		 * data[3] = vaddr(31:63)
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[0];
-		addr64 = (((uint64_t)data[3]) << 32) | data[2];
-		XDT_PROBE2(XDT_PV_PAGING_FIXUP, rip64, addr64);
-		break;
-	case TRC_PV_GDT_LDT_MAPPING_FAULT:
-		/*
-		 * Descriptor table mapping fault in a 32-bit PV domain.
-		 * data[0] = eip
-		 * data[1] = offset
-		 */
-		XDT_PROBE2(XDT_PV_DT_MAPPING_FAULT, data[0], data[1]);
-		break;
-	case TRC_PV_GDT_LDT_MAPPING_FAULT | TRC_64_FLAG:
-		/*
-		 * Descriptor table mapping fault in a 64-bit PV domain.
-		 *
-		 * data[0] = eip(0:31)
-		 * data[1] = eip(31:63)
-		 * data[2] = offset(0:31)
-		 * data[3] = offset(31:63)
-		 */
-		rip64 = (((uint64_t)data[1]) << 32) | data[0];
-		val64 = (((uint64_t)data[3]) << 32) | data[2];
-		XDT_PROBE2(XDT_PV_DT_MAPPING_FAULT, rip64, val64);
-		break;
-	case TRC_PV_PTWR_EMULATION:
-	case TRC_PV_PTWR_EMULATION_PAE | TRC_64_FLAG:
-		/*
-		 * Should only happen on 32-bit hypervisor; unused.
-		 */
-		break;
-	case TRC_PV_PTWR_EMULATION_PAE:
-		/*
-		 * PTE write emulation for a 32-bit PV domain.
-		 *
-		 * data[0] = pte
-		 * data[1] = addr
-		 * data[2] = eip
-		 */
-		XDT_PROBE3(XDT_PV_PTWR_EMULATION, data[0], data[1], data[2]);
-		break;
-	case TRC_PV_PTWR_EMULATION | TRC_64_FLAG:
-		/*
-		 * PTE write emulation for a 64-bit PV domain.
-		 *
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = addr(0:31)
-		 * data[3] = addr(32:63)
-		 * data[4] = rip(0:31)
-		 * data[5] = rip(32:63)
-		 */
-		pte64 = (((uint64_t)data[1]) << 32) | data[0];
-		addr64 = (((uint64_t)data[3]) << 32) | data[2];
-		rip64 = (((uint64_t)data[5]) << 32) | data[4];
-		XDT_PROBE3(XDT_PV_PTWR_EMULATION, pte64, addr64, rip64);
-		break;
-
-	/*
-	 * HVM probes
-	 */
-	case TRC_HVM_VMENTRY:
-		/*
-		 * Return to guest via vmx_launch/vmrun
-		 *
-		 */
-		XDT_PROBE0(XDT_HVM_VMENTRY);
-		break;
-
-	case TRC_HVM_VMEXIT:
-		/*
-		 * Entry into VMEXIT handler from 32-bit HVM domain
-		 *
-		 * data[0] = cpu vendor specific exit code
-		 * data[1] = guest eip
-		 */
-		XDT_PROBE2(XDT_HVM_VMEXIT, data[0], data[1]);
-		break;
-	case TRC_HVM_VMEXIT64:
-		/*
-		 * Entry into VMEXIT handler from 64-bit HVM domain
-		 *
-		 * data[0] = cpu vendor specific exit code
-		 * data[1] = guest rip(0:31)
-		 * data[2] = guest rip(32:64)
-		 */
-		rip64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_VMEXIT, data[0], rip64);
-		break;
-
-	case TRC_HVM_PF_XEN64:
-		/*
-		 * Pagefault in a guest that is a Xen (e.g. shadow)
-		 * artifact, and is not injected back into the guest.
-		 *
-		 * data[0] = error code
-		 * data[1] = guest VA(0:31)
-		 * data[2] = guest VA(32:64)
-		 */
-		addr64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_PF_XEN, data[0], addr64);
-		break;
-
-	case TRC_HVM_PF_XEN:
-		/*
-		 * Same as above, but for a 32-bit HVM domain.
-		 *
-		 * data[0] = error code
-		 * data[1] = guest VA
-		 */
-		XDT_PROBE2(XDT_HVM_PF_XEN, data[0], data[1]);
-		break;
-
-	case TRC_HVM_PF_INJECT:
-		/*
-		 * 32-bit Xen only.
-		 */
-		break;
-	case TRC_HVM_PF_INJECT64:
-		/*
-		 * Pagefault injected back into a guest (e.g. the shadow
-		 * code found no mapping).
-		 *
-		 * data[0] = error code
-		 * data[1] = guest VA(0:31)
-		 * data[2] = guest VA(32:64)
-		 */
-		addr64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_PF_INJECT, data[0], addr64);
-		break;
-
-	case TRC_HVM_INJ_EXC:
-		/*
-		 * Exception injected into an HVM guest.
-		 *
-		 * data[0] = trap
-		 * data[1] = error code
-		 */
-		XDT_PROBE2(XDT_HVM_EXC_INJECT, data[0], data[1]);
-		break;
-	case TRC_HVM_INJ_VIRQ:
-		/*
-		 * Interrupt inject into an HVM guest.
-		 *
-		 * data[0] = vector
-		 */
-		XDT_PROBE1(XDT_HVM_VIRQ_INJECT, data[0]);
-		break;
-	case TRC_HVM_REINJ_VIRQ:
-	case TRC_HVM_IO_READ:
-	case TRC_HVM_IO_WRITE:
-		/* unused */
-		break;
-	case TRC_HVM_CR_READ64:
-		/*
-		 * Control register read. Intel VMX only.
-		 *
-		 * data[0] = control register #
-		 * data[1] = value(0:31)
-		 * data[2] = value(32:63)
-		 */
-		val64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_CR_READ, data[0], val64);
-		break;
-	case TRC_HVM_CR_READ:
-		/*
-		 * unused (32-bit Xen only)
-		 */
-		break;
-	case TRC_HVM_CR_WRITE64:
-		/*
-		 * Control register write. Intel VMX only.
-		 *
-		 * data[0] = control register #
-		 * data[1] = value(0:31)
-		 * data[2] = value(32:63)
-		 */
-		val64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_CR_READ, data[0], val64);
-		break;
-	case TRC_HVM_CR_WRITE:
-		/*
-		 * unused (32-bit Xen only)
-		 */
-		break;
-	case TRC_HVM_DR_READ:
-		/*
-		 * unused.
-		 *
-		 * data[0] = (domid<<16 + vcpuid)
-		 */
-		break;
-	case TRC_HVM_DR_WRITE:
-		/*
-		 * Debug register write. Not too useful; no values,
-		 * so we ignore this.
-		 *
-		 * data[0] = (domid<<16 + vcpuid)
-		 */
-		break;
-	case TRC_HVM_MSR_READ:
-		/*
-		 * MSR read.
-		 *
-		 * data[0] = MSR
-		 * data[1] = value(0:31)
-		 * data[2] = value(32:63)
-		 */
-		val64 = (((uint64_t)data[3]) << 32) | data[2];
-		XDT_PROBE2(XDT_HVM_MSR_READ, data[0], val64);
-		break;
-	case TRC_HVM_MSR_WRITE:
-		/*
-		 * MSR write.
-		 *
-		 * data[0] = MSR;
-		 * data[1] = value(0:31)
-		 * data[2] = value(32:63)
-		 */
-		val64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_MSR_WRITE, data[0], val64);
-		break;
-	case TRC_HVM_CPUID:
-		/*
-		 * CPUID insn.
-		 *
-		 * data[0] = %eax (input)
-		 * data[1] = %eax
-		 * data[2] = %ebx
-		 * data[3] = %ecx
-		 * data[4] = %edx
-		 */
-		XDT_PROBE5(XDT_HVM_CPUID, data[0], data[1], data[2], data[3],
-		    data[4]);
-		break;
-	case TRC_HVM_INTR:
-		/*
-		 * VMEXIT because of an interrupt.
-		 */
-		XDT_PROBE0(XDT_HVM_INTR);
-		break;
-	case TRC_HVM_INTR_WINDOW:
-		/*
-		 * VMEXIT because of an interrupt window (an interrupt
-		 * can't be delivered immediately to a HVM guest and must
-		 * be delayed).
-		 *
-		 * data[0] = vector
-		 * data[1] = source
-		 * data[2] = info
-		 */
-		XDT_PROBE3(XDT_HVM_INTR_WINDOW, data[0], data[1], data[2]);
-		break;
-	case TRC_HVM_NMI:
-		/*
-		 * VMEXIT because of an NMI.
-		 */
-		XDT_PROBE0(XDT_HVM_NMI);
-		break;
-	case TRC_HVM_SMI:
-		/*
-		 * VMEXIT because of an SMI
-		 */
-		XDT_PROBE0(XDT_HVM_SMI);
-		break;
-	case TRC_HVM_VMMCALL:
-		/*
-		 * VMMCALL insn.
-		 *
-		 * data[0] = %eax
-		 */
-		XDT_PROBE1(XDT_HVM_VMMCALL, data[0]);
-		break;
-	case TRC_HVM_HLT:
-		/*
-		 * HLT insn.
-		 *
-		 * data[0] = 1 if VCPU runnable, 0 if not
-		 */
-		XDT_PROBE1(XDT_HVM_HLT, data[0]);
-		break;
-	case TRC_HVM_INVLPG64:
-		/*
-		 *
-		 * data[0] = INVLPGA ? 1 : 0
-		 * data[1] = vaddr(0:31)
-		 * data[2] = vaddr(32:63)
-		 */
-		addr64 = (((uint64_t)data[2]) << 32) | data[1];
-		XDT_PROBE2(XDT_HVM_INVLPG, data[0], addr64);
-		break;
-	case TRC_HVM_INVLPG:
-		/*
-		 * unused (32-bit Xen only)
-		 *
-		 * data[0] = (domid<<16 + vcpuid)
-		 */
-		break;
-	case TRC_HVM_MCE:
-		/*
-		 * #MCE VMEXIT
-		 *
-		 */
-		XDT_PROBE0(XDT_HVM_MCE);
-		break;
-	case TRC_HVM_IOPORT_READ:
-	case TRC_HVM_IOPORT_WRITE:
-	case TRC_HVM_IOMEM_READ:
-	case TRC_HVM_IOMEM_WRITE:
-		/*
-		 * data[0] = addr(0:31)
-		 * data[1] = addr(32:63)
-		 * data[2] = count
-		 * data[3] = size
-		 */
-		switch (rec->event) {
-		case TRC_HVM_IOPORT_READ:
-			eid = XDT_HVM_IOPORT_READ;
-			break;
-		case TRC_HVM_IOPORT_WRITE:
-			eid = XDT_HVM_IOPORT_WRITE;
-			break;
-		case TRC_HVM_IOMEM_READ:
-			eid = XDT_HVM_IOMEM_READ;
-			break;
-		case TRC_HVM_IOMEM_WRITE:
-			eid = XDT_HVM_IOMEM_WRITE;
-			break;
-		}
-		addr64 = (((uint64_t)data[1]) << 32) | data[0];
-		XDT_PROBE3(eid, addr64, data[2], data[3]);
-		break;
-	case TRC_HVM_CLTS:
-		/*
-		 * CLTS insn (Intel VMX only)
-		 */
-		XDT_PROBE0(XDT_HVM_CLTS);
-		break;
-	case TRC_HVM_LMSW64:
-		/*
-		 * LMSW insn.
-		 *
-		 * data[0] = value(0:31)
-		 * data[1] = value(32:63)
-		 */
-		val64 = (((uint64_t)data[1]) << 32) | data[0];
-		XDT_PROBE1(XDT_HVM_LMSW, val64);
-		break;
-	case TRC_HVM_LMSW:
-		/*
-		 * unused (32-bit Xen only)
-		 */
-		break;
-
-	/*
-	 * Shadow page table probes (mainly used for HVM domains
-	 * without hardware paging support).
-	 */
-	case TRC_SHADOW_NOT_SHADOW | SH_GUEST_32:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = va
-		 * data[3] = flags
-		 */
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE3(XDT_SHADOW_NOT_SHADOW, pte64, data[2], data[3]);
-		break;
-	case TRC_SHADOW_NOT_SHADOW | SH_GUEST_PAE:
-	case TRC_SHADOW_NOT_SHADOW | SH_GUEST_64:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = va(0:31)
-		 * data[3] = va(32:63)
-		 * data[4] = flags
-		 */
-		addr64 = ((uint64_t)data[2] << 32) | data[3];
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE3(XDT_SHADOW_NOT_SHADOW, pte64, addr64, data[4]);
-		break;
-	case TRC_SHADOW_FAST_PROPAGATE | SH_GUEST_32:
-		/*
-		 * data[0] = va
-		 */
-		XDT_PROBE1(XDT_SHADOW_FAST_PROPAGATE, data[0]);
-		break;
-	case TRC_SHADOW_FAST_PROPAGATE | SH_GUEST_PAE:
-	case TRC_SHADOW_FAST_PROPAGATE | SH_GUEST_64:
-		/*
-		 * data[0] = va(0:31)
-		 * data[1] = va(32:63)
-		 */
-		addr64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_FAST_PROPAGATE, addr64);
-		break;
-	case TRC_SHADOW_FAST_MMIO | SH_GUEST_32:
-		/*
-		 * data[0] = va
-		 */
-		XDT_PROBE1(XDT_SHADOW_FAST_MMIO, data[0]);
-		break;
-	case TRC_SHADOW_FAST_MMIO | SH_GUEST_PAE:
-	case TRC_SHADOW_FAST_MMIO | SH_GUEST_64:
-		/*
-		 * data[0] = va(0:31)
-		 * data[1] = va(32:63)
-		 */
-		addr64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_FAST_MMIO, addr64);
-		break;
-	case TRC_SHADOW_FALSE_FAST_PATH | SH_GUEST_32:
-		/*
-		 * data[0] = va
-		 */
-		XDT_PROBE1(XDT_SHADOW_FALSE_FAST_PATH, data[0]);
-		break;
-	case TRC_SHADOW_FALSE_FAST_PATH | SH_GUEST_PAE:
-	case TRC_SHADOW_FALSE_FAST_PATH | SH_GUEST_64:
-		/*
-		 * data[0] = va(0:31)
-		 * data[1] = va(32:63)
-		 */
-		addr64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_FALSE_FAST_PATH, addr64);
-		break;
-	case TRC_SHADOW_MMIO | SH_GUEST_32:
-		/*
-		 * data[0] = va
-		 */
-		XDT_PROBE1(XDT_SHADOW_MMIO, data[0]);
-		break;
-	case TRC_SHADOW_MMIO | SH_GUEST_PAE:
-	case TRC_SHADOW_MMIO | SH_GUEST_64:
-		/*
-		 * data[0] = va(0:31)
-		 * data[1] = va(32:63)
-		 */
-		addr64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_MMIO, addr64);
-		break;
-	case TRC_SHADOW_FIXUP | SH_GUEST_32:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = va
-		 * data[3] = flags
-		 */
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE3(XDT_SHADOW_FIXUP, pte64, data[2], data[3]);
-		break;
-	case TRC_SHADOW_FIXUP | SH_GUEST_64:
-	case TRC_SHADOW_FIXUP | SH_GUEST_PAE:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = va(0:31)
-		 * data[3] = va(32:63)
-		 * data[4] = flags
-		 */
-		addr64 = ((uint64_t)data[2] << 32) | data[3];
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE3(XDT_SHADOW_FIXUP, pte64, addr64, data[4]);
-		break;
-	case TRC_SHADOW_DOMF_DYING | SH_GUEST_32:
-		/*
-		 * data[0] = va
-		 */
-		XDT_PROBE1(XDT_SHADOW_DOMF_DYING, data[0]);
-		break;
-	case TRC_SHADOW_DOMF_DYING | SH_GUEST_PAE:
-	case TRC_SHADOW_DOMF_DYING | SH_GUEST_64:
-		/*
-		 * data[0] = va(0:31)
-		 * data[1] = va(32:63)
-		 */
-		addr64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_DOMF_DYING, addr64);
-		break;
-	case TRC_SHADOW_EMULATE | SH_GUEST_32:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = val(0:31)
-		 * data[3] = val(32:63)
-		 * data[4] = addr
-		 * data[5] = flags
-		 */
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		val64 = ((uint64_t)data[3] << 32) | data[2];
-		XDT_PROBE5(XDT_SHADOW_EMULATE, pte64, val64, data[4],
-		    data[5] & 0x7fffffff, data[5] >> 29);
-		break;
-	case TRC_SHADOW_EMULATE | SH_GUEST_PAE:
-	case TRC_SHADOW_EMULATE | SH_GUEST_64:
-		/*
-		 * data[0] = pte(0:31)
-		 * data[1] = pte(32:63)
-		 * data[2] = val(0:31)
-		 * data[3] = val(32:63)
-		 * data[4] = addr(0:31)
-		 * data[5] = addr(32:63)
-		 * data[6] = flags
-		 */
-		pte64 = ((uint64_t)data[1] << 32) | data[0];
-		val64 = ((uint64_t)data[3] << 32) | data[2];
-		addr64 = ((uint64_t)data[5] << 32) | data[4];
-		XDT_PROBE5(XDT_SHADOW_EMULATE, pte64, val64, data[4],
-		    data[6] & 0x7fffffff, data[6] >> 29);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_USER | SH_GUEST_32:
-		/*
-		 * data[0] = gfn
-		 * data[1] = vaddr
-		 */
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_USER, data[0], data[1]);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_USER | SH_GUEST_PAE:
-	case TRC_SHADOW_EMULATE_UNSHADOW_USER | SH_GUEST_64:
-		/*
-		 * data[0] = gfn(0:31)
-		 * data[1] = gfn(32:63)
-		 * data[2] = vaddr(0:31)
-		 * data[3] = vaddr(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		addr64 = ((uint64_t)data[3] << 32) | data[2];
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_USER, val64, addr64);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ | SH_GUEST_32:
-		/*
-		 * data[0] = gfn
-		 * data[1] = vaddr
-		 */
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_EVTINJ, data[0],
-		    data[1]);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ | SH_GUEST_PAE:
-	case TRC_SHADOW_EMULATE_UNSHADOW_EVTINJ | SH_GUEST_64:
-		/*
-		 * data[0] = gfn(0:31)
-		 * data[1] = gfn(32:63)
-		 * data[2] = vaddr(0:31)
-		 * data[3] = vaddr(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		addr64 = ((uint64_t)data[3] << 32) | data[2];
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_EVTINJ, val64, addr64);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED | SH_GUEST_32:
-		/*
-		 * data[0] = gfn
-		 * data[1] = vaddr
-		 */
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_UNHANDLED, data[0],
-		    data[1]);
-		break;
-	case TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED | SH_GUEST_PAE:
-	case TRC_SHADOW_EMULATE_UNSHADOW_UNHANDLED | SH_GUEST_64:
-		/*
-		 * data[0] = gfn(0:31)
-		 * data[1] = gfn(32:63)
-		 * data[2] = vaddr(0:31)
-		 * data[3] = vaddr(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		addr64 = ((uint64_t)data[3] << 32) | data[2];
-		XDT_PROBE2(XDT_SHADOW_EMULATE_UNSHADOW_UNHANDLED, val64,
-		    addr64);
-		break;
-	case TRC_SHADOW_WRMAP_BF:
-		/*
-		 * data[0] = gfn(0:31)
-		 * data[1] = gfn(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_WRMAP_BF, val64);
-		break;
-	case TRC_SHADOW_PREALLOC_UNPIN:
-		/*
-		 * data[0] = gfn(0:31)
-		 * data[1] = gfn(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_PREALLOC_UNPIN, val64);
-		break;
-	case TRC_SHADOW_RESYNC_FULL:
-		/*
-		 * data[0] = gmfn(0:31)
-		 * data[1] = gmfn(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_RESYNC_FULL, val64);
-		break;
-	case TRC_SHADOW_RESYNC_ONLY:
-		/*
-		 * data[0] = gmfn(0:31)
-		 * data[1] = gmfn(32:63)
-		 */
-		val64 = ((uint64_t)data[1] << 32) | data[0];
-		XDT_PROBE1(XDT_SHADOW_RESYNC_ONLY, val64);
-		break;
-
-	/*
-	 * Power management probes.
-	 */
-	case TRC_PM_FREQ_CHANGE:
-		/*
-		 * data[0] = old freq
-		 * data[1] = new freq
-		 */
-		XDT_PROBE2(XDT_PM_FREQ_CHANGE, data[0], data[1]);
-		break;
-	case TRC_PM_IDLE_ENTRY:
-		/*
-		 * data[0] = C-state
-		 * data[1] = time
-		 */
-		XDT_PROBE2(XDT_PM_IDLE_ENTRY, data[0], data[1]);
-		break;
-	case TRC_PM_IDLE_EXIT:
-		/*
-		 * data[0] = C-state
-		 * data[1] = time
-		 */
-		XDT_PROBE2(XDT_PM_IDLE_EXIT, data[0], data[1]);
-		break;
-	case TRC_LOST_RECORDS:
-		vcpu = data[1] >> 16;
-		dom = data[1] & 0xffff;
-		xdt_update_sched_context(cpuid, dom, vcpu);
-		xdt_update_domain_context(dom, vcpu);
-		XDT_PROBE1(XDT_TRC_LOST_RECORDS, cpuid);
-		tbuf.stat_dropped_recs++;
-		break;
-
-	default:
-		tbuf.stat_unknown_recs++;
-		break;
-	}
-
-done:
-	rec_size = 4 + (rec->cycles_included ? 8 : 0) + (rec->extra_u32 * 4);
-	return (rec_size);
-}
-
-/*
- * Scan all CPU buffers for the record with the lowest timestamp so
- * that the probes will fire in order.
- */
-static int
-xdt_get_first_rec(uint_t *cpuidp, struct t_rec **recp, uint32_t *consp)
-{
-	uint_t cpuid;
-	uint32_t prod, cons, offset;
-	struct t_rec *rec;
-	uint64_t minstamp = ~0ULL, stamp;
-	uintptr_t data;
-
-	for (cpuid = 0; cpuid < tbuf.cnt; cpuid++) {
-		cons = tbuf.meta[cpuid]->cons;
-		prod = tbuf.meta[cpuid]->prod;
-		membar_consumer();
-		if (prod == cons)
-			continue;
-
-		offset = cons % tbuf_data_size;
-		data = (uintptr_t)tbuf.data[cpuid] + offset;
-		rec = (struct t_rec *)data;
-		ASSERT((caddr_t)rec < tbuf.va + (tbuf.size * (cpuid + 1)));
-
-		/*
-		 * All records that we know about have time cycles included.
-		 * If this record doesn't have them, assume it's a type
-		 * that we don't handle. Use a 0 time value, which will make
-		 * it get handled first (it will be thrown away).
-		 */
-		if (rec->cycles_included)
-			stamp = (((uint64_t)rec->u.cycles.cycles_hi) << 32)
-			    | rec->u.cycles.cycles_lo;
-		else
-			stamp = 0;
-
-		if (stamp < minstamp) {
-			minstamp = stamp;
-			*cpuidp = cpuid;
-			*recp = rec;
-			*consp = cons;
-		}
-	}
-
-	if (minstamp != ~0ULL)
-		return (1);
-
-	return (0);
-}
-
-/*ARGSUSED*/
-static void
-xdt_tbuf_scan(void *arg)
-{
-	uint32_t bytes_done, cons;
-	struct t_rec *rec;
-	xdt_schedinfo_t *sp;
-	uint_t nrecs, cpuid;
-
-	for (nrecs = 0;
-	    nrecs < xdt_max_recs && xdt_get_first_rec(&cpuid, &rec, &cons) > 0;
-	    nrecs++) {
-		xdt_curpcpu = cpuid;
-		sp = &xdt_cpu_schedinfo[cpuid];
-		if (sp->curinfo_valid)
-			xdt_update_domain_context(sp->cur_domid,
-			    sp->cur_vcpuid);
-
-		bytes_done = xdt_process_rec(cpuid, rec);
-		cons += bytes_done;
-		/*
-		 * cons and prod are incremented modulo (2 * tbuf_data_size).
-		 * See <xen/public/trace.h>.
-		 */
-		if (cons >= 2 * tbuf_data_size)
-			cons -= 2 * tbuf_data_size;
-		membar_exit();
-		tbuf.meta[cpuid]->cons = cons;
-	}
-}
-
-static void
-xdt_cyclic_enable(void)
-{
-	cyc_handler_t hdlr;
-	cyc_time_t when;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-
-	hdlr.cyh_func = xdt_tbuf_scan;
-	hdlr.cyh_arg = NULL;
-	hdlr.cyh_level = CY_LOW_LEVEL;
-
-	when.cyt_interval = xdt_poll_nsec;
-	when.cyt_when = dtrace_gethrtime() + when.cyt_interval;
-
-	xdt_cyclic = cyclic_add(&hdlr, &when);
-}
-
-static void
-xdt_probe_create(xdt_probe_t *p)
-{
-	ASSERT(p != NULL && p->pr_mod != NULL);
-
-	if (dtrace_probe_lookup(xdt_id, p->pr_mod, NULL, p->pr_name) != 0)
-		return;
-
-	xdt_prid[p->evt_id] = dtrace_probe_create(xdt_id, p->pr_mod, NULL,
-	    p->pr_name, dtrace_mach_aframes(), p);
-}
-
-/*ARGSUSED*/
-static void
-xdt_provide(void *arg, const dtrace_probedesc_t *desc)
-{
-	const char *mod, *name;
-	int i;
-
-	if (desc == NULL) {
-		for (i = 0; xdt_probe[i].pr_mod != NULL; i++) {
-			xdt_probe_create(&xdt_probe[i]);
-		}
-	} else {
-		mod = desc->dtpd_mod;
-		name = desc->dtpd_name;
-		for (i = 0; xdt_probe[i].pr_mod != NULL; i++) {
-			int l1 = strlen(xdt_probe[i].pr_name);
-			int l2 = strlen(xdt_probe[i].pr_mod);
-			if (strncmp(name, xdt_probe[i].pr_name, l1) == 0 &&
-			    strncmp(mod, xdt_probe[i].pr_mod, l2) == 0)
-				break;
-		}
-
-		if (xdt_probe[i].pr_mod == NULL)
-			return;
-		xdt_probe_create(&xdt_probe[i]);
-	}
-
-}
-
-/*ARGSUSED*/
-static void
-xdt_destroy(void *arg, dtrace_id_t id, void *parg)
-{
-	xdt_probe_t *p = parg;
-	xdt_prid[p->evt_id] = 0;
-}
-
-static void
-xdt_set_trace_mask(uint32_t mask)
-{
-	xen_sysctl_tbuf_op_t tbuf_op;
-
-	/* Always need to trace scheduling, for context */
-	if (mask != 0)
-		mask |= TRC_SCHED;
-	tbuf_op.evt_mask = mask;
-	tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_evt_mask;
-	(void) xdt_sysctl_tbuf(&tbuf_op);
-}
-
-/*ARGSUSED*/
-static int
-xdt_enable(void *arg, dtrace_id_t id, void *parg)
-{
-	xdt_probe_t *p = parg;
-	xen_sysctl_tbuf_op_t tbuf_op;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-	ASSERT(xdt_prid[p->evt_id] != 0);
-
-	xdt_probemap[p->evt_id] = xdt_prid[p->evt_id];
-	xdt_classinfo[p->class].cnt++;
-
-	if (xdt_classinfo[p->class].cnt == 1) {
-		/* set the trace mask for this class */
-		cur_trace_mask |= xdt_classinfo[p->class].trc_mask;
-		xdt_set_trace_mask(cur_trace_mask);
-	}
-
-	if (xdt_cyclic == CYCLIC_NONE) {
-		tbuf_op.cmd = XEN_SYSCTL_TBUFOP_enable;
-		if (xdt_sysctl_tbuf(&tbuf_op) != 0) {
-			cmn_err(CE_NOTE, "Couldn't enable hypervisor tracing.");
-			return (-1);
-		}
-
-		xdt_cyclic_enable();
-	}
-	return (0);
-}
-
-/*ARGSUSED*/
-static void
-xdt_disable(void *arg, dtrace_id_t id, void *parg)
-{
-	xdt_probe_t *p = parg;
-	xen_sysctl_tbuf_op_t tbuf_op;
-	int i, err;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-	ASSERT(xdt_probemap[p->evt_id] != 0);
-	ASSERT(xdt_probemap[p->evt_id] == xdt_prid[p->evt_id]);
-	ASSERT(xdt_classinfo[p->class].cnt > 0);
-
-	/*
-	 * We could be here in the slight window between the cyclic firing and
-	 * a call to dtrace_probe() occurring. We need to be careful if we tear
-	 * down any shared state.
-	 */
-
-	xdt_probemap[p->evt_id] = 0;
-	xdt_classinfo[p->class].cnt--;
-
-	if (xdt_nr_active_probes() == 0) {
-		cur_trace_mask = 0;
-
-		if (xdt_cyclic == CYCLIC_NONE)
-			return;
-
-		for (i = 0; i < xdt_ncpus; i++)
-			xdt_cpu_schedinfo[i].curinfo_valid = 0;
-
-		/*
-		 * We will try to disable the trace buffers. If we fail for some
-		 * reason we will try again, up to a count of XDT_TBUF_RETRY.
-		 * If we still aren't successful we try to set the trace mask
-		 * to 0 in order to prevent trace records from being written.
-		 */
-		tbuf_op.cmd = XEN_SYSCTL_TBUFOP_disable;
-		i = 0;
-		do {
-			err = xdt_sysctl_tbuf(&tbuf_op);
-		} while ((err != 0) && (++i < XDT_TBUF_RETRY));
-
-		if (err != 0) {
-			cmn_err(CE_NOTE,
-			    "Couldn't disable hypervisor tracing.");
-			xdt_set_trace_mask(0);
-		} else {
-			cyclic_remove(xdt_cyclic);
-			xdt_cyclic = CYCLIC_NONE;
-			/*
-			 * We don't bother making the hypercall to set
-			 * the trace mask, since it will be reset when
-			 * tracing is re-enabled.
-			 */
-		}
-	} else if (xdt_classinfo[p->class].cnt == 0) {
-		cur_trace_mask ^= xdt_classinfo[p->class].trc_mask;
-		/* other probes are enabled, so add the sub-class mask back */
-		cur_trace_mask |= 0xF000;
-		xdt_set_trace_mask(cur_trace_mask);
-	}
-}
-
-static dtrace_pattr_t xdt_attr = {
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
-{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_PLATFORM },
-};
-
-static dtrace_pops_t xdt_pops = {
-	xdt_provide,		/* dtps_provide() */
-	NULL,			/* dtps_provide_module() */
-	xdt_enable,		/* dtps_enable() */
-	xdt_disable,		/* dtps_disable() */
-	NULL,			/* dtps_suspend() */
-	NULL,			/* dtps_resume() */
-	NULL,			/* dtps_getargdesc() */
-	NULL,			/* dtps_getargval() */
-	NULL,			/* dtps_usermode() */
-	xdt_destroy		/* dtps_destroy() */
-};
-
-static int
-xdt_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
-{
-	int val;
-
-	if (!DOMAIN_IS_INITDOMAIN(xen_info))
-		return (DDI_FAILURE);
-
-	switch (cmd) {
-	case DDI_ATTACH:
-		break;
-
-	case DDI_RESUME:
-		/*
-		 * We might support proper suspend/resume in the future, so,
-		 * return DDI_FAILURE for now.
-		 */
-		return (DDI_FAILURE);
-
-	default:
-		return (DDI_FAILURE);
-	}
-
-	xdt_ncpus = xpv_nr_phys_cpus();
-	ASSERT(xdt_ncpus > 0);
-
-	if (ddi_create_minor_node(devi, "xdt", S_IFCHR, 0, DDI_PSEUDO, 0) ==
-	    DDI_FAILURE || xdt_attach_trace_buffers() != 0 ||
-	    dtrace_register("xdt", &xdt_attr, DTRACE_PRIV_KERNEL, NULL,
-	    &xdt_pops, NULL, &xdt_id) != 0) {
-		if (tbuf.va != NULL)
-			xdt_detach_trace_buffers();
-		ddi_remove_minor_node(devi, NULL);
-		return (DDI_FAILURE);
-	}
-
-	val = ddi_getprop(DDI_DEV_T_ANY, devi, DDI_PROP_DONTPASS,
-	    "xdt_poll_nsec", XDT_POLL_DEFAULT);
-	xdt_poll_nsec = MAX(val, XDT_POLL_MIN);
-
-	xdt_cpu_schedinfo = (xdt_schedinfo_t *)kmem_zalloc(xdt_ncpus *
-	    sizeof (xdt_schedinfo_t), KM_SLEEP);
-	xdt_init_trace_masks();
-	xdt_kstat_init();
-
-	xdt_devi = devi;
-	ddi_report_dev(devi);
-	return (DDI_SUCCESS);
-}
-
-static int
-xdt_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
-{
-	switch (cmd) {
-	case DDI_DETACH:
-		break;
-
-	case DDI_SUSPEND:
-		/*
-		 * We might support proper suspend/resume in the future. So
-		 * return DDI_FAILURE for now.
-		 */
-		return (DDI_FAILURE);
-
-	default:
-		return (DDI_FAILURE);
-	}
-
-	if (dtrace_unregister(xdt_id) != 0)
-		return (DDI_FAILURE);
-
-	xdt_detach_trace_buffers();
-	kmem_free(xdt_cpu_schedinfo, xdt_ncpus * sizeof (xdt_schedinfo_t));
-	if (xdt_cyclic != CYCLIC_NONE)
-		cyclic_remove(xdt_cyclic);
-	if (xdt_kstats != NULL)
-		kstat_delete(xdt_kstats);
-	xdt_devi = (void *)0;
-	ddi_remove_minor_node(devi, NULL);
-
-	return (DDI_SUCCESS);
-}
-
-/*ARGSUSED*/
-static int
-xdt_info(dev_info_t *devi, ddi_info_cmd_t infocmd, void *arg, void **result)
-{
-	int error;
-
-	switch (infocmd) {
-	case DDI_INFO_DEVT2DEVINFO:
-		*result = xdt_devi;
-		error = DDI_SUCCESS;
-		break;
-	case DDI_INFO_DEVT2INSTANCE:
-		*result = (void *)0;
-		error = DDI_SUCCESS;
-		break;
-	default:
-		error = DDI_FAILURE;
-	}
-	return (error);
-}
-
-static struct cb_ops xdt_cb_ops = {
-	nulldev,		/* open(9E) */
-	nodev,			/* close(9E) */
-	nodev,			/* strategy(9E) */
-	nodev,			/* print(9E) */
-	nodev,			/* dump(9E) */
-	nodev,			/* read(9E) */
-	nodev,			/* write(9E) */
-	nodev,			/* ioctl(9E) */
-	nodev,			/* devmap(9E) */
-	nodev,			/* mmap(9E) */
-	nodev,			/* segmap(9E) */
-	nochpoll,		/* chpoll(9E) */
-	ddi_prop_op,		/* prop_op(9E) */
-	NULL,			/* streamtab(9S) */
-	D_MP | D_64BIT | D_NEW	/* cb_flag */
-};
-
-static struct dev_ops xdt_ops = {
-	DEVO_REV,		/* devo_rev */
-	0,			/* devo_refcnt */
-	xdt_info,		/* getinfo(9E) */
-	nulldev,		/* identify(9E) */
-	nulldev,		/* probe(9E) */
-	xdt_attach,		/* attach(9E) */
-	xdt_detach,		/* detach(9E) */
-	nulldev,		/* devo_reset */
-	&xdt_cb_ops,		/* devo_cb_ops */
-	NULL,			/* devo_bus_ops */
-	NULL,			/* power(9E) */
-	ddi_quiesce_not_needed,	/* devo_quiesce */
-};
-
-
-static struct modldrv modldrv = {
-	&mod_driverops,
-	"Hypervisor event tracing",
-	&xdt_ops
-};
-
-static struct modlinkage modlinkage = {
-	MODREV_1,
-	&modldrv,
-	NULL
-};
-
-int
-_init(void)
-{
-	return (mod_install(&modlinkage));
-}
-
-int
-_fini(void)
-{
-	return (mod_remove(&modlinkage));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (mod_info(&modlinkage, modinfop));
-}
--- old/usr/src/uts/common/xen/dtrace/xdt.conf	Fri Aug 10 23:19:16 2018
+++ /dev/null	Fri Aug 10 23:19:15 2018
@@ -1,33 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-
-#
-# Tunable Properties
-# xdt_poll_nsec: interval in nano-seconds to poll trace buffers 
-#
-name="xdt" parent="pseudo" instance=0;
--- old/usr/src/uts/i86pc/io/pciex/inc.flg	Fri Aug 10 23:19:16 2018
+++ new/usr/src/uts/i86pc/io/pciex/inc.flg	Fri Aug 10 23:19:16 2018
@@ -54,7 +54,6 @@
 # to compile the drivers/modules
 find_files "s.*"	\
 	usr/src/uts/i86pc/npe			\
-	usr/src/uts/i86xpv/npe			\
 	usr/src/uts/intel/pci_autoconfig	\
 	usr/src/uts/intel/pcieb			\
 	usr/src/uts/intel/pcicfg
@@ -95,11 +94,6 @@
 echo_file  usr/src/uts/i86pc/Makefile.rules
 echo_file  usr/src/uts/i86pc/Makefile.i86pc
 echo_file  usr/src/uts/i86pc/Makefile.targ
-echo_file  usr/src/uts/i86xpv/Makefile
-echo_file  usr/src/uts/i86xpv/Makefile.files
-echo_file  usr/src/uts/i86xpv/Makefile.rules
-echo_file  usr/src/uts/i86xpv/Makefile.i86xpv
-echo_file  usr/src/uts/i86xpv/Makefile.targ
 echo_file  usr/src/uts/intel/Makefile
 echo_file  usr/src/uts/intel/Makefile.files
 echo_file  usr/src/uts/intel/Makefile.rules
--- old/usr/src/uts/i86pc/os/mp_implfuncs.c	Fri Aug 10 23:19:17 2018
+++ new/usr/src/uts/i86pc/os/mp_implfuncs.c	Fri Aug 10 23:19:17 2018
@@ -32,11 +32,6 @@
 #include <sys/psm_modctl.h>
 #include <sys/smp_impldefs.h>
 #include <sys/reboot.h>
-#if defined(__xpv)
-#include <sys/hypervisor.h>
-#include <vm/kboot_mmu.h>
-#include <vm/hat_pte.h>
-#endif
 
 /*
  *	External reference functions
@@ -213,20 +208,7 @@
 		return (0);
 
 	pgoffset = addr & MMU_PAGEOFFSET;
-#ifdef __xpv
-	/*
-	 * If we're dom0, we're starting from a MA. translate that to a PA
-	 * XXPV - what about driver domains???
-	 */
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		base = pfn_to_pa(xen_assign_pfn(mmu_btop(addr))) |
-		    (addr & MMU_PAGEOFFSET);
-	} else {
-		base = addr;
-	}
-#else
 	base = addr;
-#endif
 	npages = mmu_btopr(len + pgoffset);
 	cvaddr = device_arena_alloc(ptob(npages), VM_NOSLEEP);
 	if (cvaddr == NULL)
@@ -345,11 +327,7 @@
 	return (0);
 }
 
-#if defined(__xpv)
-#define	DEFAULT_PSM_MODULE	"xpv_uppc"
-#else
 #define	DEFAULT_PSM_MODULE	"uppc"
-#endif
 
 static char *
 psm_get_impl_module(int first)
@@ -390,12 +368,6 @@
 	close_mach_list();
 }
 
-#if defined(__xpv)
-#define	NOTSUP_MSG "This version of Solaris xVM does not support this hardware"
-#else
-#define	NOTSUP_MSG "This version of Solaris does not support this hardware"
-#endif	/* __xpv */
-
 void
 psm_install(void)
 {
@@ -429,7 +401,7 @@
 	}
 	mutex_exit(&psmsw_lock);
 	if (psmcnt == 0)
-		halt(NOTSUP_MSG);
+		halt("This hardware is not supported by current OS version");
 	(*psminitf)();
 }
 
--- old/usr/src/uts/i86pc/sys/xpv_support.h	Fri Aug 10 23:19:17 2018
+++ new/usr/src/uts/i86pc/sys/xpv_support.h	Fri Aug 10 23:19:17 2018
@@ -38,9 +38,15 @@
 #include <sys/types.h>
 #include <sys/inttypes.h>
 #include <sys/dditypes.h>
-#include <sys/xpv_impl.h>
-#include <sys/xen_mmu.h>
 
+/*
+ * XXX These originally were in retired xen_mmu.h and are likely to be not
+ * needed once all of the xpv related code is removed.
+ */
+typedef uint64_t maddr_t;
+typedef ulong_t mfn_t;
+#define	mfn_to_ma(mfn)	((maddr_t)(mfn) << MMU_PAGESHIFT)
+
 #define	IPL_DEBUG	15	/* domain debug interrupt */
 #define	IPL_CONS	9
 #define	IPL_VIF		6
@@ -75,7 +81,6 @@
 extern void xen_release_pfn(pfn_t);
 extern void reassign_pfn(pfn_t, mfn_t);
 
-extern shared_info_t *HYPERVISOR_shared_info;
 extern pfn_t xen_shared_info_frame;
 
 /*
--- old/usr/src/uts/i86xpv/Makefile	Fri Aug 10 23:19:17 2018
+++ /dev/null	Fri Aug 10 23:19:17 2018
@@ -1,160 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
-#
-#	This makefile drives the production of all implementation architecture
-#	dependent modules for the i86xpv architecture.
-#
-
-UTSBASE = ..
-
-include Makefile.i86xpv
-
-#
-#	The following are x86 specific (rather than i86pc) specific modules
-#	which are required for the i86pc kernel to completely lint. They are
-#	not involved in the build in any other way. In order to minimize
-#	build time, it is assumed that they are up to date.
-#
-INTEL_LIB_DIR	 = $(UTSBASE)/intel/lint-libs/$(OBJS_DIR)
-
-INTEL_LINTS	 = genunix
-
-LINT_LIBS	 = \
-		   $(GENUNIX_KMODS:%=$(LINT_LIB_DIR)/llib-l%.ln) \
-		   $(PARALLEL_KMODS:%=$(LINT_LIB_DIR)/llib-l%.ln) \
-		   $(INTEL_LINTS:%=$(INTEL_LIB_DIR)/llib-l%.ln)
-
-I86XPV_LINTS =	xdb xnb xnbe xnbo xnbu xpvtap
-
-#
-#
-#
-def		:=	TARGET= def
-all		:=	TARGET= all
-install		:=	TARGET= install
-clean		:=	TARGET= clean
-clobber		:=	TARGET= clobber
-lint		:=	TARGET= lint
-lintlib		:=	TARGET= lintlib
-machmodlintlib	:=	TARGET= modlintlib
-modlist		:=	TARGET= modlist
-modlist	modlist.intel :=	NO_STATE= -K $$MODSTATE$$$$
-clean.lint	:=	TARGET= clean.lint
-check		:=	TARGET= check
-
-.KEEP_STATE:
-
-.PARALLEL:	$(PARALLEL_KMODS) $(XMODS) modlist modlist.intel
-
-INITIAL_TARGETS = \
-	genassym \
-	unix \
-	cpu/scripts
-
-def all clean clobber clean.lint: setup genassym unix .WAIT \
-	$(KMODS) $(XMODS)
-
-install: install_platforms setup genassym unix .WAIT \
-	$(KMODS) $(XMODS)
-
-# Need to clean in here too because of lint.
-clean: $(I86XPV_LINTS)
-
-# list the modules under i86xpv.
-modlist: unix $(KMODS) $(XMODS)
-
-# list the modules for Install -k i86xpv.
-modlist.karch: modlist modlist.intel
-
-modlist.intel:
-	@cd $(SRC)/uts/intel; pwd; $(MAKE) $(NO_STATE) modlist
-
-lintlib:	unix
-
-modlintlib:	$(KMODS)
-
-genassym unix $(KMODS):	FRC
-	@cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET)
-
-setup: FRC
-	@cd cpu/scripts; pwd; $(MAKE) $(TARGET)
-
-$(XMODS):	FRC
-	@if [ -f $@/Makefile  ]; then \
-		cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET); \
-	else \
-		true; \
-	fi
-
-install_h check:	FRC
-	@cd sys; pwd; $(MAKE) $(TARGET)
-
-#
-# Definitions for the /platform directory aliases.
-# Currently none for i86xpv.
-#
-PLAT_LINKS	=
-
-#
-# Make the /platform directories.  This is hardwired here because
-# the first stage of the project (KBI) only implements the userland
-# changes, but the only reasonable place to record the aliases is
-# here in kernel land.
-#
-install_platforms:	$(ROOT_PSM_DIR) $(USR_PSM_DIR) \
-			$(ROOT_PLAT_LINKS) $(USR_PLAT_LINKS) \
-			$(OEM_USR_PLAT_LINKS)
-
-#
-#	Full kernel lint target.
-#
-LINT_TARGET	= globallint
-
-# workaround for multiply defined errors
-globallint := LINTFLAGS += -erroff=E_NAME_MULTIPLY_DEF2
-
-globallint:
-	@-$(ECHO) "\nFULL KERNEL: global crosschecks:"
-	@-$(LINT) $(LINTFLAGS) $(LINT_LIB) $(LINT_LIBS) 2>&1 | $(LGREP.2)
-
-lint:	lintlib .WAIT modlintlib .WAIT $(INTEL_LINTS) $(LINT_DEPS)
-
-$(INTEL_LINTS):	FRC
-	@cd $(UTSBASE)/intel/$@; pwd; $(MAKE) modlintlib
-
-FRC:
-
-include ../Makefile.targ
-
-#
-# Cross-reference customization: build a cross-reference over all of the
-# i86pc-related directories.
-#
-XRDIRS	= ../i86xpv ../i86pc ../intel ../common
-XRPRUNE	= sun4v sun4u sun4 sfmmu sparc
-
-cscope.out tags: FRC
-	$(XREF) -x $@
--- old/usr/src/uts/i86xpv/Makefile.files	Fri Aug 10 23:19:17 2018
+++ /dev/null	Fri Aug 10 23:19:17 2018
@@ -1,256 +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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# Copyright 2018 Joyent, Inc.
-#
-
-#	This Makefile defines file modules in the directory uts/i86xpv
-#	and its children. These are the source files which are i86xpv
-#	"implementation architecture" dependent.
-#
-
-#
-#	object lists
-#
-CORE_OBJS +=			\
-	acpi_stubs.o		\
-	balloon.o		\
-	biosdisk.o		\
-	cbe.o			\
-	cmi.o			\
-	cmi_hw.o		\
-	cms.o			\
-	confunix.o		\
-	cpuid.o			\
-	cpuid_subr.o		\
-	cpupm.o			\
-	cpupm_mach.o		\
-	dis_tables.o		\
-	ddi_impl.o		\
-	dtrace_subr.o		\
-	dvma.o			\
-	fakebop.o		\
-	fpu_subr.o		\
-	fastboot.o		\
-	fb_swtch.o		\
-	graphics.o		\
-	hardclk.o		\
-	hat_i86.o		\
-	hat_kdi.o		\
-	hment.o			\
-	hold_page.o		\
-	hrtimers.o		\
-	htable.o		\
-	i86_mmu.o		\
-	ibft.o			\
-	instr_size.o		\
-	intr.o			\
-	kboot_mmu.o		\
-	kdi_idt.o		\
-	kdi_idthdl.o		\
-	kdi_asm.o		\
-	lgrpplat.o		\
-	mach_kdi.o		\
-	mach_sysconfig.o	\
-	machdep.o		\
-	mem_config_stubs.o	\
-	memnode.o		\
-	microcode.o		\
-	mlsetup.o		\
-	mp_call.o		\
-	mp_implfuncs.o		\
-	mp_machdep.o		\
-	mp_startup.o		\
-	memscrub.o		\
-	notes.o			\
-	pci_bios.o		\
-	pci_cfgacc.o		\
-	pci_cfgacc_x86.o	\
-	pci_cfgspace.o		\
-	pci_mech1.o		\
-	pci_mech2.o		\
-	pci_neptune.o		\
-	pci_orion.o		\
-	pmem.o			\
-	ppage.o			\
-	startup.o		\
-	ssp.o			\
-	xpv_timestamp.o		\
-	todpc_subr.o		\
-	trap.o			\
-	vm_machdep.o		\
-	x_call.o
-
-#
-#	Add the SMBIOS subsystem object files directly to the list of objects
-#	built into unix itself; this is all common code except for smb_dev.c.
-#
-CORE_OBJS += $(SMBIOS_OBJS)
-
-#
-# These get compiled twice:
-# - once in the dboot (direct boot) identity mapped code 
-# - once for use during early startup in unix
-#
-BOOT_DRIVER_OBJS =		\
-	boot_console.o		\
-	boot_keyboard.o		\
-	boot_keyboard_table.o	\
-	boot_mmu.o		\
-	boot_vga.o		\
-	boot_xconsole.o		\
-	dboot_multiboot2.o	\
-	$(FONT_OBJS)
-
-CORE_OBJS += $(BOOT_DRIVER_OBJS)
-
-#
-# Extra XEN files separated out for now.
-#
-CORE_OBJS +=			\
-	cpr_driver.o		\
-	evtchn.o		\
-	gnttab.o		\
-	hypercall.o		\
-	hyperevent.o		\
-	hypersubr.o		\
-	mp_xen.o		\
-	panic_asm.o		\
-	xenguest.o		\
-	xenbus_client.o		\
-	xenbus_comms.o		\
-	xenbus_probe.o		\
-	xenbus_xs.o		\
-	xen_machdep.o		\
-	xen_mmu.o		\
-	xpv_panic.o		\
-	xvdi.o
-
-#
-#	locore.o is special. It must be the first file relocated so that it
-#	it is relocated just where its name implies.
-#
-SPECIAL_OBJS_32 +=		\
-	locore.o		\
-	fast_trap_asm.o		\
-	interrupt.o		\
-	syscall_asm.o
-
-SPECIAL_OBJS_64 +=		\
-	locore.o		\
-	fast_trap_asm.o		\
-	interrupt.o		\
-	syscall_asm_amd64.o 	\
-	kpti_trampolines.o
-
-SPECIAL_OBJS += $(SPECIAL_OBJS_$(CLASS))
-
-#
-# object files used to boot into full kernel
-#
-DBOOT_OBJS_32 =	muldiv.o
-
-DBOOT_OBJS_64 =
-
-DBOOT_OBJS +=			\
-	dboot_asm.o		\
-	dboot_printf.o		\
-	dboot_startkern.o	\
-	dboot_xen.o		\
-	hypercall.o		\
-	hypersubr.o		\
-	memcpy.o		\
-	memset.o		\
-	string.o		\
-	$(BOOT_DRIVER_OBJS)	\
-	$(DBOOT_OBJS_$(CLASS))
-
-#
-#			driver & misc modules
-#
-BALLOON_OBJS += balloon_drv.o
-DOMCAPS_OBJS += domcaps.o
-EVTCHN_OBJS += evtchn_dev.o
-GFX_PRIVATE_OBJS += gfx_private.o gfxp_pci.o gfxp_segmap.o \
-		    gfxp_devmap.o gfxp_vgatext.o gfxp_vm.o vgasubr.o
-IOAT_OBJS += ioat.o ioat_rs.o ioat_ioctl.o ioat_chan.o
-ISANEXUS_OBJS += isa.o dma_engine.o i8237A.o
-PCI_E_NEXUS_OBJS += npe.o npe_misc.o
-PCI_E_NEXUS_OBJS += pci_common.o pci_kstats.o pci_tools.o
-PCINEXUS_OBJS += pci.o pci_common.o pci_kstats.o pci_tools.o
-PRIVCMD_OBJS += seg_mf.o privcmd.o privcmd_hcall.o
-ROOTNEX_OBJS += rootnex.o
-XPVTOD_OBJS += xpvtod.o
-XPV_AUTOCONFIG_OBJS += xpv_autoconfig.o
-XPV_PSM_OBJS += xpv_psm.o mp_platform_common.o mp_platform_xpv.o \
-		apic_regops.o psm_common.o xpv_intr.o
-XPV_UPPC_OBJS += xpv_uppc.o psm_common.o
-XENBUS_OBJS += xenbus_dev.o
-XENCONS_OBJS += xencons.o
-XPVD_OBJS += xpvd.o
-XPVTAP_OBJS += xpvtap.o blk_common.o seg_mf.o
-XNB_OBJS += xnb.o
-XNBE_OBJS += xnbe.o
-XNBO_OBJS += xnbo.o
-XNBU_OBJS += xnbu.o
-XNF_OBJS += xnf.o
-XSVC_OBJS += xsvc.o
-XDF_OBJS += xdf.o
-XDB_OBJS += xdb.o
-XDT_OBJS += xdt.o
-
-#
-#	Build up defines and paths.
-#
-INC_PATH	+= -I$(UTSBASE)/i86xpv -I$(UTSBASE)/i86pc -I$(SRC)/common \
-	-I$(UTSBASE)/common/xen
-
-#
-# Since the assym files are derived, the dependencies must be explicit for
-# all files including this file. (This is only actually required in the
-# instance when the .nse_depinfo file does not exist.) It may seem that
-# the lint targets should also have a similar dependency, but they don't
-# since only C headers are included when #defined(__lint) is true.
-#
-
-ASSYM_DEPS      += 		\
-	copy.o			\
-	desctbls_asm.o		\
-	ddi_i86_asm.o		\
-	exception.o		\
-	fast_trap_asm.o		\
-	float.o			\
-	hyperevent.o		\
-	i86_subr.o		\
-	kdi_asm.o		\
-	interrupt.o		\
-	lock_prim.o		\
-	locore.o		\
-	panic_asm.o		\
-	sseblk.o		\
-	swtch.o			\
-	syscall_asm.o		\
-	syscall_asm_amd64.o
-
-$(KDI_ASSYM_DEPS:%=$(OBJS_DIR)/%):	$(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h
--- old/usr/src/uts/i86xpv/Makefile.i86xpv	Fri Aug 10 23:19:17 2018
+++ /dev/null	Fri Aug 10 23:19:17 2018
@@ -1,320 +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
-#
-
-#
-# uts/i86xpv/Makefile.i86xpv
-#
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-# Copyright (c) 2013 Andrew Stormont.  All rights reserved.
-#
-
-#
-#	This makefile contains the common definitions for the i86xpv unix
-#	and all i86xpv implementation architecture dependent modules.
-#
-
-#
-#	Machine type (implementation architecture):
-#
-PLATFORM	 = i86xpv
-
-#
-#	uname -m value
-#
-UNAME_M		 = i86pc
-
-#
-#	Everybody needs to know how to build modstubs.o and to locate unix.o
-#
-UNIX_DIR	 = $(UTSBASE)/$(PLATFORM)/unix
-GENLIB_DIR	 = $(UTSBASE)/intel/genunix
-MODSTUBS_DIR	 = $(UNIX_DIR)
-DSF_DIR		 = $(UTSBASE)/$(PLATFORM)/genassym
-LINTS_DIR	 = $(OBJS_DIR)
-LINT_LIB_DIR	 = $(UTSBASE)/$(PLATFORM)/lint-libs/$(OBJS_DIR)
-GEN_LINT_LIB_DIR = $(UTSBASE)/intel/lint-libs/$(OBJS_DIR)
-
-DTRACESTUBS_O	 = $(OBJS_DIR)/dtracestubs.o
-DTRACESTUBS	 = $(OBJS_DIR)/libdtracestubs.so
-
-SYM_MOD		= $(OBJS_DIR)/unix.sym
-
-UNIX_O		 = $(UNIX_DIR)/$(OBJS_DIR)/unix.o
-MODSTUBS_O	 = $(MODSTUBS_DIR)/$(OBJS_DIR)/modstubs.o
-GENLIB	 	 = $(GENLIB_DIR)/$(OBJS_DIR)/libgenunix.so
-LINT_LIB	 = $(LINT_LIB_DIR)/llib-lunix.ln
-DBOOT_LINT_LIB	 = $(LINT_LIB_DIR)/llib-ldboot.ln
-GEN_LINT_LIB	 = $(GEN_LINT_LIB_DIR)/llib-lgenunix.ln
-
-LINT32_DIRS	 = $(LINT32_BUILDS:%=$(UTSBASE)/$(PLATFORM)/lint-libs/%)
-LINT32_FILES	 = $(LINT32_DIRS:%=%/llib-l$(MODULE).ln)
-
-#
-#	Include the makefiles which define build rule templates, the
-#	collection of files per module, and a few specific flags. Note
-#	that order is significant, just as with an include path. The
-#	first build rule template which matches the files name will be
-#	used. By including these in order from most machine dependent
-#	to most machine independent, we allow a machine dependent file
-#	to be used in preference over a machine independent version
-#	(Such as a machine specific optimization, which preserves the
-#	interfaces.)
-#
-include $(UTSBASE)/$(PLATFORM)/Makefile.files
-include $(UTSBASE)/intel/Makefile.files
-include $(UTSBASE)/common/Makefile.files
-
-#
-#	Include machine independent rules. Note that this does not imply
-#	that the resulting module from rules in Makefile.uts is	machine
-#	independent. Only that the build rules are machine independent.
-#
-include $(UTSBASE)/Makefile.uts
-
-#
-#	Define supported builds
-#
-DEF_BUILDS		= $(DEF_BUILDS64)
-ALL_BUILDS		= $(ALL_BUILDS64)
-
-#
-#	x86 or amd64 inline templates
-#
-INLINES_32		= $(UTSBASE)/intel/ia32/ml/ia32.il \
-			  $(UTSBASE)/$(PLATFORM)/ml/ia32.il
-INLINES_64		= $(UTSBASE)/intel/amd64/ml/amd64.il \
-			  $(UTSBASE)/$(PLATFORM)/ml/amd64.il
-INLINES			+= $(INLINES_$(CLASS))
-
-#
-#	kernel-specific optimizations; override default in Makefile.master
-#
-
-CFLAGS_XARCH_32		= $(i386_CFLAGS)
-CFLAGS_XARCH_64		= $(amd64_CFLAGS)
-CFLAGS_XARCH		= $(CFLAGS_XARCH_$(CLASS))
-
-COPTFLAG_32		= $(COPTFLAG)
-COPTFLAG_64		= $(COPTFLAG64)
-COPTIMIZE		= $(COPTFLAG_$(CLASS))
-
-CFLAGS			= $(CFLAGS_XARCH)
-CFLAGS			+= $(COPTIMIZE)
-CFLAGS			+= $(INLINES) -D_ASM_INLINES
-CFLAGS			+= $(CCMODE)
-CFLAGS			+= $(SPACEFLAG)
-CFLAGS			+= $(CCUNBOUND)
-CFLAGS			+= $(CFLAGS_uts)
-
-ASFLAGS_XARCH_32	= $(i386_ASFLAGS)
-ASFLAGS_XARCH_64	= $(amd64_ASFLAGS)
-ASFLAGS_XARCH		= $(ASFLAGS_XARCH_$(CLASS))
-
-ASFLAGS			+= $(ASFLAGS_XARCH)
-
-AS_INC_PATH		+= -I$(DSF_DIR)/$(OBJS_DIR)
-
-#
-#	The following must be defined for all implementations:
-#
-#	MAPFILE:	ld mapfile for the build of kernel/unix.
-#	MODSTUBS:	Module stubs source file.
-#	GENASSYM_SRC:	genassym.c
-
-MAPFILE		= $(UTSBASE)/$(PLATFORM)/conf/Mapfile
-MODSTUBS	= $(UTSBASE)/intel/ia32/ml/modstubs.s
-GENASSYM_SRC	= $(UTSBASE)/i86pc/ml/genassym.c
-OFFSETS_SRC	= $(UTSBASE)/i86pc/ml/offsets.in
-
-#PLATFORM_OFFSETS_32	= $(UTSBASE)/$(PLATFORM)/ml/mach_offsets.in
-PLATFORM_OFFSETS_32	= $(UTSBASE)/i86pc/ml/mach_offsets.in
-PLATFORM_OFFSETS_64	= $(UTSBASE)/intel/amd64/ml/mach_offsets.in
-PLATFORM_OFFSETS_SRC	= $(PLATFORM_OFFSETS_$(CLASS))
-KDI_OFFSETS_SRC		= $(UTSBASE)/intel/kdi/kdi_offsets.in
-
-#
-#	Define the actual specific platforms
-#
-MACHINE_DEFS	 = -D__$(PLATFORM) -D__xpv -D_MACHDEP
-
-#
-#	Software workarounds for hardware "features"
-#
-
-include	$(UTSBASE)/i86pc/Makefile.workarounds
-
-#
-#	Debugging level
-#
-#	Special knowledge of which special debugging options effect which
-#	file is used to optimize the build if these flags are changed.
-#
-#	XXX: The above could possibly be done for more flags and files, but
-#	     is left as an experiment to the interested reader. Be forewarned,
-#	     that excessive use could lead to maintenance difficulties.
-#
-DEBUG_DEFS_OBJ32	=
-DEBUG_DEFS_DBG32	= -DDEBUG
-DEBUG_DEFS_OBJ64	=
-DEBUG_DEFS_DBG64	= -DDEBUG
-DEBUG_DEFS		= $(DEBUG_DEFS_$(BUILD_TYPE))
-
-DEBUG_COND_OBJ32	= $(POUND_SIGN)
-DEBUG_COND_DBG32	=
-DEBUG_COND_OBJ64	= $(POUND_SIGN)
-DEBUG_COND_DBG64	=
-IF_DEBUG_OBJ		= $(DEBUG_COND_$(BUILD_TYPE))$(OBJS_DIR)/
-
-$(IF_DEBUG_OBJ)trap.o		:= DEBUG_DEFS += -DTRAPDEBUG -DTRAPTRACE
-$(IF_DEBUG_OBJ)syscall_asm.o	:= DEBUG_DEFS += -DSYSCALLTRACE -DTRAPTRACE
-$(IF_DEBUG_OBJ)syscall_asm_amd64.o := DEBUG_DEFS += -DSYSCALLTRACE -DTRAPTRACE
-$(IF_DEBUG_OBJ)fast_trap_asm.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)interrupt.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)intr.o		:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)locore.o		:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)mp_startup.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)machdep.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)exception.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)x_call.o		:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)mp_call.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)cbe.o		:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)hyperevent.o	:= DEBUG_DEFS += -DTRAPTRACE
-$(IF_DEBUG_OBJ)evtchn.o		:= DEBUG_DEFS += -DTRAPTRACE
-
-#
-#	Collect the preprocessor definitions to be associated with *all*
-#	files.
-#
-ALL_DEFS	 = $(MACHINE_DEFS) $(WORKAROUND_DEFS) $(DEBUG_DEFS) \
-		   $(OPTION_DEFS)
-GENASSYM_DEFS	 = $(MACHINE_DEFS) $(OPTION_DEFS) \
-			-_gcc=-fno-eliminate-unused-debug-symbols \
-			-_gcc=-fno-eliminate-unused-debug-types
-
-#
-# ----- TRANSITIONAL SECTION --------------------------------------------------
-#
-
-#
-#	Not everything which *should* be a module is a module yet. The
-#	following is a list of such objects which are currently part of
-#	the base kernel but should soon become kmods.
-#
-#	XXX: $(KMACCT_OBJS) is neither in the MT kernel nor was it ever
-#	     made into a module. If it is made MT safe before being made
-#	     into a module, it should be added to this list. It was in
-#	     this list pre ON-4.0.
-#
-#
-MACH_NOT_YET_KMODS	= $(AUTOCONF_OBJS)
-
-#
-# ----- END OF TRANSITIONAL SECTION -------------------------------------------
-#
-
-#
-#	The kernels modules which are "implementation architecture"
-#	specific for this machine are enumerated below. Note that most
-#	of these modules must exist (in one form or another) for each
-#	architecture.
-#
-#	Machine Specific Driver Modules (/kernel/drv):
-#	DRV_KMODS are built both 32-bit and 64-bit
-#	DRV_KMODS_32 are built only 32-bit
-#	DRV_KMODS_64 are built only 64-bit
-#
-
-DRV_KMODS	+= rootnex
-DRV_KMODS	+= ioat
-DRV_KMODS	+= isa
-DRV_KMODS	+= pci
-DRV_KMODS	+= pit_beep
-DRV_KMODS	+= npe
-DRV_KMODS	+= pci-ide
-DRV_KMODS	+= xsvc
-DRV_KMODS	+= xenbus
-DRV_KMODS	+= xencons
-DRV_KMODS	+= xpvd
-DRV_KMODS	+= xnbe
-DRV_KMODS	+= xnbo
-DRV_KMODS	+= xnbu
-DRV_KMODS	+= xnf
-DRV_KMODS	+= xdb
-DRV_KMODS	+= xdf
-DRV_KMODS	+= privcmd
-DRV_KMODS	+= domcaps
-DRV_KMODS	+= evtchn
-DRV_KMODS	+= balloon
-DRV_KMODS	+= xpvtap
-DRV_KMODS	+= xdt
-
-#
-#	CPU Modules
-#
-CPU_KMODS	+= generic_cpu
-CPU_KMODS	+= amd_opteron
-CPU_KMODS	+= genuineintel
-CPU_KMODS	+= authenticamd
-
-#
-#	Exec Class Modules (/kernel/exec):
-#
-EXEC_KMODS	+=
-
-#
-#	Scheduling Class Modules (/kernel/sched):
-#
-SCHED_KMODS	+=
-
-#
-#	File System Modules (/kernel/fs):
-#
-FS_KMODS	+=
-
-#
-#	Streams Modules (/kernel/strmod):
-#
-STRMOD_KMODS	+=
-
-#
-#	'System' Modules (/kernel/sys):
-#
-SYS_KMODS	+=
-
-#
-#	'Misc' Modules (/kernel/misc):
-#
-MISC_KMODS	+= xpv_autoconfig gfx_private xnb
-
-#	'Dacf' modules (/kernel/dacf)
-#
-DACF_KMODS	+= consconfig_dacf
-
-#
-#	'Mach' Modules (/kernel/mach):
-#
-MACH_KMODS     	+= xpv_psm xpv_uppc
-
-#
-#	'TOD' modules (/platform/.../kernel/tod):
-#
-TOD_KMODS	+= xpvtod
--- old/usr/src/uts/i86xpv/Makefile.rules	Fri Aug 10 23:19:17 2018
+++ /dev/null	Fri Aug 10 23:19:17 2018
@@ -1,288 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This Makefile defines the build rules for the directory uts/i86xpv
-#	and its children. These are the source files which are i86xpv
-#	"implementation architecture" dependent.
-#
-#	The following two-level ordering must be maintained in this file.
-#
-#	- Lines are sorted first in order of decreasing specificity based on
-#	  the first directory component.  That is, sun4u rules come before
-#	  sparc rules come before common rules.
-#
-#	- Lines whose initial directory components are equal are sorted
-#	  alphabetically by the remaining components.
-#
-
-#
-#	We share many files with the i86pc implementation to reduce
-#	the amount of merge work
-#
-
-#
-#	Section 1a: C object build rules
-#
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/conf/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/cpu/generic_cpu/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/io/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/ioat/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pci/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/pciex/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/intel/io/pciex/hotplug/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/io/psm/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/ml/%.s
-	$(COMPILE.s) -o $@ $<
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/os/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/vm/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/boot/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/gfx_private/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/io/xsvc/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/io/pciex/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-#	We need this one to make sure we share dtrace_subr.c with i86pc
-#	Otherwise we pick up common/os/dtrace_subr.c instead :(
-#	Note that only the non-commented versions of this hack end up
-#	in the lint section below.
-
-$(OBJS_DIR)/dtrace_subr.o:	$(UTSBASE)/i86pc/os/dtrace_subr.c
-	$(COMPILE.c) -o $@ $(UTSBASE)/i86pc/os/dtrace_subr.c
-	$(CTFCONVERT_O)
-
-#
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/cpr/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/io/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/os/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-$(OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/dtrace/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-#
-#	Section 1b: Lint `object' build rules
-#
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/conf/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/io/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/io/psm/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/ml/%.s
-	@($(LHEAD) $(LINT.s) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/os/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/vm/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/boot/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/boot/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/xen/dtrace/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-#	See note above.
-
-$(LINTS_DIR)/dtrace_subr.ln:	$(UTSBASE)/i86pc/os/dtrace_subr.c
-	@($(LHEAD) $(LINT.c) $(UTSBASE)/i86pc/os/dtrace_subr.c $(LTAIL))
-
-#
-# stuff for dboot
-#
-# This is different from i86pc - uses 64 bit compiler for 64 bit
-#
-# Note that we *don't* want to use the definitions that have been augmented
-# by various bits of the context of the kernel build environment; so we
-# start constructing flags and things afresh.
-
-DBOOT_OBJS_DIR= dboot/$(OBJS_DIR)
-
-DBOOT_XARCH_32 = $(i386_XARCH)
-DBOOT_XARCH_64 = $(amd64_XARCH)
-DBOOT_CFLAGS = $(DBOOT_XARCH_$(CLASS)) $(CSTD) $(CERRWARN) \
-    $(CCNOAUTOINLINE) -O
-
-DBOOT_AS_XARCH_32 = $(i386_AS_XARCH)
-DBOOT_AS_XARCH_64 = $(amd64_AS_XARCH)
-DBOOT_ASFLAGS = $(DBOOT_AS_XARCH_$(CLASS)) -P -D_ASM
-
-DBOOT_LINTFLAGS_i86xpv	= $(LINTFLAGS_i386_$(CLASS)) $(LINTTAGS_i386_$(CLASS))
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/common/xen/os/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/common/font/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(DBOOT_OBJS_DIR)/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/boot/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/boot/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.c
-	$(CC) $(DBOOT_CFLAGS)  $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/os/%.c
-	$(CC) $(DBOOT_CFLAGS) $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/intel/ia32/ml/%.s
-	$(AS) $(DBOOT_ASFLAGS) $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(COMMONBASE)/util/i386/%.s
-	$(AS) $(DBOOT_ASFLAGS) $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86xpv/ml/%.s
-	$(AS) $(DBOOT_ASFLAGS) $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
-
-$(DBOOT_OBJS_DIR)/%.o:		$(UTSBASE)/i86pc/dboot/%.s
-	$(AS) $(DBOOT_ASFLAGS) $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
-
-include $(UTSBASE)/i86pc/Makefile.rules
-
-DBOOT_DEFS += -D__xpv
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/cpr/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/font/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/ioat/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pci/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/pciex/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/intel/io/pciex/hotplug/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/gfx_private/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/i86pc/io/xsvc/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/io/pciex/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/xen/io/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(LINTS_DIR)/%.ln:		$(UTSBASE)/common/xen/os/%.c
-	@($(LHEAD) $(LINT.c) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/intel/ia32/ml/%.s
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/common/font/%.c
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(DBOOT_LINTS_DIR)/%.c
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/common/xen/os/%.c
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/os/%.c
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/ml/%.s
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
-
-$(DBOOT_LINTS_DIR)/%.ln:		$(UTSBASE)/i86xpv/boot/%.c
-	@($(LHEAD) $(DBOOT_LINT) $(DBOOT_LOCAL_LINTFLAGS) $< $(LTAIL))
--- old/usr/src/uts/i86xpv/Makefile.targ	Fri Aug 10 23:19:17 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,42 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#	This Makefile defines the set of all required, target containing
-# included Makefiles for the i86xpv "implementation architecture".
-#
-
-#
-#	Targets for all implementations:
-#
-include $(UTSBASE)/Makefile.targ
-
-#
-#	Target set for i86xpv (order is not important, as it is with the
-# isomorphic Makefile.files set).
-#
-include $(UTSBASE)/i86xpv/Makefile.rules
-include $(UTSBASE)/intel/Makefile.rules
-include $(UTSBASE)/common/Makefile.rules
-
--- old/usr/src/uts/i86xpv/amd_opteron/Makefile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,108 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
-# Copyright 2016 Joyent, Inc.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-#       Define the module and object file sets.
-#
-MODULE		= cpu_ms.AuthenticAMD.15
-#
-OBJECTS		= $(CPU_AO_OBJS:%=$(OBJS_DIR)/%)
-LINTS           = $(CPU_AO_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE      = $(ROOT_PSM_CPU_DIR)/$(MODULE)
-
-SRCDIR		= ../../i86pc/cpu/amd_opteron
-
-AO_MCA_DISP_C	= $(OBJS_DIR)/ao_mca_disp.c
-AO_MCA_DISP_SRC = $(SRCDIR)/ao_mca_disp.in
-AO_GENDISP	= ../cpu/scripts/ao_gendisp
-
-#
-#       Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-include $(UTSBASE)/i86pc/cpu/Makefile.files
-
-#
-#	Our lint library has a different name from that of the module we build.
-#
-LINT_MODULE	= amd_opteron
-
-#
-#       Define targets
-#
-ALL_TARGET      = $(BINARY)
-LINT_TARGET     = $(LINT_MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides and additions
-#
-$(OBJS_DIR)/ao_mca.o :=	CERRWARN	+= -_gcc=-Wno-unused-function
-CLEANFILES	+= $(AO_MCA_DISP_C)
-CPPFLAGS	+= -I$(SRCDIR) -I$(OBJS_DIR)
-ASFLAGS		+= -I$(SRCDIR) -I$(OBJS_DIR)
-LDFLAGS		+= -dy -N misc/acpica
-
-#
-#       Default build targets.
-#
-.KEEP_STATE:
-
-def:            $(DEF_DEPS)
-
-all:            $(ALL_DEPS)
-
-clean:          $(CLEAN_DEPS)
-
-clobber:        $(CLOBBER_DEPS)
-
-lint:           $(LINT_DEPS)
-
-modlintlib:     $(MODLINTLIB_DEPS)
-
-clean.lint:     $(CLEAN_LINT_DEPS)
-
-install:        $(INSTALL_DEPS)
-
-#
-# Create ao_mca_disp.c
-#
-$(AO_MCA_DISP_C): $(AO_MCA_DISP_SRC) $(AO_GENDISP)
-	$(AO_GENDISP) $(AO_MCA_DISP_SRC) >$@
-
-$(OBJS_DIR)/%.o:		$(OBJS_DIR)/%.c
-	$(COMPILE.c) -o $@ $<
-	$(CTFCONVERT_O)
-
-#
-#       Include common targets.
-#
-include ../Makefile.targ
--- old/usr/src/uts/i86xpv/authenticamd/Makefile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,89 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-#       Define the module and object file sets.
-#
-MODULE		= cpu_ms.AuthenticAMD
-#
-OBJECTS		= $(CPU_AUTHAMD_OBJS:%=$(OBJS_DIR)/%)
-LINTS           = $(CPU_AUTHAMD_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE      = $(ROOT_PSM_CPU_DIR)/$(MODULE)
-
-SRCDIR		= ../cpu/authenticamd
-
-#
-#       Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-include $(UTSBASE)/i86pc/cpu/Makefile.files
-
-#
-#	Our lint library has a different name from that of the module we build.
-#
-LINT_MODULE	= authenticamd
-
-#
-#       Define targets
-#
-ALL_TARGET      = $(BINARY)
-LINT_TARGET     = $(LINT_MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides and additions
-#
-CPPFLAGS	+= -I$(SRCDIR) -I$(OBJS_DIR)
-ASFLAGS		+= -I$(SRCDIR) -I$(OBJS_DIR)
-LDFLAGS		+= -dy -N misc/acpica
-
-#
-#       Default build targets.
-#
-.KEEP_STATE:
-
-def:            $(DEF_DEPS)
-
-all:            $(ALL_DEPS)
-
-clean:          $(CLEAN_DEPS)
-
-clobber:        $(CLOBBER_DEPS)
-
-lint:           $(LINT_DEPS)
-
-modlintlib:     $(MODLINTLIB_DEPS)
-
-clean.lint:     $(CLEAN_LINT_DEPS)
-
-install:        $(INSTALL_DEPS)
-
-#
-#       Include common targets.
-#
-include ../Makefile.targ
--- old/usr/src/uts/i86xpv/balloon/Makefile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,83 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of the balloon
-#	driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= balloon
-OBJECTS		= $(BALLOON_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(BALLOON_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/boot/boot_xconsole.c	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,242 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-
-#include <sys/hypervisor.h>
-#include <sys/machparam.h>
-#include <xen/public/io/console.h>
-#include <sys/mach_mmu.h>
-
-shared_info_t *HYPERVISOR_shared_info;
-void *HYPERVISOR_console_page;
-
-#if defined(_BOOT)
-#include "dboot/dboot_printf.h"
-char big_empty[MMU_PAGESIZE * 3];	/* room for 2 page aligned page */
-#endif /* _BOOT */
-
-unsigned short video_fb_buf[32 * 1024 + MMU_PAGESIZE];
-unsigned char kb_status_buf[MMU_PAGESIZE * 2];
-unsigned short *video_fb = NULL;
-unsigned char *kb_status = NULL;
-
-static volatile struct xencons_interface *cons_ifp;
-
-#define	XR_FULL(r)	((r)->xr_in_cnt - (r)->xr_out_cnt == XR_SIZE)
-#define	XR_EMPTY(r)	((r)->xr_in_cnt == (r)->xr_out_cnt)
-
-#define	PTE_BITS	(PT_VALID | PT_WRITABLE)
-#define	PTE_DEV_BITS	(PT_VALID | PT_WRITABLE | PT_NOCACHE | PT_NOCONSIST | \
-			PT_FOREIGN)
-
-/*
- * For some unfortunate reason, the hypervisor doesn't bother to include the
- * shared info in the original virtual address space.  This means we can't
- * do any console I/O until we have manipulated some pagetables. So we have to
- * do this bit of code with no ability to get debug output.
- */
-/*ARGSUSED*/
-void
-bcons_init_xen(char *cmdline)
-{
-#ifdef _BOOT
-	int i = 0;
-	uintptr_t vaddr;
-
-	/*
-	 * find a page aligned virtual address in "big_empty"
-	 */
-	vaddr = (uintptr_t)&big_empty;
-	vaddr = (vaddr + MMU_PAGEOFFSET) & MMU_PAGEMASK;
-	HYPERVISOR_shared_info = (shared_info_t *)vaddr;
-
-	/*
-	 * Sets the "present" and "writable" bits in the PTE
-	 * plus user for amd64.
-	 */
-	(void) HYPERVISOR_update_va_mapping(vaddr,
-	    xen_info->shared_info | PTE_BITS, UVMF_INVLPG | UVMF_LOCAL);
-
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		/*
-		 * map the xen console ring buffers
-		 */
-		(void) HYPERVISOR_update_va_mapping(vaddr + MMU_PAGESIZE,
-		    mmu_ptob((x86pte_t)xen_info->console.domU.mfn) | PTE_BITS,
-		    UVMF_INVLPG | UVMF_LOCAL);
-	} else {
-		/*
-		 * Xen will pass dom0 information about the current
-		 * display settings via xen_info->console.dom0.  This
-		 * information includes what video mode we're in (vga
-		 * or vesa) and some basic information about the video
-		 * mode.  (screen size, cursor location, etc.)  We're
-		 * just going to ignore all this info.  Here's some
-		 * reasons why:
-		 *
-		 * - Currently Solaris itself has no support for vesa.
-		 *   Also, the only way to boot Solaris is using our
-		 *   patched version of grub, which conveniently doesn't
-		 *   support vesa either.
-		 *
-		 * - By default when solaris boots up it clears the screen
-		 *   thereby removing any previously displayed grub/xen
-		 *   console messages, so we really don't care about the
-		 *   current vga settings.
-		 *
-		 * Initially we'll map device memory for the frame buffer
-		 * and keyboard into some local memory that already has
-		 * page table entries so that we can get very basic debug
-		 * output.  Later on when we're initializing page tables
-		 * we'll map re-map these devices to be at their expected
-		 * addresses.  Note that these mappings created below will
-		 * be torn down right before the kernel boots up when
-		 * all the memory and mappings associated with dboot are
-		 * released.
-		 *
-		 * Map the frame buffer.
-		 */
-		vaddr = (uintptr_t)&video_fb_buf;
-		vaddr = (vaddr + MMU_PAGEOFFSET) & MMU_PAGEMASK;
-		for (i = 0; i < 32 * 1024; i += MMU_PAGESIZE)
-			(void) HYPERVISOR_update_va_mapping(vaddr + i,
-			    0xb8000 + i | PTE_DEV_BITS,
-			    UVMF_INVLPG | UVMF_LOCAL);
-		video_fb = (unsigned short *)vaddr;
-
-		/* Map the keyboard */
-		vaddr = (uintptr_t)&kb_status_buf;
-		vaddr = (vaddr + MMU_PAGEOFFSET) & MMU_PAGEMASK;
-		(void) HYPERVISOR_update_va_mapping(vaddr, 0x0 | PTE_DEV_BITS,
-		    UVMF_INVLPG | UVMF_LOCAL);
-		kb_status = (unsigned char *)vaddr;
-	}
-
-#endif /* _BOOT */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		HYPERVISOR_console_page =
-		    (void *)((uintptr_t)HYPERVISOR_shared_info + MMU_PAGESIZE);
-	} else {
-		HYPERVISOR_console_page = NULL;
-	}
-}
-
-
-/*
- * This is the equivalent of polled I/O across the hypervisor CONSOLE
- * channel to output 1 character at a time.
- */
-void
-bcons_putchar_xen(int c)
-{
-	evtchn_send_t send;
-	char buffer = (char)c;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		(void) HYPERVISOR_console_io(CONSOLEIO_write, 1, &buffer);
-		return;
-	}
-
-	cons_ifp = (volatile struct xencons_interface *)HYPERVISOR_console_page;
-
-	/*
-	 * need to add carriage return for new lines
-	 */
-	if (c == '\n')
-		bcons_putchar_xen('\r');
-
-	/*
-	 * We have to wait till we have an open transmit slot.
-	 */
-	while (cons_ifp->out_prod - cons_ifp->out_cons >=
-	    sizeof (cons_ifp->out))
-		(void) HYPERVISOR_yield();
-
-	cons_ifp->out[MASK_XENCONS_IDX(cons_ifp->out_prod, cons_ifp->out)] =
-	    (char)c;
-	++cons_ifp->out_prod;
-
-	/*
-	 * Signal Domain 0 that it has something to do for us.
-	 */
-	send.port = xen_info->console.domU.evtchn;
-	(void) HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
-}
-
-static uint_t have_char = 0;
-static char buffered;
-
-/*
- * See if there is a character on input.
- */
-int
-bcons_ischar_xen(void)
-{
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		if (have_char)
-			return (1);
-		if (HYPERVISOR_console_io(CONSOLEIO_read, 1, &buffered) > 0)
-			return (have_char = 1);
-		return (0);
-	}
-
-	cons_ifp = (volatile struct xencons_interface *)HYPERVISOR_console_page;
-	if (cons_ifp->in_cons == cons_ifp->in_prod)
-		return (0);
-	return (1);
-}
-
-/*
- * get a console input character
- */
-int
-bcons_getchar_xen(void)
-{
-	evtchn_send_t send;
-	char c;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		while (have_char == 0)
-			(void) bcons_ischar_xen();
-		have_char = 0;
-		return (buffered);
-	}
-
-	cons_ifp = (volatile struct xencons_interface *)HYPERVISOR_console_page;
-	while (cons_ifp->in_cons == cons_ifp->in_prod)
-		(void) HYPERVISOR_yield();
-
-	c = cons_ifp->in[MASK_XENCONS_IDX(cons_ifp->in_cons, cons_ifp->in)];
-	++cons_ifp->in_cons;
-
-	/*
-	 * Signal Domain 0 that we ate a character.
-	 */
-	send.port = xen_info->console.domU.evtchn;
-	(void) HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
-	return (c);
-}
--- old/usr/src/uts/i86xpv/conf/Mapfile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,81 +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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-$mapfile_version 2
-
-#
-# This is 1:1 mapped code to setup the kernel memory image.
-# It needs to be after (in physical) the kernel bits, so that
-# they have full 8 Meg of memory.
-# 
-LOAD_SEGMENT dboot {
-	FLAGS = READ WRITE EXECUTE;
-	NOHDR;
-	PADDR = 0x40800000;
-	VADDR = 0x40800000;
-	ASSIGN_SECTION {
-		IS_NAME = .data;
-		FILE_BASENAME = dboot.o;
-	};
-};
-
-#
-# kernel text segment
-#
-LOAD_SEGMENT text {
-	FLAGS = READ EXECUTE;
-	NOHDR;
-	PADDR = 0x40000000;
-	VADDR = 0xf4c00000;
-	OS_ORDER = .text;
-	ASSIGN_SECTION {
-		TYPE = PROGBITS;
-		FLAGS = ALLOC !WRITE;
-	};
-};
-
-#
-# start the data segment on a new 4MB page boundary
-#
-LOAD_SEGMENT data {
-	FLAGS = READ WRITE EXECUTE;
-	PADDR = 0x40400000;
-	VADDR = 0xf5000000;
-	OS_ORDER = .data;
-	ASSIGN_SECTION {
-		TYPE = PROGBITS;
-		FLAGS = ALLOC WRITE;
-	};
-	ASSIGN_SECTION {
-		TYPE = NOBITS;
-		FLAGS = ALLOC WRITE;
-	};
-};
-
-NOTE_SEGMENT note {
-	ASSIGN_SECTION {
-		TYPE = NOTE;
-	};
-};
--- old/usr/src/uts/i86xpv/conf/Mapfile.amd64	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,78 +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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-$mapfile_version 2
-
-#
-# This is 1:1 mapped code to setup the kernel memory image.
-# It needs to be after (in physical) the kernel bits, so that
-# they have full 8 Meg of memory.
-# 
-LOAD_SEGMENT dboot {
-	FLAGS = READ WRITE EXECUTE;
-	NOHDR;
-	PADDR = 0x40800000;
-	VADDR = 0x40800000;
-	ASSIGN_SECTION {
-		IS_NAME = .data;
-		FILE_BASENAME = dboot.o;
-	};
-};
-
-LOAD_SEGMENT text {
-	FLAGS = READ EXECUTE;
-	NOHDR;
-	PADDR = 0x40000000;
-	VADDR = 0xFFFFFFFFFB800000;
-	OS_ORDER = .text;
-	ASSIGN_SECTION {
-		TYPE = PROGBITS;
-		FLAGS = ALLOC !WRITE;
-	};
-};
-
-#
-# start the data segment on a new 4MB page boundary
-#
-LOAD_SEGMENT data {
-	FLAGS = READ WRITE EXECUTE;
-	PADDR = 0x40400000;
-	VADDR = 0xFFFFFFFFFBC00000;
-	OS_ORDER = .data;
-	ASSIGN_SECTION {
-		TYPE = PROGBITS;
-		FLAGS = ALLOC WRITE;
-	};
-	ASSIGN_SECTION {
-		TYPE = NOBITS;
-		FLAGS = ALLOC WRITE;
-	};
-};
-
-NOTE_SEGMENT note {
-	ASSIGN_SECTION {
-		TYPE = NOTE;
-	};
-};
--- old/usr/src/uts/i86xpv/consconfig_dacf/Makefile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,82 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the consconfig_dacf module.
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= consconfig_dacf
-OBJECTS		= $(CONSCONFIG_DACF_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(CONSCONFIG_DACF_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DACF_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#       Define targets
-#
-ALL_TARGET      = $(BINARY)
-LINT_TARGET     = $(MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides
-#
-LDFLAGS		+= -dy -Nmisc/usbser
-
-CERRWARN	+= -_gcc=-Wno-parentheses
-
-.KEEP_STATE:
-
-def:            $(DEF_DEPS)
-
-all:            $(ALL_DEPS)
-
-clean:          $(CLEAN_DEPS)
-
-clobber:        $(CLOBBER_DEPS)
-
-lint:           $(LINT_DEPS)
-
-modlintlib:     $(MODLINTLIB_DEPS)
-
-clean.lint:     $(CLEAN_LINT_DEPS)
-
-install:        $(INSTALL_DEPS)
-
-#
-#       Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/cpu/generic_cpu/gcpu_mca_xpv.c	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,302 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef __xpv
-#error "This file is for i86xpv only"
-#endif
-
-#include <sys/types.h>
-#include <sys/mca_x86.h>
-#include <sys/archsystm.h>
-#include <sys/hypervisor.h>
-
-#include "../../i86pc/cpu/generic_cpu/gcpu.h"
-
-extern xpv_mca_panic_data_t *xpv_mca_panic_data;
-
-mc_info_t gcpu_mce_data;
-
-enum mctelem_direction {
-	MCTELEM_FORWARD,
-	MCTELEM_REVERSE
-};
-
-static uint32_t gcpu_xpv_hdl_lookupfails;
-static uint32_t gcpu_xpv_bankhdr_found;
-static uint32_t gcpu_xpv_spechdr_found;
-
-static uint32_t gcpu_xpv_mca_hcall_fails[16];
-static uint32_t gcpu_xpv_globalhdr_found;
-
-static cmi_mca_regs_t *gcpu_xpv_bankregs;
-size_t gcpu_xpv_bankregs_sz;
-
-#define	GCPU_XPV_ARCH_NREGS	3
-
-void
-gcpu_xpv_mca_init(int nbanks)
-{
-	if (gcpu_xpv_bankregs == NULL) {
-		gcpu_xpv_bankregs_sz = nbanks * GCPU_XPV_ARCH_NREGS *
-		    sizeof (cmi_mca_regs_t);
-
-		gcpu_xpv_bankregs = kmem_zalloc(gcpu_xpv_bankregs_sz, KM_SLEEP);
-	}
-}
-
-static void
-gcpu_xpv_proxy_logout(int what, struct mc_info *mi, struct mcinfo_common **micp,
-    int *idxp, cmi_mca_regs_t *bankregs, size_t bankregs_sz)
-{
-	struct mcinfo_global *mgi = (struct mcinfo_global *)(uintptr_t)*micp;
-	struct mcinfo_common *mic;
-	struct mcinfo_bank *mib;
-	cmi_hdl_t hdl = NULL;
-	cmi_mca_regs_t *mcrp;
-	int idx = *idxp;
-	int tried = 0;
-	int j;
-
-	/* Skip over the MC_TYPE_GLOBAL record */
-	ASSERT(mgi->common.type == MC_TYPE_GLOBAL);
-	mic = x86_mcinfo_next((struct mcinfo_common *)(uintptr_t)mgi);
-	idx++;
-
-	/*
-	 * Process all MC_TYPE_BANK and MC_TYPE_EXTENDED records that
-	 * follow the MC_TYPE_GLOBAL record, ending when we reach any
-	 * other record type or when we're out of record.
-	 *
-	 * We skip over MC_TYPE_EXTENDED for now - nothing consumes
-	 * the extended MSR data even in native Solaris.
-	 */
-	while (idx < x86_mcinfo_nentries(mi) &&
-	    (mic->type == MC_TYPE_BANK || mic->type == MC_TYPE_EXTENDED)) {
-		if (mic->type == MC_TYPE_EXTENDED) {
-			gcpu_xpv_spechdr_found++;
-			goto next_record;
-		} else {
-			gcpu_xpv_bankhdr_found++;
-		}
-
-		if (hdl == NULL && !tried++) {
-			if ((hdl = cmi_hdl_lookup(CMI_HDL_SOLARIS_xVM_MCA,
-			    mgi->mc_socketid, mgi->mc_coreid,
-			    mgi->mc_core_threadid)) == NULL) {
-				gcpu_xpv_hdl_lookupfails++;
-				goto next_record;
-			} else {
-				bzero(bankregs, bankregs_sz);
-				mcrp = bankregs;
-			}
-		}
-
-		mib = (struct mcinfo_bank *)(uintptr_t)mic;
-
-		mcrp->cmr_msrnum = IA32_MSR_MC(mib->mc_bank, STATUS);
-		mcrp->cmr_msrval = mib->mc_status;
-		mcrp++;
-
-		mcrp->cmr_msrnum = IA32_MSR_MC(mib->mc_bank, ADDR);
-		mcrp->cmr_msrval = mib->mc_addr;
-		mcrp++;
-
-		mcrp->cmr_msrnum = IA32_MSR_MC(mib->mc_bank, MISC);
-		mcrp->cmr_msrval = mib->mc_misc;
-		mcrp++;
-
-next_record:
-		idx++;
-		mic = x86_mcinfo_next(mic);
-	}
-
-	/*
-	 * If we found some telemetry and a handle to associate it with
-	 * then "forward" that telemetry into the MSR interpose layer
-	 * and then request logout which will find that interposed
-	 * telemetry.  Indicate that logout code should clear bank
-	 * status registers so that it can invalidate them in the interpose
-	 * layer - they won't actually make it as far as real MSR writes.
-	 */
-	if (hdl != NULL) {
-		cmi_mca_regs_t gsr;
-		gcpu_mce_status_t mce;
-
-		gsr.cmr_msrnum = IA32_MSR_MCG_STATUS;
-		gsr.cmr_msrval = mgi->mc_gstatus;
-		cmi_hdl_msrforward(hdl, &gsr, 1);
-
-		cmi_hdl_msrforward(hdl, bankregs, mcrp - bankregs);
-		gcpu_mca_logout(hdl, NULL, (uint64_t)-1, &mce, B_TRUE, what);
-		cmi_hdl_rele(hdl);
-	}
-
-	/*
-	 * We must move the index on at least one record or our caller
-	 * may loop forever;  our initial increment over the global
-	 * record assures this.
-	 */
-	ASSERT(idx > *idxp);
-	*idxp = idx;
-	*micp = mic;
-}
-
-/*
- * Process a struct mc_info.
- *
- * There are x86_mcinfo_nentries(mi) entries.  An entry of type
- * MC_TYPE_GLOBAL precedes a number (potentially zero) of
- * entries of type MC_TYPE_BANK for telemetry from MCA banks
- * of the resource identified in the MC_TYPE_GLOBAL entry.
- * I think there can be multiple MC_TYPE_GLOBAL entries per buffer.
- */
-void
-gcpu_xpv_mci_process(mc_info_t *mi, int type,
-    cmi_mca_regs_t *bankregs, size_t bankregs_sz)
-{
-	struct mcinfo_common *mic;
-	int idx;
-
-	mic = x86_mcinfo_first(mi);
-
-	idx = 0;
-	while (idx < x86_mcinfo_nentries(mi)) {
-		if (mic->type == MC_TYPE_GLOBAL) {
-			gcpu_xpv_globalhdr_found++;
-			gcpu_xpv_proxy_logout(type == XEN_MC_URGENT ?
-			    GCPU_MPT_WHAT_MC_ERR : GCPU_MPT_WHAT_XPV_VIRQ,
-			    mi, &mic, &idx, bankregs, bankregs_sz);
-		} else {
-			idx++;
-			mic = x86_mcinfo_next(mic);
-		}
-	}
-}
-
-int
-gcpu_xpv_telem_read(mc_info_t *mci, int type, uint64_t *idp)
-{
-	xen_mc_t xmc;
-	xen_mc_fetch_t *mcf = &xmc.u.mc_fetch;
-	long err;
-
-	mcf->flags = type;
-	set_xen_guest_handle(mcf->data, mci);
-
-	if ((err = HYPERVISOR_mca(XEN_MC_fetch, &xmc)) != 0) {
-		gcpu_xpv_mca_hcall_fails[err < 16 ? err : 0]++;
-		return (0);
-	}
-
-	if (mcf->flags == XEN_MC_OK) {
-		*idp = mcf->fetch_id;
-		return (1);
-	} else {
-		*idp = 0;
-		return (0);
-	}
-}
-
-void
-gcpu_xpv_telem_ack(int type, uint64_t fetch_id)
-{
-	xen_mc_t xmc;
-	struct xen_mc_fetch *mcf = &xmc.u.mc_fetch;
-
-	mcf->flags = type | XEN_MC_ACK;
-	mcf->fetch_id = fetch_id;
-	(void) HYPERVISOR_mca(XEN_MC_fetch, &xmc);
-}
-
-static void
-mctelem_traverse(void *head, enum mctelem_direction direction,
-    boolean_t urgent)
-{
-	char *tep = head, **ntepp;
-	int noff = (direction == MCTELEM_FORWARD) ?
-	    xpv_mca_panic_data->mpd_fwdptr_offset :
-	    xpv_mca_panic_data->mpd_revptr_offset;
-
-
-	while (tep != NULL) {
-		struct mc_info **mcip = (struct mc_info **)
-		    (tep + xpv_mca_panic_data->mpd_dataptr_offset);
-
-		gcpu_xpv_mci_process(*mcip,
-		    urgent ? XEN_MC_URGENT : XEN_MC_NONURGENT,
-		    gcpu_xpv_bankregs, gcpu_xpv_bankregs_sz);
-
-		ntepp = (char **)(tep + noff);
-		tep = *ntepp;
-	}
-}
-
-/*
- * Callback made from panicsys.  We may have reached panicsys from a
- * Solaris-initiated panic or a hypervisor-initiated panic;  for the
- * latter we may not perform any hypercalls.  Our task is to retrieve
- * unprocessed MCA telemetry from the hypervisor and shovel it into
- * errorqs for later processing during panic.
- */
-void
-gcpu_xpv_panic_callback(void)
-{
-	if (IN_XPV_PANIC()) {
-		xpv_mca_panic_data_t *ti = xpv_mca_panic_data;
-
-		if (ti == NULL ||
-		    ti->mpd_magic != MCA_PANICDATA_MAGIC ||
-		    ti->mpd_version != MCA_PANICDATA_VERS)
-			return;
-
-		mctelem_traverse(ti->mpd_urgent_processing, MCTELEM_FORWARD,
-		    B_TRUE);
-		mctelem_traverse(ti->mpd_urgent_dangling, MCTELEM_REVERSE,
-		    B_TRUE);
-		mctelem_traverse(ti->mpd_urgent_committed, MCTELEM_REVERSE,
-		    B_TRUE);
-
-		mctelem_traverse(ti->mpd_nonurgent_processing, MCTELEM_FORWARD,
-		    B_FALSE);
-		mctelem_traverse(ti->mpd_nonurgent_dangling, MCTELEM_REVERSE,
-		    B_FALSE);
-		mctelem_traverse(ti->mpd_nonurgent_committed, MCTELEM_REVERSE,
-		    B_FALSE);
-	} else {
-		int types[] = { XEN_MC_URGENT, XEN_MC_NONURGENT };
-		uint64_t fetch_id;
-		int i;
-
-		for (i = 0; i < sizeof (types) / sizeof (types[0]); i++) {
-			while (gcpu_xpv_telem_read(&gcpu_mce_data,
-			    types[i], &fetch_id)) {
-				gcpu_xpv_mci_process(&gcpu_mce_data, types[i],
-				    gcpu_xpv_bankregs, gcpu_xpv_bankregs_sz);
-				gcpu_xpv_telem_ack(types[i], fetch_id);
-			}
-		}
-	}
-}
--- old/usr/src/uts/i86xpv/cpu/generic_cpu/gcpu_poll_xpv.c	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,200 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * "Polled" MCA events in an i86xpv dom0.  A timeout runs in the hypervisor
- * and checks MCA state.  If it observes valid MCA state in a bank and if
- * it sees that dom0 has registered a handler for the VIRQ_MCA then it
- * raises that VIRQ to dom0.  The interrupt handler performs a
- * hypercall to retrieve the polled telemetry and then pushes that telemetry
- * into the MSR interpose hash and calls the generic logout code which
- * will then find the provided interposed MSR values when it performs
- * cmi_hdl_rdmsr so logout code works unchanged for native or i86xpv dom0.
- */
-
-#include <sys/types.h>
-#include <sys/conf.h>
-#include <sys/x86_archext.h>
-#include <sys/mca_x86.h>
-#include <sys/ddi.h>
-#include <sys/spl.h>
-#include <sys/sunddi.h>
-#include <sys/evtchn_impl.h>
-#include <sys/hypervisor.h>
-
-#include "../../i86pc/cpu/generic_cpu/gcpu.h"
-
-extern int *gcpu_xpv_telem_read(mc_info_t *, int, uint64_t *);
-extern void gcpu_xpv_telem_ack(int, uint64_t);
-extern void gcpu_xpv_mci_process(mc_info_t *, int, cmi_mca_regs_t *, size_t);
-
-int gcpu_xpv_mch_poll_interval_secs = 10;
-int gcpu_xpv_virq_level = 3;
-
-static timeout_id_t gcpu_xpv_mch_poll_timeoutid;
-
-static int gcpu_xpv_virq_vect = -1;
-
-static mc_info_t gcpu_xpv_polldata;
-static kmutex_t gcpu_xpv_polldata_lock;
-
-static cmi_mca_regs_t *gcpu_xpv_poll_bankregs;
-static size_t gcpu_xpv_poll_bankregs_sz;
-
-static uint32_t gcpu_xpv_intr_unclaimed;
-static uint32_t gcpu_xpv_mca_hcall_busy;
-
-static gcpu_poll_trace_ctl_t gcpu_xpv_poll_trace_ctl;
-
-#define	GCPU_XPV_ARCH_NREGS		3
-#define	GCPU_XPV_MCH_POLL_REARM		((void *)1)
-#define	GCPU_XPV_MCH_POLL_NO_REARM	NULL
-
-static uint_t
-gcpu_xpv_virq_intr(void)
-{
-	int types[] = { XEN_MC_URGENT, XEN_MC_NONURGENT };
-	uint64_t fetch_id;
-	int count = 0;
-	int i;
-
-	if (gcpu_xpv_virq_vect == -1 || gcpu_xpv_poll_bankregs_sz == 0) {
-		gcpu_xpv_intr_unclaimed++;
-		return (DDI_INTR_UNCLAIMED);
-	}
-
-	if (!mutex_tryenter(&gcpu_xpv_polldata_lock)) {
-		gcpu_xpv_mca_hcall_busy++;
-		return (DDI_INTR_CLAIMED);
-	}
-
-	for (i = 0; i < sizeof (types) / sizeof (types[0]); i++) {
-		while (gcpu_xpv_telem_read(&gcpu_xpv_polldata, types[i],
-		    &fetch_id)) {
-			gcpu_poll_trace(&gcpu_xpv_poll_trace_ctl,
-			    GCPU_MPT_WHAT_XPV_VIRQ,
-			    x86_mcinfo_nentries(&gcpu_xpv_polldata));
-			gcpu_xpv_mci_process(&gcpu_xpv_polldata, types[i],
-			    gcpu_xpv_poll_bankregs, gcpu_xpv_poll_bankregs_sz);
-			gcpu_xpv_telem_ack(types[i], fetch_id);
-			count++;
-		}
-	}
-
-	mutex_exit(&gcpu_xpv_polldata_lock);
-
-	return (DDI_INTR_CLAIMED);
-}
-
-static void
-gcpu_xpv_mch_poll(void *arg)
-{
-	cmi_hdl_t hdl = cmi_hdl_any();
-
-	if (hdl != NULL) {
-		cmi_mc_logout(hdl, 0, 0);
-		cmi_hdl_rele(hdl);
-	}
-
-	if (arg == GCPU_XPV_MCH_POLL_REARM &&
-	    gcpu_xpv_mch_poll_interval_secs != 0) {
-		gcpu_xpv_mch_poll_timeoutid = timeout(gcpu_xpv_mch_poll,
-		    GCPU_XPV_MCH_POLL_REARM,
-		    drv_usectohz(gcpu_xpv_mch_poll_interval_secs * MICROSEC));
-	}
-}
-
-/*
- * gcpu_mca_poll_init is called from gcpu_mca_init for each cpu handle
- * that we initialize for.  It should prepare for polling by allocating
- * control structures and the like, but must not kick polling off yet.
- *
- * Since we initialize all cpus in a serialized loop there is no race
- * on allocating the bankregs structure, nor in free'ing and enlarging
- * it if we find the number of MCA banks is not uniform in the system
- * (unlikely) since polling is only started post mp startup.
- */
-
-void
-gcpu_mca_poll_init(cmi_hdl_t hdl)
-{
-	gcpu_data_t *gcpu = cmi_hdl_getcmidata(hdl);
-	int nbanks = gcpu->gcpu_mca.gcpu_mca_nbanks;
-	size_t sz = nbanks * GCPU_XPV_ARCH_NREGS * sizeof (cmi_mca_regs_t);
-
-	ASSERT(cmi_hdl_class(hdl) == CMI_HDL_SOLARIS_xVM_MCA);
-
-	if (gcpu_xpv_poll_bankregs == NULL || sz > gcpu_xpv_poll_bankregs_sz) {
-		if (gcpu_xpv_poll_bankregs != NULL) {
-			kmem_free(gcpu_xpv_poll_bankregs,
-			    gcpu_xpv_poll_bankregs_sz);
-		} else {
-			gcpu_poll_trace_init(&gcpu_xpv_poll_trace_ctl);
-		}
-
-		gcpu_xpv_poll_bankregs_sz = sz;
-		gcpu_xpv_poll_bankregs = kmem_zalloc(sz, KM_SLEEP);
-
-	}
-}
-
-/* deconfigure gcpu_mca_poll_init() */
-void
-gcpu_mca_poll_fini(cmi_hdl_t hdl)
-{
-}
-
-void
-gcpu_mca_poll_start(cmi_hdl_t hdl)
-{
-	ASSERT(cmi_hdl_class(hdl) == CMI_HDL_SOLARIS_xVM_MCA);
-	/*
-	 * We are on the boot cpu (cpu 0), called at the end of its
-	 * multiprocessor startup.
-	 */
-	if (gcpu_xpv_poll_bankregs_sz != 0 && gcpu_xpv_virq_vect == -1) {
-		/*
-		 * The hypervisor will poll MCA state for us, but it cannot
-		 * poll MCH state so we do that via a timeout.
-		 */
-		if (gcpu_xpv_mch_poll_interval_secs != 0) {
-			gcpu_xpv_mch_poll_timeoutid =
-			    timeout(gcpu_xpv_mch_poll, GCPU_XPV_MCH_POLL_REARM,
-			    drv_usectohz(gcpu_xpv_mch_poll_interval_secs *
-			    MICROSEC));
-		}
-
-		/*
-		 * Register handler for VIRQ_MCA; once this is in place
-		 * the hypervisor will begin to forward polled MCA observations
-		 * to us.
-		 */
-		gcpu_xpv_virq_vect = ec_bind_virq_to_irq(VIRQ_MCA, 0);
-		(void) add_avintr(NULL, gcpu_xpv_virq_level,
-		    (avfunc)gcpu_xpv_virq_intr, "MCA", gcpu_xpv_virq_vect,
-		    NULL, NULL, NULL, NULL);
-	}
-}
--- old/usr/src/uts/i86xpv/cpu/scripts/Makefile	Fri Aug 10 23:19:18 2018
+++ /dev/null	Fri Aug 10 23:19:18 2018
@@ -1,46 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
-#
-
-PERLFILES= \
-	ao_gendisp
-
-include ../../../Makefile.uts
-
-.KEEP_STATE:
-
-def all install setup: ao_gendisp.pl $(PERLFILES)
-
-# We are sharing the ao_gendisp source with the i86pc
-AO_GENDISP_PL=../../../i86pc/cpu/scripts/ao_gendisp.pl
-ao_gendisp.pl: $(AO_GENDISP_PL)
-	$(SYMLINK) $(AO_GENDISP_PL) $@
-
-clean clobber:
-	$(RM) ao_gendisp.pl $(PERLFILES)
-
-include ../../../Makefile.targ
--- old/usr/src/uts/i86xpv/domcaps/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,83 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of the domcaps
-#	driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= domcaps
-OBJECTS		= $(DOMCAPS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(DOMCAPS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/evtchn/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,88 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of the evtchn
-#	driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= evtchn
-OBJECTS		= $(EVTCHN_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(EVTCHN_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-# Since we don't always pick up $(ALWAYS_LINT_DEFS)...
-#
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/genassym/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,100 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of assym.h through
-#	compile time intialized data.
-#
-#	i86xpv implementation architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-ASSYM_H		= $(DSF_DIR)/$(OBJS_DIR)/assym.h
-KDI_ASSYM_H	= $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h
-GENASSYM	= $(DSF_DIR)/$(OBJS_DIR)/genassym
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(ASSYM_H) $(KDI_ASSYM_H)
-
-#
-# This is DSF_DIR.  Use a short path.
-#
-DSF_DIR		= .
-
-
-#
-#	Overrides
-#
-CLEANFILES	= $(GENASSYM) Nothing_to_remove
-CLOBBERFILES	= $(ASSYM_H) $(KDI_ASSYM_H) $(CLEANFILES) Nothing_to_remove
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-clean.lint:
-
-install:	def
-
-#
-# Create assym.h
-#
-$(GENASSYM): $(GENASSYM_SRC)
-	$(NATIVECC) $(NATIVE_CFLAGS) $(ALWAYS_DEFS) $(GENASSYM_DEFS) \
-	    $(NATIVE_INC_PATH) -o $@ $(GENASSYM_SRC)
-
-$(ASSYM_H): $(OFFSETS_SRC) $(PLATFORM_OFFSETS_SRC) $(GENASSYM)
-	$(OFFSETS_CREATE) <$(OFFSETS_SRC) >$@
-	$(OFFSETS_CREATE) <$(PLATFORM_OFFSETS_SRC) >>$@
-	$(GENASSYM) >>$@
-
-$(KDI_ASSYM_H): $(KDI_OFFSETS_SRC) $(GENASSYM)
-	$(OFFSETS_CREATE) <$(KDI_OFFSETS_SRC) >$@
-	$(GENASSYM) >>$@
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/generic_cpu/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,87 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-#       Define the module and object file sets.
-#
-MODULE		= cpu.generic
-#
-OBJECTS		= $(CPU_GCPU_OBJS:%=$(OBJS_DIR)/%)
-OBJECTS		+= $(CPU_GCPU_XPV_OBJS:%=$(OBJS_DIR)/%)
-LINTS           = $(CPU_GCPU_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE      = $(ROOT_PSM_CPU_DIR)/$(MODULE)
-
-#
-#       Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-include $(UTSBASE)/i86pc/cpu/Makefile.files
-
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-unused-variable
-
-#
-#	Our lint library has a different name from that of the module we build.
-#
-LINT_MODULE	= generic_cpu
-
-#
-#       Define targets
-#
-ALL_TARGET      = $(BINARY)
-LINT_TARGET     = $(LINT_MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE)
-
-#
-#       Default build targets.
-#
-.KEEP_STATE:
-
-def:            $(DEF_DEPS)
-
-all:            $(ALL_DEPS)
-
-clean:          $(CLEAN_DEPS)
-
-clobber:        $(CLOBBER_DEPS)
-
-lint:           $(LINT_DEPS)
-
-modlintlib:     $(MODLINTLIB_DEPS)
-
-clean.lint:     $(CLEAN_LINT_DEPS)
-
-install:        $(INSTALL_DEPS)
-
-#
-#       Include common targets.
-#
-include ../Makefile.targ
--- old/usr/src/uts/i86xpv/genuineintel/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,89 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-#       Define the module and object file sets.
-#
-MODULE		= cpu_ms.GenuineIntel
-#
-OBJECTS		= $(CPU_GENINTEL_OBJS:%=$(OBJS_DIR)/%)
-LINTS           = $(CPU_GENINTEL_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE      = $(ROOT_PSM_CPU_DIR)/$(MODULE)
-
-SRCDIR		= ../../i86pc/cpu/genuineintel
-
-#
-#       Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-include $(UTSBASE)/i86pc/cpu/Makefile.files
-
-#
-#	Our lint library has a different name from that of the module we build.
-#
-LINT_MODULE	= genuineintel
-
-#
-#       Define targets
-#
-ALL_TARGET      = $(BINARY)
-LINT_TARGET     = $(LINT_MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides and additions
-#
-CPPFLAGS	+= -I$(SRCDIR) -I$(OBJS_DIR)
-ASFLAGS		+= -I$(SRCDIR) -I$(OBJS_DIR)
-LDFLAGS		+= -dy -N misc/acpica
-
-#
-#       Default build targets.
-#
-.KEEP_STATE:
-
-def:            $(DEF_DEPS)
-
-all:            $(ALL_DEPS)
-
-clean:          $(CLEAN_DEPS)
-
-clobber:        $(CLOBBER_DEPS)
-
-lint:           $(LINT_DEPS)
-
-modlintlib:     $(MODLINTLIB_DEPS)
-
-clean.lint:     $(CLEAN_LINT_DEPS)
-
-install:        $(INSTALL_DEPS)
-
-#
-#       Include common targets.
-#
-include ../Makefile.targ
--- old/usr/src/uts/i86xpv/gfx_private/Makefile	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,96 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-# Copyright 2015 Igor Kozhukhov <ikozhukhov@gmail.com>
-#
-
-#
-#	This makefile drives the production of the graphics private
-#	interface kernel module.
-#
-#	i86xpv platform dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= gfx_private
-OBJECTS		= $(GFX_PRIVATE_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(GFX_PRIVATE_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MISC_DIR)/$(MODULE)
-
-#
-#	dependency
-#
-LDFLAGS	+=      -dy -Nmisc/pci_autoconfig
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS +=	-erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS +=	-erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS +=	-erroff=E_STATIC_UNUSED
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-parentheses
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/inc.flg	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-#
-# 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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-
-find_files "s.*" usr/src/common/dis
--- old/usr/src/uts/i86xpv/io/balloon_drv.c	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,197 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-
-/*
- * A simple wrapper around the balloon kernel thread to allow userland
- * programs access to the balloon status.
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/errno.h>
-#include <sys/open.h>
-#include <sys/cred.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/modctl.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/hypervisor.h>
-#include <sys/sysmacros.h>
-#include <sys/balloon_impl.h>
-
-static dev_info_t *balloon_devi;
-
-/*ARGSUSED*/
-static int
-balloon_getinfo(dev_info_t *devi, ddi_info_cmd_t cmd, void *arg, void **result)
-{
-	if (getminor((dev_t)arg) != BALLOON_MINOR)
-		return (DDI_FAILURE);
-
-	switch (cmd) {
-	case DDI_INFO_DEVT2DEVINFO:
-		*result = balloon_devi;
-		break;
-	case DDI_INFO_DEVT2INSTANCE:
-		*result = 0;
-		break;
-	default:
-		return (DDI_FAILURE);
-	}
-
-	return (DDI_SUCCESS);
-}
-
-static int
-balloon_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
-{
-	if (cmd != DDI_ATTACH)
-		return (DDI_FAILURE);
-
-	if (ddi_create_minor_node(devi, ddi_get_name(devi), S_IFCHR,
-	    ddi_get_instance(devi), DDI_PSEUDO, 0) != DDI_SUCCESS)
-		return (DDI_FAILURE);
-
-	balloon_devi = devi;
-	ddi_report_dev(devi);
-	return (DDI_SUCCESS);
-}
-
-static int
-balloon_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
-{
-	if (cmd != DDI_DETACH)
-		return (DDI_FAILURE);
-	ddi_remove_minor_node(devi, NULL);
-	balloon_devi = NULL;
-	return (DDI_SUCCESS);
-}
-
-/*ARGSUSED1*/
-static int
-balloon_open(dev_t *dev, int flag, int otyp, cred_t *cr)
-{
-	return (getminor(*dev) == BALLOON_MINOR ? 0 : ENXIO);
-}
-
-/*
- * When asked for one of the balloon values, we simply query the balloon thread.
- */
-/*ARGSUSED*/
-static int
-balloon_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr,
-    int *rval_p)
-{
-	int rval = 0;
-	size_t value;
-
-	switch (cmd) {
-	case BLN_IOCTL_CURRENT:
-	case BLN_IOCTL_TARGET:
-	case BLN_IOCTL_LOW:
-	case BLN_IOCTL_HIGH:
-	case BLN_IOCTL_LIMIT:
-		value = balloon_values(cmd);
-		if (ddi_copyout((void *)&value, (void *)arg, sizeof (value),
-		    mode))
-			return (EFAULT);
-		break;
-	default:
-		rval = EINVAL;
-		break;
-	}
-	return (rval);
-}
-
-static struct cb_ops balloon_cb_ops = {
-	balloon_open,
-	nulldev,	/* close */
-	nodev,		/* strategy */
-	nodev,		/* print */
-	nodev,		/* dump */
-	nodev,		/* read */
-	nodev,		/* write */
-	balloon_ioctl,	/* ioctl */
-	nodev,		/* devmap */
-	nodev,		/* mmap */
-	nodev,		/* segmap */
-	nochpoll,	/* poll */
-	ddi_prop_op,
-	NULL,
-	D_64BIT | D_MP,
-	CB_REV,
-	NULL,
-	NULL
-};
-
-static struct dev_ops balloon_dv_ops = {
-	DEVO_REV,
-	0,
-	balloon_getinfo,
-	nulldev,		/* identify */
-	nulldev,		/* probe */
-	balloon_attach,
-	balloon_detach,
-	nodev,			/* reset */
-	&balloon_cb_ops,
-	NULL,			/* struct bus_ops */
-	NULL,			/* power */
-	ddi_quiesce_not_needed,		/* quiesce */
-};
-
-static struct modldrv modldrv = {
-	&mod_driverops,
-	"balloon driver",
-	&balloon_dv_ops
-};
-
-static struct modlinkage modl = {
-	MODREV_1,
-	{
-		(void *)&modldrv,
-		NULL		/* null termination */
-	}
-};
-
-int
-_init(void)
-{
-	return (mod_install(&modl));
-}
-
-int
-_fini(void)
-{
-	return (mod_remove(&modl));
-}
-
-int
-_info(struct modinfo *modinfo)
-{
-	return (mod_info(&modl, modinfo));
-}
--- old/usr/src/uts/i86xpv/io/domcaps.c	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,187 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * This rather uninspiring device enables userland to discover if
- * the current kernel is actually a dom0 or other domain e.g. domU.
- */
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/errno.h>
-#include <sys/open.h>
-#include <sys/cred.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/modctl.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/hypervisor.h>
-#include <sys/sysmacros.h>
-
-#include <sys/domcaps_impl.h>
-
-static dev_info_t *domcaps_devi;
-
-/*ARGSUSED*/
-static int
-domcaps_getinfo(dev_info_t *devi, ddi_info_cmd_t cmd, void *arg, void **result)
-{
-	if (getminor((dev_t)arg) != DOMCAPS_MINOR)
-		return (DDI_FAILURE);
-
-	switch (cmd) {
-	case DDI_INFO_DEVT2DEVINFO:
-		*result = domcaps_devi;
-		break;
-	case DDI_INFO_DEVT2INSTANCE:
-		*result = 0;
-		break;
-	default:
-		return (DDI_FAILURE);
-	}
-
-	return (DDI_SUCCESS);
-}
-
-static int
-domcaps_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
-{
-	if (cmd != DDI_ATTACH)
-		return (DDI_FAILURE);
-
-	if (ddi_create_minor_node(devi, ddi_get_name(devi), S_IFCHR,
-	    ddi_get_instance(devi), DDI_PSEUDO, 0) != DDI_SUCCESS)
-		return (DDI_FAILURE);
-
-	domcaps_devi = devi;
-	ddi_report_dev(devi);
-	return (DDI_SUCCESS);
-}
-
-static int
-domcaps_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
-{
-	if (cmd != DDI_DETACH)
-		return (DDI_FAILURE);
-	ddi_remove_minor_node(devi, NULL);
-	domcaps_devi = NULL;
-	return (DDI_SUCCESS);
-}
-
-/*ARGSUSED1*/
-static int
-domcaps_open(dev_t *dev, int flag, int otyp, cred_t *cr)
-{
-	return (getminor(*dev) == DOMCAPS_MINOR ? 0 : ENXIO);
-}
-
-/*ARGSUSED*/
-static int
-domcaps_read(dev_t dev, uio_t *uio, cred_t *cr)
-{
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		static char data[] = "control_d\n";
-		size_t nbytes;
-
-		if (uio->uio_loffset > sizeof (data))
-			return (0);
-		nbytes = MIN(uio->uio_resid, sizeof (data) - uio->uio_loffset);
-
-		return (uiomove(data + uio->uio_loffset, nbytes,
-		    UIO_READ, uio));
-	}
-
-	return (0);
-}
-
-static struct cb_ops domcaps_cb_ops = {
-	domcaps_open,
-	nulldev,	/* close */
-	nodev,		/* strategy */
-	nodev,		/* print */
-	nodev,		/* dump */
-	domcaps_read,
-	nodev,		/* write */
-	nodev,		/* ioctl */
-	nodev,		/* devmap */
-	nodev,		/* mmap */
-	nodev,		/* segmap */
-	nochpoll,	/* poll */
-	ddi_prop_op,
-	NULL,
-	D_64BIT | D_MP,
-	CB_REV,
-	NULL,
-	NULL
-};
-
-static struct dev_ops domcaps_dv_ops = {
-	DEVO_REV,
-	0,
-	domcaps_getinfo,
-	nulldev,		/* identify */
-	nulldev,		/* probe */
-	domcaps_attach,
-	domcaps_detach,
-	nodev,			/* reset */
-	&domcaps_cb_ops,
-	NULL,			/* struct bus_ops */
-	NULL,			/* power */
-	ddi_quiesce_not_needed,		/* quiesce */
-};
-
-static struct modldrv modldrv = {
-	&mod_driverops,
-	"hypervisor capabilities driver",
-	&domcaps_dv_ops
-};
-
-static struct modlinkage modl = {
-	MODREV_1,
-	{
-		(void *)&modldrv,
-		NULL		/* null termination */
-	}
-};
-
-int
-_init(void)
-{
-	return (mod_install(&modl));
-}
-
-int
-_fini(void)
-{
-	return (mod_remove(&modl));
-}
-
-int
-_info(struct modinfo *modinfo)
-{
-	return (mod_info(&modl, modinfo));
-}
--- old/usr/src/uts/i86xpv/io/privcmd.c	Fri Aug 10 23:19:19 2018
+++ /dev/null	Fri Aug 10 23:19:19 2018
@@ -1,411 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/xpv_user.h>
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/errno.h>
-#include <sys/open.h>
-#include <sys/cred.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/modctl.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/vmsystm.h>
-#include <sys/sdt.h>
-#include <sys/hypervisor.h>
-#include <sys/xen_errno.h>
-#include <sys/policy.h>
-
-#include <vm/hat_i86.h>
-#include <vm/hat_pte.h>
-#include <vm/seg_mf.h>
-
-#include <xen/sys/privcmd.h>
-#include <sys/privcmd_impl.h>
-
-static dev_info_t *privcmd_devi;
-
-/*ARGSUSED*/
-static int
-privcmd_getinfo(dev_info_t *devi, ddi_info_cmd_t cmd, void *arg, void **result)
-{
-	switch (cmd) {
-	case DDI_INFO_DEVT2DEVINFO:
-	case DDI_INFO_DEVT2INSTANCE:
-		break;
-	default:
-		return (DDI_FAILURE);
-	}
-
-	switch (getminor((dev_t)arg)) {
-	case PRIVCMD_MINOR:
-		break;
-	default:
-		return (DDI_FAILURE);
-	}
-
-	if (cmd == DDI_INFO_DEVT2INSTANCE)
-		*result = 0;
-	else
-		*result = privcmd_devi;
-	return (DDI_SUCCESS);
-}
-
-static int
-privcmd_attach(dev_info_t *devi, ddi_attach_cmd_t cmd)
-{
-	if (cmd != DDI_ATTACH)
-		return (DDI_FAILURE);
-
-	if (ddi_create_minor_node(devi, PRIVCMD_NODE,
-	    S_IFCHR, PRIVCMD_MINOR, DDI_PSEUDO, 0) != DDI_SUCCESS)
-		return (DDI_FAILURE);
-
-	privcmd_devi = devi;
-	ddi_report_dev(devi);
-	return (DDI_SUCCESS);
-}
-
-static int
-privcmd_detach(dev_info_t *devi, ddi_detach_cmd_t cmd)
-{
-	if (cmd != DDI_DETACH)
-		return (DDI_FAILURE);
-	ddi_remove_minor_node(devi, NULL);
-	privcmd_devi = NULL;
-	return (DDI_SUCCESS);
-}
-
-/*ARGSUSED1*/
-static int
-privcmd_open(dev_t *dev, int flag, int otyp, cred_t *cr)
-{
-	return (getminor(*dev) == PRIVCMD_MINOR ? 0 : ENXIO);
-}
-
-/*
- * Map a contiguous set of machine frames in a foreign domain.
- * Used in the following way:
- *
- *	privcmd_mmap_t p;
- *	privcmd_mmap_entry_t e;
- *
- *	addr = mmap(NULL, size, prot, MAP_SHARED, fd, 0);
- *	p.num = number of privcmd_mmap_entry_t's
- *	p.dom = domid;
- *	p.entry = &e;
- *	e.va = addr;
- *	e.mfn = mfn;
- *	e.npages = btopr(size);
- *	ioctl(fd, IOCTL_PRIVCMD_MMAP, &p);
- */
-/*ARGSUSED2*/
-int
-do_privcmd_mmap(void *uarg, int mode, cred_t *cr)
-{
-	privcmd_mmap_t __mmapcmd, *mmc = &__mmapcmd;
-	privcmd_mmap_entry_t *umme;
-	struct as *as = curproc->p_as;
-	struct seg *seg;
-	int i, error = 0;
-
-	if (ddi_copyin(uarg, mmc, sizeof (*mmc), mode))
-		return (EFAULT);
-
-	DTRACE_XPV3(mmap__start, domid_t, mmc->dom, int, mmc->num,
-	    privcmd_mmap_entry_t *, mmc->entry);
-
-	if (mmc->dom == DOMID_SELF) {
-		error = ENOTSUP;	/* Too paranoid? */
-		goto done;
-	}
-
-	for (umme = mmc->entry, i = 0; i < mmc->num; i++, umme++) {
-		privcmd_mmap_entry_t __mmapent, *mme = &__mmapent;
-		caddr_t addr;
-
-		if (ddi_copyin(umme, mme, sizeof (*mme), mode)) {
-			error = EFAULT;
-			break;
-		}
-
-		DTRACE_XPV3(mmap__entry, ulong_t, mme->va, ulong_t, mme->mfn,
-		    ulong_t, mme->npages);
-
-		if (mme->mfn == MFN_INVALID) {
-			error = EINVAL;
-			break;
-		}
-
-		addr = (caddr_t)mme->va;
-
-		/*
-		 * Find the segment we want to mess with, then add
-		 * the mfn range to the segment.
-		 */
-		AS_LOCK_ENTER(as, RW_READER);
-		if ((seg = as_findseg(as, addr, 0)) == NULL ||
-		    addr + mmu_ptob(mme->npages) > seg->s_base + seg->s_size)
-			error = EINVAL;
-		else
-			error = segmf_add_mfns(seg, addr,
-			    mme->mfn, mme->npages, mmc->dom);
-		AS_LOCK_EXIT(as);
-
-		if (error != 0)
-			break;
-	}
-
-done:
-	DTRACE_XPV1(mmap__end, int, error);
-
-	return (error);
-}
-
-/*
- * Set up the address range to map to an array of mfns in
- * a foreign domain.  Used in the following way:
- *
- *	privcmd_mmap_batch_t p;
- *
- *	addr = mmap(NULL, size, prot, MAP_SHARED, fd, 0);
- *	p.num = number of pages
- *	p.dom = domid
- *	p.addr = addr;
- *	p.arr = array of mfns, indexed 0 .. p.num - 1
- *	ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &p);
- */
-/*ARGSUSED2*/
-static int
-do_privcmd_mmapbatch(void *uarg, int mode, cred_t *cr)
-{
-	privcmd_mmapbatch_t __mmapbatch, *mmb = &__mmapbatch;
-	struct as *as = curproc->p_as;
-	struct seg *seg;
-	int i, error = 0;
-	caddr_t addr;
-	ulong_t *ulp;
-
-	if (ddi_copyin(uarg, mmb, sizeof (*mmb), mode))
-		return (EFAULT);
-
-	DTRACE_XPV3(mmapbatch__start, domid_t, mmb->dom, int, mmb->num,
-	    caddr_t, mmb->addr);
-
-	addr = (caddr_t)mmb->addr;
-	AS_LOCK_ENTER(as, RW_READER);
-	if ((seg = as_findseg(as, addr, 0)) == NULL ||
-	    addr + ptob(mmb->num) > seg->s_base + seg->s_size) {
-		error = EINVAL;
-		goto done;
-	}
-
-	for (i = 0, ulp = mmb->arr;
-	    i < mmb->num; i++, addr += PAGESIZE, ulp++) {
-		mfn_t mfn;
-
-		if (fulword(ulp, &mfn) != 0) {
-			error = EFAULT;
-			break;
-		}
-
-		if (mfn == MFN_INVALID) {
-			/*
-			 * This mfn is invalid and should not be added to
-			 * segmf, as we'd only cause an immediate EFAULT when
-			 * we tried to fault it in.
-			 */
-			mfn |= XEN_DOMCTL_PFINFO_XTAB;
-			continue;
-		}
-
-		if (segmf_add_mfns(seg, addr, mfn, 1, mmb->dom) == 0)
-			continue;
-
-		/*
-		 * Tell the process that this MFN could not be mapped, so it
-		 * won't later try to access it.
-		 */
-		mfn |= XEN_DOMCTL_PFINFO_XTAB;
-		if (sulword(ulp, mfn) != 0) {
-			error = EFAULT;
-			break;
-		}
-	}
-
-done:
-	AS_LOCK_EXIT(as);
-
-	DTRACE_XPV3(mmapbatch__end, int, error, struct seg *, seg, caddr_t,
-	    mmb->addr);
-
-	return (error);
-}
-
-/*ARGSUSED*/
-static int
-privcmd_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *cr, int *rval)
-{
-	if (secpolicy_xvm_control(cr))
-		return (EPERM);
-
-	/*
-	 * Everything is a -native- data type.
-	 */
-	if ((mode & FMODELS) != FNATIVE)
-		return (EOVERFLOW);
-
-	switch (cmd) {
-	case IOCTL_PRIVCMD_HYPERCALL:
-		return (do_privcmd_hypercall((void *)arg, mode, cr, rval));
-	case IOCTL_PRIVCMD_MMAP:
-		if (DOMAIN_IS_PRIVILEGED(xen_info))
-			return (do_privcmd_mmap((void *)arg, mode, cr));
-		break;
-	case IOCTL_PRIVCMD_MMAPBATCH:
-		if (DOMAIN_IS_PRIVILEGED(xen_info))
-			return (do_privcmd_mmapbatch((void *)arg, mode, cr));
-		break;
-	default:
-		break;
-	}
-	return (EINVAL);
-}
-
-/*
- * The real magic happens in the segmf segment driver.
- */
-/*ARGSUSED8*/
-static int
-privcmd_segmap(dev_t dev, off_t off, struct as *as, caddr_t *addrp,
-    off_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cr)
-{
-	struct segmf_crargs a;
-	int error;
-
-	if (secpolicy_xvm_control(cr))
-		return (EPERM);
-
-	as_rangelock(as);
-	if ((flags & MAP_FIXED) == 0) {
-		map_addr(addrp, len, (offset_t)off, 0, flags);
-		if (*addrp == NULL) {
-			error = ENOMEM;
-			goto rangeunlock;
-		}
-	} else {
-		/*
-		 * User specified address
-		 */
-		(void) as_unmap(as, *addrp, len);
-	}
-
-	/*
-	 * The mapping *must* be MAP_SHARED at offset 0.
-	 *
-	 * (Foreign pages are treated like device memory; the
-	 * ioctl interface allows the backing objects to be
-	 * arbitrarily redefined to point at any machine frame.)
-	 */
-	if ((flags & MAP_TYPE) != MAP_SHARED || off != 0) {
-		error = EINVAL;
-		goto rangeunlock;
-	}
-
-	a.dev = dev;
-	a.prot = (uchar_t)prot;
-	a.maxprot = (uchar_t)maxprot;
-	error = as_map(as, *addrp, len, segmf_create, &a);
-
-rangeunlock:
-	as_rangeunlock(as);
-	return (error);
-}
-
-static struct cb_ops privcmd_cb_ops = {
-	privcmd_open,
-	nulldev,	/* close */
-	nodev,		/* strategy */
-	nodev,		/* print */
-	nodev,		/* dump */
-	nodev,		/* read */
-	nodev,		/* write */
-	privcmd_ioctl,
-	nodev,		/* devmap */
-	nodev,		/* mmap */
-	privcmd_segmap,
-	nochpoll,	/* poll */
-	ddi_prop_op,
-	NULL,
-	D_64BIT | D_NEW | D_MP
-};
-
-static struct dev_ops privcmd_dv_ops = {
-	DEVO_REV,
-	0,
-	privcmd_getinfo,
-	nulldev,		/* identify */
-	nulldev,		/* probe */
-	privcmd_attach,
-	privcmd_detach,
-	nodev,			/* reset */
-	&privcmd_cb_ops,
-	0,			/* struct bus_ops */
-	NULL,			/* power */
-	ddi_quiesce_not_needed,		/* quiesce */
-};
-
-static struct modldrv modldrv = {
-	&mod_driverops,
-	"privcmd driver",
-	&privcmd_dv_ops
-};
-
-static struct modlinkage modl = {
-	MODREV_1,
-	&modldrv
-};
-
-int
-_init(void)
-{
-	return (mod_install(&modl));
-}
-
-int
-_fini(void)
-{
-	return (mod_remove(&modl));
-}
-
-int
-_info(struct modinfo *modinfo)
-{
-	return (mod_info(&modl, modinfo));
-}
--- old/usr/src/uts/i86xpv/io/privcmd_hcall.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,1252 +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 2010 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/xpv_user.h>
-
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/errno.h>
-#include <sys/open.h>
-#include <sys/cred.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/modctl.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/vmsystm.h>
-#include <sys/hypervisor.h>
-#include <sys/xen_errno.h>
-#include <sys/sysmacros.h>
-#include <sys/sdt.h>
-
-#include <xen/sys/privcmd.h>
-#include <sys/privcmd_impl.h>
-
-typedef struct import_export {
-	void *			ie_uaddr;
-	void *			ie_kaddr;
-	size_t			ie_size;
-	uint32_t		ie_flags;
-} import_export_t;
-
-static import_export_t null_ie = {NULL, NULL, 0, 0};
-
-#define	IE_IMPORT	0x0001		/* Data needs to be copied in */
-#define	IE_EXPORT	0x0002		/* Data needs to be copied out */
-#define	IE_FREE		0x0004
-#define	IE_IMPEXP	(IE_IMPORT | IE_EXPORT)
-
-static void *
-uaddr_from_handle(void *field)
-{
-	struct { void *p; } *hdl = field;
-	void *ptr;
-
-	/*LINTED: constant in conditional context*/
-	get_xen_guest_handle(ptr, (*hdl));
-	return (ptr);
-}
-
-
-/*
- * Import a buffer from user-space.  If the caller provides a kernel
- * address, we import to that address.  If not, we kmem_alloc() the space
- * ourselves.
- */
-static int
-import_buffer(import_export_t *iep, void *uaddr, void *kaddr, size_t size,
-    uint32_t flags)
-{
-	iep->ie_uaddr = uaddr;
-	iep->ie_size = size;
-	iep->ie_flags = flags & IE_EXPORT;
-
-	if (size == 0 || uaddr == NULL) {
-		*iep = null_ie;
-		return (0);
-	}
-
-	if (kaddr == NULL) {
-		iep->ie_kaddr = kmem_alloc(size, KM_SLEEP);
-		iep->ie_flags |= IE_FREE;
-	} else {
-		iep->ie_kaddr = kaddr;
-		iep->ie_flags &= ~IE_FREE;
-	}
-
-	if ((flags & IE_IMPORT) &&
-	    (ddi_copyin(uaddr, iep->ie_kaddr, size, 0) != 0)) {
-		if (iep->ie_flags & IE_FREE) {
-			kmem_free(iep->ie_kaddr, iep->ie_size);
-			iep->ie_kaddr = NULL;
-			iep->ie_flags = 0;
-		}
-		return (-X_EFAULT);
-	}
-
-	return (0);
-}
-
-static void
-export_buffer(import_export_t *iep, int *error)
-{
-	int copy_err = 0;
-
-	if (iep->ie_size == 0 || iep->ie_uaddr == NULL)
-		return;
-
-	/*
-	 * If the buffer was marked for export initially, and if the
-	 * hypercall completed successfully, resync the user-space buffer
-	 * with our in-kernel buffer.
-	 */
-	if ((iep->ie_flags & IE_EXPORT) && (*error >= 0) &&
-	    (ddi_copyout(iep->ie_kaddr, iep->ie_uaddr, iep->ie_size, 0) != 0))
-		copy_err = -X_EFAULT;
-	if (iep->ie_flags & IE_FREE) {
-		kmem_free(iep->ie_kaddr, iep->ie_size);
-		iep->ie_kaddr = NULL;
-		iep->ie_flags = 0;
-	}
-
-	if (copy_err != 0 && *error >= 0)
-		*error = copy_err;
-}
-
-/*
- * Xen 'op' structures often include pointers disguised as 'handles', which
- * refer to addresses in user space.  This routine copies a buffer
- * associated with an embedded pointer into kernel space, and replaces the
- * pointer to userspace with a pointer to the new kernel buffer.
- *
- * Note: if Xen ever redefines the structure of a 'handle', this routine
- * (specifically the definition of 'hdl') will need to be updated.
- */
-static int
-import_handle(import_export_t *iep, void *field, size_t size, int flags)
-{
-	struct { void *p; } *hdl = field;
-	void *ptr;
-	int err;
-
-	ptr = uaddr_from_handle(field);
-	err = import_buffer(iep, ptr, NULL, size, (flags));
-	if (err == 0) {
-		/*LINTED: constant in conditional context*/
-		set_xen_guest_handle((*hdl), (void *)((iep)->ie_kaddr));
-	}
-	return (err);
-}
-
-static int
-privcmd_HYPERVISOR_mmu_update(mmu_update_t *ureq, int count, int *scount,
-    domid_t domid)
-{
-	mmu_update_t *kreq, single_kreq;
-	import_export_t cnt_ie, req_ie;
-	int error, kscount, bytes;
-
-	bytes = count * sizeof (*kreq);
-	kreq = (count == 1) ? &single_kreq : kmem_alloc(bytes, KM_SLEEP);
-
-	error = import_buffer(&cnt_ie, scount, &kscount, sizeof (kscount),
-	    IE_IMPEXP);
-	if (error != 0)
-		req_ie = null_ie;
-	else
-		error = import_buffer(&req_ie, ureq, kreq, bytes, IE_IMPEXP);
-
-	DTRACE_XPV3(mmu__update__start, int, domid, int, count, mmu_update_t *,
-	    ((error == -X_EFAULT) ? ureq : kreq));
-
-	if (error == 0)
-		error = HYPERVISOR_mmu_update(kreq, count, &kscount, domid);
-	export_buffer(&cnt_ie, &error);
-	export_buffer(&req_ie, &error);
-	if (count != 1)
-		kmem_free(kreq, bytes);
-
-	DTRACE_XPV1(mmu__update__end, int, error);
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_domctl(xen_domctl_t *opp)
-{
-	xen_domctl_t op;
-	import_export_t op_ie, sub_ie;
-	int error = 0;
-
-	if ((error = import_buffer(&op_ie, opp, &op, sizeof (op),
-	    IE_IMPEXP)) != 0)
-		return (error);
-
-	sub_ie = null_ie;
-
-	/*
-	 * Check this first because our wrapper will forcibly overwrite it.
-	 */
-	if (op.interface_version != XEN_DOMCTL_INTERFACE_VERSION) {
-#ifdef DEBUG
-		printf("domctl vers mismatch (cmd %d, found 0x%x, need 0x%x\n",
-		    op.cmd, op.interface_version, XEN_DOMCTL_INTERFACE_VERSION);
-#endif
-		error = -X_EACCES;
-		export_buffer(&op_ie, &error);
-		return (error);
-	}
-
-	/*
-	 * Now handle any domctl ops with embedded pointers elsewhere
-	 * in the user address space that also need to be tacked down
-	 * while the hypervisor futzes with them.
-	 */
-	switch (op.cmd) {
-	case XEN_DOMCTL_createdomain:
-		DTRACE_XPV1(dom__create__start, xen_domctl_t *,
-		    &op.u.createdomain);
-		break;
-
-	case XEN_DOMCTL_destroydomain:
-		DTRACE_XPV1(dom__destroy__start, domid_t, op.domain);
-		break;
-
-	case XEN_DOMCTL_pausedomain:
-		DTRACE_XPV1(dom__pause__start, domid_t, op.domain);
-		break;
-
-	case XEN_DOMCTL_unpausedomain:
-		DTRACE_XPV1(dom__unpause__start, domid_t, op.domain);
-		break;
-
-	case XEN_DOMCTL_getmemlist: {
-		error = import_handle(&sub_ie, &op.u.getmemlist.buffer,
-		    op.u.getmemlist.max_pfns * sizeof (xen_pfn_t), IE_EXPORT);
-		break;
-	}
-
-	case XEN_DOMCTL_getpageframeinfo2: {
-		error = import_handle(&sub_ie, &op.u.getpageframeinfo2.array,
-		    op.u.getpageframeinfo2.num * sizeof (ulong_t), IE_IMPEXP);
-		break;
-	}
-
-	case XEN_DOMCTL_shadow_op: {
-		size_t size;
-
-		size = roundup(howmany(op.u.shadow_op.pages, NBBY),
-		    sizeof (ulong_t));
-		error = import_handle(&sub_ie,
-		    &op.u.shadow_op.dirty_bitmap, size, IE_IMPEXP);
-		break;
-	}
-
-	case XEN_DOMCTL_setvcpucontext: {
-		vcpu_guest_context_t *taddr;
-		error = import_handle(&sub_ie, &op.u.vcpucontext.ctxt,
-		    sizeof (vcpu_guest_context_t), IE_IMPORT);
-		if (error == -X_EFAULT)
-			/*LINTED: constant in conditional context*/
-			get_xen_guest_handle_u(taddr, op.u.vcpucontext.ctxt);
-		else
-			taddr = sub_ie.ie_kaddr;
-		DTRACE_XPV2(setvcpucontext__start, domid_t, op.domain,
-		    vcpu_guest_context_t *, taddr);
-		break;
-	}
-
-	case XEN_DOMCTL_getvcpucontext: {
-		error = import_handle(&sub_ie, &op.u.vcpucontext.ctxt,
-		    sizeof (vcpu_guest_context_t), IE_EXPORT);
-		break;
-	}
-
-
-	case XEN_DOMCTL_sethvmcontext: {
-		error = import_handle(&sub_ie, &op.u.hvmcontext.buffer,
-		    op.u.hvmcontext.size, IE_IMPORT);
-		break;
-	}
-
-	case XEN_DOMCTL_gethvmcontext: {
-#if !defined(__GNUC__) && defined(__i386__)
-		if (op.u.hvmcontext.buffer.u.p != NULL)
-#else
-		if (op.u.hvmcontext.buffer.p != NULL)
-#endif
-			error = import_handle(&sub_ie, &op.u.hvmcontext.buffer,
-			    op.u.hvmcontext.size, IE_EXPORT);
-		break;
-	}
-
-	case XEN_DOMCTL_getdomaininfo:
-	case XEN_DOMCTL_getpageframeinfo:
-	case XEN_DOMCTL_max_mem:
-	case XEN_DOMCTL_resumedomain:
-	case XEN_DOMCTL_getvcpuinfo:
-	case XEN_DOMCTL_setvcpuaffinity:
-	case XEN_DOMCTL_getvcpuaffinity:
-	case XEN_DOMCTL_max_vcpus:
-	case XEN_DOMCTL_scheduler_op:
-	case XEN_DOMCTL_setdomainhandle:
-	case XEN_DOMCTL_setdebugging:
-	case XEN_DOMCTL_irq_permission:
-	case XEN_DOMCTL_iomem_permission:
-	case XEN_DOMCTL_ioport_permission:
-	case XEN_DOMCTL_hypercall_init:
-	case XEN_DOMCTL_arch_setup:
-	case XEN_DOMCTL_settimeoffset:
-	case XEN_DOMCTL_real_mode_area:
-	case XEN_DOMCTL_sendtrigger:
-	case XEN_DOMCTL_assign_device:
-	case XEN_DOMCTL_bind_pt_irq:
-	case XEN_DOMCTL_get_address_size:
-	case XEN_DOMCTL_set_address_size:
-	case XEN_DOMCTL_get_ext_vcpucontext:
-	case XEN_DOMCTL_set_ext_vcpucontext:
-	case XEN_DOMCTL_set_opt_feature:
-	case XEN_DOMCTL_memory_mapping:
-	case XEN_DOMCTL_ioport_mapping:
-	case XEN_DOMCTL_pin_mem_cacheattr:
-	case XEN_DOMCTL_test_assign_device:
-	case XEN_DOMCTL_set_target:
-	case XEN_DOMCTL_deassign_device:
-	case XEN_DOMCTL_set_cpuid:
-	case XEN_DOMCTL_get_device_group:
-	case XEN_DOMCTL_get_machine_address_size:
-	case XEN_DOMCTL_set_machine_address_size:
-	case XEN_DOMCTL_suppress_spurious_page_faults:
-		break;
-
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_domctl %d\n", op.cmd);
-#endif
-		error = -X_EINVAL;
-	}
-
-	if (error == 0)
-		error = HYPERVISOR_domctl(&op);
-
-	export_buffer(&op_ie, &error);
-	export_buffer(&sub_ie, &error);
-
-	switch (op.cmd) {
-	case XEN_DOMCTL_createdomain:
-		DTRACE_XPV1(dom__create__end, int, error);
-		break;
-	case XEN_DOMCTL_destroydomain:
-		DTRACE_XPV1(dom__destroy__end, int, error);
-		break;
-	case XEN_DOMCTL_pausedomain:
-		DTRACE_XPV1(dom__pause__end, int, error);
-		break;
-	case XEN_DOMCTL_unpausedomain:
-		DTRACE_XPV1(dom__unpause__end, int, error);
-		break;
-	case XEN_DOMCTL_setvcpucontext:
-		DTRACE_XPV1(setvcpucontext__end, int, error);
-		break;
-	default:
-		;
-	}
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_sysctl(xen_sysctl_t *opp)
-{
-	xen_sysctl_t op, dop;
-	import_export_t op_ie, sub_ie, sub2_ie;
-	int error = 0;
-
-	if (import_buffer(&op_ie, opp, &op, sizeof (op), IE_IMPEXP) != 0)
-		return (-X_EFAULT);
-
-	sub_ie = null_ie;
-	sub2_ie = null_ie;
-
-	/*
-	 * Check this first because our wrapper will forcibly overwrite it.
-	 */
-	if (op.interface_version != XEN_SYSCTL_INTERFACE_VERSION) {
-		error = -X_EACCES;
-		export_buffer(&op_ie, &error);
-		return (error);
-	}
-
-	switch (op.cmd) {
-	case XEN_SYSCTL_readconsole: {
-		error = import_handle(&sub_ie, &op.u.readconsole.buffer,
-		    op.u.readconsole.count, IE_EXPORT);
-		break;
-	}
-
-	case XEN_SYSCTL_debug_keys: {
-		error = import_handle(&sub_ie, &op.u.debug_keys.keys,
-		    op.u.debug_keys.nr_keys, IE_IMPORT);
-		break;
-	}
-
-	case XEN_SYSCTL_tbuf_op:
-	case XEN_SYSCTL_physinfo: {
-		if (uaddr_from_handle(&op.u.physinfo.cpu_to_node) != NULL &&
-		    op.u.physinfo.max_cpu_id != 0) {
-			error = import_handle(&sub_ie,
-			    &op.u.physinfo.cpu_to_node,
-			    op.u.physinfo.max_cpu_id * sizeof (uint32_t),
-			    IE_EXPORT);
-		}
-		break;
-	}
-	case XEN_SYSCTL_sched_id:
-	case XEN_SYSCTL_availheap:
-	case XEN_SYSCTL_cpu_hotplug:
-		break;
-	case XEN_SYSCTL_get_pmstat: {
-		unsigned int maxs;
-
-		switch (op.u.get_pmstat.type) {
-		case PMSTAT_get_pxstat:
-			/*
-			 * This interface is broken. Xen always copies out
-			 * all the state information, and the interface
-			 * does not specify how much space the caller has
-			 * reserved. So, the only thing to do is just mirror
-			 * the hypervisor and libxc behavior, and use the
-			 * maximum amount of data.
-			 */
-			dop.cmd = XEN_SYSCTL_get_pmstat;
-			dop.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
-			dop.u.get_pmstat.cpuid = op.u.get_pmstat.cpuid;
-			dop.u.get_pmstat.type = PMSTAT_get_max_px;
-			error = HYPERVISOR_sysctl(&dop);
-			if (error != 0)
-				break;
-
-			maxs = dop.u.get_pmstat.u.getpx.total;
-			if (maxs == 0) {
-				error = -X_EINVAL;
-				break;
-			}
-
-			error = import_handle(&sub_ie,
-			    &op.u.get_pmstat.u.getpx.trans_pt,
-			    maxs * maxs * sizeof (uint64_t), IE_EXPORT);
-			if (error != 0)
-				break;
-
-			error = import_handle(&sub2_ie,
-			    &op.u.get_pmstat.u.getpx.pt,
-			    maxs * sizeof (pm_px_val_t), IE_EXPORT);
-			break;
-		case PMSTAT_get_cxstat:
-			/* See above */
-			dop.cmd = XEN_SYSCTL_get_pmstat;
-			dop.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
-			dop.u.get_pmstat.cpuid = op.u.get_pmstat.cpuid;
-			dop.u.get_pmstat.type = PMSTAT_get_max_cx;
-			error = HYPERVISOR_sysctl(&dop);
-			if (error != 0)
-				break;
-
-			maxs = dop.u.get_pmstat.u.getcx.nr;
-			if (maxs == 0) {
-				error = -X_EINVAL;
-				break;
-			}
-
-			error = import_handle(&sub_ie,
-			    &op.u.get_pmstat.u.getcx.triggers,
-			    maxs * sizeof (uint64_t), IE_EXPORT);
-			if (error != 0)
-				break;
-			error = import_handle(&sub2_ie,
-			    &op.u.get_pmstat.u.getcx.residencies,
-			    maxs * sizeof (uint64_t), IE_EXPORT);
-			break;
-
-		case PMSTAT_get_max_px:
-		case PMSTAT_reset_pxstat:
-		case PMSTAT_get_max_cx:
-		case PMSTAT_reset_cxstat:
-			break;
-		default:
-			error = -X_EINVAL;
-			break;
-		}
-		break;
-	}
-
-	case XEN_SYSCTL_perfc_op: {
-		xen_sysctl_perfc_desc_t *scdp;
-		/*
-		 * If 'desc' is NULL, then the caller is asking for
-		 * the number of counters.  If 'desc' is non-NULL,
-		 * then we need to know how many counters there are
-		 * before wiring down the output buffer appropriately.
-		 */
-		/*LINTED: constant in conditional context*/
-		get_xen_guest_handle_u(scdp, op.u.perfc_op.desc);
-		if (scdp != NULL) {
-			static int numcounters = -1;
-			static int numvals = -1;
-
-			if (numcounters == -1) {
-				dop.cmd = XEN_SYSCTL_perfc_op;
-				dop.interface_version =
-				    XEN_SYSCTL_INTERFACE_VERSION;
-				dop.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query;
-				/*LINTED: constant in conditional context*/
-				set_xen_guest_handle_u(dop.u.perfc_op.desc,
-				    NULL);
-				/*LINTED: constant in conditional context*/
-				set_xen_guest_handle_u(dop.u.perfc_op.val,
-				    NULL);
-
-				error = HYPERVISOR_sysctl(&dop);
-				if (error != 0)
-					break;
-				numcounters = dop.u.perfc_op.nr_counters;
-				numvals = dop.u.perfc_op.nr_vals;
-			}
-			ASSERT(numcounters != -1);
-			ASSERT(numvals != -1);
-			error = import_handle(&sub_ie, &op.u.perfc_op.desc,
-			    (sizeof (xen_sysctl_perfc_desc_t) * numcounters),
-			    IE_EXPORT);
-			error = import_handle(&sub2_ie, &op.u.perfc_op.val,
-			    (sizeof (xen_sysctl_perfc_val_t) * numvals),
-			    IE_EXPORT);
-		}
-		break;
-	}
-
-	case XEN_SYSCTL_getdomaininfolist: {
-		error = import_handle(&sub_ie, &op.u.getdomaininfolist.buffer,
-		    (op.u.getdomaininfolist.max_domains *
-		    sizeof (xen_domctl_getdomaininfo_t)), IE_EXPORT);
-		break;
-	}
-
-	case XEN_SYSCTL_getcpuinfo:
-		error = import_handle(&sub_ie, &op.u.getcpuinfo.info,
-		    op.u.getcpuinfo.max_cpus *
-		    sizeof (xen_sysctl_cpuinfo_t), IE_EXPORT);
-		break;
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_sysctl %d\n", op.cmd);
-#endif
-		error = -X_EINVAL;
-	}
-
-	if (error == 0)
-		error = HYPERVISOR_sysctl(&op);
-
-	export_buffer(&op_ie, &error);
-	export_buffer(&sub_ie, &error);
-	export_buffer(&sub2_ie, &error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_platform_op(xen_platform_op_t *opp)
-{
-	import_export_t op_ie, sub_ie, sub2_ie;
-	xen_platform_op_t op;
-	int error;
-
-	if (import_buffer(&op_ie, opp, &op, sizeof (op), IE_IMPEXP) != 0)
-		return (-X_EFAULT);
-
-	sub_ie = null_ie;
-	sub2_ie = null_ie;
-
-	/*
-	 * Check this first because our wrapper will forcibly overwrite it.
-	 */
-	if (op.interface_version != XENPF_INTERFACE_VERSION) {
-		error = -X_EACCES;
-		export_buffer(&op_ie, &error);
-		return (error);
-	}
-
-	/*
-	 * Now handle any platform ops with embedded pointers elsewhere
-	 * in the user address space that also need to be tacked down
-	 * while the hypervisor futzes with them.
-	 */
-	switch (op.cmd) {
-	case XENPF_settime:
-	case XENPF_add_memtype:
-	case XENPF_del_memtype:
-	case XENPF_read_memtype:
-	case XENPF_platform_quirk:
-	case XENPF_enter_acpi_sleep:
-	case XENPF_change_freq:
-	case XENPF_panic_init:
-		break;
-
-	case XENPF_microcode_update:
-		error = import_handle(&sub_ie, &op.u.microcode.data,
-		    op.u.microcode.length, IE_IMPORT);
-		break;
-	case XENPF_getidletime:
-		error = import_handle(&sub_ie, &op.u.getidletime.cpumap_bitmap,
-		    op.u.getidletime.cpumap_nr_cpus, IE_IMPEXP);
-		if (error != 0)
-			break;
-
-		error = import_handle(&sub2_ie, &op.u.getidletime.idletime,
-		    op.u.getidletime.cpumap_nr_cpus * sizeof (uint64_t),
-		    IE_EXPORT);
-		break;
-
-	case XENPF_set_processor_pminfo: {
-		size_t s;
-
-		switch (op.u.set_pminfo.type) {
-		case XEN_PM_PX:
-			s = op.u.set_pminfo.u.perf.state_count *
-			    sizeof (xen_processor_px_t);
-			if (op.u.set_pminfo.u.perf.flags & XEN_PX_PSS) {
-				error = import_handle(&sub_ie,
-				    &op.u.set_pminfo.u.perf.states, s,
-				    IE_IMPORT);
-			}
-			break;
-		case XEN_PM_CX:
-			s = op.u.set_pminfo.u.power.count *
-			    sizeof (xen_processor_cx_t);
-			error = import_handle(&sub_ie,
-			    &op.u.set_pminfo.u.power.states, s, IE_IMPORT);
-			break;
-		case XEN_PM_TX:
-			break;
-		default:
-			error = -X_EINVAL;
-			break;
-		}
-		break;
-	}
-	case XENPF_firmware_info: {
-		uint16_t len;
-		void *uaddr;
-
-		switch (op.u.firmware_info.type) {
-		case XEN_FW_DISK_INFO:
-			/*
-			 * Ugh.. another hokey interface. The first 16 bits
-			 * of the buffer are also used as the (input) length.
-			 */
-			uaddr = uaddr_from_handle(
-			    &op.u.firmware_info.u.disk_info.edd_params);
-			error = ddi_copyin(uaddr, &len, sizeof (len), 0);
-			if (error != 0)
-				break;
-			error = import_handle(&sub_ie,
-			    &op.u.firmware_info.u.disk_info.edd_params, len,
-			    IE_IMPEXP);
-			break;
-		case XEN_FW_VBEDDC_INFO:
-			error = import_handle(&sub_ie,
-			    &op.u.firmware_info.u.vbeddc_info.edid, 128,
-			    IE_EXPORT);
-			break;
-		case XEN_FW_DISK_MBR_SIGNATURE:
-		default:
-			break;
-		}
-		break;
-	}
-	default:
-		/* FIXME: see this with non-existed ID 38 ???? */
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_platform_op %d pid %d\n",
-		    op.cmd, curthread->t_procp->p_pid);
-#endif
-		return (-X_EINVAL);
-	}
-
-	if (error == 0)
-		error = HYPERVISOR_platform_op(&op);
-
-	export_buffer(&op_ie, &error);
-	export_buffer(&sub_ie, &error);
-	export_buffer(&sub2_ie, &error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_memory_op(int cmd, void *arg)
-{
-	int error = 0;
-	import_export_t op_ie, sub_ie, gpfn_ie, mfn_ie;
-	union {
-		domid_t domid;
-		struct xen_memory_reservation resv;
-		struct xen_machphys_mfn_list xmml;
-		struct xen_add_to_physmap xatp;
-		struct xen_memory_map mm;
-		struct xen_foreign_memory_map fmm;
-		struct xen_pod_target pd;
-	} op_arg;
-
-	op_ie = sub_ie = gpfn_ie = mfn_ie = null_ie;
-
-	switch (cmd) {
-	case XENMEM_increase_reservation:
-	case XENMEM_decrease_reservation:
-	case XENMEM_populate_physmap: {
-		ulong_t *taddr;
-
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.resv),
-		    IE_IMPEXP) != 0)
-			return (-X_EFAULT);
-
-		error = import_handle(&sub_ie, &op_arg.resv.extent_start,
-		    (op_arg.resv.nr_extents * sizeof (ulong_t)), IE_IMPEXP);
-
-		if (error == -X_EFAULT)
-			/*LINTED: constant in conditional context*/
-			get_xen_guest_handle(taddr, op_arg.resv.extent_start);
-		else
-			taddr = sub_ie.ie_kaddr;
-
-		switch (cmd) {
-		case XENMEM_increase_reservation:
-			DTRACE_XPV4(increase__reservation__start,
-			    domid_t, op_arg.resv.domid,
-			    ulong_t, op_arg.resv.nr_extents,
-			    uint_t, op_arg.resv.extent_order,
-			    ulong_t *, taddr);
-			break;
-		case XENMEM_decrease_reservation:
-			DTRACE_XPV4(decrease__reservation__start,
-			    domid_t, op_arg.resv.domid,
-			    ulong_t, op_arg.resv.nr_extents,
-			    uint_t, op_arg.resv.extent_order,
-			    ulong_t *, taddr);
-			break;
-		case XENMEM_populate_physmap:
-			DTRACE_XPV3(populate__physmap__start,
-			    domid_t, op_arg.resv.domid,
-			    ulong_t, op_arg.resv.nr_extents,
-			    ulong_t *, taddr);
-			break;
-		}
-
-		break;
-	}
-
-	case XENMEM_maximum_ram_page:
-		break;
-
-	case XENMEM_current_reservation:
-	case XENMEM_maximum_reservation:
-	case XENMEM_maximum_gpfn:
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.domid),
-		    IE_IMPEXP) != 0)
-			return (-X_EFAULT);
-		break;
-
-	case XENMEM_machphys_mfn_list: {
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.xmml),
-		    IE_IMPEXP) != 0)
-			return (-X_EFAULT);
-
-		error = import_handle(&sub_ie, &op_arg.xmml.extent_start,
-		    (op_arg.xmml.max_extents * sizeof (ulong_t)), IE_IMPEXP);
-		break;
-	}
-
-	case XENMEM_add_to_physmap:
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.xatp),
-		    IE_IMPEXP) != 0)
-			return (-X_EFAULT);
-		DTRACE_XPV4(add__to__physmap__start, domid_t,
-		    op_arg.xatp.domid, uint_t, op_arg.xatp.space, ulong_t,
-		    op_arg.xatp.idx, ulong_t, op_arg.xatp.gpfn);
-		break;
-
-	case XENMEM_memory_map:
-	case XENMEM_machine_memory_map: {
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.mm),
-		    IE_EXPORT) != 0)
-			return (-X_EFAULT);
-
-		/*
-		 * XXPV: ugh. e820entry is packed, but not in the kernel, since
-		 * we remove all attributes; seems like this is a nice way to
-		 * break mysteriously.
-		 */
-		error = import_handle(&sub_ie, &op_arg.mm.buffer,
-		    (op_arg.mm.nr_entries * 20), IE_IMPEXP);
-		break;
-	}
-
-	case XENMEM_set_memory_map: {
-		struct xen_memory_map *taddr;
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.fmm),
-		    IE_IMPORT) != 0)
-			return (-X_EFAULT);
-
-		/*
-		 * As above.
-		 */
-		error = import_handle(&sub_ie, &op_arg.fmm.map.buffer,
-		    (op_arg.fmm.map.nr_entries * 20), IE_IMPEXP);
-
-		if (error == -X_EFAULT)
-			/*LINTED: constant in conditional context*/
-			get_xen_guest_handle(taddr, op_arg.fmm.map.buffer);
-		else
-			taddr = sub_ie.ie_kaddr;
-		DTRACE_XPV3(set__memory__map__start, domid_t,
-		    op_arg.fmm.domid, int, op_arg.fmm.map.nr_entries,
-		    struct xen_memory_map *, taddr);
-		break;
-	}
-
-	case XENMEM_set_pod_target:
-	case XENMEM_get_pod_target:
-		if (import_buffer(&op_ie, arg, &op_arg, sizeof (op_arg.pd),
-		    IE_IMPEXP) != 0)
-			return (-X_EFAULT);
-		break;
-
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_memory_op %d\n", cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	if (error == 0)
-		error = HYPERVISOR_memory_op(cmd,
-		    (arg == NULL) ? NULL: &op_arg);
-
-	export_buffer(&op_ie, &error);
-	export_buffer(&sub_ie, &error);
-	export_buffer(&gpfn_ie, &error);
-	export_buffer(&mfn_ie, &error);
-
-	switch (cmd) {
-	case XENMEM_increase_reservation:
-		DTRACE_XPV1(increase__reservation__end, int, error);
-		break;
-	case XENMEM_decrease_reservation:
-		DTRACE_XPV1(decrease__reservation__end, int, error);
-		break;
-	case XENMEM_populate_physmap:
-		DTRACE_XPV1(populate__physmap__end, int, error);
-		break;
-	case XENMEM_add_to_physmap:
-		DTRACE_XPV1(add__to__physmap__end, int, error);
-		break;
-	case XENMEM_set_memory_map:
-		DTRACE_XPV1(set__memory__map__end, int, error);
-		break;
-	}
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_event_channel_op(int cmd, void *arg)
-{
-	int error;
-	size_t size;
-	import_export_t op_ie;
-	uint32_t flags;
-
-	switch (cmd) {
-	case EVTCHNOP_alloc_unbound:
-		size = sizeof (evtchn_alloc_unbound_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_bind_interdomain:
-		size = sizeof (evtchn_bind_interdomain_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_bind_virq:
-		size = sizeof (evtchn_bind_virq_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_bind_pirq:
-		size = sizeof (evtchn_bind_pirq_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_bind_ipi:
-		size = sizeof (evtchn_bind_ipi_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_close:
-		size = sizeof (evtchn_close_t);
-		flags = IE_IMPORT;
-		break;
-	case EVTCHNOP_send:
-		size = sizeof (evtchn_send_t);
-		flags = IE_IMPORT;
-		break;
-	case EVTCHNOP_status:
-		size = sizeof (evtchn_status_t);
-		flags = IE_IMPEXP;
-		break;
-	case EVTCHNOP_bind_vcpu:
-		size = sizeof (evtchn_bind_vcpu_t);
-		flags = IE_IMPORT;
-		break;
-	case EVTCHNOP_unmask:
-		size = sizeof (evtchn_unmask_t);
-		flags = IE_IMPORT;
-		break;
-	case EVTCHNOP_reset:
-		size = sizeof (evtchn_reset_t);
-		flags = IE_IMPORT;
-		break;
-
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_event_channel op %d\n", cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	error = import_buffer(&op_ie, arg, NULL, size, flags);
-
-	/*
-	 * If there is sufficient demand, we can replace this void * with
-	 * the proper op structure pointer.
-	 */
-	DTRACE_XPV2(evtchn__op__start, int, cmd, void *,
-	    ((error == -X_EFAULT) ? arg : op_ie.ie_kaddr));
-
-	if (error == 0)
-		error = HYPERVISOR_event_channel_op(cmd, op_ie.ie_kaddr);
-	export_buffer(&op_ie, &error);
-
-	DTRACE_XPV1(evtchn__op__end, int, error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_xen_version(int cmd, void *arg)
-{
-	int error;
-	int size = 0;
-	import_export_t op_ie;
-	uint32_t flags = IE_EXPORT;
-
-	switch (cmd) {
-	case XENVER_version:
-		break;
-	case XENVER_extraversion:
-		size = sizeof (xen_extraversion_t);
-		break;
-	case XENVER_compile_info:
-		size = sizeof (xen_compile_info_t);
-		break;
-	case XENVER_capabilities:
-		size = sizeof (xen_capabilities_info_t);
-		break;
-	case XENVER_changeset:
-		size = sizeof (xen_changeset_info_t);
-		break;
-	case XENVER_platform_parameters:
-		size = sizeof (xen_platform_parameters_t);
-		break;
-	case XENVER_get_features:
-		flags = IE_IMPEXP;
-		size = sizeof (xen_feature_info_t);
-		break;
-	case XENVER_pagesize:
-		break;
-	case XENVER_guest_handle:
-		size = sizeof (xen_domain_handle_t);
-		break;
-
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_xen_version op %d\n", cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	error = import_buffer(&op_ie, arg, NULL, size, flags);
-	if (error == 0)
-		error = HYPERVISOR_xen_version(cmd, op_ie.ie_kaddr);
-	export_buffer(&op_ie, &error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_xsm_op(void *uacmctl)
-{
-	int error;
-	struct xen_acmctl *acmctl;
-	import_export_t op_ie;
-
-	error = import_buffer(&op_ie, uacmctl, NULL, sizeof (*acmctl),
-	    IE_IMPEXP);
-	if (error != 0)
-		return (error);
-
-	acmctl = op_ie.ie_kaddr;
-
-	if (acmctl->interface_version != ACM_INTERFACE_VERSION) {
-#ifdef DEBUG
-		printf("acm vers mismatch (cmd %d, found 0x%x, need 0x%x\n",
-		    acmctl->cmd, acmctl->interface_version,
-		    ACM_INTERFACE_VERSION);
-#endif
-		error = -X_EACCES;
-		export_buffer(&op_ie, &error);
-		return (error);
-	}
-
-	/* FIXME: flask ops??? */
-
-	switch (acmctl->cmd) {
-	case ACMOP_setpolicy:
-	case ACMOP_getpolicy:
-	case ACMOP_dumpstats:
-	case ACMOP_getssid:
-	case ACMOP_getdecision:
-	case ACMOP_chgpolicy:
-	case ACMOP_relabeldoms:
-		/* flags = IE_IMPEXP; */
-		break;
-	default:
-#ifdef DEBUG
-		printf("unrecognized HYPERVISOR_xsm_op op %d\n", acmctl->cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	if (error == 0)
-		error = HYPERVISOR_xsm_op(acmctl);
-	export_buffer(&op_ie, &error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_mmuext_op(struct mmuext_op *op, int count, uint_t *scount,
-    domid_t domid)
-{
-	int error, bytes;
-	uint_t kscount;
-	struct mmuext_op *kop, single_kop;
-	import_export_t op_ie, scnt_ie;
-
-	op_ie = scnt_ie = null_ie;
-	error = 0;
-
-	if (count >= 1) {
-		bytes = count * sizeof (*kop);
-		kop = (count == 1) ? &single_kop : kmem_alloc(bytes, KM_SLEEP);
-		error = import_buffer(&op_ie, op, kop, bytes, IE_IMPORT);
-	}
-
-	DTRACE_XPV2(mmu__ext__op__start, int, count, struct mmuext_op *,
-	    ((error == -X_EFAULT) ? op : kop));
-
-	if (scount != NULL && error == 0)
-		error = import_buffer(&scnt_ie, scount, &kscount,
-		    sizeof (kscount), IE_EXPORT);
-
-	if (error == 0)
-		error = HYPERVISOR_mmuext_op(kop, count, &kscount, domid);
-	export_buffer(&op_ie, &error);
-	export_buffer(&scnt_ie, &error);
-
-	DTRACE_XPV1(mmu__ext__op__end, int, error);
-
-	if (count > 1)
-		kmem_free(kop, bytes);
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_hvm_op(int cmd, void *arg)
-{
-	int error;
-	int size = 0;
-	import_export_t arg_ie;
-	uint32_t flags = IE_IMPORT;
-
-	switch (cmd) {
-	case HVMOP_set_param:
-	case HVMOP_get_param:
-		size = sizeof (struct xen_hvm_param);
-		flags = IE_IMPEXP;
-		break;
-	case HVMOP_set_pci_intx_level:
-		size = sizeof (struct xen_hvm_set_pci_intx_level);
-		break;
-	case HVMOP_set_isa_irq_level:
-		size = sizeof (struct xen_hvm_set_isa_irq_level);
-		break;
-	case HVMOP_set_pci_link_route:
-		size = sizeof (struct xen_hvm_set_pci_link_route);
-		break;
-	case HVMOP_track_dirty_vram:
-		size = sizeof (struct xen_hvm_track_dirty_vram);
-		break;
-	case HVMOP_modified_memory:
-		size = sizeof (struct xen_hvm_modified_memory);
-		break;
-	case HVMOP_set_mem_type:
-		size = sizeof (struct xen_hvm_set_mem_type);
-		break;
-
-	default:
-#ifdef DEBUG
-		printf("unrecognized HVM op 0x%x\n", cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	error = import_buffer(&arg_ie, arg, NULL, size, flags);
-	if (error == 0)
-		error = HYPERVISOR_hvm_op(cmd, arg_ie.ie_kaddr);
-	export_buffer(&arg_ie, &error);
-
-	return (error);
-}
-
-static int
-privcmd_HYPERVISOR_sched_op(int cmd, void *arg)
-{
-	int error;
-	int size = 0;
-	import_export_t op_ie;
-	struct sched_remote_shutdown op;
-
-	switch (cmd) {
-	case SCHEDOP_remote_shutdown:
-		size = sizeof (struct sched_remote_shutdown);
-		break;
-	default:
-#ifdef DEBUG
-		printf("unrecognized sched op 0x%x\n", cmd);
-#endif
-		return (-X_EINVAL);
-	}
-
-	error = import_buffer(&op_ie, arg, &op, size, IE_IMPORT);
-	if (error == 0)
-		error = HYPERVISOR_sched_op(cmd, (arg == NULL) ? NULL : &op);
-	export_buffer(&op_ie, &error);
-
-	return (error);
-}
-
-int allow_all_hypercalls = 0;
-int privcmd_efault_debug = 0;
-
-/*ARGSUSED*/
-int
-do_privcmd_hypercall(void *uarg, int mode, cred_t *cr, int *rval)
-{
-	privcmd_hypercall_t __hc, *hc = &__hc;
-	int error;
-
-	if (ddi_copyin(uarg, hc, sizeof (*hc), mode))
-		return (EFAULT);
-
-	switch (hc->op) {
-	case __HYPERVISOR_mmu_update:
-		error = privcmd_HYPERVISOR_mmu_update(
-		    (mmu_update_t *)hc->arg[0], (int)hc->arg[1],
-		    (int *)hc->arg[2], (domid_t)hc->arg[3]);
-		break;
-	case __HYPERVISOR_domctl:
-		error = privcmd_HYPERVISOR_domctl(
-		    (xen_domctl_t *)hc->arg[0]);
-		break;
-	case __HYPERVISOR_sysctl:
-		error = privcmd_HYPERVISOR_sysctl(
-		    (xen_sysctl_t *)hc->arg[0]);
-		break;
-	case __HYPERVISOR_platform_op:
-		error = privcmd_HYPERVISOR_platform_op(
-		    (xen_platform_op_t *)hc->arg[0]);
-		break;
-	case __HYPERVISOR_memory_op:
-		error = privcmd_HYPERVISOR_memory_op(
-		    (int)hc->arg[0], (void *)hc->arg[1]);
-		break;
-	case __HYPERVISOR_event_channel_op:
-		error = privcmd_HYPERVISOR_event_channel_op(
-		    (int)hc->arg[0], (void *)hc->arg[1]);
-		break;
-	case __HYPERVISOR_xen_version:
-		error = privcmd_HYPERVISOR_xen_version(
-		    (int)hc->arg[0], (void *)hc->arg[1]);
-		break;
-	case __HYPERVISOR_mmuext_op:
-		error = privcmd_HYPERVISOR_mmuext_op(
-		    (struct mmuext_op *)hc->arg[0], (int)hc->arg[1],
-		    (uint_t *)hc->arg[2], (domid_t)hc->arg[3]);
-		break;
-	case __HYPERVISOR_xsm_op:
-		error = privcmd_HYPERVISOR_xsm_op((void *)hc->arg[0]);
-		break;
-	case __HYPERVISOR_hvm_op:
-		error = privcmd_HYPERVISOR_hvm_op(
-		    (int)hc->arg[0], (void *)hc->arg[1]);
-		break;
-	case __HYPERVISOR_sched_op:
-		error = privcmd_HYPERVISOR_sched_op(
-		    (int)hc->arg[0], (void *)hc->arg[1]);
-		break;
-	default:
-		if (allow_all_hypercalls)
-			error = __hypercall5(hc->op, hc->arg[0], hc->arg[1],
-			    hc->arg[2], hc->arg[3], hc->arg[4]);
-		else {
-#ifdef DEBUG
-			printf("unrecognized hypercall %ld\n", hc->op);
-#endif
-			error = -X_EPERM;
-		}
-		break;
-	}
-
-	if (error > 0) {
-		*rval = error;
-		error = 0;
-	} else if (error != 0)
-		error = xen_xlate_errcode(error);
-
-	return (error);
-}
--- old/usr/src/uts/i86xpv/io/psm/mp_platform_xpv.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,2153 +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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Copyright (c) 2010, Intel Corporation.
- * All rights reserved.
- * Copyright 2016 PALO, Richard.
- */
-
-/*
- * PSMI 1.1 extensions are supported only in 2.6 and later versions.
- * PSMI 1.2 extensions are supported only in 2.7 and later versions.
- * PSMI 1.3 and 1.4 extensions are supported in Solaris 10.
- * PSMI 1.5 extensions are supported in Solaris Nevada.
- * PSMI 1.6 extensions are supported in Solaris Nevada.
- * PSMI 1.7 extensions are supported in Solaris Nevada.
- */
-#define	PSMI_1_7
-
-#include <sys/processor.h>
-#include <sys/time.h>
-#include <sys/psm.h>
-#include <sys/smp_impldefs.h>
-#include <sys/cram.h>
-#include <sys/acpi/acpi.h>
-#include <sys/acpica.h>
-#include <sys/psm_common.h>
-#include <sys/apic.h>
-#include <sys/apic_common.h>
-#include <sys/pit.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/pci.h>
-#include <sys/promif.h>
-#include <sys/x86_archext.h>
-#include <sys/cpc_impl.h>
-#include <sys/uadmin.h>
-#include <sys/panic.h>
-#include <sys/debug.h>
-#include <sys/archsystm.h>
-#include <sys/trap.h>
-#include <sys/machsystm.h>
-#include <sys/cpuvar.h>
-#include <sys/rm_platter.h>
-#include <sys/privregs.h>
-#include <sys/cyclic.h>
-#include <sys/note.h>
-#include <sys/pci_intr_lib.h>
-#include <sys/sunndi.h>
-
-
-/*
- *      Local Function Prototypes
- */
-static void apic_mark_vector(uchar_t oldvector, uchar_t newvector);
-static void apic_xlate_vector_free_timeout_handler(void *arg);
-static int apic_check_stuck_interrupt(apic_irq_t *irq_ptr, int old_bind_cpu,
-    int new_bind_cpu, int apicindex, int intin_no, int which_irq,
-    struct ioapic_reprogram_data *drep);
-static int apic_setup_irq_table(dev_info_t *dip, int irqno,
-    struct apic_io_intr *intrp, struct intrspec *ispec, iflag_t *intr_flagp,
-    int type);
-static void apic_try_deferred_reprogram(int ipl, int vect);
-static void delete_defer_repro_ent(int which_irq);
-static void apic_ioapic_wait_pending_clear(int ioapicindex,
-    int intin_no);
-
-extern int apic_acpi_translate_pci_irq(dev_info_t *dip, int busid, int devid,
-    int ipin, int *pci_irqp, iflag_t *intr_flagp);
-extern int apic_handle_pci_pci_bridge(dev_info_t *idip, int child_devno,
-    int child_ipin, struct apic_io_intr **intrp);
-extern uchar_t acpi_find_ioapic(int irq);
-extern struct apic_io_intr *apic_find_io_intr_w_busid(int irqno, int busid);
-extern int apic_find_bus_id(int bustype);
-extern int apic_find_intin(uchar_t ioapic, uchar_t intin);
-extern void apic_record_rdt_entry(apic_irq_t *irqptr, int irq);
-
-extern	int apic_sci_vect;
-extern	iflag_t apic_sci_flags;
-extern	int	apic_intr_policy;
-extern	char *psm_name;
-
-/*
- * number of bits per byte, from <sys/param.h>
- */
-#define	UCHAR_MAX	((1 << NBBY) - 1)
-
-/* Max wait time (in repetitions) for flags to clear in an RDT entry. */
-extern int apic_max_reps_clear_pending;
-
-/* The irq # is implicit in the array index: */
-struct ioapic_reprogram_data apic_reprogram_info[APIC_MAX_VECTOR+1];
-/*
- * APIC_MAX_VECTOR + 1 is the maximum # of IRQs as well. ioapic_reprogram_info
- * is indexed by IRQ number, NOT by vector number.
- */
-
-extern	int	apic_int_busy_mark;
-extern	int	apic_int_free_mark;
-extern	int	apic_diff_for_redistribution;
-extern	int	apic_sample_factor_redistribution;
-extern	int	apic_redist_cpu_skip;
-extern	int	apic_num_imbalance;
-extern	int	apic_num_rebind;
-
-/* timeout for xlate_vector, mark_vector */
-int	apic_revector_timeout = 16 * 10000; /* 160 millisec */
-
-extern int	apic_defconf;
-extern int	apic_irq_translate;
-
-extern int	apic_use_acpi_madt_only;	/* 1=ONLY use MADT from ACPI */
-
-extern	uchar_t	apic_io_vectbase[MAX_IO_APIC];
-
-extern	boolean_t ioapic_mask_workaround[MAX_IO_APIC];
-
-/*
- * First available slot to be used as IRQ index into the apic_irq_table
- * for those interrupts (like MSI/X) that don't have a physical IRQ.
- */
-extern int apic_first_avail_irq;
-
-/*
- * apic_defer_reprogram_lock ensures that only one processor is handling
- * deferred interrupt programming at *_intr_exit time.
- */
-static	lock_t	apic_defer_reprogram_lock;
-
-/*
- * The current number of deferred reprogrammings outstanding
- */
-uint_t	apic_reprogram_outstanding = 0;
-
-#ifdef DEBUG
-/*
- * Counters that keep track of deferred reprogramming stats
- */
-uint_t	apic_intr_deferrals = 0;
-uint_t	apic_intr_deliver_timeouts = 0;
-uint_t	apic_last_ditch_reprogram_failures = 0;
-uint_t	apic_deferred_setup_failures = 0;
-uint_t	apic_defer_repro_total_retries = 0;
-uint_t	apic_defer_repro_successes = 0;
-uint_t	apic_deferred_spurious_enters = 0;
-#endif
-
-extern	int	apic_io_max;
-extern	struct apic_io_intr *apic_io_intrp;
-
-uchar_t	apic_vector_to_irq[APIC_MAX_VECTOR+1];
-
-extern	uint32_t	eisa_level_intr_mask;
-	/* At least MSB will be set if EISA bus */
-
-extern	int	apic_pci_bus_total;
-extern	uchar_t	apic_single_pci_busid;
-
-/*
- * Following declarations are for revectoring; used when ISRs at different
- * IPLs share an irq.
- */
-static	lock_t	apic_revector_lock;
-int	apic_revector_pending = 0;
-static	uchar_t	*apic_oldvec_to_newvec;
-static	uchar_t	*apic_newvec_to_oldvec;
-
-/* ACPI Interrupt Source Override Structure ptr */
-ACPI_MADT_INTERRUPT_OVERRIDE *acpi_isop;
-extern	int acpi_iso_cnt;
-
-/*
- * Auto-configuration routines
- */
-
-/*
- * Initialise vector->ipl and ipl->pri arrays. level_intr and irqtable
- * are also set to NULL. vector->irq is set to a value which cannot map
- * to a real irq to show that it is free.
- */
-void
-apic_init_common(void)
-{
-	int	i, j, indx;
-	int	*iptr;
-
-	/*
-	 * Initialize apic_ipls from apic_vectortoipl.  This array is
-	 * used in apic_intr_enter to determine the IPL to use for the
-	 * corresponding vector.  On some systems, due to hardware errata
-	 * and interrupt sharing, the IPL may not correspond to the IPL listed
-	 * in apic_vectortoipl (see apic_addspl and apic_delspl).
-	 */
-	for (i = 0; i < (APIC_AVAIL_VECTOR / APIC_VECTOR_PER_IPL); i++) {
-		indx = i * APIC_VECTOR_PER_IPL;
-
-		for (j = 0; j < APIC_VECTOR_PER_IPL; j++, indx++)
-			apic_ipls[indx] = apic_vectortoipl[i];
-	}
-
-	/* cpu 0 is always up (for now) */
-	apic_cpus[0].aci_status = APIC_CPU_ONLINE | APIC_CPU_INTR_ENABLE;
-
-	iptr = (int *)&apic_irq_table[0];
-	for (i = 0; i <= APIC_MAX_VECTOR; i++) {
-		apic_level_intr[i] = 0;
-		*iptr++ = 0;
-		apic_vector_to_irq[i] = APIC_RESV_IRQ;
-
-		/* These *must* be initted to B_TRUE! */
-		apic_reprogram_info[i].done = B_TRUE;
-		apic_reprogram_info[i].irqp = NULL;
-		apic_reprogram_info[i].tries = 0;
-		apic_reprogram_info[i].bindcpu = 0;
-	}
-
-	/*
-	 * Allocate a dummy irq table entry for the reserved entry.
-	 * This takes care of the race between removing an irq and
-	 * clock detecting a CPU in that irq during interrupt load
-	 * sampling.
-	 */
-	apic_irq_table[APIC_RESV_IRQ] =
-	    kmem_zalloc(sizeof (apic_irq_t), KM_SLEEP);
-
-	mutex_init(&airq_mutex, NULL, MUTEX_DEFAULT, NULL);
-}
-
-void
-ioapic_init_intr(int mask_apic)
-{
-	int ioapic_ix;
-	struct intrspec ispec;
-	apic_irq_t *irqptr;
-	int i, j;
-	ulong_t iflag;
-
-	LOCK_INIT_CLEAR(&apic_revector_lock);
-	LOCK_INIT_CLEAR(&apic_defer_reprogram_lock);
-
-	/* mask interrupt vectors */
-	for (j = 0; j < apic_io_max && mask_apic; j++) {
-		int intin_max;
-
-		ioapic_ix = j;
-		/* Bits 23-16 define the maximum redirection entries */
-		intin_max = (ioapic_read(ioapic_ix, APIC_VERS_CMD) >> 16)
-		    & 0xff;
-		for (i = 0; i <= intin_max; i++)
-			ioapic_write(ioapic_ix, APIC_RDT_CMD + 2 * i, AV_MASK);
-	}
-
-	/*
-	 * Hack alert: deal with ACPI SCI interrupt chicken/egg here
-	 */
-	if (apic_sci_vect > 0) {
-		/*
-		 * acpica has already done add_avintr(); we just
-		 * to finish the job by mimicing translate_irq()
-		 *
-		 * Fake up an intrspec and setup the tables
-		 */
-		ispec.intrspec_vec = apic_sci_vect;
-		ispec.intrspec_pri = SCI_IPL;
-
-		if (apic_setup_irq_table(NULL, apic_sci_vect, NULL,
-		    &ispec, &apic_sci_flags, DDI_INTR_TYPE_FIXED) < 0) {
-			cmn_err(CE_WARN, "!apic: SCI setup failed");
-			return;
-		}
-		irqptr = apic_irq_table[apic_sci_vect];
-
-		iflag = intr_clear();
-		lock_set(&apic_ioapic_lock);
-
-		/* Program I/O APIC */
-		(void) apic_setup_io_intr(irqptr, apic_sci_vect, B_FALSE);
-
-		lock_clear(&apic_ioapic_lock);
-		intr_restore(iflag);
-
-		irqptr->airq_share++;
-	}
-}
-
-/*
- * Add mask bits to disable interrupt vector from happening
- * at or above IPL. In addition, it should remove mask bits
- * to enable interrupt vectors below the given IPL.
- *
- * Both add and delspl are complicated by the fact that different interrupts
- * may share IRQs. This can happen in two ways.
- * 1. The same H/W line is shared by more than 1 device
- * 1a. with interrupts at different IPLs
- * 1b. with interrupts at same IPL
- * 2. We ran out of vectors at a given IPL and started sharing vectors.
- * 1b and 2 should be handled gracefully, except for the fact some ISRs
- * will get called often when no interrupt is pending for the device.
- * For 1a, we handle it at the higher IPL.
- */
-/*ARGSUSED*/
-int
-apic_addspl_common(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	uchar_t vector;
-	ulong_t iflag;
-	apic_irq_t *irqptr, *irqheadptr;
-	int irqindex;
-
-	ASSERT(max_ipl <= UCHAR_MAX);
-	irqindex = IRQINDEX(irqno);
-
-	if ((irqindex == -1) || (!apic_irq_table[irqindex]))
-		return (PSM_FAILURE);
-
-	mutex_enter(&airq_mutex);
-	irqptr = irqheadptr = apic_irq_table[irqindex];
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_addspl: dip=0x%p type=%d irqno=0x%x "
-	    "vector=0x%x\n", (void *)irqptr->airq_dip,
-	    irqptr->airq_mps_intr_index, irqno, irqptr->airq_vector));
-
-	while (irqptr) {
-		if (VIRTIRQ(irqindex, irqptr->airq_share_id) == irqno)
-			break;
-		irqptr = irqptr->airq_next;
-	}
-	irqptr->airq_share++;
-
-	mutex_exit(&airq_mutex);
-
-	/* return if it is not hardware interrupt */
-	if (irqptr->airq_mps_intr_index == RESERVE_INDEX)
-		return (PSM_SUCCESS);
-
-	/* Or if there are more interupts at a higher IPL */
-	if (ipl != max_ipl)
-		return (PSM_SUCCESS);
-
-	/*
-	 * if apic_picinit() has not been called yet, just return.
-	 * At the end of apic_picinit(), we will call setup_io_intr().
-	 */
-
-	if (!apic_picinit_called)
-		return (PSM_SUCCESS);
-
-	/*
-	 * Upgrade vector if max_ipl is not earlier ipl. If we cannot allocate,
-	 * return failure.
-	 */
-	if (irqptr->airq_ipl != max_ipl &&
-	    !ioapic_mask_workaround[irqptr->airq_ioapicindex]) {
-
-		vector = apic_allocate_vector(max_ipl, irqindex, 1);
-		if (vector == 0) {
-			irqptr->airq_share--;
-			return (PSM_FAILURE);
-		}
-		irqptr = irqheadptr;
-		apic_mark_vector(irqptr->airq_vector, vector);
-		while (irqptr) {
-			irqptr->airq_vector = vector;
-			irqptr->airq_ipl = (uchar_t)max_ipl;
-			/*
-			 * reprogram irq being added and every one else
-			 * who is not in the UNINIT state
-			 */
-			if ((VIRTIRQ(irqindex, irqptr->airq_share_id) ==
-			    irqno) || (irqptr->airq_temp_cpu != IRQ_UNINIT)) {
-				apic_record_rdt_entry(irqptr, irqindex);
-
-				iflag = intr_clear();
-				lock_set(&apic_ioapic_lock);
-
-				(void) apic_setup_io_intr(irqptr, irqindex,
-				    B_FALSE);
-
-				lock_clear(&apic_ioapic_lock);
-				intr_restore(iflag);
-			}
-			irqptr = irqptr->airq_next;
-		}
-		return (PSM_SUCCESS);
-
-	} else if (irqptr->airq_ipl != max_ipl &&
-	    ioapic_mask_workaround[irqptr->airq_ioapicindex]) {
-		/*
-		 * We cannot upgrade the vector, but we can change
-		 * the IPL that this vector induces.
-		 *
-		 * Note that we subtract APIC_BASE_VECT from the vector
-		 * here because this array is used in apic_intr_enter
-		 * (no need to add APIC_BASE_VECT in that hot code
-		 * path since we can do it in the rarely-executed path
-		 * here).
-		 */
-		apic_ipls[irqptr->airq_vector - APIC_BASE_VECT] =
-		    (uchar_t)max_ipl;
-
-		irqptr = irqheadptr;
-		while (irqptr) {
-			irqptr->airq_ipl = (uchar_t)max_ipl;
-			irqptr = irqptr->airq_next;
-		}
-
-		return (PSM_SUCCESS);
-	}
-
-	ASSERT(irqptr);
-
-	iflag = intr_clear();
-	lock_set(&apic_ioapic_lock);
-
-	(void) apic_setup_io_intr(irqptr, irqindex, B_FALSE);
-
-	lock_clear(&apic_ioapic_lock);
-	intr_restore(iflag);
-
-	return (PSM_SUCCESS);
-}
-
-/*
- * Recompute mask bits for the given interrupt vector.
- * If there is no interrupt servicing routine for this
- * vector, this function should disable interrupt vector
- * from happening at all IPLs. If there are still
- * handlers using the given vector, this function should
- * disable the given vector from happening below the lowest
- * IPL of the remaining hadlers.
- */
-/*ARGSUSED*/
-int
-apic_delspl_common(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	uchar_t vector;
-	uint32_t bind_cpu;
-	int intin, irqindex;
-	int ioapic_ix;
-	apic_irq_t	*irqptr, *preirqptr, *irqheadptr, *irqp;
-	ulong_t iflag;
-
-	mutex_enter(&airq_mutex);
-	irqindex = IRQINDEX(irqno);
-	irqptr = preirqptr = irqheadptr = apic_irq_table[irqindex];
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_delspl: dip=0x%p type=%d irqno=0x%x "
-	    "vector=0x%x\n", (void *)irqptr->airq_dip,
-	    irqptr->airq_mps_intr_index, irqno, irqptr->airq_vector));
-
-	while (irqptr) {
-		if (VIRTIRQ(irqindex, irqptr->airq_share_id) == irqno)
-			break;
-		preirqptr = irqptr;
-		irqptr = irqptr->airq_next;
-	}
-	ASSERT(irqptr);
-
-	irqptr->airq_share--;
-
-	mutex_exit(&airq_mutex);
-
-	/*
-	 * If there are more interrupts at a higher IPL, we don't need
-	 * to disable anything.
-	 */
-	if (ipl < max_ipl)
-		return (PSM_SUCCESS);
-
-	/* return if it is not hardware interrupt */
-	if (irqptr->airq_mps_intr_index == RESERVE_INDEX)
-		return (PSM_SUCCESS);
-
-	if (!apic_picinit_called) {
-		/*
-		 * Clear irq_struct. If two devices shared an intpt
-		 * line & 1 unloaded before picinit, we are hosed. But, then
-		 * we hope the machine survive.
-		 */
-		irqptr->airq_mps_intr_index = FREE_INDEX;
-		irqptr->airq_temp_cpu = IRQ_UNINIT;
-		apic_free_vector(irqptr->airq_vector);
-		return (PSM_SUCCESS);
-	}
-	/*
-	 * Downgrade vector to new max_ipl if needed. If we cannot allocate,
-	 * use old IPL. Not very elegant, but it should work.
-	 */
-	if ((irqptr->airq_ipl != max_ipl) && (max_ipl != PSM_INVALID_IPL) &&
-	    !ioapic_mask_workaround[irqptr->airq_ioapicindex]) {
-		apic_irq_t	*irqp;
-		if (vector = apic_allocate_vector(max_ipl, irqno, 1)) {
-			apic_mark_vector(irqheadptr->airq_vector, vector);
-			irqp = irqheadptr;
-			while (irqp) {
-				irqp->airq_vector = vector;
-				irqp->airq_ipl = (uchar_t)max_ipl;
-				if (irqp->airq_temp_cpu != IRQ_UNINIT) {
-					apic_record_rdt_entry(irqp, irqindex);
-
-					iflag = intr_clear();
-					lock_set(&apic_ioapic_lock);
-
-					(void) apic_setup_io_intr(irqp,
-					    irqindex, B_FALSE);
-
-					lock_clear(&apic_ioapic_lock);
-					intr_restore(iflag);
-				}
-				irqp = irqp->airq_next;
-			}
-		}
-
-	} else if (irqptr->airq_ipl != max_ipl &&
-	    max_ipl != PSM_INVALID_IPL &&
-	    ioapic_mask_workaround[irqptr->airq_ioapicindex]) {
-
-	/*
-	 * We cannot downgrade the IPL of the vector below the vector's
-	 * hardware priority. If we did, it would be possible for a
-	 * higher-priority hardware vector to interrupt a CPU running at an IPL
-	 * lower than the hardware priority of the interrupting vector (but
-	 * higher than the soft IPL of this IRQ). When this happens, we would
-	 * then try to drop the IPL BELOW what it was (effectively dropping
-	 * below base_spl) which would be potentially catastrophic.
-	 *
-	 * (e.g. Suppose the hardware vector associated with this IRQ is 0x40
-	 * (hardware IPL of 4).  Further assume that the old IPL of this IRQ
-	 * was 4, but the new IPL is 1.  If we forced vector 0x40 to result in
-	 * an IPL of 1, it would be possible for the processor to be executing
-	 * at IPL 3 and for an interrupt to come in on vector 0x40, interrupting
-	 * the currently-executing ISR.  When apic_intr_enter consults
-	 * apic_irqs[], it will return 1, bringing the IPL of the CPU down to 1
-	 * so even though the processor was running at IPL 4, an IPL 1
-	 * interrupt will have interrupted it, which must not happen)).
-	 *
-	 * Effectively, this means that the hardware priority corresponding to
-	 * the IRQ's IPL (in apic_ipls[]) cannot be lower than the vector's
-	 * hardware priority.
-	 *
-	 * (In the above example, then, after removal of the IPL 4 device's
-	 * interrupt handler, the new IPL will continue to be 4 because the
-	 * hardware priority that IPL 1 implies is lower than the hardware
-	 * priority of the vector used.)
-	 */
-		/* apic_ipls is indexed by vector, starting at APIC_BASE_VECT */
-		const int apic_ipls_index = irqptr->airq_vector -
-		    APIC_BASE_VECT;
-		const int vect_inherent_hwpri = irqptr->airq_vector >>
-		    APIC_IPL_SHIFT;
-
-		/*
-		 * If there are still devices using this IRQ, determine the
-		 * new ipl to use.
-		 */
-		if (irqptr->airq_share) {
-			int vect_desired_hwpri, hwpri;
-
-			ASSERT(max_ipl < MAXIPL);
-			vect_desired_hwpri = apic_ipltopri[max_ipl] >>
-			    APIC_IPL_SHIFT;
-
-			/*
-			 * If the desired IPL's hardware priority is lower
-			 * than that of the vector, use the hardware priority
-			 * of the vector to determine the new IPL.
-			 */
-			hwpri = (vect_desired_hwpri < vect_inherent_hwpri) ?
-			    vect_inherent_hwpri : vect_desired_hwpri;
-
-			/*
-			 * Now, to get the right index for apic_vectortoipl,
-			 * we need to subtract APIC_BASE_VECT from the
-			 * hardware-vector-equivalent (in hwpri).  Since hwpri
-			 * is already shifted, we shift APIC_BASE_VECT before
-			 * doing the subtraction.
-			 */
-			hwpri -= (APIC_BASE_VECT >> APIC_IPL_SHIFT);
-
-			ASSERT(hwpri >= 0);
-			ASSERT(hwpri < MAXIPL);
-			max_ipl = apic_vectortoipl[hwpri];
-			apic_ipls[apic_ipls_index] = max_ipl;
-
-			irqp = irqheadptr;
-			while (irqp) {
-				irqp->airq_ipl = (uchar_t)max_ipl;
-				irqp = irqp->airq_next;
-			}
-		} else {
-			/*
-			 * No more devices on this IRQ, so reset this vector's
-			 * element in apic_ipls to the original IPL for this
-			 * vector
-			 */
-			apic_ipls[apic_ipls_index] =
-			    apic_vectortoipl[vect_inherent_hwpri];
-		}
-	}
-
-	/*
-	 * If there are still active interrupts, we are done.
-	 */
-	if (irqptr->airq_share)
-		return (PSM_SUCCESS);
-
-	iflag = intr_clear();
-	lock_set(&apic_ioapic_lock);
-
-	if (irqptr->airq_mps_intr_index == MSI_INDEX) {
-		/*
-		 * Disable the MSI vector
-		 * Make sure we only disable on the last
-		 * of the multi-MSI support
-		 */
-		if (i_ddi_intr_get_current_nenables(irqptr->airq_dip) == 1) {
-			apic_pci_msi_disable_mode(irqptr->airq_dip,
-			    DDI_INTR_TYPE_MSI);
-		}
-	} else if (irqptr->airq_mps_intr_index == MSIX_INDEX) {
-		/*
-		 * Disable the MSI-X vector
-		 * needs to clear its mask and addr/data for each MSI-X
-		 */
-		apic_pci_msi_unconfigure(irqptr->airq_dip, DDI_INTR_TYPE_MSIX,
-		    irqptr->airq_origirq);
-		/*
-		 * Make sure we only disable on the last MSI-X
-		 */
-		if (i_ddi_intr_get_current_nenables(irqptr->airq_dip) == 1) {
-			apic_pci_msi_disable_mode(irqptr->airq_dip,
-			    DDI_INTR_TYPE_MSIX);
-		}
-	} else {
-		/*
-		 * The assumption here is that this is safe, even for
-		 * systems with IOAPICs that suffer from the hardware
-		 * erratum because all devices have been quiesced before
-		 * they unregister their interrupt handlers.  If that
-		 * assumption turns out to be false, this mask operation
-		 * can induce the same erratum result we're trying to
-		 * avoid.
-		 */
-		ioapic_ix = irqptr->airq_ioapicindex;
-		intin = irqptr->airq_intin_no;
-		ioapic_write(ioapic_ix, APIC_RDT_CMD + 2 * intin, AV_MASK);
-	}
-
-	/*
-	 * This irq entry is the only one in the chain.
-	 */
-	if (irqheadptr->airq_next == NULL) {
-		ASSERT(irqheadptr == irqptr);
-		bind_cpu = irqptr->airq_temp_cpu;
-		if (((uint32_t)bind_cpu != IRQ_UNBOUND) &&
-		    ((uint32_t)bind_cpu != IRQ_UNINIT)) {
-			ASSERT(apic_cpu_in_range(bind_cpu));
-			if (bind_cpu & IRQ_USER_BOUND) {
-				/* If hardbound, temp_cpu == cpu */
-				bind_cpu &= ~IRQ_USER_BOUND;
-				apic_cpus[bind_cpu].aci_bound--;
-			} else
-				apic_cpus[bind_cpu].aci_temp_bound--;
-		}
-		irqptr->airq_temp_cpu = IRQ_UNINIT;
-		irqptr->airq_mps_intr_index = FREE_INDEX;
-		lock_clear(&apic_ioapic_lock);
-		intr_restore(iflag);
-		apic_free_vector(irqptr->airq_vector);
-		return (PSM_SUCCESS);
-	}
-
-	/*
-	 * If we get here, we are sharing the vector and there are more than
-	 * one active irq entries in the chain.
-	 */
-	lock_clear(&apic_ioapic_lock);
-	intr_restore(iflag);
-
-	mutex_enter(&airq_mutex);
-	/* Remove the irq entry from the chain */
-	if (irqptr == irqheadptr) { /* The irq entry is at the head */
-		apic_irq_table[irqindex] = irqptr->airq_next;
-	} else {
-		preirqptr->airq_next = irqptr->airq_next;
-	}
-	/* Free the irq entry */
-	kmem_free(irqptr, sizeof (apic_irq_t));
-	mutex_exit(&airq_mutex);
-
-	return (PSM_SUCCESS);
-}
-
-/*
- * apic_introp_xlate() replaces apic_translate_irq() and is
- * called only from apic_intr_ops().  With the new ADII framework,
- * the priority can no longer be retrieved through i_ddi_get_intrspec().
- * It has to be passed in from the caller.
- *
- * Return value:
- *      Success: irqno for the given device
- *      Failure: -1
- */
-int
-apic_introp_xlate(dev_info_t *dip, struct intrspec *ispec, int type)
-{
-	char dev_type[16];
-	int dev_len, pci_irq, newirq, bustype, devid, busid, i;
-	int irqno = ispec->intrspec_vec;
-	ddi_acc_handle_t cfg_handle;
-	uchar_t ipin;
-	struct apic_io_intr *intrp;
-	iflag_t intr_flag;
-	ACPI_SUBTABLE_HEADER	*hp;
-	ACPI_MADT_INTERRUPT_OVERRIDE *isop;
-	apic_irq_t *airqp;
-	int parent_is_pci_or_pciex = 0;
-	int child_is_pciex = 0;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_introp_xlate: dip=0x%p name=%s "
-	    "type=%d irqno=0x%x\n", (void *)dip, ddi_get_name(dip), type,
-	    irqno));
-
-	dev_len = sizeof (dev_type);
-	if (ddi_getlongprop_buf(DDI_DEV_T_ANY, ddi_get_parent(dip),
-	    DDI_PROP_DONTPASS, "device_type", (caddr_t)dev_type,
-	    &dev_len) == DDI_PROP_SUCCESS) {
-		if ((strcmp(dev_type, "pci") == 0) ||
-		    (strcmp(dev_type, "pciex") == 0))
-			parent_is_pci_or_pciex = 1;
-	}
-
-	if (ddi_getlongprop_buf(DDI_DEV_T_ANY, dip,
-	    DDI_PROP_DONTPASS, "compatible", (caddr_t)dev_type,
-	    &dev_len) == DDI_PROP_SUCCESS) {
-		if (strstr(dev_type, "pciex"))
-			child_is_pciex = 1;
-	}
-
-	if (DDI_INTR_IS_MSI_OR_MSIX(type)) {
-		if ((airqp = apic_find_irq(dip, ispec, type)) != NULL) {
-			airqp->airq_iflag.bustype =
-			    child_is_pciex ? BUS_PCIE : BUS_PCI;
-			return (apic_vector_to_irq[airqp->airq_vector]);
-		}
-		return (apic_setup_irq_table(dip, irqno, NULL, ispec,
-		    NULL, type));
-	}
-
-	bustype = 0;
-
-	/* check if we have already translated this irq */
-	mutex_enter(&airq_mutex);
-	newirq = apic_min_device_irq;
-	for (; newirq <= apic_max_device_irq; newirq++) {
-		airqp = apic_irq_table[newirq];
-		while (airqp) {
-			if ((airqp->airq_dip == dip) &&
-			    (airqp->airq_origirq == irqno) &&
-			    (airqp->airq_mps_intr_index != FREE_INDEX)) {
-
-				mutex_exit(&airq_mutex);
-				return (VIRTIRQ(newirq, airqp->airq_share_id));
-			}
-			airqp = airqp->airq_next;
-		}
-	}
-	mutex_exit(&airq_mutex);
-
-	if (apic_defconf)
-		goto defconf;
-
-	if ((dip == NULL) || (!apic_irq_translate && !apic_enable_acpi))
-		goto nonpci;
-
-	if (parent_is_pci_or_pciex) {
-		/* pci device */
-		if (acpica_get_bdf(dip, &busid, &devid, NULL) != 0)
-			goto nonpci;
-		if (busid == 0 && apic_pci_bus_total == 1)
-			busid = (int)apic_single_pci_busid;
-
-		if (pci_config_setup(dip, &cfg_handle) != DDI_SUCCESS)
-			return (-1);
-		ipin = pci_config_get8(cfg_handle, PCI_CONF_IPIN) - PCI_INTA;
-		pci_config_teardown(&cfg_handle);
-		if (apic_enable_acpi && !apic_use_acpi_madt_only) {
-			if (apic_acpi_translate_pci_irq(dip, busid, devid,
-			    ipin, &pci_irq, &intr_flag) != ACPI_PSM_SUCCESS)
-				return (-1);
-
-			intr_flag.bustype = child_is_pciex ? BUS_PCIE : BUS_PCI;
-			return (apic_setup_irq_table(dip, pci_irq, NULL, ispec,
-			    &intr_flag, type));
-		} else {
-			pci_irq = ((devid & 0x1f) << 2) | (ipin & 0x3);
-			if ((intrp = apic_find_io_intr_w_busid(pci_irq, busid))
-			    == NULL) {
-				if ((pci_irq = apic_handle_pci_pci_bridge(dip,
-				    devid, ipin, &intrp)) == -1)
-					return (-1);
-			}
-			return (apic_setup_irq_table(dip, pci_irq, intrp, ispec,
-			    NULL, type));
-		}
-	} else if (strcmp(dev_type, "isa") == 0)
-		bustype = BUS_ISA;
-	else if (strcmp(dev_type, "eisa") == 0)
-		bustype = BUS_EISA;
-
-nonpci:
-	if (apic_enable_acpi && !apic_use_acpi_madt_only) {
-		/* search iso entries first */
-		if (acpi_iso_cnt != 0) {
-			hp = (ACPI_SUBTABLE_HEADER *)acpi_isop;
-			i = 0;
-			while (i < acpi_iso_cnt) {
-				if (hp->Type ==
-				    ACPI_MADT_TYPE_INTERRUPT_OVERRIDE) {
-					isop =
-					    (ACPI_MADT_INTERRUPT_OVERRIDE *) hp;
-					if (isop->Bus == 0 &&
-					    isop->SourceIrq == irqno) {
-						newirq = isop->GlobalIrq;
-						intr_flag.intr_po =
-						    isop->IntiFlags &
-						    ACPI_MADT_POLARITY_MASK;
-						intr_flag.intr_el =
-						    (isop->IntiFlags &
-						    ACPI_MADT_TRIGGER_MASK)
-						    >> 2;
-						intr_flag.bustype = BUS_ISA;
-
-						return (apic_setup_irq_table(
-						    dip, newirq, NULL, ispec,
-						    &intr_flag, type));
-
-					}
-					i++;
-				}
-				hp = (ACPI_SUBTABLE_HEADER *)(((char *)hp) +
-				    hp->Length);
-			}
-		}
-		intr_flag.intr_po = INTR_PO_ACTIVE_HIGH;
-		intr_flag.intr_el = INTR_EL_EDGE;
-		intr_flag.bustype = BUS_ISA;
-		return (apic_setup_irq_table(dip, irqno, NULL, ispec,
-		    &intr_flag, type));
-	} else {
-		if (bustype == 0)	/* not initialized */
-			bustype = eisa_level_intr_mask ? BUS_EISA : BUS_ISA;
-		for (i = 0; i < 2; i++) {
-			if (((busid = apic_find_bus_id(bustype)) != -1) &&
-			    ((intrp = apic_find_io_intr_w_busid(irqno, busid))
-			    != NULL)) {
-				if ((newirq = apic_setup_irq_table(dip, irqno,
-				    intrp, ispec, NULL, type)) != -1) {
-					return (newirq);
-				}
-				goto defconf;
-			}
-			bustype = (bustype == BUS_EISA) ? BUS_ISA : BUS_EISA;
-		}
-	}
-
-/* MPS default configuration */
-defconf:
-	newirq = apic_setup_irq_table(dip, irqno, NULL, ispec, NULL, type);
-	if (newirq == -1)
-		return (-1);
-	ASSERT(IRQINDEX(newirq) == irqno);
-	ASSERT(apic_irq_table[irqno]);
-	return (newirq);
-}
-
-/*
- * Attempt to share vector with someone else
- */
-static int
-apic_share_vector(int irqno, iflag_t *intr_flagp, short intr_index, int ipl,
-    uchar_t ioapicindex, uchar_t ipin, apic_irq_t **irqptrp)
-{
-#ifdef DEBUG
-	apic_irq_t *tmpirqp = NULL;
-#endif /* DEBUG */
-	apic_irq_t *irqptr, dummyirq;
-	int	newirq, chosen_irq = -1, share = 127;
-	int	lowest, highest, i;
-	uchar_t	share_id;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_share_vector: irqno=0x%x "
-	    "intr_index=0x%x ipl=0x%x\n", irqno, intr_index, ipl));
-
-	highest = apic_ipltopri[ipl] + APIC_VECTOR_MASK;
-	lowest = apic_ipltopri[ipl-1] + APIC_VECTOR_PER_IPL;
-
-	if (highest < lowest) /* Both ipl and ipl-1 map to same pri */
-		lowest -= APIC_VECTOR_PER_IPL;
-	dummyirq.airq_mps_intr_index = intr_index;
-	dummyirq.airq_ioapicindex = ioapicindex;
-	dummyirq.airq_intin_no = ipin;
-	if (intr_flagp)
-		dummyirq.airq_iflag = *intr_flagp;
-	apic_record_rdt_entry(&dummyirq, irqno);
-	for (i = lowest; i <= highest; i++) {
-		newirq = apic_vector_to_irq[i];
-		if (newirq == APIC_RESV_IRQ)
-			continue;
-		irqptr = apic_irq_table[newirq];
-
-		if ((dummyirq.airq_rdt_entry & 0xFF00) !=
-		    (irqptr->airq_rdt_entry & 0xFF00))
-			/* not compatible */
-			continue;
-
-		if (irqptr->airq_share < share) {
-			share = irqptr->airq_share;
-			chosen_irq = newirq;
-		}
-	}
-	if (chosen_irq != -1) {
-		/*
-		 * Assign a share id which is free or which is larger
-		 * than the largest one.
-		 */
-		share_id = 1;
-		mutex_enter(&airq_mutex);
-		irqptr = apic_irq_table[chosen_irq];
-		while (irqptr) {
-			if (irqptr->airq_mps_intr_index == FREE_INDEX) {
-				share_id = irqptr->airq_share_id;
-				break;
-			}
-			if (share_id <= irqptr->airq_share_id)
-				share_id = irqptr->airq_share_id + 1;
-#ifdef DEBUG
-			tmpirqp = irqptr;
-#endif /* DEBUG */
-			irqptr = irqptr->airq_next;
-		}
-		if (!irqptr) {
-			irqptr = kmem_zalloc(sizeof (apic_irq_t), KM_SLEEP);
-			irqptr->airq_temp_cpu = IRQ_UNINIT;
-			irqptr->airq_next =
-			    apic_irq_table[chosen_irq]->airq_next;
-			apic_irq_table[chosen_irq]->airq_next = irqptr;
-#ifdef	DEBUG
-			tmpirqp = apic_irq_table[chosen_irq];
-#endif /* DEBUG */
-		}
-		irqptr->airq_mps_intr_index = intr_index;
-		irqptr->airq_ioapicindex = ioapicindex;
-		irqptr->airq_intin_no = ipin;
-		if (intr_flagp)
-			irqptr->airq_iflag = *intr_flagp;
-		irqptr->airq_vector = apic_irq_table[chosen_irq]->airq_vector;
-		irqptr->airq_share_id = share_id;
-		apic_record_rdt_entry(irqptr, irqno);
-		*irqptrp = irqptr;
-#ifdef	DEBUG
-		/* shuffle the pointers to test apic_delspl path */
-		if (tmpirqp) {
-			tmpirqp->airq_next = irqptr->airq_next;
-			irqptr->airq_next = apic_irq_table[chosen_irq];
-			apic_irq_table[chosen_irq] = irqptr;
-		}
-#endif /* DEBUG */
-		mutex_exit(&airq_mutex);
-		return (VIRTIRQ(chosen_irq, share_id));
-	}
-	return (-1);
-}
-
-/*
- * Allocate/Initialize the apic_irq_table[] entry for given irqno. If the entry
- * is used already, we will try to allocate a new irqno.
- *
- * Return value:
- *	Success: irqno
- *	Failure: -1
- */
-static int
-apic_setup_irq_table(dev_info_t *dip, int irqno, struct apic_io_intr *intrp,
-    struct intrspec *ispec, iflag_t *intr_flagp, int type)
-{
-	int origirq = ispec->intrspec_vec;
-	uchar_t ipl = ispec->intrspec_pri;
-	int	newirq, intr_index;
-	uchar_t	ipin, ioapic, ioapicindex, vector;
-	apic_irq_t *irqptr;
-	major_t	major;
-	dev_info_t	*sdip;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_setup_irq_table: dip=0x%p type=%d "
-	    "irqno=0x%x origirq=0x%x\n", (void *)dip, type, irqno, origirq));
-
-	ASSERT(ispec != NULL);
-
-	major =  (dip != NULL) ? ddi_driver_major(dip) : 0;
-
-	if (DDI_INTR_IS_MSI_OR_MSIX(type)) {
-		/* MSI/X doesn't need to setup ioapic stuffs */
-		ioapicindex = 0xff;
-		ioapic = 0xff;
-		ipin = (uchar_t)0xff;
-		intr_index = (type == DDI_INTR_TYPE_MSI) ? MSI_INDEX :
-		    MSIX_INDEX;
-		mutex_enter(&airq_mutex);
-		if ((irqno = apic_allocate_irq(apic_first_avail_irq)) == -1) {
-			mutex_exit(&airq_mutex);
-			/* need an irq for MSI/X to index into autovect[] */
-			cmn_err(CE_WARN, "No interrupt irq: %s instance %d",
-			    ddi_get_name(dip), ddi_get_instance(dip));
-			return (-1);
-		}
-		mutex_exit(&airq_mutex);
-
-	} else if (intrp != NULL) {
-		intr_index = (int)(intrp - apic_io_intrp);
-		ioapic = intrp->intr_destid;
-		ipin = intrp->intr_destintin;
-		/* Find ioapicindex. If destid was ALL, we will exit with 0. */
-		for (ioapicindex = apic_io_max - 1; ioapicindex; ioapicindex--)
-			if (apic_io_id[ioapicindex] == ioapic)
-				break;
-		ASSERT((ioapic == apic_io_id[ioapicindex]) ||
-		    (ioapic == INTR_ALL_APIC));
-
-		/* check whether this intin# has been used by another irqno */
-		if ((newirq = apic_find_intin(ioapicindex, ipin)) != -1) {
-			return (newirq);
-		}
-
-	} else if (intr_flagp != NULL) {
-		/* ACPI case */
-		intr_index = ACPI_INDEX;
-		ioapicindex = acpi_find_ioapic(irqno);
-		ASSERT(ioapicindex != 0xFF);
-		ioapic = apic_io_id[ioapicindex];
-		ipin = irqno - apic_io_vectbase[ioapicindex];
-		if (apic_irq_table[irqno] &&
-		    apic_irq_table[irqno]->airq_mps_intr_index == ACPI_INDEX) {
-			ASSERT(apic_irq_table[irqno]->airq_intin_no == ipin &&
-			    apic_irq_table[irqno]->airq_ioapicindex ==
-			    ioapicindex);
-			return (irqno);
-		}
-
-	} else {
-		/* default configuration */
-		ioapicindex = 0;
-		ioapic = apic_io_id[ioapicindex];
-		ipin = (uchar_t)irqno;
-		intr_index = DEFAULT_INDEX;
-	}
-
-	if (ispec == NULL) {
-		APIC_VERBOSE_IOAPIC((CE_WARN, "No intrspec for irqno = %x\n",
-		    irqno));
-	} else if ((vector = apic_allocate_vector(ipl, irqno, 0)) == 0) {
-		if ((newirq = apic_share_vector(irqno, intr_flagp, intr_index,
-		    ipl, ioapicindex, ipin, &irqptr)) != -1) {
-			irqptr->airq_ipl = ipl;
-			irqptr->airq_origirq = (uchar_t)origirq;
-			irqptr->airq_dip = dip;
-			irqptr->airq_major = major;
-			sdip = apic_irq_table[IRQINDEX(newirq)]->airq_dip;
-			/* This is OK to do really */
-			if (sdip == NULL) {
-				cmn_err(CE_WARN, "Sharing vectors: %s"
-				    " instance %d and SCI",
-				    ddi_get_name(dip), ddi_get_instance(dip));
-			} else {
-				cmn_err(CE_WARN, "Sharing vectors: %s"
-				    " instance %d and %s instance %d",
-				    ddi_get_name(sdip), ddi_get_instance(sdip),
-				    ddi_get_name(dip), ddi_get_instance(dip));
-			}
-			return (newirq);
-		}
-		/* try high priority allocation now  that share has failed */
-		if ((vector = apic_allocate_vector(ipl, irqno, 1)) == 0) {
-			cmn_err(CE_WARN, "No interrupt vector: %s instance %d",
-			    ddi_get_name(dip), ddi_get_instance(dip));
-			return (-1);
-		}
-	}
-
-	mutex_enter(&airq_mutex);
-	if (apic_irq_table[irqno] == NULL) {
-		irqptr = kmem_zalloc(sizeof (apic_irq_t), KM_SLEEP);
-		irqptr->airq_temp_cpu = IRQ_UNINIT;
-		apic_irq_table[irqno] = irqptr;
-	} else {
-		irqptr = apic_irq_table[irqno];
-		if (irqptr->airq_mps_intr_index != FREE_INDEX) {
-			/*
-			 * The slot is used by another irqno, so allocate
-			 * a free irqno for this interrupt
-			 */
-			newirq = apic_allocate_irq(apic_first_avail_irq);
-			if (newirq == -1) {
-				mutex_exit(&airq_mutex);
-				return (-1);
-			}
-			irqno = newirq;
-			irqptr = apic_irq_table[irqno];
-			if (irqptr == NULL) {
-				irqptr = kmem_zalloc(sizeof (apic_irq_t),
-				    KM_SLEEP);
-				irqptr->airq_temp_cpu = IRQ_UNINIT;
-				apic_irq_table[irqno] = irqptr;
-			}
-			vector = apic_modify_vector(vector, newirq);
-		}
-	}
-	apic_max_device_irq = max(irqno, apic_max_device_irq);
-	apic_min_device_irq = min(irqno, apic_min_device_irq);
-	mutex_exit(&airq_mutex);
-	irqptr->airq_ioapicindex = ioapicindex;
-	irqptr->airq_intin_no = ipin;
-	irqptr->airq_ipl = ipl;
-	irqptr->airq_vector = vector;
-	irqptr->airq_origirq = (uchar_t)origirq;
-	irqptr->airq_share_id = 0;
-	irqptr->airq_mps_intr_index = (short)intr_index;
-	irqptr->airq_dip = dip;
-	irqptr->airq_major = major;
-	irqptr->airq_cpu = apic_bind_intr(dip, irqno, ioapic, ipin);
-	if (intr_flagp)
-		irqptr->airq_iflag = *intr_flagp;
-
-	if (!DDI_INTR_IS_MSI_OR_MSIX(type)) {
-		/* setup I/O APIC entry for non-MSI/X interrupts */
-		apic_record_rdt_entry(irqptr, irqno);
-	}
-	return (irqno);
-}
-
-/*
- * return the cpu to which this intr should be bound.
- * Check properties or any other mechanism to see if user wants it
- * bound to a specific CPU. If so, return the cpu id with high bit set.
- * If not, use the policy to choose a cpu and return the id.
- */
-uint32_t
-apic_bind_intr(dev_info_t *dip, int irq, uchar_t ioapicid, uchar_t intin)
-{
-	int	instance, instno, prop_len, bind_cpu, count;
-	uint_t	i, rc;
-	uint32_t cpu;
-	major_t	major;
-	char	*name, *drv_name, *prop_val, *cptr;
-	char	prop_name[32];
-	ulong_t iflag;
-
-
-	if (apic_intr_policy == INTR_LOWEST_PRIORITY)
-		return (IRQ_UNBOUND);
-
-	if (apic_nproc == 1)
-		return (0);
-
-	drv_name = NULL;
-	rc = DDI_PROP_NOT_FOUND;
-	major = (major_t)-1;
-	if (dip != NULL) {
-		name = ddi_get_name(dip);
-		major = ddi_name_to_major(name);
-		drv_name = ddi_major_to_name(major);
-		instance = ddi_get_instance(dip);
-		if (apic_intr_policy == INTR_ROUND_ROBIN_WITH_AFFINITY) {
-			i = apic_min_device_irq;
-			for (; i <= apic_max_device_irq; i++) {
-
-				if ((i == irq) || (apic_irq_table[i] == NULL) ||
-				    (apic_irq_table[i]->airq_mps_intr_index
-				    == FREE_INDEX))
-					continue;
-
-				if ((apic_irq_table[i]->airq_major == major) &&
-				    (!(apic_irq_table[i]->airq_cpu &
-				    IRQ_USER_BOUND))) {
-
-					cpu = apic_irq_table[i]->airq_cpu;
-
-					cmn_err(CE_CONT,
-					    "!%s: %s (%s) instance #%d "
-					    "irq 0x%x vector 0x%x ioapic 0x%x "
-					    "intin 0x%x is bound to cpu %d\n",
-					    psm_name,
-					    name, drv_name, instance, irq,
-					    apic_irq_table[irq]->airq_vector,
-					    ioapicid, intin, cpu);
-					return (cpu);
-				}
-			}
-		}
-		/*
-		 * search for "drvname"_intpt_bind_cpus property first, the
-		 * syntax of the property should be "a[,b,c,...]" where
-		 * instance 0 binds to cpu a, instance 1 binds to cpu b,
-		 * instance 3 binds to cpu c...
-		 * ddi_getlongprop() will search /option first, then /
-		 * if "drvname"_intpt_bind_cpus doesn't exist, then find
-		 * intpt_bind_cpus property.  The syntax is the same, and
-		 * it applies to all the devices if its "drvname" specific
-		 * property doesn't exist
-		 */
-		(void) strcpy(prop_name, drv_name);
-		(void) strcat(prop_name, "_intpt_bind_cpus");
-		rc = ddi_getlongprop(DDI_DEV_T_ANY, dip, 0, prop_name,
-		    (caddr_t)&prop_val, &prop_len);
-		if (rc != DDI_PROP_SUCCESS) {
-			rc = ddi_getlongprop(DDI_DEV_T_ANY, dip, 0,
-			    "intpt_bind_cpus", (caddr_t)&prop_val, &prop_len);
-		}
-	}
-	if (rc == DDI_PROP_SUCCESS) {
-		for (i = count = 0; i < (prop_len - 1); i++)
-			if (prop_val[i] == ',')
-				count++;
-		if (prop_val[i-1] != ',')
-			count++;
-		/*
-		 * if somehow the binding instances defined in the
-		 * property are not enough for this instno., then
-		 * reuse the pattern for the next instance until
-		 * it reaches the requested instno
-		 */
-		instno = instance % count;
-		i = 0;
-		cptr = prop_val;
-		while (i < instno)
-			if (*cptr++ == ',')
-				i++;
-		bind_cpu = stoi(&cptr);
-		kmem_free(prop_val, prop_len);
-		/* if specific CPU is bogus, then default to next cpu */
-		if (!apic_cpu_in_range(bind_cpu)) {
-			cmn_err(CE_WARN, "%s: %s=%s: CPU %d not present",
-			    psm_name, prop_name, prop_val, bind_cpu);
-			rc = DDI_PROP_NOT_FOUND;
-		} else {
-			/* indicate that we are bound at user request */
-			bind_cpu |= IRQ_USER_BOUND;
-		}
-		/*
-		 * no need to check apic_cpus[].aci_status, if specific CPU is
-		 * not up, then post_cpu_start will handle it.
-		 */
-	}
-	if (rc != DDI_PROP_SUCCESS) {
-		iflag = intr_clear();
-		lock_set(&apic_ioapic_lock);
-		bind_cpu = apic_get_next_bind_cpu();
-		lock_clear(&apic_ioapic_lock);
-		intr_restore(iflag);
-	}
-
-	if (drv_name != NULL)
-		cmn_err(CE_CONT, "!%s: %s (%s) instance %d irq 0x%x "
-		    "vector 0x%x ioapic 0x%x intin 0x%x is bound to cpu %d\n",
-		    psm_name, name, drv_name, instance, irq,
-		    apic_irq_table[irq]->airq_vector, ioapicid, intin,
-		    bind_cpu & ~IRQ_USER_BOUND);
-	else
-		cmn_err(CE_CONT, "!%s: irq 0x%x "
-		    "vector 0x%x ioapic 0x%x intin 0x%x is bound to cpu %d\n",
-		    psm_name, irq, apic_irq_table[irq]->airq_vector, ioapicid,
-		    intin, bind_cpu & ~IRQ_USER_BOUND);
-
-	return ((uint32_t)bind_cpu);
-}
-
-/*
- * Mark vector as being in the process of being deleted. Interrupts
- * may still come in on some CPU. The moment an interrupt comes with
- * the new vector, we know we can free the old one. Called only from
- * addspl and delspl with interrupts disabled. Because an interrupt
- * can be shared, but no interrupt from either device may come in,
- * we also use a timeout mechanism, which we arbitrarily set to
- * apic_revector_timeout microseconds.
- */
-static void
-apic_mark_vector(uchar_t oldvector, uchar_t newvector)
-{
-	ulong_t iflag;
-
-	iflag = intr_clear();
-	lock_set(&apic_revector_lock);
-	if (!apic_oldvec_to_newvec) {
-		apic_oldvec_to_newvec =
-		    kmem_zalloc(sizeof (newvector) * APIC_MAX_VECTOR * 2,
-		    KM_NOSLEEP);
-
-		if (!apic_oldvec_to_newvec) {
-			/*
-			 * This failure is not catastrophic.
-			 * But, the oldvec will never be freed.
-			 */
-			apic_error |= APIC_ERR_MARK_VECTOR_FAIL;
-			lock_clear(&apic_revector_lock);
-			intr_restore(iflag);
-			return;
-		}
-		apic_newvec_to_oldvec = &apic_oldvec_to_newvec[APIC_MAX_VECTOR];
-	}
-
-	/* See if we already did this for drivers which do double addintrs */
-	if (apic_oldvec_to_newvec[oldvector] != newvector) {
-		apic_oldvec_to_newvec[oldvector] = newvector;
-		apic_newvec_to_oldvec[newvector] = oldvector;
-		apic_revector_pending++;
-	}
-	lock_clear(&apic_revector_lock);
-	intr_restore(iflag);
-	(void) timeout(apic_xlate_vector_free_timeout_handler,
-	    (void *)(uintptr_t)oldvector, drv_usectohz(apic_revector_timeout));
-}
-
-/*
- * xlate_vector is called from intr_enter if revector_pending is set.
- * It will xlate it if needed and mark the old vector as free.
- */
-uchar_t
-apic_xlate_vector(uchar_t vector)
-{
-	uchar_t	newvector, oldvector = 0;
-
-	lock_set(&apic_revector_lock);
-	/* Do we really need to do this ? */
-	if (!apic_revector_pending) {
-		lock_clear(&apic_revector_lock);
-		return (vector);
-	}
-	if ((newvector = apic_oldvec_to_newvec[vector]) != 0)
-		oldvector = vector;
-	else {
-		/*
-		 * The incoming vector is new . See if a stale entry is
-		 * remaining
-		 */
-		if ((oldvector = apic_newvec_to_oldvec[vector]) != 0)
-			newvector = vector;
-	}
-
-	if (oldvector) {
-		apic_revector_pending--;
-		apic_oldvec_to_newvec[oldvector] = 0;
-		apic_newvec_to_oldvec[newvector] = 0;
-		apic_free_vector(oldvector);
-		lock_clear(&apic_revector_lock);
-		/* There could have been more than one reprogramming! */
-		return (apic_xlate_vector(newvector));
-	}
-	lock_clear(&apic_revector_lock);
-	return (vector);
-}
-
-void
-apic_xlate_vector_free_timeout_handler(void *arg)
-{
-	ulong_t iflag;
-	uchar_t oldvector, newvector;
-
-	oldvector = (uchar_t)(uintptr_t)arg;
-	iflag = intr_clear();
-	lock_set(&apic_revector_lock);
-	if ((newvector = apic_oldvec_to_newvec[oldvector]) != 0) {
-		apic_free_vector(oldvector);
-		apic_oldvec_to_newvec[oldvector] = 0;
-		apic_newvec_to_oldvec[newvector] = 0;
-		apic_revector_pending--;
-	}
-
-	lock_clear(&apic_revector_lock);
-	intr_restore(iflag);
-}
-
-/*
- * Bind interrupt corresponding to irq_ptr to bind_cpu.
- * Must be called with interrupts disabled and apic_ioapic_lock held
- */
-int
-apic_rebind(apic_irq_t *irq_ptr, int bind_cpu,
-    struct ioapic_reprogram_data *drep)
-{
-	int			ioapicindex, intin_no;
-	uint32_t		airq_temp_cpu;
-	apic_cpus_info_t	*cpu_infop;
-	uint32_t		rdt_entry;
-	int			which_irq;
-	ioapic_rdt_t		irdt;
-
-	which_irq = apic_vector_to_irq[irq_ptr->airq_vector];
-
-	intin_no = irq_ptr->airq_intin_no;
-	ioapicindex = irq_ptr->airq_ioapicindex;
-	airq_temp_cpu = irq_ptr->airq_temp_cpu;
-	if (airq_temp_cpu != IRQ_UNINIT && airq_temp_cpu != IRQ_UNBOUND) {
-		if (airq_temp_cpu & IRQ_USER_BOUND)
-			/* Mask off high bit so it can be used as array index */
-			airq_temp_cpu &= ~IRQ_USER_BOUND;
-
-		ASSERT(apic_cpu_in_range(airq_temp_cpu));
-	}
-
-	/*
-	 * Can't bind to a CPU that's not accepting interrupts:
-	 */
-	cpu_infop = &apic_cpus[bind_cpu & ~IRQ_USER_BOUND];
-	if (!(cpu_infop->aci_status & APIC_CPU_INTR_ENABLE))
-		return (1);
-
-	/*
-	 * If we are about to change the interrupt vector for this interrupt,
-	 * and this interrupt is level-triggered, attached to an IOAPIC,
-	 * has been delivered to a CPU and that CPU has not handled it
-	 * yet, we cannot reprogram the IOAPIC now.
-	 */
-	if (!APIC_IS_MSI_OR_MSIX_INDEX(irq_ptr->airq_mps_intr_index)) {
-
-		rdt_entry = READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapicindex,
-		    intin_no);
-
-		if ((irq_ptr->airq_vector != RDT_VECTOR(rdt_entry)) &&
-		    apic_check_stuck_interrupt(irq_ptr, airq_temp_cpu,
-		    bind_cpu, ioapicindex, intin_no, which_irq, drep) != 0) {
-
-			return (0);
-		}
-
-		/*
-		 * NOTE: We do not unmask the RDT here, as an interrupt MAY
-		 * still come in before we have a chance to reprogram it below.
-		 * The reprogramming below will simultaneously change and
-		 * unmask the RDT entry.
-		 */
-
-		if ((uint32_t)bind_cpu == IRQ_UNBOUND) {
-			irdt.ir_lo =  AV_LDEST | AV_LOPRI |
-			    irq_ptr->airq_rdt_entry;
-
-			WRITE_IOAPIC_RDT_ENTRY_HIGH_DWORD(ioapicindex, intin_no,
-			    AV_TOALL);
-
-			if (airq_temp_cpu != IRQ_UNINIT && airq_temp_cpu !=
-			    IRQ_UNBOUND)
-				apic_cpus[airq_temp_cpu].aci_temp_bound--;
-
-			/*
-			 * Write the vector, trigger, and polarity portion of
-			 * the RDT
-			 */
-			WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapicindex, intin_no,
-			    irdt.ir_lo);
-
-			irq_ptr->airq_temp_cpu = IRQ_UNBOUND;
-			return (0);
-		}
-	}
-
-	if (bind_cpu & IRQ_USER_BOUND) {
-		cpu_infop->aci_bound++;
-	} else {
-		cpu_infop->aci_temp_bound++;
-	}
-	ASSERT(apic_cpu_in_range(bind_cpu));
-
-	if ((airq_temp_cpu != IRQ_UNBOUND) && (airq_temp_cpu != IRQ_UNINIT)) {
-		apic_cpus[airq_temp_cpu].aci_temp_bound--;
-	}
-	if (!APIC_IS_MSI_OR_MSIX_INDEX(irq_ptr->airq_mps_intr_index)) {
-
-		irdt.ir_lo = AV_PDEST | AV_FIXED | irq_ptr->airq_rdt_entry;
-		irdt.ir_hi = cpu_infop->aci_local_id;
-
-		/* Write the RDT entry -- bind to a specific CPU: */
-		WRITE_IOAPIC_RDT_ENTRY_HIGH_DWORD(ioapicindex, intin_no,
-		    irdt.ir_hi << APIC_ID_BIT_OFFSET);
-
-		/* Write the vector, trigger, and polarity portion of the RDT */
-		WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapicindex, intin_no,
-		    irdt.ir_lo);
-
-	} else {
-		int type = (irq_ptr->airq_mps_intr_index == MSI_INDEX) ?
-		    DDI_INTR_TYPE_MSI : DDI_INTR_TYPE_MSIX;
-		if (type == DDI_INTR_TYPE_MSI) {
-			if (irq_ptr->airq_ioapicindex ==
-			    irq_ptr->airq_origirq) {
-				/* first one */
-				DDI_INTR_IMPLDBG((CE_CONT, "apic_rebind: call "
-				    "apic_pci_msi_enable_vector\n"));
-				apic_pci_msi_enable_vector(irq_ptr,
-				    type, which_irq, irq_ptr->airq_vector,
-				    irq_ptr->airq_intin_no,
-				    cpu_infop->aci_local_id);
-			}
-			if ((irq_ptr->airq_ioapicindex +
-			    irq_ptr->airq_intin_no - 1) ==
-			    irq_ptr->airq_origirq) { /* last one */
-				DDI_INTR_IMPLDBG((CE_CONT, "apic_rebind: call "
-				    "apic_pci_msi_enable_mode\n"));
-				apic_pci_msi_enable_mode(irq_ptr->airq_dip,
-				    type, which_irq);
-			}
-		} else { /* MSI-X */
-			apic_pci_msi_enable_vector(irq_ptr, type,
-			    irq_ptr->airq_origirq, irq_ptr->airq_vector, 1,
-			    cpu_infop->aci_local_id);
-			apic_pci_msi_enable_mode(irq_ptr->airq_dip, type,
-			    irq_ptr->airq_origirq);
-		}
-	}
-	irq_ptr->airq_temp_cpu = (uint32_t)bind_cpu;
-	apic_redist_cpu_skip &= ~(1 << (bind_cpu & ~IRQ_USER_BOUND));
-	return (0);
-}
-
-static void
-apic_last_ditch_clear_remote_irr(int ioapic_ix, int intin_no)
-{
-	if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix, intin_no)
-	    & AV_REMOTE_IRR) != 0) {
-		/*
-		 * Trying to clear the bit through normal
-		 * channels has failed.  So as a last-ditch
-		 * effort, try to set the trigger mode to
-		 * edge, then to level.  This has been
-		 * observed to work on many systems.
-		 */
-		WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no,
-		    READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no) & ~AV_LEVEL);
-
-		WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no,
-		    READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no) | AV_LEVEL);
-
-		/*
-		 * If the bit's STILL set, this interrupt may
-		 * be hosed.
-		 */
-		if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no) & AV_REMOTE_IRR) != 0) {
-
-			prom_printf("%s: Remote IRR still "
-			    "not clear for IOAPIC %d intin %d.\n"
-			    "\tInterrupts to this pin may cease "
-			    "functioning.\n", psm_name, ioapic_ix,
-			    intin_no);
-#ifdef DEBUG
-			apic_last_ditch_reprogram_failures++;
-#endif
-		}
-	}
-}
-
-/*
- * This function is protected by apic_ioapic_lock coupled with the
- * fact that interrupts are disabled.
- */
-static void
-delete_defer_repro_ent(int which_irq)
-{
-	ASSERT(which_irq >= 0);
-	ASSERT(which_irq <= 255);
-	ASSERT(LOCK_HELD(&apic_ioapic_lock));
-
-	if (apic_reprogram_info[which_irq].done)
-		return;
-
-	apic_reprogram_info[which_irq].done = B_TRUE;
-
-#ifdef DEBUG
-	apic_defer_repro_total_retries +=
-	    apic_reprogram_info[which_irq].tries;
-
-	apic_defer_repro_successes++;
-#endif
-
-	if (--apic_reprogram_outstanding == 0) {
-
-		setlvlx = psm_intr_exit_fn();
-	}
-}
-
-
-/*
- * Interrupts must be disabled during this function to prevent
- * self-deadlock.  Interrupts are disabled because this function
- * is called from apic_check_stuck_interrupt(), which is called
- * from apic_rebind(), which requires its caller to disable interrupts.
- */
-static void
-add_defer_repro_ent(apic_irq_t *irq_ptr, int which_irq, int new_bind_cpu)
-{
-	ASSERT(which_irq >= 0);
-	ASSERT(which_irq <= 255);
-	ASSERT(!interrupts_enabled());
-
-	/*
-	 * On the off-chance that there's already a deferred
-	 * reprogramming on this irq, check, and if so, just update the
-	 * CPU and irq pointer to which the interrupt is targeted, then return.
-	 */
-	if (!apic_reprogram_info[which_irq].done) {
-		apic_reprogram_info[which_irq].bindcpu = new_bind_cpu;
-		apic_reprogram_info[which_irq].irqp = irq_ptr;
-		return;
-	}
-
-	apic_reprogram_info[which_irq].irqp = irq_ptr;
-	apic_reprogram_info[which_irq].bindcpu = new_bind_cpu;
-	apic_reprogram_info[which_irq].tries = 0;
-	/*
-	 * This must be the last thing set, since we're not
-	 * grabbing any locks, apic_try_deferred_reprogram() will
-	 * make its decision about using this entry iff done
-	 * is false.
-	 */
-	apic_reprogram_info[which_irq].done = B_FALSE;
-
-	/*
-	 * If there were previously no deferred reprogrammings, change
-	 * setlvlx to call apic_try_deferred_reprogram()
-	 */
-	if (++apic_reprogram_outstanding == 1) {
-
-		setlvlx = apic_try_deferred_reprogram;
-	}
-}
-
-static void
-apic_try_deferred_reprogram(int prev_ipl, int irq)
-{
-	int reproirq;
-	ulong_t iflag;
-	struct ioapic_reprogram_data *drep;
-
-	(*psm_intr_exit_fn())(prev_ipl, irq);
-
-	if (!lock_try(&apic_defer_reprogram_lock)) {
-		return;
-	}
-
-	/*
-	 * Acquire the apic_ioapic_lock so that any other operations that
-	 * may affect the apic_reprogram_info state are serialized.
-	 * It's still possible for the last deferred reprogramming to clear
-	 * between the time we entered this function and the time we get to
-	 * the for loop below.  In that case, *setlvlx will have been set
-	 * back to *_intr_exit and drep will be NULL. (There's no way to
-	 * stop that from happening -- we would need to grab a lock before
-	 * calling *setlvlx, which is neither realistic nor prudent).
-	 */
-	iflag = intr_clear();
-	lock_set(&apic_ioapic_lock);
-
-	/*
-	 * For each deferred RDT entry, try to reprogram it now.  Note that
-	 * there is no lock acquisition to read apic_reprogram_info because
-	 * '.done' is set only after the other fields in the structure are set.
-	 */
-
-	drep = NULL;
-	for (reproirq = 0; reproirq <= APIC_MAX_VECTOR; reproirq++) {
-		if (apic_reprogram_info[reproirq].done == B_FALSE) {
-			drep = &apic_reprogram_info[reproirq];
-			break;
-		}
-	}
-
-	/*
-	 * Either we found a deferred action to perform, or
-	 * we entered this function spuriously, after *setlvlx
-	 * was restored to point to *_intr_exit.  Any other
-	 * permutation is invalid.
-	 */
-	ASSERT(drep != NULL || *setlvlx == psm_intr_exit_fn());
-
-	/*
-	 * Though we can't really do anything about errors
-	 * at this point, keep track of them for reporting.
-	 * Note that it is very possible for apic_setup_io_intr
-	 * to re-register this very timeout if the Remote IRR bit
-	 * has not yet cleared.
-	 */
-
-#ifdef DEBUG
-	if (drep != NULL) {
-		if (apic_setup_io_intr(drep, reproirq, B_TRUE) != 0) {
-			apic_deferred_setup_failures++;
-		}
-	} else {
-		apic_deferred_spurious_enters++;
-	}
-#else
-	if (drep != NULL)
-		(void) apic_setup_io_intr(drep, reproirq, B_TRUE);
-#endif
-
-	lock_clear(&apic_ioapic_lock);
-	intr_restore(iflag);
-
-	lock_clear(&apic_defer_reprogram_lock);
-}
-
-static void
-apic_ioapic_wait_pending_clear(int ioapic_ix, int intin_no)
-{
-	int waited;
-
-	/*
-	 * Wait for the delivery pending bit to clear.
-	 */
-	if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix, intin_no) &
-	    (AV_LEVEL|AV_PENDING)) == (AV_LEVEL|AV_PENDING)) {
-
-		/*
-		 * If we're still waiting on the delivery of this interrupt,
-		 * continue to wait here until it is delivered (this should be
-		 * a very small amount of time, but include a timeout just in
-		 * case).
-		 */
-		for (waited = 0; waited < apic_max_reps_clear_pending;
-		    waited++) {
-			if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-			    intin_no) & AV_PENDING) == 0) {
-				break;
-			}
-		}
-	}
-}
-
-
-/*
- * Checks to see if the IOAPIC interrupt entry specified has its Remote IRR
- * bit set.  Calls functions that modify the function that setlvlx points to,
- * so that the reprogramming can be retried very shortly.
- *
- * This function will mask the RDT entry if the interrupt is level-triggered.
- * (The caller is responsible for unmasking the RDT entry.)
- *
- * Returns non-zero if the caller should defer IOAPIC reprogramming.
- */
-static int
-apic_check_stuck_interrupt(apic_irq_t *irq_ptr, int old_bind_cpu,
-    int new_bind_cpu, int ioapic_ix, int intin_no, int which_irq,
-    struct ioapic_reprogram_data *drep)
-{
-	int32_t			rdt_entry;
-	int			waited;
-	int			reps = 0;
-
-	/*
-	 * Wait for the delivery pending bit to clear.
-	 */
-	do {
-		++reps;
-
-		apic_ioapic_wait_pending_clear(ioapic_ix, intin_no);
-
-		/*
-		 * Mask the RDT entry, but only if it's a level-triggered
-		 * interrupt
-		 */
-		rdt_entry = READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-		    intin_no);
-		if ((rdt_entry & (AV_LEVEL|AV_MASK)) == AV_LEVEL) {
-
-			/* Mask it */
-			WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix, intin_no,
-			    AV_MASK | rdt_entry);
-		}
-
-		if ((rdt_entry & AV_LEVEL) == AV_LEVEL) {
-			/*
-			 * If there was a race and an interrupt was injected
-			 * just before we masked, check for that case here.
-			 * Then, unmask the RDT entry and try again.  If we're
-			 * on our last try, don't unmask (because we want the
-			 * RDT entry to remain masked for the rest of the
-			 * function).
-			 */
-			rdt_entry = READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-			    intin_no);
-			if ((rdt_entry & AV_PENDING) &&
-			    (reps < apic_max_reps_clear_pending)) {
-				/* Unmask it */
-				WRITE_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-				    intin_no, rdt_entry & ~AV_MASK);
-			}
-		}
-
-	} while ((rdt_entry & AV_PENDING) &&
-	    (reps < apic_max_reps_clear_pending));
-
-#ifdef DEBUG
-		if (rdt_entry & AV_PENDING)
-			apic_intr_deliver_timeouts++;
-#endif
-
-	/*
-	 * If the remote IRR bit is set, then the interrupt has been sent
-	 * to a CPU for processing.  We have no choice but to wait for
-	 * that CPU to process the interrupt, at which point the remote IRR
-	 * bit will be cleared.
-	 */
-	if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix, intin_no) &
-	    (AV_LEVEL|AV_REMOTE_IRR)) == (AV_LEVEL|AV_REMOTE_IRR)) {
-
-		/*
-		 * If the CPU that this RDT is bound to is NOT the current
-		 * CPU, wait until that CPU handles the interrupt and ACKs
-		 * it.  If this interrupt is not bound to any CPU (that is,
-		 * if it's bound to the logical destination of "anyone"), it
-		 * may have been delivered to the current CPU so handle that
-		 * case by deferring the reprogramming (below).
-		 */
-		if ((old_bind_cpu != IRQ_UNBOUND) &&
-		    (old_bind_cpu != IRQ_UNINIT) &&
-		    (old_bind_cpu != psm_get_cpu_id())) {
-			for (waited = 0; waited < apic_max_reps_clear_pending;
-			    waited++) {
-				if ((READ_IOAPIC_RDT_ENTRY_LOW_DWORD(ioapic_ix,
-				    intin_no) & AV_REMOTE_IRR) == 0) {
-
-					delete_defer_repro_ent(which_irq);
-
-					/* Remote IRR has cleared! */
-					return (0);
-				}
-			}
-		}
-
-		/*
-		 * If we waited and the Remote IRR bit is still not cleared,
-		 * AND if we've invoked the timeout APIC_REPROGRAM_MAX_TIMEOUTS
-		 * times for this interrupt, try the last-ditch workaround:
-		 */
-		if (drep && drep->tries >= APIC_REPROGRAM_MAX_TRIES) {
-
-			apic_last_ditch_clear_remote_irr(ioapic_ix, intin_no);
-
-			/* Mark this one as reprogrammed: */
-			delete_defer_repro_ent(which_irq);
-
-			return (0);
-		} else {
-#ifdef DEBUG
-			apic_intr_deferrals++;
-#endif
-
-			/*
-			 * If waiting for the Remote IRR bit (above) didn't
-			 * allow it to clear, defer the reprogramming.
-			 * Add a new deferred-programming entry if the
-			 * caller passed a NULL one (and update the existing one
-			 * in case anything changed).
-			 */
-			add_defer_repro_ent(irq_ptr, which_irq, new_bind_cpu);
-			if (drep)
-				drep->tries++;
-
-			/* Inform caller to defer IOAPIC programming: */
-			return (1);
-		}
-
-	}
-
-	/* Remote IRR is clear */
-	delete_defer_repro_ent(which_irq);
-
-	return (0);
-}
-
-/*
- * Called to migrate all interrupts at an irq to another cpu.
- * Must be called with interrupts disabled and apic_ioapic_lock held
- */
-int
-apic_rebind_all(apic_irq_t *irq_ptr, int bind_cpu)
-{
-	apic_irq_t	*irqptr = irq_ptr;
-	int		retval = 0;
-
-	while (irqptr) {
-		if (irqptr->airq_temp_cpu != IRQ_UNINIT)
-			retval |= apic_rebind(irqptr, bind_cpu, NULL);
-		irqptr = irqptr->airq_next;
-	}
-
-	return (retval);
-}
-
-/*
- * apic_intr_redistribute does all the messy computations for identifying
- * which interrupt to move to which CPU. Currently we do just one interrupt
- * at a time. This reduces the time we spent doing all this within clock
- * interrupt. When it is done in idle, we could do more than 1.
- * First we find the most busy and the most free CPU (time in ISR only)
- * skipping those CPUs that has been identified as being ineligible (cpu_skip)
- * Then we look for IRQs which are closest to the difference between the
- * most busy CPU and the average ISR load. We try to find one whose load
- * is less than difference.If none exists, then we chose one larger than the
- * difference, provided it does not make the most idle CPU worse than the
- * most busy one. In the end, we clear all the busy fields for CPUs. For
- * IRQs, they are cleared as they are scanned.
- */
-void
-apic_intr_redistribute(void)
-{
-	int busiest_cpu, most_free_cpu;
-	int cpu_free, cpu_busy, max_busy, min_busy;
-	int min_free, diff;
-	int average_busy, cpus_online;
-	int i, busy;
-	ulong_t iflag;
-	apic_cpus_info_t *cpu_infop;
-	apic_irq_t *min_busy_irq = NULL;
-	apic_irq_t *max_busy_irq = NULL;
-
-	busiest_cpu = most_free_cpu = -1;
-	cpu_free = cpu_busy = max_busy = average_busy = 0;
-	min_free = apic_sample_factor_redistribution;
-	cpus_online = 0;
-	/*
-	 * Below we will check for CPU_INTR_ENABLE, bound, temp_bound, temp_cpu
-	 * without ioapic_lock. That is OK as we are just doing statistical
-	 * sampling anyway and any inaccuracy now will get corrected next time
-	 * The call to rebind which actually changes things will make sure
-	 * we are consistent.
-	 */
-	for (i = 0; i < apic_nproc; i++) {
-		if (apic_cpu_in_range(i) &&
-		    !(apic_redist_cpu_skip & (1 << i)) &&
-		    (apic_cpus[i].aci_status & APIC_CPU_INTR_ENABLE)) {
-
-			cpu_infop = &apic_cpus[i];
-			/*
-			 * If no unbound interrupts or only 1 total on this
-			 * CPU, skip
-			 */
-			if (!cpu_infop->aci_temp_bound ||
-			    (cpu_infop->aci_bound + cpu_infop->aci_temp_bound)
-			    == 1) {
-				apic_redist_cpu_skip |= 1 << i;
-				continue;
-			}
-
-			busy = cpu_infop->aci_busy;
-			average_busy += busy;
-			cpus_online++;
-			if (max_busy < busy) {
-				max_busy = busy;
-				busiest_cpu = i;
-			}
-			if (min_free > busy) {
-				min_free = busy;
-				most_free_cpu = i;
-			}
-			if (busy > apic_int_busy_mark) {
-				cpu_busy |= 1 << i;
-			} else {
-				if (busy < apic_int_free_mark)
-					cpu_free |= 1 << i;
-			}
-		}
-	}
-	if ((cpu_busy && cpu_free) ||
-	    (max_busy >= (min_free + apic_diff_for_redistribution))) {
-
-		apic_num_imbalance++;
-#ifdef	DEBUG
-		if (apic_verbose & APIC_VERBOSE_IOAPIC_FLAG) {
-			prom_printf(
-			    "redistribute busy=%x free=%x max=%x min=%x",
-			    cpu_busy, cpu_free, max_busy, min_free);
-		}
-#endif /* DEBUG */
-
-
-		average_busy /= cpus_online;
-
-		diff = max_busy - average_busy;
-		min_busy = max_busy; /* start with the max possible value */
-		max_busy = 0;
-		min_busy_irq = max_busy_irq = NULL;
-		i = apic_min_device_irq;
-		for (; i <= apic_max_device_irq; i++) {
-			apic_irq_t *irq_ptr;
-			/* Change to linked list per CPU ? */
-			if ((irq_ptr = apic_irq_table[i]) == NULL)
-				continue;
-			/* Check for irq_busy & decide which one to move */
-			/* Also zero them for next round */
-			if ((irq_ptr->airq_temp_cpu == busiest_cpu) &&
-			    irq_ptr->airq_busy) {
-				if (irq_ptr->airq_busy < diff) {
-					/*
-					 * Check for least busy CPU,
-					 * best fit or what ?
-					 */
-					if (max_busy < irq_ptr->airq_busy) {
-						/*
-						 * Most busy within the
-						 * required differential
-						 */
-						max_busy = irq_ptr->airq_busy;
-						max_busy_irq = irq_ptr;
-					}
-				} else {
-					if (min_busy > irq_ptr->airq_busy) {
-						/*
-						 * least busy, but more than
-						 * the reqd diff
-						 */
-						if (min_busy <
-						    (diff + average_busy -
-						    min_free)) {
-							/*
-							 * Making sure new cpu
-							 * will not end up
-							 * worse
-							 */
-							min_busy =
-							    irq_ptr->airq_busy;
-
-							min_busy_irq = irq_ptr;
-						}
-					}
-				}
-			}
-			irq_ptr->airq_busy = 0;
-		}
-
-		if (max_busy_irq != NULL) {
-#ifdef	DEBUG
-			if (apic_verbose & APIC_VERBOSE_IOAPIC_FLAG) {
-				prom_printf("rebinding %x to %x",
-				    max_busy_irq->airq_vector, most_free_cpu);
-			}
-#endif /* DEBUG */
-			iflag = intr_clear();
-			if (lock_try(&apic_ioapic_lock)) {
-				if (apic_rebind_all(max_busy_irq,
-				    most_free_cpu) == 0) {
-					/* Make change permenant */
-					max_busy_irq->airq_cpu =
-					    (uint32_t)most_free_cpu;
-				}
-				lock_clear(&apic_ioapic_lock);
-			}
-			intr_restore(iflag);
-
-		} else if (min_busy_irq != NULL) {
-#ifdef	DEBUG
-			if (apic_verbose & APIC_VERBOSE_IOAPIC_FLAG) {
-				prom_printf("rebinding %x to %x",
-				    min_busy_irq->airq_vector, most_free_cpu);
-			}
-#endif /* DEBUG */
-
-			iflag = intr_clear();
-			if (lock_try(&apic_ioapic_lock)) {
-				if (apic_rebind_all(min_busy_irq,
-				    most_free_cpu) == 0) {
-					/* Make change permenant */
-					min_busy_irq->airq_cpu =
-					    (uint32_t)most_free_cpu;
-				}
-				lock_clear(&apic_ioapic_lock);
-			}
-			intr_restore(iflag);
-
-		} else {
-			if (cpu_busy != (1 << busiest_cpu)) {
-				apic_redist_cpu_skip |= 1 << busiest_cpu;
-				/*
-				 * We leave cpu_skip set so that next time we
-				 * can choose another cpu
-				 */
-			}
-		}
-		apic_num_rebind++;
-	} else {
-		/*
-		 * found nothing. Could be that we skipped over valid CPUs
-		 * or we have balanced everything. If we had a variable
-		 * ticks_for_redistribution, it could be increased here.
-		 * apic_int_busy, int_free etc would also need to be
-		 * changed.
-		 */
-		if (apic_redist_cpu_skip)
-			apic_redist_cpu_skip = 0;
-	}
-	for (i = 0; i < apic_nproc; i++) {
-		if (apic_cpu_in_range(i)) {
-			apic_cpus[i].aci_busy = 0;
-		}
-	}
-}
-
-void
-apic_cleanup_busy(void)
-{
-	int i;
-	apic_irq_t *irq_ptr;
-
-	for (i = 0; i < apic_nproc; i++) {
-		if (apic_cpu_in_range(i)) {
-			apic_cpus[i].aci_busy = 0;
-		}
-	}
-
-	for (i = apic_min_device_irq; i <= apic_max_device_irq; i++) {
-		if ((irq_ptr = apic_irq_table[i]) != NULL)
-			irq_ptr->airq_busy = 0;
-	}
-}
-
-int
-apic_ioapic_method_probe()
-{
-	return (PSM_SUCCESS);
-}
--- old/usr/src/uts/i86xpv/io/psm/xpv_intr.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,363 +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 (c) 2010, Oracle and/or its affiliates. All rights reserved.
- */
-
-#include <sys/mutex.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/clock.h>
-#include <sys/machlock.h>
-#include <sys/smp_impldefs.h>
-#include <sys/uadmin.h>
-#include <sys/promif.h>
-#include <sys/psm.h>
-#include <sys/psm_common.h>
-#include <sys/atomic.h>
-#include <sys/apic.h>
-#include <sys/archsystm.h>
-#include <sys/mach_intr.h>
-#include <sys/modctl.h>
-#include <sys/sysmacros.h>
-#include <sys/pci_intr_lib.h>
-
-
-/* Multiple vector support for MSI */
-int	apic_multi_msi_enable = 1;
-
-/* Multiple vector support for MSI-X */
-int	apic_msix_enable = 1;
-
-/*
- * check whether the system supports MSI
- *
- * If PCI-E capability is found, then this must be a PCI-E system.
- * Since MSI is required for PCI-E system, it returns PSM_SUCCESS
- * to indicate this system supports MSI.
- */
-int
-apic_check_msi_support()
-{
-	dev_info_t *cdip;
-	char dev_type[16];
-	int dev_len;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_check_msi_support:\n"));
-
-	/*
-	 * check whether the first level children of root_node have
-	 * PCI-E capability
-	 */
-	for (cdip = ddi_get_child(ddi_root_node()); cdip != NULL;
-	    cdip = ddi_get_next_sibling(cdip)) {
-
-		DDI_INTR_IMPLDBG((CE_CONT, "apic_check_msi_support: cdip: 0x%p,"
-		    " driver: %s, binding: %s, nodename: %s\n", (void *)cdip,
-		    ddi_driver_name(cdip), ddi_binding_name(cdip),
-		    ddi_node_name(cdip)));
-		dev_len = sizeof (dev_type);
-		if (ddi_getlongprop_buf(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS,
-		    "device_type", (caddr_t)dev_type, &dev_len)
-		    != DDI_PROP_SUCCESS)
-			continue;
-		if (strcmp(dev_type, "pciex") == 0)
-			return (PSM_SUCCESS);
-	}
-
-	/* MSI is not supported on this system */
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_check_msi_support: no 'pciex' "
-	    "device_type found\n"));
-	return (PSM_FAILURE);
-}
-
-
-/*
- * It finds the apic_irq_t associates with the dip, ispec and type.
- */
-apic_irq_t *
-apic_find_irq(dev_info_t *dip, struct intrspec *ispec, int type)
-{
-	apic_irq_t	*irqp;
-	int i;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_find_irq: dip=0x%p vec=0x%x "
-	    "ipl=0x%x type=0x%x\n", (void *)dip, ispec->intrspec_vec,
-	    ispec->intrspec_pri, type));
-
-	for (i = apic_min_device_irq; i <= apic_max_device_irq; i++) {
-		for (irqp = apic_irq_table[i]; irqp; irqp = irqp->airq_next) {
-			if ((irqp->airq_dip == dip) &&
-			    (irqp->airq_origirq == ispec->intrspec_vec) &&
-			    (irqp->airq_ipl == ispec->intrspec_pri)) {
-				if (type == DDI_INTR_TYPE_MSI) {
-					if (irqp->airq_mps_intr_index ==
-					    MSI_INDEX)
-						return (irqp);
-				} else if (type == DDI_INTR_TYPE_MSIX) {
-					if (irqp->airq_mps_intr_index ==
-					    MSIX_INDEX)
-						return (irqp);
-				} else
-					return (irqp);
-			}
-		}
-	}
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_find_irq: return NULL\n"));
-	return (NULL);
-}
-
-
-int
-apic_get_vector_intr_info(int vecirq, apic_get_intr_t *intr_params_p)
-{
-	struct autovec *av_dev;
-	uchar_t irqno;
-	int i;
-	apic_irq_t *irq_p;
-
-	/* Sanity check the vector/irq argument. */
-	ASSERT((vecirq >= 0) || (vecirq <= APIC_MAX_VECTOR));
-
-	mutex_enter(&airq_mutex);
-
-	/*
-	 * Convert the vecirq arg to an irq using vector_to_irq table
-	 * if the arg is a vector.  Pass thru if already an irq.
-	 */
-	if ((intr_params_p->avgi_req_flags & PSMGI_INTRBY_FLAGS) ==
-	    PSMGI_INTRBY_VEC)
-		irqno = apic_vector_to_irq[vecirq];
-	else
-		irqno = vecirq;
-
-	irq_p = apic_irq_table[irqno];
-
-	if ((irq_p == NULL) ||
-	    ((irq_p->airq_mps_intr_index != RESERVE_INDEX) &&
-	    ((irq_p->airq_temp_cpu == IRQ_UNBOUND) ||
-	    (irq_p->airq_temp_cpu == IRQ_UNINIT)))) {
-		mutex_exit(&airq_mutex);
-		return (PSM_FAILURE);
-	}
-
-	if (intr_params_p->avgi_req_flags & PSMGI_REQ_CPUID) {
-
-		/* Get the (temp) cpu from apic_irq table, indexed by irq. */
-		intr_params_p->avgi_cpu_id = irq_p->airq_temp_cpu;
-
-		/* Return user bound info for intrd. */
-		if (intr_params_p->avgi_cpu_id & IRQ_USER_BOUND) {
-			intr_params_p->avgi_cpu_id &= ~IRQ_USER_BOUND;
-			intr_params_p->avgi_cpu_id |= PSMGI_CPU_USER_BOUND;
-		}
-	}
-
-	if (intr_params_p->avgi_req_flags & PSMGI_REQ_VECTOR)
-		intr_params_p->avgi_vector = irq_p->airq_vector;
-
-	if (intr_params_p->avgi_req_flags &
-	    (PSMGI_REQ_NUM_DEVS | PSMGI_REQ_GET_DEVS))
-		/* Get number of devices from apic_irq table shared field. */
-		intr_params_p->avgi_num_devs = irq_p->airq_share;
-
-	if (intr_params_p->avgi_req_flags &  PSMGI_REQ_GET_DEVS) {
-
-		intr_params_p->avgi_req_flags  |= PSMGI_REQ_NUM_DEVS;
-
-		/* Some devices have NULL dip.  Don't count these. */
-		if (intr_params_p->avgi_num_devs > 0) {
-			for (i = 0, av_dev = autovect[irqno].avh_link;
-			    av_dev; av_dev = av_dev->av_link)
-				if (av_dev->av_vector && av_dev->av_dip)
-					i++;
-			intr_params_p->avgi_num_devs =
-			    MIN(intr_params_p->avgi_num_devs, i);
-		}
-
-		/* There are no viable dips to return. */
-		if (intr_params_p->avgi_num_devs == 0)
-			intr_params_p->avgi_dip_list = NULL;
-
-		else {	/* Return list of dips */
-
-			/* Allocate space in array for that number of devs. */
-			intr_params_p->avgi_dip_list = kmem_zalloc(
-			    intr_params_p->avgi_num_devs *
-			    sizeof (dev_info_t *),
-			    KM_SLEEP);
-
-			/*
-			 * Loop through the device list of the autovec table
-			 * filling in the dip array.
-			 *
-			 * Note that the autovect table may have some special
-			 * entries which contain NULL dips.  These will be
-			 * ignored.
-			 */
-			for (i = 0, av_dev = autovect[irqno].avh_link;
-			    av_dev; av_dev = av_dev->av_link)
-				if (av_dev->av_vector && av_dev->av_dip)
-					intr_params_p->avgi_dip_list[i++] =
-					    av_dev->av_dip;
-		}
-	}
-
-	mutex_exit(&airq_mutex);
-
-	return (PSM_SUCCESS);
-}
-
-
-/*
- * apic_pci_msi_enable_vector:
- *	Set the address/data fields in the MSI/X capability structure
- *	XXX: MSI-X support
- */
-/* ARGSUSED */
-void
-apic_pci_msi_enable_vector(apic_irq_t *irq_ptr, int type, int inum, int vector,
-    int count, int target_apic_id)
-{
-	uint64_t		msi_addr, msi_data;
-	ushort_t		msi_ctrl;
-	dev_info_t		*dip = irq_ptr->airq_dip;
-	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(dip);
-	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(dip);
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_pci_msi_enable_vector: dip=0x%p\n"
-	    "\tdriver = %s, inum=0x%x vector=0x%x apicid=0x%x\n", (void *)dip,
-	    ddi_driver_name(dip), inum, vector, target_apic_id));
-
-	ASSERT((handle != NULL) && (cap_ptr != 0));
-
-	/* MSI Address */
-	msi_addr = (MSI_ADDR_HDR |
-	    (target_apic_id << MSI_ADDR_DEST_SHIFT));
-	msi_addr |= ((MSI_ADDR_RH_FIXED << MSI_ADDR_RH_SHIFT) |
-	    (MSI_ADDR_DM_PHYSICAL << MSI_ADDR_DM_SHIFT));
-
-	/* MSI Data: MSI is edge triggered according to spec */
-	msi_data = ((MSI_DATA_TM_EDGE << MSI_DATA_TM_SHIFT) | vector);
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_pci_msi_enable_vector: addr=0x%lx "
-	    "data=0x%lx\n", (long)msi_addr, (long)msi_data));
-
-	if (type == DDI_INTR_TYPE_MSI) {
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
-
-		/* Set the bits to inform how many MSIs are enabled */
-		msi_ctrl |= ((highbit(count) -1) << PCI_MSI_MME_SHIFT);
-		pci_config_put16(handle, cap_ptr + PCI_MSI_CTRL, msi_ctrl);
-	}
-}
-
-
-/*
- * apic_pci_msi_disable_mode:
- */
-void
-apic_pci_msi_disable_mode(dev_info_t *rdip, int type)
-{
-	ushort_t		msi_ctrl;
-	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(rdip);
-	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(rdip);
-
-	ASSERT((handle != NULL) && (cap_ptr != 0));
-
-	if (type == DDI_INTR_TYPE_MSI) {
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
-		if (!(msi_ctrl & PCI_MSI_ENABLE_BIT))
-			return;
-
-		msi_ctrl &= ~PCI_MSI_ENABLE_BIT;	/* MSI disable */
-		pci_config_put16(handle, cap_ptr + PCI_MSI_CTRL, msi_ctrl);
-
-	} else if (type == DDI_INTR_TYPE_MSIX) {
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSIX_CTRL);
-		if (msi_ctrl & PCI_MSIX_ENABLE_BIT) {
-			msi_ctrl &= ~PCI_MSIX_ENABLE_BIT;
-			pci_config_put16(handle, cap_ptr + PCI_MSIX_CTRL,
-			    msi_ctrl);
-		}
-	}
-}
-
-
-/*
- * apic_pci_msi_enable_mode:
- */
-void
-apic_pci_msi_enable_mode(dev_info_t *rdip, int type, int inum)
-{
-	ushort_t		msi_ctrl;
-	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(rdip);
-	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(rdip);
-
-	ASSERT((handle != NULL) && (cap_ptr != 0));
-
-	if (type == DDI_INTR_TYPE_MSI) {
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
-		if ((msi_ctrl & PCI_MSI_ENABLE_BIT))
-			return;
-
-		msi_ctrl |= PCI_MSI_ENABLE_BIT;
-		pci_config_put16(handle, cap_ptr + PCI_MSI_CTRL, msi_ctrl);
-
-	} else if (type == DDI_INTR_TYPE_MSIX) {
-		uintptr_t	off;
-		uint32_t	mask;
-		ddi_intr_msix_t	*msix_p;
-
-		msix_p = i_ddi_get_msix(rdip);
-
-		ASSERT(msix_p != NULL);
-
-		/* Offset into "inum"th entry in the MSI-X table & clear mask */
-		off = (uintptr_t)msix_p->msix_tbl_addr + (inum *
-		    PCI_MSIX_VECTOR_SIZE) + PCI_MSIX_VECTOR_CTRL_OFFSET;
-
-		mask = ddi_get32(msix_p->msix_tbl_hdl, (uint32_t *)off);
-
-		ddi_put32(msix_p->msix_tbl_hdl, (uint32_t *)off, (mask & ~1));
-
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSIX_CTRL);
-
-		if (!(msi_ctrl & PCI_MSIX_ENABLE_BIT)) {
-			msi_ctrl |= PCI_MSIX_ENABLE_BIT;
-			pci_config_put16(handle, cap_ptr + PCI_MSIX_CTRL,
-			    msi_ctrl);
-		}
-	}
-}
-
-
-/*
- * We let the hypervisor deal with msi configutation
- * so just stub this out.
- */
-
-/* ARGSUSED */
-void
-apic_pci_msi_unconfigure(dev_info_t *rdip, int type, int inum)
-{
-}
--- old/usr/src/uts/i86xpv/io/psm/xpv_psm.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,1705 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#define	PSMI_1_7
-
-#include <sys/mutex.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/clock.h>
-#include <sys/machlock.h>
-#include <sys/smp_impldefs.h>
-#include <sys/uadmin.h>
-#include <sys/promif.h>
-#include <sys/psm.h>
-#include <sys/psm_common.h>
-#include <sys/atomic.h>
-#include <sys/apic.h>
-#include <sys/archsystm.h>
-#include <sys/mach_intr.h>
-#include <sys/hypervisor.h>
-#include <sys/evtchn_impl.h>
-#include <sys/modctl.h>
-#include <sys/trap.h>
-#include <sys/panic.h>
-#include <sys/sysmacros.h>
-#include <sys/pci_intr_lib.h>
-#include <vm/hat_i86.h>
-
-#include <xen/public/vcpu.h>
-#include <xen/public/physdev.h>
-
-
-/*
- * Global Data
- */
-
-int xen_psm_verbose = 0;
-
-/* As of now we don't support x2apic in xVM */
-volatile uint32_t *apicadr = NULL;	/* dummy, so common code will link */
-int apic_error = 0;
-int apic_verbose = 0;
-cpuset_t apic_cpumask;
-int apic_forceload = 0;
-uchar_t apic_vectortoipl[APIC_AVAIL_VECTOR / APIC_VECTOR_PER_IPL] = {
-	3, 4, 5, 5, 6, 6, 9, 10, 11, 12, 13, 14, 15, 15
-};
-uchar_t apic_ipltopri[MAXIPL + 1];
-uchar_t apic_ipls[APIC_AVAIL_VECTOR];
-uint_t apic_picinit_called;
-apic_cpus_info_t *apic_cpus;
-int xen_psm_intr_policy = INTR_ROUND_ROBIN_WITH_AFFINITY;
-/* use to make sure only one cpu handles the nmi */
-static lock_t xen_psm_nmi_lock;
-int xen_psm_kmdb_on_nmi = 0;		/* 0 - no, 1 - yes enter kmdb */
-int xen_psm_panic_on_nmi = 0;
-int xen_psm_num_nmis = 0;
-
-cpuset_t xen_psm_cpus_online;	/* online cpus */
-int xen_psm_ncpus = 1;		/* cpu count */
-int xen_psm_next_bind_cpu;	/* next cpu to bind an interrupt to */
-
-int xen_support_msi = 0;
-
-static int xen_clock_irq = INVALID_IRQ;
-
-/* flag definitions for xen_psm_verbose */
-#define	XEN_PSM_VERBOSE_IRQ_FLAG		0x00000001
-#define	XEN_PSM_VERBOSE_POWEROFF_FLAG		0x00000002
-#define	XEN_PSM_VERBOSE_POWEROFF_PAUSE_FLAG	0x00000004
-
-#define	XEN_PSM_VERBOSE_IRQ(fmt) \
-	if (xen_psm_verbose & XEN_PSM_VERBOSE_IRQ_FLAG) \
-		cmn_err fmt;
-
-#define	XEN_PSM_VERBOSE_POWEROFF(fmt) \
-	if (xen_psm_verbose & XEN_PSM_VERBOSE_POWEROFF_FLAG) \
-		prom_printf fmt;
-
-/*
- * Dummy apic array to point common routines at that want to do some apic
- * manipulation.  Xen doesn't allow guest apic access so we point at these
- * memory locations to fake out those who want to do apic fiddling.
- */
-uint32_t xen_psm_dummy_apic[APIC_IRR_REG + 1];
-
-static struct psm_info xen_psm_info;
-static void xen_psm_setspl(int);
-
-int
-apic_alloc_msi_vectors(dev_info_t *dip, int inum, int count, int pri,
-    int behavior);
-int
-apic_alloc_msix_vectors(dev_info_t *dip, int inum, int count, int pri,
-    int behavior);
-
-/*
- * Local support routines
- */
-
-/*
- * Select vcpu to bind xen virtual device interrupt to.
- */
-/*ARGSUSED*/
-int
-xen_psm_bind_intr(int irq)
-{
-	int bind_cpu;
-	apic_irq_t *irqptr;
-
-	bind_cpu = IRQ_UNBOUND;
-	if (xen_psm_intr_policy == INTR_LOWEST_PRIORITY)
-		return (bind_cpu);
-	if (irq <= APIC_MAX_VECTOR)
-		irqptr = apic_irq_table[irq];
-	else
-		irqptr = NULL;
-	if (irqptr && (irqptr->airq_cpu != IRQ_UNBOUND))
-		bind_cpu = irqptr->airq_cpu & ~IRQ_USER_BOUND;
-	if (bind_cpu != IRQ_UNBOUND) {
-		if (!CPU_IN_SET(xen_psm_cpus_online, bind_cpu))
-			bind_cpu = 0;
-		goto done;
-	}
-	if (xen_psm_intr_policy == INTR_ROUND_ROBIN_WITH_AFFINITY) {
-		do {
-			bind_cpu = xen_psm_next_bind_cpu++;
-			if (xen_psm_next_bind_cpu >= xen_psm_ncpus)
-				xen_psm_next_bind_cpu = 0;
-		} while (!CPU_IN_SET(xen_psm_cpus_online, bind_cpu));
-	} else {
-		bind_cpu = 0;
-	}
-done:
-	return (bind_cpu);
-}
-
-/*
- * Autoconfiguration Routines
- */
-
-static int
-xen_psm_probe(void)
-{
-	int ret = PSM_SUCCESS;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info))
-		ret = apic_probe_common(xen_psm_info.p_mach_idstring);
-	return (ret);
-}
-
-static void
-xen_psm_softinit(void)
-{
-	/* LINTED logical expression always true: op "||" */
-	ASSERT((1 << EVTCHN_SHIFT) == NBBY * sizeof (ulong_t));
-	CPUSET_ATOMIC_ADD(xen_psm_cpus_online, 0);
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		apic_init_common();
-	}
-}
-
-#define	XEN_NSEC_PER_TICK	10 /* XXX - assume we have a 100 Mhz clock */
-
-/*ARGSUSED*/
-static int
-xen_psm_clkinit(int hertz)
-{
-	extern enum tod_fault_type tod_fault(enum tod_fault_type, int);
-	extern int dosynctodr;
-
-	/*
-	 * domU cannot set the TOD hardware, fault the TOD clock now to
-	 * indicate that and turn off attempts to sync TOD hardware
-	 * with the hires timer.
-	 */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		mutex_enter(&tod_lock);
-		(void) tod_fault(TOD_RDONLY, 0);
-		dosynctodr = 0;
-		mutex_exit(&tod_lock);
-	}
-	/*
-	 * The hypervisor provides a timer based on the local APIC timer.
-	 * The interface supports requests of nanosecond resolution.
-	 * A common frequency of the apic clock is 100 Mhz which
-	 * gives a resolution of 10 nsec per tick.  What we would really like
-	 * is a way to get the ns per tick value from xen.
-	 * XXPV - This is an assumption that needs checking and may change
-	 */
-	return (XEN_NSEC_PER_TICK);
-}
-
-static void
-xen_psm_hrtimeinit(void)
-{
-	extern int gethrtime_hires;
-	gethrtime_hires = 1;
-}
-
-/* xen_psm NMI handler */
-/*ARGSUSED*/
-static void
-xen_psm_nmi_intr(caddr_t arg, struct regs *rp)
-{
-	xen_psm_num_nmis++;
-
-	if (!lock_try(&xen_psm_nmi_lock))
-		return;
-
-	if (xen_psm_kmdb_on_nmi && psm_debugger()) {
-		debug_enter("NMI received: entering kmdb\n");
-	} else if (xen_psm_panic_on_nmi) {
-		/* Keep panic from entering kmdb. */
-		nopanicdebug = 1;
-		panic("NMI received\n");
-	} else {
-		/*
-		 * prom_printf is the best shot we have of something which is
-		 * problem free from high level/NMI type of interrupts
-		 */
-		prom_printf("NMI received\n");
-	}
-
-	lock_clear(&xen_psm_nmi_lock);
-}
-
-static void
-xen_psm_picinit()
-{
-	int cpu, irqno;
-	cpuset_t cpus;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		/* set a flag so we know we have run xen_psm_picinit() */
-		apic_picinit_called = 1;
-		LOCK_INIT_CLEAR(&apic_ioapic_lock);
-
-		/* XXPV - do we need to do this? */
-		picsetup();	 /* initialise the 8259 */
-
-		/* enable apic mode if imcr present */
-		/* XXPV - do we need to do this either? */
-		if (apic_imcrp) {
-			outb(APIC_IMCR_P1, (uchar_t)APIC_IMCR_SELECT);
-			outb(APIC_IMCR_P2, (uchar_t)APIC_IMCR_APIC);
-		}
-
-		ioapic_init_intr(IOAPIC_NOMASK);
-		/*
-		 * We never called xen_psm_addspl() when the SCI
-		 * interrupt was added because that happened before the
-		 * PSM module was loaded.  Fix that up here by doing
-		 * any missed operations (e.g. bind to CPU)
-		 */
-		if ((irqno = apic_sci_vect) > 0) {
-			if ((cpu = xen_psm_bind_intr(irqno)) == IRQ_UNBOUND) {
-				CPUSET_ZERO(cpus);
-				CPUSET_OR(cpus, xen_psm_cpus_online);
-			} else {
-				CPUSET_ONLY(cpus, cpu & ~IRQ_USER_BOUND);
-			}
-			ec_set_irq_affinity(irqno, cpus);
-			apic_irq_table[irqno]->airq_temp_cpu =
-			    (uchar_t)(cpu & ~IRQ_USER_BOUND);
-			ec_enable_irq(irqno);
-		}
-	}
-
-	/* add nmi handler - least priority nmi handler */
-	LOCK_INIT_CLEAR(&xen_psm_nmi_lock);
-
-	if (!psm_add_nmintr(0, (avfunc) xen_psm_nmi_intr,
-	    "xVM_psm NMI handler", (caddr_t)NULL))
-		cmn_err(CE_WARN, "xVM_psm: Unable to add nmi handler");
-}
-
-
-/*
- * generates an interprocessor interrupt to another CPU
- */
-static void
-xen_psm_send_ipi(int cpun, int ipl)
-{
-	ulong_t flag = intr_clear();
-
-	ec_send_ipi(ipl, cpun);
-	intr_restore(flag);
-}
-
-/*ARGSUSED*/
-static int
-xen_psm_addspl(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	int cpu, ret;
-	cpuset_t cpus;
-
-	/*
-	 * We are called at splhi() so we can't call anything that might end
-	 * up trying to context switch.
-	 */
-	if (irqno >= PIRQ_BASE && irqno < NR_PIRQS &&
-	    DOMAIN_IS_INITDOMAIN(xen_info)) {
-		/*
-		 * Priority/affinity/enable for PIRQ's is set in ec_setup_pirq()
-		 */
-		ret = apic_addspl_common(irqno, ipl, min_ipl, max_ipl);
-	} else {
-		/*
-		 * Set priority/affinity/enable for non PIRQs
-		 */
-		ret = ec_set_irq_priority(irqno, ipl);
-		ASSERT(ret == 0);
-		if ((cpu = xen_psm_bind_intr(irqno)) == IRQ_UNBOUND) {
-			CPUSET_ZERO(cpus);
-			CPUSET_OR(cpus, xen_psm_cpus_online);
-		} else {
-			CPUSET_ONLY(cpus, cpu & ~IRQ_USER_BOUND);
-		}
-		ec_set_irq_affinity(irqno, cpus);
-		ec_enable_irq(irqno);
-	}
-	return (ret);
-}
-
-/*
- * Acquire ownership of this irq on this cpu
- */
-void
-xen_psm_acquire_irq(int irq)
-{
-	ulong_t flags;
-	int cpuid;
-
-	/*
-	 * If the irq is currently being serviced by another cpu
-	 * we busy-wait for the other cpu to finish.  Take any
-	 * pending interrupts before retrying.
-	 */
-	do {
-		flags = intr_clear();
-		cpuid = ec_block_irq(irq);
-		intr_restore(flags);
-	} while (cpuid != CPU->cpu_id);
-}
-
-/*ARGSUSED*/
-static int
-xen_psm_delspl(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	apic_irq_t *irqptr;
-	int err = PSM_SUCCESS;
-
-	if (irqno >= PIRQ_BASE && irqno < NR_PIRQS &&
-	    DOMAIN_IS_INITDOMAIN(xen_info)) {
-		irqptr = apic_irq_table[irqno];
-		/*
-		 * unbind if no more sharers of this irq/evtchn
-		 */
-		if (irqptr->airq_share == 1) {
-			xen_psm_acquire_irq(irqno);
-			ec_unbind_irq(irqno);
-		}
-		err = apic_delspl_common(irqno, ipl, min_ipl, max_ipl);
-		/*
-		 * If still in use reset priority
-		 */
-		if (!err && irqptr->airq_share != 0) {
-			err = ec_set_irq_priority(irqno, max_ipl);
-			return (err);
-		}
-	} else {
-		xen_psm_acquire_irq(irqno);
-		ec_unbind_irq(irqno);
-	}
-	return (err);
-}
-
-static processorid_t
-xen_psm_get_next_processorid(processorid_t id)
-{
-	if (id == -1)
-		return (0);
-
-	for (id++; id < NCPU; id++) {
-		switch (-HYPERVISOR_vcpu_op(VCPUOP_is_up, id, NULL)) {
-		case 0:		/* yeah, that one's there */
-			return (id);
-		default:
-		case X_EINVAL:	/* out of range */
-			return (-1);
-		case X_ENOENT:	/* not present in the domain */
-			/*
-			 * It's not clear that we -need- to keep looking
-			 * at this point, if, e.g., we can guarantee
-			 * the hypervisor always keeps a contiguous range
-			 * of vcpus around this is equivalent to "out of range".
-			 *
-			 * But it would be sad to miss a vcpu we're
-			 * supposed to be using ..
-			 */
-			break;
-		}
-	}
-
-	return (-1);
-}
-
-/*
- * XXPV - undo the start cpu op change; return to ignoring this value
- *	- also tweak error handling in main startup loop
- */
-/*ARGSUSED*/
-static int
-xen_psm_cpu_start(processorid_t id, caddr_t arg)
-{
-	int ret;
-
-	ASSERT(id > 0);
-	CPUSET_ATOMIC_ADD(xen_psm_cpus_online, id);
-	ec_bind_cpu_ipis(id);
-	(void) ec_bind_virq_to_irq(VIRQ_TIMER, id);
-	if ((ret = xen_vcpu_up(id)) == 0)
-		xen_psm_ncpus++;
-	else
-		ret = EINVAL;
-	return (ret);
-}
-
-/*
- * Allocate an irq for inter cpu signaling
- */
-/*ARGSUSED*/
-static int
-xen_psm_get_ipivect(int ipl, int type)
-{
-	return (ec_bind_ipi_to_irq(ipl, 0));
-}
-
-/*ARGSUSED*/
-static int
-xen_psm_get_clockirq(int ipl)
-{
-	if (xen_clock_irq != INVALID_IRQ)
-		return (xen_clock_irq);
-
-	xen_clock_irq = ec_bind_virq_to_irq(VIRQ_TIMER, 0);
-	return (xen_clock_irq);
-}
-
-/*ARGSUSED*/
-static void
-xen_psm_shutdown(int cmd, int fcn)
-{
-	XEN_PSM_VERBOSE_POWEROFF(("xen_psm_shutdown(%d,%d);\n", cmd, fcn));
-
-	switch (cmd) {
-	case A_SHUTDOWN:
-		switch (fcn) {
-		case AD_BOOT:
-		case AD_IBOOT:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_reboot);
-			break;
-		case AD_POWEROFF:
-			/* fall through if domU or if poweroff fails */
-			if (DOMAIN_IS_INITDOMAIN(xen_info))
-				if (apic_enable_acpi)
-					(void) acpi_poweroff();
-			/* FALLTHRU */
-		case AD_HALT:
-		default:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_poweroff);
-			break;
-		}
-		break;
-	case A_REBOOT:
-		(void) HYPERVISOR_shutdown(SHUTDOWN_reboot);
-		break;
-	default:
-		return;
-	}
-}
-
-
-static int
-xen_psm_translate_irq(dev_info_t *dip, int irqno)
-{
-	if (dip == NULL) {
-		XEN_PSM_VERBOSE_IRQ((CE_CONT, "!xen_psm: irqno = %d"
-		    " dip = NULL\n", irqno));
-		return (irqno);
-	}
-	return (irqno);
-}
-
-/*
- * xen_psm_intr_enter() acks the event that triggered the interrupt and
- * returns the new priority level,
- */
-/*ARGSUSED*/
-static int
-xen_psm_intr_enter(int ipl, int *vector)
-{
-	int newipl;
-	uint_t intno;
-	cpu_t *cpu = CPU;
-
-	intno = (*vector);
-
-	ASSERT(intno < NR_IRQS);
-	ASSERT(cpu->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask != 0);
-
-	if (!ec_is_edge_pirq(intno))
-		ec_clear_irq(intno);
-
-	newipl = autovect[intno].avh_hi_pri;
-	if (newipl == 0) {
-		/*
-		 * (newipl == 0) means we have no service routines for this
-		 * vector.  We will treat this as a spurious interrupt.
-		 * We have cleared the pending bit already, clear the event
-		 * mask and return a spurious interrupt.  This case can happen
-		 * when an interrupt delivery is racing with the removal of
-		 * of the service routine for that interrupt.
-		 */
-		ec_unmask_irq(intno);
-		newipl = -1;	/* flag spurious interrupt */
-	} else if (newipl <= cpu->cpu_pri) {
-		/*
-		 * (newipl <= cpu->cpu_pri) means that we must be trying to
-		 * service a vector that was shared with a higher priority
-		 * isr.  The higher priority handler has been removed and
-		 * we need to service this int.  We can't return a lower
-		 * priority than current cpu priority.  Just synthesize a
-		 * priority to return that should be acceptable.
-		 * It should never happen that we synthesize a priority that
-		 * moves us from low-priority to high-priority that would make
-		 * a us incorrectly run on the high priority stack.
-		 */
-		newipl = cpu->cpu_pri + 1;	/* synthetic priority */
-		ASSERT(newipl != LOCK_LEVEL + 1);
-	}
-	return (newipl);
-}
-
-
-/*
- * xen_psm_intr_exit() restores the old interrupt
- * priority level after processing an interrupt.
- * It is called with interrupts disabled, and does not enable interrupts.
- */
-/* ARGSUSED */
-static void
-xen_psm_intr_exit(int ipl, int vector)
-{
-	ec_try_unmask_irq(vector);
-	xen_psm_setspl(ipl);
-}
-
-intr_exit_fn_t
-psm_intr_exit_fn(void)
-{
-	return (xen_psm_intr_exit);
-}
-
-/*
- * Check if new ipl level allows delivery of previously unserviced events
- */
-static void
-xen_psm_setspl(int ipl)
-{
-	struct cpu *cpu = CPU;
-	volatile vcpu_info_t *vci = cpu->cpu_m.mcpu_vcpu_info;
-	uint16_t pending;
-
-	ASSERT(vci->evtchn_upcall_mask != 0);
-
-	/*
-	 * If new ipl level will enable any pending interrupts, setup so the
-	 * upcoming sti will cause us to get an upcall.
-	 */
-	pending = cpu->cpu_m.mcpu_intr_pending & ~((1 << (ipl + 1)) - 1);
-	if (pending) {
-		int i;
-		ulong_t pending_sels = 0;
-		volatile ulong_t *selp;
-		struct xen_evt_data *cpe = cpu->cpu_m.mcpu_evt_pend;
-
-		for (i = bsrw_insn(pending); i > ipl; i--)
-			pending_sels |= cpe->pending_sel[i];
-		ASSERT(pending_sels);
-		selp = (volatile ulong_t *)&vci->evtchn_pending_sel;
-		atomic_or_ulong(selp, pending_sels);
-		vci->evtchn_upcall_pending = 1;
-	}
-}
-
-/*
- * This function provides external interface to the nexus for all
- * functionality related to the new DDI interrupt framework.
- *
- * Input:
- * dip     - pointer to the dev_info structure of the requested device
- * hdlp    - pointer to the internal interrupt handle structure for the
- *	     requested interrupt
- * intr_op - opcode for this call
- * result  - pointer to the integer that will hold the result to be
- *	     passed back if return value is PSM_SUCCESS
- *
- * Output:
- * return value is either PSM_SUCCESS or PSM_FAILURE
- */
-int
-xen_intr_ops(dev_info_t *dip, ddi_intr_handle_impl_t *hdlp,
-    psm_intr_op_t intr_op, int *result)
-{
-	int		cap;
-	int		err;
-	int		new_priority;
-	apic_irq_t	*irqp;
-	struct intrspec *ispec;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "xen_intr_ops: dip: %p hdlp: %p "
-	    "intr_op: %x\n", (void *)dip, (void *)hdlp, intr_op));
-
-	switch (intr_op) {
-	case PSM_INTR_OP_CHECK_MSI:
-		/*
-		 * Till PCI passthru is supported, only dom0 has MSI/MSIX
-		 */
-		if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-			*result = hdlp->ih_type & ~(DDI_INTR_TYPE_MSI |
-			    DDI_INTR_TYPE_MSIX);
-			break;
-		}
-		/*
-		 * Check MSI/X is supported or not at APIC level and
-		 * masked off the MSI/X bits in hdlp->ih_type if not
-		 * supported before return.  If MSI/X is supported,
-		 * leave the ih_type unchanged and return.
-		 *
-		 * hdlp->ih_type passed in from the nexus has all the
-		 * interrupt types supported by the device.
-		 */
-		if (xen_support_msi == 0) {
-			/*
-			 * if xen_support_msi is not set, call
-			 * apic_check_msi_support() to check whether msi
-			 * is supported first
-			 */
-			if (apic_check_msi_support() == PSM_SUCCESS)
-				xen_support_msi = 1;
-			else
-				xen_support_msi = -1;
-		}
-		if (xen_support_msi == 1)
-			*result = hdlp->ih_type;
-		else
-			*result = hdlp->ih_type & ~(DDI_INTR_TYPE_MSI |
-			    DDI_INTR_TYPE_MSIX);
-		break;
-	case PSM_INTR_OP_ALLOC_VECTORS:
-		if (hdlp->ih_type == DDI_INTR_TYPE_MSI)
-			*result = apic_alloc_msi_vectors(dip, hdlp->ih_inum,
-			    hdlp->ih_scratch1, hdlp->ih_pri,
-			    (int)(uintptr_t)hdlp->ih_scratch2);
-		else
-			*result = apic_alloc_msix_vectors(dip, hdlp->ih_inum,
-			    hdlp->ih_scratch1, hdlp->ih_pri,
-			    (int)(uintptr_t)hdlp->ih_scratch2);
-		break;
-	case PSM_INTR_OP_FREE_VECTORS:
-		apic_free_vectors(dip, hdlp->ih_inum, hdlp->ih_scratch1,
-		    hdlp->ih_pri, hdlp->ih_type);
-		break;
-	case PSM_INTR_OP_NAVAIL_VECTORS:
-		/*
-		 * XXPV - maybe we should make this be:
-		 * min(APIC_VECTOR_PER_IPL, count of all avail vectors);
-		 */
-		if (DOMAIN_IS_INITDOMAIN(xen_info))
-			*result = APIC_VECTOR_PER_IPL;
-		else
-			*result = 1;
-		break;
-	case PSM_INTR_OP_XLATE_VECTOR:
-		ispec = ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp;
-		if (ispec->intrspec_vec >= PIRQ_BASE &&
-		    ispec->intrspec_vec < NR_PIRQS &&
-		    DOMAIN_IS_INITDOMAIN(xen_info)) {
-			*result = apic_introp_xlate(dip, ispec, hdlp->ih_type);
-		} else {
-			*result = ispec->intrspec_vec;
-		}
-		break;
-	case PSM_INTR_OP_GET_PENDING:
-		/* XXPV - is this enough for dom0 or do we need to ref ioapic */
-		*result = ec_pending_irq(hdlp->ih_vector);
-		break;
-	case PSM_INTR_OP_CLEAR_MASK:
-		/* XXPV - is this enough for dom0 or do we need to set ioapic */
-		if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
-			return (PSM_FAILURE);
-		ec_enable_irq(hdlp->ih_vector);
-		break;
-	case PSM_INTR_OP_SET_MASK:
-		/* XXPV - is this enough for dom0 or do we need to set ioapic */
-		if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
-			return (PSM_FAILURE);
-		ec_disable_irq(hdlp->ih_vector);
-		break;
-	case PSM_INTR_OP_GET_CAP:
-		cap = DDI_INTR_FLAG_PENDING | DDI_INTR_FLAG_EDGE;
-		if (hdlp->ih_type == DDI_INTR_TYPE_FIXED)
-			cap |= DDI_INTR_FLAG_MASKABLE;
-		*result = cap;
-		break;
-	case PSM_INTR_OP_GET_SHARED:
-		if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-			if (hdlp->ih_type != DDI_INTR_TYPE_FIXED)
-				return (PSM_FAILURE);
-			ispec = ((ihdl_plat_t *)hdlp->ih_private)->ip_ispecp;
-			if ((irqp = apic_find_irq(dip, ispec, hdlp->ih_type))
-			    == NULL)
-				return (PSM_FAILURE);
-			*result = (irqp->airq_share > 1) ? 1: 0;
-		} else {
-			return (PSM_FAILURE);
-		}
-		break;
-	case PSM_INTR_OP_SET_PRI:
-		new_priority = *(int *)result;
-		err = ec_set_irq_priority(hdlp->ih_vector, new_priority);
-		if (err != 0)
-			return (PSM_FAILURE);
-		break;
-	case PSM_INTR_OP_GET_INTR:
-		if (!DOMAIN_IS_INITDOMAIN(xen_info))
-			return (PSM_FAILURE);
-		/*
-		 * The interrupt handle given here has been allocated
-		 * specifically for this command, and ih_private carries
-		 * a pointer to a apic_get_intr_t.
-		 */
-		if (apic_get_vector_intr_info(
-		    hdlp->ih_vector, hdlp->ih_private) != PSM_SUCCESS)
-			return (PSM_FAILURE);
-		break;
-	case PSM_INTR_OP_SET_CAP:
-		/* FALLTHRU */
-	default:
-		return (PSM_FAILURE);
-	}
-	return (PSM_SUCCESS);
-}
-
-static void
-xen_psm_rebind_irq(int irq)
-{
-	cpuset_t ncpu;
-	processorid_t newcpu;
-	apic_irq_t *irqptr;
-
-	newcpu = xen_psm_bind_intr(irq);
-	if (newcpu == IRQ_UNBOUND) {
-		CPUSET_ZERO(ncpu);
-		CPUSET_OR(ncpu, xen_psm_cpus_online);
-	} else {
-		CPUSET_ONLY(ncpu, newcpu & ~IRQ_USER_BOUND);
-	}
-	ec_set_irq_affinity(irq, ncpu);
-	if (irq <= APIC_MAX_VECTOR) {
-		irqptr = apic_irq_table[irq];
-		ASSERT(irqptr != NULL);
-		irqptr->airq_temp_cpu = (uchar_t)newcpu;
-	}
-}
-
-/*
- * Disable all device interrupts for the given cpu.
- * High priority interrupts are not disabled and will still be serviced.
- */
-static int
-xen_psm_disable_intr(processorid_t cpun)
-{
-	int irq;
-
-	/*
-	 * Can't offline VCPU 0 on this hypervisor.  There's no reason
-	 * anyone would want to given that the CPUs are virtual. Also note
-	 * that the hypervisor requires suspend/resume to be on VCPU 0.
-	 */
-	if (cpun == 0)
-		return (PSM_FAILURE);
-
-	CPUSET_ATOMIC_DEL(xen_psm_cpus_online, cpun);
-	for (irq = 0; irq < NR_IRQS; irq++) {
-		if (!ec_irq_needs_rebind(irq, cpun))
-			continue;
-		xen_psm_rebind_irq(irq);
-	}
-	return (PSM_SUCCESS);
-}
-
-static void
-xen_psm_enable_intr(processorid_t cpun)
-{
-	int irq;
-
-	if (cpun == 0)
-		return;
-
-	CPUSET_ATOMIC_ADD(xen_psm_cpus_online, cpun);
-
-	/*
-	 * Rebalance device interrupts among online processors
-	 */
-	for (irq = 0; irq < NR_IRQS; irq++) {
-		if (!ec_irq_rebindable(irq))
-			continue;
-		xen_psm_rebind_irq(irq);
-	}
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		apic_cpus[cpun].aci_status |= APIC_CPU_INTR_ENABLE;
-	}
-}
-
-static int
-xen_psm_post_cpu_start()
-{
-	processorid_t cpun;
-
-	cpun = psm_get_cpu_id();
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		/*
-		 * Non-virtualized environments can call psm_post_cpu_start
-		 * from Suspend/Resume with the APIC_CPU_INTR_ENABLE bit set.
-		 * xen_psm_post_cpu_start() is only called from boot.
-		 */
-		apic_cpus[cpun].aci_status |= APIC_CPU_ONLINE;
-	}
-	return (PSM_SUCCESS);
-}
-
-/*
- * This function will reprogram the timer.
- *
- * When in oneshot mode the argument is the absolute time in future at which to
- * generate the interrupt.
- *
- * When in periodic mode, the argument is the interval at which the
- * interrupts should be generated. There is no need to support the periodic
- * mode timer change at this time.
- *
- * Note that we must be careful to convert from hrtime to Xen system time (see
- * xpv_timestamp.c).
- */
-static void
-xen_psm_timer_reprogram(hrtime_t timer_req)
-{
-	hrtime_t now, timer_new, time_delta, xen_time;
-	ulong_t flags;
-
-	flags = intr_clear();
-	/*
-	 * We should be called from high PIL context (CBE_HIGH_PIL),
-	 * so kpreempt is disabled.
-	 */
-
-	now = xpv_gethrtime();
-	xen_time = xpv_getsystime();
-	if (timer_req <= now) {
-		/*
-		 * requested to generate an interrupt in the past
-		 * generate an interrupt as soon as possible
-		 */
-		time_delta = XEN_NSEC_PER_TICK;
-	} else
-		time_delta = timer_req - now;
-
-	timer_new = xen_time + time_delta;
-	if (HYPERVISOR_set_timer_op(timer_new) != 0)
-		panic("can't set hypervisor timer?");
-	intr_restore(flags);
-}
-
-/*
- * This function will enable timer interrupts.
- */
-static void
-xen_psm_timer_enable(void)
-{
-	ec_unmask_irq(xen_clock_irq);
-}
-
-/*
- * This function will disable timer interrupts on the current cpu.
- */
-static void
-xen_psm_timer_disable(void)
-{
-	(void) ec_block_irq(xen_clock_irq);
-	/*
-	 * If the clock irq is pending on this cpu then we need to
-	 * clear the pending interrupt.
-	 */
-	ec_unpend_irq(xen_clock_irq);
-}
-
-/*
- *
- * The following functions are in the platform specific file so that they
- * can be different functions depending on whether we are running on
- * bare metal or a hypervisor.
- */
-
-/*
- * Allocate a free vector for irq at ipl.
- */
-/* ARGSUSED */
-uchar_t
-apic_allocate_vector(int ipl, int irq, int pri)
-{
-	physdev_irq_t irq_op;
-	uchar_t vector;
-	int rc;
-
-	irq_op.irq = irq;
-
-	if ((rc = HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op))
-	    != 0)
-		panic("Hypervisor alloc vector failed err: %d", -rc);
-	vector = irq_op.vector;
-	/*
-	 * No need to worry about vector colliding with our reserved vectors
-	 * e.g. T_FASTTRAP, xen can differentiate between hardware and software
-	 * generated traps and handle them properly.
-	 */
-	apic_vector_to_irq[vector] = (uchar_t)irq;
-	return (vector);
-}
-
-/* Mark vector as not being used by any irq */
-void
-apic_free_vector(uchar_t vector)
-{
-	apic_vector_to_irq[vector] = APIC_RESV_IRQ;
-}
-
-/*
- * This function returns the no. of vectors available for the pri.
- * dip is not used at this moment.  If we really don't need that,
- * it will be removed.  Since priority is not limited by hardware
- * when running on the hypervisor we simply return the maximum no.
- * of available contiguous vectors.
- */
-/*ARGSUSED*/
-int
-apic_navail_vector(dev_info_t *dip, int pri)
-{
-	int	lowest, highest, i, navail, count;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_navail_vector: dip: %p, pri: %x\n",
-	    (void *)dip, pri));
-
-	highest = APIC_MAX_VECTOR;
-	lowest = APIC_BASE_VECT;
-	navail = count = 0;
-
-	/* It has to be contiguous */
-	for (i = lowest; i < highest; i++) {
-		count = 0;
-		while ((apic_vector_to_irq[i] == APIC_RESV_IRQ) &&
-		    (i < highest)) {
-			count++;
-			i++;
-		}
-		if (count > navail)
-			navail = count;
-	}
-	return (navail);
-}
-
-static physdev_manage_pci_t *managed_devlist;
-static int mdev_cnt;
-static int mdev_size = 128;
-static uchar_t	msi_vector_to_pirq[APIC_MAX_VECTOR+1];
-
-/*
- * Add devfn on given bus to devices managed by hypervisor
- */
-static int
-xen_manage_device(uint8_t bus, uint8_t devfn)
-{
-	physdev_manage_pci_t manage_pci, *newlist;
-	int rc, i, oldsize;
-
-	/*
-	 * Check if bus/devfn already managed.  If so just return success.
-	 */
-	if (managed_devlist == NULL) {
-		managed_devlist = kmem_alloc(sizeof (physdev_manage_pci_t) *
-		    mdev_size, KM_NOSLEEP);
-		if (managed_devlist == NULL) {
-			cmn_err(CE_WARN,
-			    "Can't alloc space for managed device list");
-			return (0);
-		}
-	};
-	for (i = 0; i < mdev_cnt; i++) {
-		if (managed_devlist[i].bus == bus &&
-		    managed_devlist[i].devfn == devfn)
-			return (1); /* device already managed */
-	}
-	manage_pci.bus = bus;
-	manage_pci.devfn = devfn;
-	rc = HYPERVISOR_physdev_op(PHYSDEVOP_manage_pci_add, &manage_pci);
-	if (rc < 0) {
-		cmn_err(CE_WARN,
-		    "hypervisor add pci device call failed bus:0x%x"
-		    " devfn:0x%x", bus, devfn);
-		return (0);
-	}
-	/*
-	 * Add device to the managed device list
-	 */
-	if (i == mdev_size) {
-		/*
-		 * grow the managed device list
-		 */
-		oldsize = mdev_size * sizeof (physdev_manage_pci_t);
-		mdev_size *= 2;
-		newlist = kmem_alloc(sizeof (physdev_manage_pci_t) * mdev_size,
-		    KM_NOSLEEP);
-		if (newlist == NULL) {
-			cmn_err(CE_WARN, "Can't grow managed device list");
-			return (0);
-		}
-		bcopy(managed_devlist, newlist, oldsize);
-		kmem_free(managed_devlist, oldsize);
-		managed_devlist = newlist;
-	}
-	managed_devlist[i].bus = bus;
-	managed_devlist[i].devfn = devfn;
-	mdev_cnt++;
-	return (1);
-}
-
-/*
- * allocate an apic irq struct for an MSI interrupt
- */
-static int
-msi_allocate_irq(int irq)
-{
-	apic_irq_t *irqptr = apic_irq_table[irq];
-
-	if (irqptr == NULL) {
-		irqptr = kmem_zalloc(sizeof (apic_irq_t), KM_NOSLEEP);
-		if (irqptr == NULL) {
-			cmn_err(CE_WARN, "xpv_psm: NO memory to allocate IRQ");
-			return (-1);
-		}
-		apic_irq_table[irq] = irqptr;
-	} else {
-		if (irq == APIC_RESV_IRQ && irqptr->airq_mps_intr_index == 0)
-			irqptr->airq_mps_intr_index = FREE_INDEX;
-		if (irqptr->airq_mps_intr_index != FREE_INDEX) {
-			cmn_err(CE_WARN, "xpv_psm: MSI IRQ already in use");
-			return (-1);
-		}
-	}
-	irqptr->airq_mps_intr_index = FREE_INDEX;
-	return (irq);
-}
-
-/*
- * read MSI/MSIX vector out of config space
- */
-static uchar_t
-xpv_psm_get_msi_vector(dev_info_t *dip, int type, int entry)
-{
-	uint64_t		msi_data = 0;
-	int			cap_ptr = i_ddi_get_msi_msix_cap_ptr(dip);
-	ddi_acc_handle_t	handle = i_ddi_get_pci_config_handle(dip);
-	ushort_t		msi_ctrl;
-	uchar_t			vector;
-
-	ASSERT((handle != NULL) && (cap_ptr != 0));
-	if (type == DDI_INTR_TYPE_MSI) {
-		msi_ctrl = pci_config_get16(handle, cap_ptr + PCI_MSI_CTRL);
-		/*
-		 * Get vector
-		 */
-		if (msi_ctrl &  PCI_MSI_64BIT_MASK) {
-			msi_data = pci_config_get16(handle,
-			    cap_ptr + PCI_MSI_64BIT_DATA);
-		} else {
-			msi_data = pci_config_get16(handle,
-			    cap_ptr + PCI_MSI_32BIT_DATA);
-		}
-		vector = (msi_data & 0xff) + entry;
-	} else if (type == DDI_INTR_TYPE_MSIX) {
-		uintptr_t	off;
-		ddi_intr_msix_t	*msix_p = i_ddi_get_msix(dip);
-
-		/* Offset into the given entry in the MSI-X table */
-		off = (uintptr_t)msix_p->msix_tbl_addr +
-		    (entry  * PCI_MSIX_VECTOR_SIZE);
-
-		msi_data = ddi_get32(msix_p->msix_tbl_hdl,
-		    (uint32_t *)(off + PCI_MSIX_DATA_OFFSET));
-		vector = msi_data & 0xff;
-	}
-	return (vector);
-}
-
-
-static void
-get_busdevfn(dev_info_t *dip, int *busp, int *devfnp)
-{
-	pci_regspec_t *regspec;
-	int reglen;
-
-	/*
-	 * Get device reg spec, first word has PCI bus and
-	 * device/function info we need.
-	 */
-	if (ddi_getlongprop(DDI_DEV_T_NONE, dip, DDI_PROP_DONTPASS, "reg",
-	    (caddr_t)&regspec, &reglen) != DDI_SUCCESS) {
-		cmn_err(CE_WARN,
-		    "get_busdevfn() failed to get regspec.");
-		return;
-	}
-	/*
-	 * get PCI bus # from reg spec for device
-	 */
-	*busp = PCI_REG_BUS_G(regspec[0].pci_phys_hi);
-	/*
-	 * get combined device/function from reg spec for device.
-	 */
-	*devfnp = (regspec[0].pci_phys_hi & (PCI_REG_FUNC_M | PCI_REG_DEV_M)) >>
-	    PCI_REG_FUNC_SHIFT;
-
-	kmem_free(regspec, reglen);
-}
-
-/*
- * This function allocates "count" MSI vector(s) for the given "dip/pri/type"
- */
-int
-apic_alloc_msi_vectors(dev_info_t *dip, int inum, int count, int pri,
-    int behavior)
-{
-	int	rcount, i, rc, irqno;
-	uchar_t	vector, cpu;
-	major_t	major;
-	apic_irq_t	*irqptr;
-	physdev_map_pirq_t map_irq;
-	int busnum, devfn;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_alloc_msi_vectors: dip=0x%p "
-	    "inum=0x%x  pri=0x%x count=0x%x behavior=%d\n",
-	    (void *)dip, inum, pri, count, behavior));
-
-	if (count > 1) {
-		if (behavior == DDI_INTR_ALLOC_STRICT &&
-		    apic_multi_msi_enable == 0)
-			return (0);
-		if (apic_multi_msi_enable == 0)
-			count = 1;
-	}
-
-	if ((rcount = apic_navail_vector(dip, pri)) > count)
-		rcount = count;
-	else if (rcount == 0 || (rcount < count &&
-	    behavior == DDI_INTR_ALLOC_STRICT))
-		return (0);
-
-	/* if not ISP2, then round it down */
-	if (!ISP2(rcount))
-		rcount = 1 << (highbit(rcount) - 1);
-
-	/*
-	 * get PCI bus #  and devfn from reg spec for device
-	 */
-	get_busdevfn(dip, &busnum, &devfn);
-
-	/*
-	 * Tell xen about this pci device
-	 */
-	if (!xen_manage_device(busnum, devfn))
-		return (0);
-
-	mutex_enter(&airq_mutex);
-
-	major = (dip != NULL) ? ddi_name_to_major(ddi_get_name(dip)) : 0;
-	for (i = 0; i < rcount; i++) {
-		/*
-		 * use PHYSDEVOP_map_pirq to have xen map MSI to a pirq
-		 */
-		map_irq.domid = DOMID_SELF;
-		map_irq.type = MAP_PIRQ_TYPE_MSI;
-		map_irq.index = -rcount; /* hypervisor auto allocates vectors */
-		map_irq.pirq = -1;
-		map_irq.bus = busnum;
-		map_irq.devfn = devfn;
-		map_irq.entry_nr = i;
-		map_irq.table_base = 0;
-		rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
-		irqno = map_irq.pirq;
-		if (rc < 0) {
-			mutex_exit(&airq_mutex);
-			cmn_err(CE_WARN, "map MSI irq failed err: %d", -rc);
-			return (i);
-		}
-		if (irqno < 0) {
-			mutex_exit(&airq_mutex);
-			cmn_err(CE_NOTE,
-			    "!hypervisor not configured for MSI support");
-			xen_support_msi = -1;
-			return (0);
-		}
-
-		/*
-		 * Find out what vector the hypervisor assigned
-		 */
-		vector = xpv_psm_get_msi_vector(dip, DDI_INTR_TYPE_MSI, i);
-
-		if (msi_allocate_irq(irqno) < 0) {
-			mutex_exit(&airq_mutex);
-			return (i);
-		}
-		apic_max_device_irq = max(irqno, apic_max_device_irq);
-		apic_min_device_irq = min(irqno, apic_min_device_irq);
-		irqptr = apic_irq_table[irqno];
-		ASSERT(irqptr != NULL);
-#ifdef	DEBUG
-		if (apic_vector_to_irq[vector] != APIC_RESV_IRQ)
-			DDI_INTR_IMPLDBG((CE_CONT, "apic_alloc_msi_vectors: "
-			    "apic_vector_to_irq is not APIC_RESV_IRQ\n"));
-#endif
-		apic_vector_to_irq[vector] = (uchar_t)irqno;
-		msi_vector_to_pirq[vector] = (uchar_t)irqno;
-
-		irqptr->airq_vector = vector;
-		irqptr->airq_ioapicindex = (uchar_t)inum;	/* start */
-		irqptr->airq_intin_no = (uchar_t)rcount;
-		irqptr->airq_ipl = pri;
-		irqptr->airq_origirq = (uchar_t)(inum + i);
-		irqptr->airq_share_id = 0;
-		irqptr->airq_mps_intr_index = MSI_INDEX;
-		irqptr->airq_dip = dip;
-		irqptr->airq_major = major;
-		if (i == 0) /* they all bind to the same cpu */
-			cpu = irqptr->airq_cpu = xen_psm_bind_intr(irqno);
-		else
-			irqptr->airq_cpu = cpu;
-		DDI_INTR_IMPLDBG((CE_CONT, "apic_alloc_msi_vectors: irq=0x%x "
-		    "dip=0x%p vector=0x%x origirq=0x%x pri=0x%x\n", irqno,
-		    (void *)irqptr->airq_dip, irqptr->airq_vector,
-		    irqptr->airq_origirq, pri));
-	}
-	mutex_exit(&airq_mutex);
-	return (rcount);
-}
-
-/*
- * This function allocates "count" MSI-X vector(s) for the given "dip/pri/type"
- */
-int
-apic_alloc_msix_vectors(dev_info_t *dip, int inum, int count, int pri,
-    int behavior)
-{
-	int	rcount, i, rc;
-	major_t	major;
-	physdev_map_pirq_t map_irq;
-	int busnum, devfn;
-	ddi_intr_msix_t *msix_p = i_ddi_get_msix(dip);
-	uint64_t table_base;
-	pfn_t pfnum;
-
-	if (msix_p == NULL) {
-		msix_p = pci_msix_init(dip);
-		if (msix_p != NULL) {
-			i_ddi_set_msix(dip, msix_p);
-		} else {
-			cmn_err(CE_WARN, "apic_alloc_msix_vectors()"
-			    " msix_init failed");
-			return (0);
-		}
-	}
-	/*
-	 * Hypervisor wants PCI config space address of msix table base
-	 */
-	pfnum = hat_getpfnum(kas.a_hat, (caddr_t)msix_p->msix_tbl_addr) &
-	    ~PFN_IS_FOREIGN_MFN;
-	table_base = (uint64_t)((pfnum << PAGESHIFT) - msix_p->msix_tbl_offset |
-	    ((uintptr_t)msix_p->msix_tbl_addr & PAGEOFFSET));
-	/*
-	 * get PCI bus #  and devfn from reg spec for device
-	 */
-	get_busdevfn(dip, &busnum, &devfn);
-
-	/*
-	 * Tell xen about this pci device
-	 */
-	if (!xen_manage_device(busnum, devfn))
-		return (0);
-	mutex_enter(&airq_mutex);
-
-	if ((rcount = apic_navail_vector(dip, pri)) > count)
-		rcount = count;
-	else if (rcount == 0 || (rcount < count &&
-	    behavior == DDI_INTR_ALLOC_STRICT)) {
-		rcount = 0;
-		goto out;
-	}
-
-	major = (dip != NULL) ? ddi_name_to_major(ddi_get_name(dip)) : 0;
-	for (i = 0; i < rcount; i++) {
-		int irqno;
-		uchar_t	vector;
-		apic_irq_t	*irqptr;
-
-		/*
-		 * use PHYSDEVOP_map_pirq to have xen map MSI-X to a pirq
-		 */
-		map_irq.domid = DOMID_SELF;
-		map_irq.type = MAP_PIRQ_TYPE_MSI;
-		map_irq.index = -1; /* hypervisor auto allocates vector */
-		map_irq.pirq = -1;
-		map_irq.bus = busnum;
-		map_irq.devfn = devfn;
-		map_irq.entry_nr = i;
-		map_irq.table_base = table_base;
-		rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
-		irqno = map_irq.pirq;
-		if (rc < 0) {
-			mutex_exit(&airq_mutex);
-			cmn_err(CE_WARN, "map MSI irq failed err: %d", -rc);
-			return (i);
-		}
-		if (irqno < 0) {
-			mutex_exit(&airq_mutex);
-			cmn_err(CE_NOTE,
-			    "!hypervisor not configured for MSI support");
-			xen_support_msi = -1;
-			return (0);
-		}
-		/*
-		 * Find out what vector the hypervisor assigned
-		 */
-		vector = xpv_psm_get_msi_vector(dip, DDI_INTR_TYPE_MSIX, i);
-
-		if (msi_allocate_irq(irqno) < 0) {
-			mutex_exit(&airq_mutex);
-			return (i);
-		}
-		apic_vector_to_irq[vector] = (uchar_t)irqno;
-		msi_vector_to_pirq[vector] = (uchar_t)irqno;
-		apic_max_device_irq = max(irqno, apic_max_device_irq);
-		apic_min_device_irq = min(irqno, apic_min_device_irq);
-		irqptr = apic_irq_table[irqno];
-		ASSERT(irqptr != NULL);
-		irqptr->airq_vector = (uchar_t)vector;
-		irqptr->airq_ipl = pri;
-		irqptr->airq_origirq = (uchar_t)(inum + i);
-		irqptr->airq_share_id = 0;
-		irqptr->airq_mps_intr_index = MSIX_INDEX;
-		irqptr->airq_dip = dip;
-		irqptr->airq_major = major;
-		irqptr->airq_cpu = IRQ_UNBOUND; /* will be bound when addspl */
-	}
-out:
-	mutex_exit(&airq_mutex);
-	return (rcount);
-}
-
-
-/*
- * This finds the apic_irq_t associated with the dip, ispec and type.
- * The entry should have already been freed, but it can not have been
- * reused yet since the hypervisor can not have reassigned the pirq since
- * we have not freed that yet.
- */
-static apic_irq_t *
-msi_find_irq(dev_info_t *dip, struct intrspec *ispec)
-{
-	apic_irq_t	*irqp;
-	int i;
-
-	for (i = apic_min_device_irq; i <= apic_max_device_irq; i++) {
-		if ((irqp = apic_irq_table[i]) == NULL)
-			continue;
-		if ((irqp->airq_dip == dip) &&
-		    (irqp->airq_origirq == ispec->intrspec_vec) &&
-		    (irqp->airq_ipl == ispec->intrspec_pri)) {
-			return (irqp);
-		}
-	}
-	return (NULL);
-}
-
-void
-apic_free_vectors(dev_info_t *dip, int inum, int count, int pri, int type)
-{
-	int i, rc;
-	physdev_unmap_pirq_t unmap_pirq;
-	apic_irq_t *irqptr;
-	struct intrspec ispec;
-
-	DDI_INTR_IMPLDBG((CE_CONT, "apic_free_vectors: dip: %p inum: %x "
-	    "count: %x pri: %x type: %x\n",
-	    (void *)dip, inum, count, pri, type));
-
-	/* for MSI/X only */
-	if (!DDI_INTR_IS_MSI_OR_MSIX(type))
-		return;
-
-	for (i = 0; i < count; i++) {
-		DDI_INTR_IMPLDBG((CE_CONT, "apic_free_vectors: inum=0x%x "
-		    "pri=0x%x count=0x%x\n", inum, pri, count));
-		ispec.intrspec_vec = inum + i;
-		ispec.intrspec_pri = pri;
-		if ((irqptr = msi_find_irq(dip, &ispec)) == NULL) {
-			cmn_err(CE_WARN,
-			    "couldn't find irq %s,%s dip: 0x%p vec: %x pri: %x",
-			    ddi_get_name(dip), ddi_get_name_addr(dip),
-			    (void *)dip, inum + i, pri);
-			continue;
-		}
-		/*
-		 * use PHYSDEVOP_unmap_pirq to have xen unmap MSI from a pirq
-		 */
-		unmap_pirq.domid = DOMID_SELF;
-		unmap_pirq.pirq = msi_vector_to_pirq[irqptr->airq_vector];
-		rc = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap_pirq);
-		if (rc < 0) {
-			cmn_err(CE_WARN, "unmap pirq failed");
-			return;
-		}
-		irqptr->airq_mps_intr_index = FREE_INDEX;
-		apic_vector_to_irq[irqptr->airq_vector] = APIC_RESV_IRQ;
-	}
-}
-
-/*
- * The hypervisor doesn't permit access to local apics directly
- */
-/* ARGSUSED */
-uint32_t *
-mapin_apic(uint32_t addr, size_t len, int flags)
-{
-	/*
-	 * Return a pointer to a memory area to fake out the
-	 * probe code that wants to read apic registers.
-	 * The dummy values will end up being ignored by xen
-	 * later on when they are used anyway.
-	 */
-	xen_psm_dummy_apic[APIC_VERS_REG] = APIC_INTEGRATED_VERS;
-	return (xen_psm_dummy_apic);
-}
-
-/* ARGSUSED */
-uint32_t *
-mapin_ioapic(uint32_t addr, size_t len, int flags)
-{
-	/*
-	 * Return non-null here to fake out configure code that calls this.
-	 * The i86xpv platform will not reference through the returned value..
-	 */
-	return ((uint32_t *)0x1);
-}
-
-/* ARGSUSED */
-void
-mapout_apic(caddr_t addr, size_t len)
-{
-}
-
-/* ARGSUSED */
-void
-mapout_ioapic(caddr_t addr, size_t len)
-{
-}
-
-uint32_t
-ioapic_read(int apic_ix, uint32_t reg)
-{
-	physdev_apic_t apic;
-
-	apic.apic_physbase = (unsigned long)apic_physaddr[apic_ix];
-	apic.reg = reg;
-	if (HYPERVISOR_physdev_op(PHYSDEVOP_apic_read, &apic))
-		panic("read ioapic %d reg %d failed", apic_ix, reg);
-	return (apic.value);
-}
-
-void
-ioapic_write(int apic_ix, uint32_t reg, uint32_t value)
-{
-	physdev_apic_t apic;
-
-	apic.apic_physbase = (unsigned long)apic_physaddr[apic_ix];
-	apic.reg = reg;
-	apic.value = value;
-	if (HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic))
-		panic("write ioapic %d reg %d failed", apic_ix, reg);
-}
-
-/*
- * This function was added as part of x2APIC support in pcplusmp.
- */
-void
-ioapic_write_eoi(int apic_ix, uint32_t value)
-{
-	physdev_apic_t apic;
-
-	apic.apic_physbase = (unsigned long)apic_physaddr[apic_ix];
-	apic.reg = APIC_IO_EOI;
-	apic.value = value;
-	if (HYPERVISOR_physdev_op(PHYSDEVOP_apic_write, &apic))
-		panic("write ioapic reg : APIC_IO_EOI %d failed", apic_ix);
-}
-
-/*
- * This function was added as part of x2APIC support in pcplusmp to resolve
- * undefined symbol in xpv_psm.
- */
-void
-x2apic_update_psm()
-{
-}
-
-/*
- * This function was added as part of x2APIC support in pcplusmp to resolve
- * undefined symbol in xpv_psm.
- */
-void
-apic_ret()
-{
-}
-
-/*
- * Call rebind to do the actual programming.
- */
-int
-apic_setup_io_intr(void *p, int irq, boolean_t deferred)
-{
-	apic_irq_t *irqptr;
-	struct ioapic_reprogram_data *drep = NULL;
-	int rv, cpu;
-	cpuset_t cpus;
-
-	if (deferred) {
-		drep = (struct ioapic_reprogram_data *)p;
-		ASSERT(drep != NULL);
-		irqptr = drep->irqp;
-	} else {
-		irqptr = (apic_irq_t *)p;
-	}
-	ASSERT(irqptr != NULL);
-	/*
-	 * Set cpu based on xen idea of online cpu's not apic tables.
-	 * Note that xen ignores/sets to it's own preferred value the
-	 * target cpu field when programming ioapic anyway.
-	 */
-	if (irqptr->airq_mps_intr_index == MSI_INDEX)
-		cpu = irqptr->airq_cpu; /* MSI cpus are already set */
-	else {
-		cpu = xen_psm_bind_intr(irq);
-		irqptr->airq_cpu = cpu;
-	}
-	if (cpu == IRQ_UNBOUND) {
-		CPUSET_ZERO(cpus);
-		CPUSET_OR(cpus, xen_psm_cpus_online);
-	} else {
-		CPUSET_ONLY(cpus, cpu & ~IRQ_USER_BOUND);
-	}
-	rv = apic_rebind(irqptr, cpu, drep);
-	if (rv) {
-		/* CPU is not up or interrupt is disabled. Fall back to 0 */
-		cpu = 0;
-		irqptr->airq_cpu = cpu;
-		rv = apic_rebind(irqptr, cpu, drep);
-	}
-	/*
-	 * If rebind successful bind the irq to an event channel
-	 */
-	if (rv == 0) {
-		ec_setup_pirq(irq, irqptr->airq_ipl, &cpus);
-		CPUSET_FIND(cpus, cpu);
-		apic_irq_table[irq]->airq_temp_cpu = cpu & ~IRQ_USER_BOUND;
-	}
-	return (rv);
-}
-
-/*
- * Allocate a new vector for the given irq
- */
-/* ARGSUSED */
-uchar_t
-apic_modify_vector(uchar_t vector, int irq)
-{
-	return (apic_allocate_vector(0, irq, 0));
-}
-
-/*
- * The rest of the file is just generic psm module boilerplate
- */
-
-static struct psm_ops xen_psm_ops = {
-	xen_psm_probe,				/* psm_probe		*/
-
-	xen_psm_softinit,			/* psm_init		*/
-	xen_psm_picinit,			/* psm_picinit		*/
-	xen_psm_intr_enter,			/* psm_intr_enter	*/
-	xen_psm_intr_exit,			/* psm_intr_exit	*/
-	xen_psm_setspl,				/* psm_setspl		*/
-	xen_psm_addspl,				/* psm_addspl		*/
-	xen_psm_delspl,				/* psm_delspl		*/
-	xen_psm_disable_intr,			/* psm_disable_intr	*/
-	xen_psm_enable_intr,			/* psm_enable_intr	*/
-	(int (*)(int))NULL,			/* psm_softlvl_to_irq	*/
-	(void (*)(int))NULL,			/* psm_set_softintr	*/
-	(void (*)(processorid_t))NULL,		/* psm_set_idlecpu	*/
-	(void (*)(processorid_t))NULL,		/* psm_unset_idlecpu	*/
-
-	xen_psm_clkinit,			/* psm_clkinit		*/
-	xen_psm_get_clockirq,			/* psm_get_clockirq	*/
-	xen_psm_hrtimeinit,			/* psm_hrtimeinit	*/
-	xpv_gethrtime,				/* psm_gethrtime	*/
-
-	xen_psm_get_next_processorid,		/* psm_get_next_processorid */
-	xen_psm_cpu_start,			/* psm_cpu_start	*/
-	xen_psm_post_cpu_start,			/* psm_post_cpu_start	*/
-	xen_psm_shutdown,			/* psm_shutdown		*/
-	xen_psm_get_ipivect,			/* psm_get_ipivect	*/
-	xen_psm_send_ipi,			/* psm_send_ipi		*/
-
-	xen_psm_translate_irq,			/* psm_translate_irq	*/
-
-	(void (*)(int, char *))NULL,		/* psm_notify_error	*/
-	(void (*)(int msg))NULL,		/* psm_notify_func	*/
-	xen_psm_timer_reprogram,		/* psm_timer_reprogram	*/
-	xen_psm_timer_enable,			/* psm_timer_enable	*/
-	xen_psm_timer_disable,			/* psm_timer_disable	*/
-	(void (*)(void *arg))NULL,		/* psm_post_cyclic_setup */
-	(void (*)(int, int))NULL,		/* psm_preshutdown	*/
-	xen_intr_ops,			/* Advanced DDI Interrupt framework */
-	(int (*)(psm_state_request_t *))NULL,	/* psm_state		*/
-	(int (*)(psm_cpu_request_t *))NULL	/* psm_cpu_ops		*/
-};
-
-static struct psm_info xen_psm_info = {
-	PSM_INFO_VER01_5,	/* version				*/
-	PSM_OWN_EXCLUSIVE,	/* ownership				*/
-	&xen_psm_ops,		/* operation				*/
-	"xVM_psm",		/* machine name				*/
-	"platform module"	/* machine descriptions			*/
-};
-
-static void *xen_psm_hdlp;
-
-int
-_init(void)
-{
-	return (psm_mod_init(&xen_psm_hdlp, &xen_psm_info));
-}
-
-int
-_fini(void)
-{
-	return (psm_mod_fini(&xen_psm_hdlp, &xen_psm_info));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (psm_mod_info(&xen_psm_hdlp, &xen_psm_info, modinfop));
-}
--- old/usr/src/uts/i86xpv/io/psm/xpv_uppc.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,924 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#define	PSMI_1_7
-
-#include <sys/mutex.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/clock.h>
-#include <sys/machlock.h>
-#include <sys/smp_impldefs.h>
-#include <sys/uadmin.h>
-#include <sys/promif.h>
-#include <sys/psm.h>
-#include <sys/psm_common.h>
-#include <sys/atomic.h>
-#include <sys/archsystm.h>
-#include <sys/mach_intr.h>
-#include <sys/hypervisor.h>
-#include <sys/evtchn_impl.h>
-#include <sys/modctl.h>
-#include <sys/trap.h>
-#include <sys/panic.h>
-
-#include <xen/public/vcpu.h>
-#include <xen/public/physdev.h>
-
-
-/*
- * Global Data
- */
-int xen_uppc_use_acpi = 1;	/* Use ACPI by default */
-int xen_uppc_enable_acpi = 0;
-
-static int xen_clock_irq = -1;
-
-/*
- * For interrupt link devices, if xen_uppc_unconditional_srs is set, an irq
- * resource will be assigned (via _SRS). If it is not set, use the current
- * irq setting (via _CRS), but only if that irq is in the set of possible
- * irqs (returned by _PRS) for the device.
- */
-int xen_uppc_unconditional_srs = 1;
-
-/*
- * For interrupt link devices, if xen_uppc_prefer_crs is set when we are
- * assigning an IRQ resource to a device, prefer the current IRQ setting
- * over other possible irq settings under same conditions.
- */
-int xen_uppc_prefer_crs = 1;
-
-int xen_uppc_verbose = 0;
-
-/* flag definitions for xen_uppc_verbose */
-#define	XEN_UPPC_VERBOSE_IRQ_FLAG		0x00000001
-#define	XEN_UPPC_VERBOSE_POWEROFF_FLAG		0x00000002
-#define	XEN_UPPC_VERBOSE_POWEROFF_PAUSE_FLAG	0x00000004
-
-#define	XEN_UPPC_VERBOSE_IRQ(fmt) \
-	if (xen_uppc_verbose & XEN_UPPC_VERBOSE_IRQ_FLAG) \
-		cmn_err fmt;
-
-#define	XEN_UPPC_VERBOSE_POWEROFF(fmt) \
-	if (xen_uppc_verbose & XEN_UPPC_VERBOSE_POWEROFF_FLAG) \
-		prom_printf fmt;
-
-uchar_t xen_uppc_reserved_irqlist[MAX_ISA_IRQ + 1];
-
-static uint16_t xen_uppc_irq_shared_table[MAX_ISA_IRQ + 1];
-
-/*
- * Contains SCI irqno from FADT after initialization
- */
-static int xen_uppc_sci = -1;
-
-static struct psm_info xen_uppc_info;
-
-/*
- * Local support routines
- */
-
-static int
-xen_uppc_init_acpi(void)
-{
-	int verboseflags = 0;
-	int	sci;
-	iflag_t sci_flags;
-
-	/*
-	 * Process SCI configuration here; this may return
-	 * an error if acpi-user-options has specified
-	 * legacy mode (use ACPI without ACPI mode or SCI)
-	 */
-	if (acpica_get_sci(&sci, &sci_flags) != AE_OK)
-		sci = -1;
-
-	/*
-	 * Initialize sub-system - if error is returns, ACPI is not
-	 * used.
-	 */
-	if (acpica_init() != AE_OK)
-		return (0);
-
-	/*
-	 * uppc implies system is in PIC mode; set edge/level
-	 * via ELCR based on return value from get_sci; this
-	 * will default to level/low if no override present,
-	 * as recommended by Intel ACPI CA team.
-	 */
-	if (sci >= 0) {
-		ASSERT((sci_flags.intr_el == INTR_EL_LEVEL) ||
-		    (sci_flags.intr_el == INTR_EL_EDGE));
-
-		psm_set_elcr(sci, sci_flags.intr_el == INTR_EL_LEVEL);
-	}
-
-	/*
-	 * Remember SCI for later use
-	 */
-	xen_uppc_sci = sci;
-
-	if (xen_uppc_verbose & XEN_UPPC_VERBOSE_IRQ_FLAG)
-		verboseflags |= PSM_VERBOSE_IRQ_FLAG;
-
-	if (xen_uppc_verbose & XEN_UPPC_VERBOSE_POWEROFF_FLAG)
-		verboseflags |= PSM_VERBOSE_POWEROFF_FLAG;
-
-	if (xen_uppc_verbose & XEN_UPPC_VERBOSE_POWEROFF_PAUSE_FLAG)
-		verboseflags |= PSM_VERBOSE_POWEROFF_PAUSE_FLAG;
-
-	if (acpi_psm_init(xen_uppc_info.p_mach_idstring, verboseflags) ==
-	    ACPI_PSM_FAILURE) {
-		return (0);
-	}
-
-	return (1);
-}
-
-/*
- * Autoconfiguration Routines
- */
-
-static int
-xen_uppc_probe(void)
-{
-
-	return (PSM_SUCCESS);
-}
-
-static void
-xen_uppc_softinit(void)
-{
-	int i;
-
-	/* LINTED logical expression always true: op "||" */
-	ASSERT((1 << EVTCHN_SHIFT) == NBBY * sizeof (ulong_t));
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		if (xen_uppc_use_acpi && xen_uppc_init_acpi()) {
-			build_reserved_irqlist((uchar_t *)
-			    xen_uppc_reserved_irqlist);
-			for (i = 0; i <= MAX_ISA_IRQ; i++)
-				xen_uppc_irq_shared_table[i] = 0;
-			xen_uppc_enable_acpi = 1;
-		}
-	}
-}
-
-
-#define	XEN_NSEC_PER_TICK	10 /* XXX - assume we have a 100 Mhz clock */
-
-/*ARGSUSED*/
-static int
-xen_uppc_clkinit(int hertz)
-{
-	extern enum tod_fault_type tod_fault(enum tod_fault_type, int);
-	extern int dosynctodr;
-
-	/*
-	 * domU cannot set the TOD hardware, fault the TOD clock now to
-	 * indicate that and turn off attempts to sync TOD hardware
-	 * with the hires timer.
-	 */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		mutex_enter(&tod_lock);
-		(void) tod_fault(TOD_RDONLY, 0);
-		dosynctodr = 0;
-		mutex_exit(&tod_lock);
-	}
-	/*
-	 * The hypervisor provides a timer based on the local APIC timer.
-	 * The interface supports requests of nanosecond resolution.
-	 * A common frequency of the apic clock is 100 Mhz which
-	 * gives a resolution of 10 nsec per tick.  What we would really like
-	 * is a way to get the ns per tick value from xen.
-	 * XXPV - This is an assumption that needs checking and may change
-	 */
-	return (XEN_NSEC_PER_TICK);
-}
-
-static void
-xen_uppc_picinit()
-{
-	int irqno;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-#if 0
-		/* hypervisor initializes the 8259, don't mess with it */
-		picsetup();	 /* initialise the 8259 */
-#endif
-		/*
-		 * We never called xen_uppc_addspl() when the SCI
-		 * interrupt was added because that happened before the
-		 * PSM module was loaded.  Fix that up here by doing
-		 * any missed operations (e.g. bind to CPU)
-		 */
-		if ((irqno = xen_uppc_sci) >= 0) {
-			ec_enable_irq(irqno);
-		}
-	}
-}
-
-
-/*ARGSUSED*/
-static int
-xen_uppc_addspl(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	int ret = PSM_SUCCESS;
-	cpuset_t cpus;
-
-	if (irqno >= 0 && irqno <= MAX_ISA_IRQ)
-		atomic_inc_16(&xen_uppc_irq_shared_table[irqno]);
-
-	/*
-	 * We are called at splhi() so we can't call anything that might end
-	 * up trying to context switch.
-	 */
-	if (irqno >= PIRQ_BASE && irqno < NR_PIRQS &&
-	    DOMAIN_IS_INITDOMAIN(xen_info)) {
-		CPUSET_ZERO(cpus);
-		CPUSET_ADD(cpus, 0);
-		ec_setup_pirq(irqno, ipl, &cpus);
-	} else {
-		/*
-		 * Set priority/affinity/enable for non PIRQs
-		 */
-		ret = ec_set_irq_priority(irqno, ipl);
-		ASSERT(ret == 0);
-		CPUSET_ZERO(cpus);
-		CPUSET_ADD(cpus, 0);
-		ec_set_irq_affinity(irqno, cpus);
-		ec_enable_irq(irqno);
-	}
-
-	return (ret);
-}
-
-/*ARGSUSED*/
-static int
-xen_uppc_delspl(int irqno, int ipl, int min_ipl, int max_ipl)
-{
-	int err = PSM_SUCCESS;
-
-	if (irqno >= 0 && irqno <= MAX_ISA_IRQ)
-		atomic_dec_16(&xen_uppc_irq_shared_table[irqno]);
-
-	if (irqno >= PIRQ_BASE && irqno < NR_PIRQS &&
-	    DOMAIN_IS_INITDOMAIN(xen_info)) {
-		if (max_ipl == PSM_INVALID_IPL) {
-			/*
-			 * unbind if no more sharers of this irq/evtchn
-			 */
-			(void) ec_block_irq(irqno);
-			ec_unbind_irq(irqno);
-		} else {
-			/*
-			 * If still in use reset priority
-			 */
-			err = ec_set_irq_priority(irqno, max_ipl);
-		}
-	} else {
-		(void) ec_block_irq(irqno);
-		ec_unbind_irq(irqno);
-	}
-	return (err);
-}
-
-static processorid_t
-xen_uppc_get_next_processorid(processorid_t id)
-{
-	if (id == -1)
-		return (0);
-	return (-1);
-}
-
-/*ARGSUSED*/
-static int
-xen_uppc_get_clockirq(int ipl)
-{
-	if (xen_clock_irq != -1)
-		return (xen_clock_irq);
-
-	xen_clock_irq = ec_bind_virq_to_irq(VIRQ_TIMER, 0);
-	return (xen_clock_irq);
-}
-
-/*ARGSUSED*/
-static void
-xen_uppc_shutdown(int cmd, int fcn)
-{
-	XEN_UPPC_VERBOSE_POWEROFF(("xen_uppc_shutdown(%d,%d);\n", cmd, fcn));
-
-	switch (cmd) {
-	case A_SHUTDOWN:
-		switch (fcn) {
-		case AD_BOOT:
-		case AD_IBOOT:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_reboot);
-			break;
-		case AD_POWEROFF:
-			/* fall through if domU or if poweroff fails */
-			if (DOMAIN_IS_INITDOMAIN(xen_info))
-				if (xen_uppc_enable_acpi)
-					(void) acpi_poweroff();
-			/* FALLTHRU */
-		case AD_HALT:
-		default:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_poweroff);
-			break;
-		}
-		break;
-	case A_REBOOT:
-		(void) HYPERVISOR_shutdown(SHUTDOWN_reboot);
-		break;
-	default:
-		return;
-	}
-}
-
-
-/*
- * This function will reprogram the timer.
- *
- * When in oneshot mode the argument is the absolute time in future at which to
- * generate the interrupt.
- *
- * When in periodic mode, the argument is the interval at which the
- * interrupts should be generated. There is no need to support the periodic
- * mode timer change at this time.
- *
- * Note that we must be careful to convert from hrtime to Xen system time (see
- * xpv_timestamp.c).
- */
-static void
-xen_uppc_timer_reprogram(hrtime_t timer_req)
-{
-	hrtime_t now, timer_new, time_delta, xen_time;
-	ulong_t flags;
-
-	flags = intr_clear();
-	/*
-	 * We should be called from high PIL context (CBE_HIGH_PIL),
-	 * so kpreempt is disabled.
-	 */
-
-	now = xpv_gethrtime();
-	xen_time = xpv_getsystime();
-	if (timer_req <= now) {
-		/*
-		 * requested to generate an interrupt in the past
-		 * generate an interrupt as soon as possible
-		 */
-		time_delta = XEN_NSEC_PER_TICK;
-	} else
-		time_delta = timer_req - now;
-
-	timer_new = xen_time + time_delta;
-	if (HYPERVISOR_set_timer_op(timer_new) != 0)
-		panic("can't set hypervisor timer?");
-	intr_restore(flags);
-}
-
-/*
- * This function will enable timer interrupts.
- */
-static void
-xen_uppc_timer_enable(void)
-{
-	ec_unmask_irq(xen_clock_irq);
-}
-
-/*
- * This function will disable timer interrupts on the current cpu.
- */
-static void
-xen_uppc_timer_disable(void)
-{
-	(void) ec_block_irq(xen_clock_irq);
-	/*
-	 * If the clock irq is pending on this cpu then we need to
-	 * clear the pending interrupt.
-	 */
-	ec_unpend_irq(xen_clock_irq);
-}
-
-
-/*
- * Configures the irq for the interrupt link device identified by
- * acpipsmlnkp.
- *
- * Gets the current and the list of possible irq settings for the
- * device. If xen_uppc_unconditional_srs is not set, and the current
- * resource setting is in the list of possible irq settings,
- * current irq resource setting is passed to the caller.
- *
- * Otherwise, picks an irq number from the list of possible irq
- * settings, and sets the irq of the device to this value.
- * If prefer_crs is set, among a set of irq numbers in the list that have
- * the least number of devices sharing the interrupt, we pick current irq
- * resource setting if it is a member of this set.
- *
- * Passes the irq number in the value pointed to by pci_irqp, and
- * polarity and sensitivity in the structure pointed to by dipintrflagp
- * to the caller.
- *
- * Note that if setting the irq resource failed, but successfuly obtained
- * the current irq resource settings, passes the current irq resources
- * and considers it a success.
- *
- * Returns:
- * ACPI_PSM_SUCCESS on success.
- *
- * ACPI_PSM_FAILURE if an error occured during the configuration or
- * if a suitable irq was not found for this device, or if setting the
- * irq resource and obtaining the current resource fails.
- *
- */
-static int
-xen_uppc_acpi_irq_configure(acpi_psm_lnk_t *acpipsmlnkp, dev_info_t *dip,
-    int *pci_irqp, iflag_t *dipintr_flagp)
-{
-	int i, min_share, foundnow, done = 0;
-	int32_t irq;
-	int32_t share_irq = -1;
-	int32_t chosen_irq = -1;
-	int cur_irq = -1;
-	acpi_irqlist_t *irqlistp;
-	acpi_irqlist_t *irqlistent;
-
-	if ((acpi_get_possible_irq_resources(acpipsmlnkp, &irqlistp))
-	    == ACPI_PSM_FAILURE) {
-		XEN_UPPC_VERBOSE_IRQ((CE_WARN, "!xVM_uppc: Unable to determine "
-		    "or assign IRQ for device %s, instance #%d: The system was "
-		    "unable to get the list of potential IRQs from ACPI.",
-		    ddi_get_name(dip), ddi_get_instance(dip)));
-
-		return (ACPI_PSM_FAILURE);
-	}
-
-	if ((acpi_get_current_irq_resource(acpipsmlnkp, &cur_irq,
-	    dipintr_flagp) == ACPI_PSM_SUCCESS) &&
-	    (!xen_uppc_unconditional_srs) &&
-	    (cur_irq > 0)) {
-
-		if (acpi_irqlist_find_irq(irqlistp, cur_irq, NULL)
-		    == ACPI_PSM_SUCCESS) {
-
-			acpi_free_irqlist(irqlistp);
-			ASSERT(pci_irqp != NULL);
-			*pci_irqp = cur_irq;
-			return (ACPI_PSM_SUCCESS);
-		}
-		XEN_UPPC_VERBOSE_IRQ((CE_WARN, "!xVM_uppc: Could not find the "
-		    "current irq %d for device %s, instance #%d in ACPI's "
-		    "list of possible irqs for this device. Picking one from "
-		    " the latter list.", cur_irq, ddi_get_name(dip),
-		    ddi_get_instance(dip)));
-
-	}
-
-	irqlistent = irqlistp;
-	min_share = 255;
-
-	while (irqlistent != NULL) {
-
-		for (foundnow = 0, i = 0; i < irqlistent->num_irqs; i++) {
-
-			irq = irqlistp->irqs[i];
-
-			if ((irq > MAX_ISA_IRQ) ||
-			    (irqlistent->intr_flags.intr_el == INTR_EL_EDGE) ||
-			    (irq == 0))
-				continue;
-
-			if (xen_uppc_reserved_irqlist[irq])
-				continue;
-
-			if (xen_uppc_irq_shared_table[irq] == 0) {
-				chosen_irq = irq;
-				foundnow = 1;
-				if (!(xen_uppc_prefer_crs) ||
-				    (irq == cur_irq)) {
-					done = 1;
-					break;
-				}
-			}
-
-			if ((xen_uppc_irq_shared_table[irq] < min_share) ||
-			    ((xen_uppc_irq_shared_table[irq] == min_share) &&
-			    (cur_irq == irq) && (xen_uppc_prefer_crs))) {
-				min_share = xen_uppc_irq_shared_table[irq];
-				share_irq = irq;
-				foundnow = 1;
-			}
-		}
-
-		/* If we found an IRQ in the inner loop, save the details */
-		if (foundnow && ((chosen_irq != -1) || (share_irq != -1))) {
-			/*
-			 * Copy the acpi_prs_private_t and flags from this
-			 * irq list entry, since we found an irq from this
-			 * entry.
-			 */
-			acpipsmlnkp->acpi_prs_prv = irqlistent->acpi_prs_prv;
-			*dipintr_flagp = irqlistent->intr_flags;
-		}
-
-		if (done)
-			break;
-
-		/* Load the next entry in the irqlist */
-		irqlistent = irqlistent->next;
-	}
-
-	acpi_free_irqlist(irqlistp);
-
-	if (chosen_irq != -1)
-		irq = chosen_irq;
-	else if (share_irq != -1)
-		irq = share_irq;
-	else {
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: Could not find a "
-		    "suitable irq from the list of possible irqs for device "
-		    "%s, instance #%d in ACPI's list of possible\n",
-		    ddi_get_name(dip), ddi_get_instance(dip)));
-
-		return (ACPI_PSM_FAILURE);
-	}
-
-
-	XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: Setting irq %d "
-	    "for device %s instance #%d\n", irq, ddi_get_name(dip),
-	    ddi_get_instance(dip)));
-
-	if ((acpi_set_irq_resource(acpipsmlnkp, irq)) == ACPI_PSM_SUCCESS) {
-		/*
-		 * setting irq was successful, check to make sure CRS
-		 * reflects that. If CRS does not agree with what we
-		 * set, return the irq that was set.
-		 */
-
-		if (acpi_get_current_irq_resource(acpipsmlnkp, &cur_irq,
-		    dipintr_flagp) == ACPI_PSM_SUCCESS) {
-
-			if (cur_irq != irq)
-				XEN_UPPC_VERBOSE_IRQ((CE_WARN, "!xVM_uppc: "
-				    "IRQ resource set (irqno %d) for device %s "
-				    "instance #%d, differs from current "
-				    "setting irqno %d",
-				    irq, ddi_get_name(dip),
-				    ddi_get_instance(dip), cur_irq));
-		}
-		/*
-		 * return the irq that was set, and not what CRS reports,
-		 * since CRS has been seen to be bogus on some systems
-		 */
-		cur_irq = irq;
-	} else {
-		XEN_UPPC_VERBOSE_IRQ((CE_WARN, "!xVM_uppc: set resource irq %d "
-		    "failed for device %s instance #%d",
-		    irq, ddi_get_name(dip), ddi_get_instance(dip)));
-		if (cur_irq == -1)
-			return (ACPI_PSM_FAILURE);
-	}
-
-	ASSERT(pci_irqp != NULL);
-	*pci_irqp = cur_irq;
-	return (ACPI_PSM_SUCCESS);
-}
-
-
-static int
-xen_uppc_acpi_translate_pci_irq(dev_info_t *dip, int busid, int devid,
-    int ipin, int *pci_irqp, iflag_t *intr_flagp)
-{
-	int status;
-	acpi_psm_lnk_t acpipsmlnk;
-
-	if ((status = acpi_get_irq_cache_ent(busid, devid, ipin, pci_irqp,
-	    intr_flagp)) == ACPI_PSM_SUCCESS) {
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: Found irqno %d "
-		    "from cache for device %s, instance #%d\n", *pci_irqp,
-		    ddi_get_name(dip), ddi_get_instance(dip)));
-		return (status);
-	}
-
-	bzero(&acpipsmlnk, sizeof (acpi_psm_lnk_t));
-
-	if ((status = acpi_translate_pci_irq(dip, ipin, pci_irqp,
-	    intr_flagp, &acpipsmlnk)) == ACPI_PSM_FAILURE) {
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: "
-		    " acpi_translate_pci_irq failed for device %s, instance"
-		    " #%d\n", ddi_get_name(dip), ddi_get_instance(dip)));
-
-		return (status);
-	}
-
-	if (status == ACPI_PSM_PARTIAL && acpipsmlnk.lnkobj != NULL) {
-		status = xen_uppc_acpi_irq_configure(&acpipsmlnk, dip, pci_irqp,
-		    intr_flagp);
-		if (status != ACPI_PSM_SUCCESS) {
-			status = acpi_get_current_irq_resource(&acpipsmlnk,
-			    pci_irqp, intr_flagp);
-		}
-	}
-
-	if (status == ACPI_PSM_SUCCESS) {
-		acpi_new_irq_cache_ent(busid, devid, ipin, *pci_irqp,
-		    intr_flagp, &acpipsmlnk);
-		psm_set_elcr(*pci_irqp, 1); 	/* set IRQ to PCI mode */
-
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: [ACPI] "
-		    "new irq %d for device %s, instance #%d\n",
-		    *pci_irqp, ddi_get_name(dip), ddi_get_instance(dip)));
-	}
-
-	return (status);
-}
-
-
-/*ARGSUSED*/
-static int
-xen_uppc_translate_irq(dev_info_t *dip, int irqno)
-{
-	char dev_type[16];
-	int dev_len, pci_irq, devid, busid;
-	ddi_acc_handle_t cfg_handle;
-	uchar_t ipin, iline;
-	iflag_t intr_flag;
-
-	if (dip == NULL) {
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: irqno = %d"
-		    " dip = NULL\n", irqno));
-		return (irqno);
-	}
-
-	if (!xen_uppc_enable_acpi) {
-		return (irqno);
-	}
-
-	dev_len = sizeof (dev_type);
-	if (ddi_getlongprop_buf(DDI_DEV_T_ANY, ddi_get_parent(dip),
-	    DDI_PROP_DONTPASS, "device_type", (caddr_t)dev_type,
-	    &dev_len) != DDI_PROP_SUCCESS) {
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: irqno %d"
-		    " device %s instance %d no device_type\n", irqno,
-		    ddi_get_name(dip), ddi_get_instance(dip)));
-		return (irqno);
-	}
-
-	if ((strcmp(dev_type, "pci") == 0) ||
-	    (strcmp(dev_type, "pciex") == 0)) {
-
-		/* pci device */
-		if (acpica_get_bdf(dip, &busid, &devid, NULL) != 0)
-			return (irqno);
-
-		if (pci_config_setup(dip, &cfg_handle) != DDI_SUCCESS)
-			return (irqno);
-
-		ipin = pci_config_get8(cfg_handle, PCI_CONF_IPIN) - PCI_INTA;
-		iline = pci_config_get8(cfg_handle, PCI_CONF_ILINE);
-		if (xen_uppc_acpi_translate_pci_irq(dip, busid, devid,
-		    ipin, &pci_irq, &intr_flag) == ACPI_PSM_SUCCESS) {
-
-			XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: [ACPI] "
-			    "new irq %d old irq %d device %s, instance %d\n",
-			    pci_irq, irqno, ddi_get_name(dip),
-			    ddi_get_instance(dip)));
-
-			/*
-			 * Make sure pci_irq is within range.
-			 * Otherwise, fall through and return irqno.
-			 */
-			if (pci_irq <= MAX_ISA_IRQ) {
-				if (iline != pci_irq) {
-					/*
-					 * Update the device's ILINE byte,
-					 * in case uppc_acpi_translate_pci_irq
-					 * has choosen a different pci_irq
-					 * than the BIOS has configured.
-					 * Some chipsets use the value in
-					 * ILINE to control interrupt routing,
-					 * in conflict with the PCI spec.
-					 */
-					pci_config_put8(cfg_handle,
-					    PCI_CONF_ILINE, pci_irq);
-				}
-				pci_config_teardown(&cfg_handle);
-				return (pci_irq);
-			}
-		}
-		pci_config_teardown(&cfg_handle);
-
-		/* FALLTHRU to common case - returning irqno */
-	} else {
-		/* non-PCI; assumes ISA-style edge-triggered */
-		psm_set_elcr(irqno, 0); 	/* set IRQ to ISA mode */
-
-		XEN_UPPC_VERBOSE_IRQ((CE_CONT, "!xVM_uppc: non-pci,"
-		    "irqno %d device %s instance %d\n", irqno,
-		    ddi_get_name(dip), ddi_get_instance(dip)));
-	}
-
-	return (irqno);
-}
-
-/*
- * xen_uppc_intr_enter() acks the event that triggered the interrupt and
- * returns the new priority level,
- */
-/*ARGSUSED*/
-static int
-xen_uppc_intr_enter(int ipl, int *vector)
-{
-	int newipl;
-	uint_t intno;
-	cpu_t *cpu = CPU;
-
-	intno = (*vector);
-
-	ASSERT(intno < NR_IRQS);
-	ASSERT(cpu->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask != 0);
-
-	ec_clear_irq(intno);
-
-	newipl = autovect[intno].avh_hi_pri;
-	if (newipl == 0) {
-		/*
-		 * (newipl == 0) means we have no service routines for this
-		 * vector.  We will treat this as a spurious interrupt.
-		 * We have cleared the pending bit already, clear the event
-		 * mask and return a spurious interrupt.  This case can happen
-		 * when an interrupt delivery is racing with the removal of
-		 * of the service routine for that interrupt.
-		 */
-		ec_unmask_irq(intno);
-		newipl = -1;	/* flag spurious interrupt */
-	} else if (newipl <= cpu->cpu_pri) {
-		/*
-		 * (newipl <= cpu->cpu_pri) means that we must be trying to
-		 * service a vector that was shared with a higher priority
-		 * isr.  The higher priority handler has been removed and
-		 * we need to service this int.  We can't return a lower
-		 * priority than current cpu priority.  Just synthesize a
-		 * priority to return that should be acceptable.
-		 */
-		newipl = cpu->cpu_pri + 1;	/* synthetic priority */
-	}
-	return (newipl);
-}
-
-
-static void xen_uppc_setspl(int);
-
-/*
- * xen_uppc_intr_exit() restores the old interrupt
- * priority level after processing an interrupt.
- * It is called with interrupts disabled, and does not enable interrupts.
- */
-/* ARGSUSED */
-static void
-xen_uppc_intr_exit(int ipl, int vector)
-{
-	ec_try_unmask_irq(vector);
-	xen_uppc_setspl(ipl);
-}
-
-intr_exit_fn_t
-psm_intr_exit_fn(void)
-{
-	return (xen_uppc_intr_exit);
-}
-
-/*
- * Check if new ipl level allows delivery of previously unserviced events
- */
-static void
-xen_uppc_setspl(int ipl)
-{
-	struct cpu *cpu = CPU;
-	volatile vcpu_info_t *vci = cpu->cpu_m.mcpu_vcpu_info;
-	uint16_t pending;
-
-	ASSERT(vci->evtchn_upcall_mask != 0);
-
-	/*
-	 * If new ipl level will enable any pending interrupts, setup so the
-	 * upcoming sti will cause us to get an upcall.
-	 */
-	pending = cpu->cpu_m.mcpu_intr_pending & ~((1 << (ipl + 1)) - 1);
-	if (pending) {
-		int i;
-		ulong_t pending_sels = 0;
-		volatile ulong_t *selp;
-		struct xen_evt_data *cpe = cpu->cpu_m.mcpu_evt_pend;
-
-		for (i = bsrw_insn(pending); i > ipl; i--)
-			pending_sels |= cpe->pending_sel[i];
-		ASSERT(pending_sels);
-		selp = (volatile ulong_t *)&vci->evtchn_pending_sel;
-		atomic_or_ulong(selp, pending_sels);
-		vci->evtchn_upcall_pending = 1;
-	}
-}
-
-/*
- * The rest of the file is just generic psm module boilerplate
- */
-
-static struct psm_ops xen_uppc_ops = {
-	xen_uppc_probe,				/* psm_probe		*/
-
-	xen_uppc_softinit,			/* psm_init		*/
-	xen_uppc_picinit,			/* psm_picinit		*/
-	xen_uppc_intr_enter,			/* psm_intr_enter	*/
-	xen_uppc_intr_exit,			/* psm_intr_exit	*/
-	xen_uppc_setspl,			/* psm_setspl		*/
-	xen_uppc_addspl,			/* psm_addspl		*/
-	xen_uppc_delspl,			/* psm_delspl		*/
-	(int (*)(processorid_t))NULL,		/* psm_disable_intr	*/
-	(void (*)(processorid_t))NULL,		/* psm_enable_intr	*/
-	(int (*)(int))NULL,			/* psm_softlvl_to_irq	*/
-	(void (*)(int))NULL,			/* psm_set_softintr	*/
-	(void (*)(processorid_t))NULL,		/* psm_set_idlecpu	*/
-	(void (*)(processorid_t))NULL,		/* psm_unset_idlecpu	*/
-
-	xen_uppc_clkinit,			/* psm_clkinit		*/
-	xen_uppc_get_clockirq,			/* psm_get_clockirq	*/
-	(void (*)(void))NULL,			/* psm_hrtimeinit	*/
-	xpv_gethrtime,				/* psm_gethrtime	*/
-
-	xen_uppc_get_next_processorid,		/* psm_get_next_processorid */
-	(int (*)(processorid_t, caddr_t))NULL,	/* psm_cpu_start	*/
-	(int (*)(void))NULL,			/* psm_post_cpu_start	*/
-	xen_uppc_shutdown,			/* psm_shutdown		*/
-	(int (*)(int, int))NULL,		/* psm_get_ipivect	*/
-	(void (*)(processorid_t, int))NULL,	/* psm_send_ipi		*/
-
-	xen_uppc_translate_irq,			/* psm_translate_irq	*/
-
-	(void (*)(int, char *))NULL,		/* psm_notify_error	*/
-	(void (*)(int msg))NULL,		/* psm_notify_func	*/
-	xen_uppc_timer_reprogram,		/* psm_timer_reprogram	*/
-	xen_uppc_timer_enable,			/* psm_timer_enable	*/
-	xen_uppc_timer_disable,			/* psm_timer_disable	*/
-	(void (*)(void *arg))NULL,		/* psm_post_cyclic_setup */
-	(void (*)(int, int))NULL,		/* psm_preshutdown	*/
-
-	(int (*)(dev_info_t *, ddi_intr_handle_impl_t *,
-	    psm_intr_op_t, int *))NULL,		/* psm_intr_ops		*/
-	(int (*)(psm_state_request_t *))NULL,	/* psm_state		*/
-	(int (*)(psm_cpu_request_t *))NULL	/* psm_cpu_ops		*/
-};
-
-static struct psm_info xen_uppc_info = {
-	PSM_INFO_VER01_5,	/* version				*/
-	PSM_OWN_SYS_DEFAULT,	/* ownership				*/
-	&xen_uppc_ops,		/* operation				*/
-	"xVM_uppc",		/* machine name				*/
-	"UniProcessor PC"	/* machine descriptions			*/
-};
-
-static void *xen_uppc_hdlp;
-
-int
-_init(void)
-{
-	return (psm_mod_init(&xen_uppc_hdlp, &xen_uppc_info));
-}
-
-int
-_fini(void)
-{
-	return (psm_mod_fini(&xen_uppc_hdlp, &xen_uppc_info));
-}
-
-int
-_info(struct modinfo *modinfop)
-{
-	return (psm_mod_info(&xen_uppc_hdlp, &xen_uppc_info, modinfop));
-}
--- old/usr/src/uts/i86xpv/io/xpvtod.c	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,191 +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 2007 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/systm.h>
-#include <sys/mutex.h>
-#include <sys/time.h>
-#include <sys/clock.h>
-#include <sys/archsystm.h>
-#include <sys/modctl.h>
-#include <sys/autoconf.h>
-#include <sys/cmn_err.h>
-#include <sys/atomic.h>
-#include <sys/hypervisor.h>
-
-/*
- * tod driver module for i86xpv
- */
-
-static timestruc_t
-todxen_get(tod_ops_t *top)
-{
-	todinfo_t tod;
-	timestruc_t ts, wcts;
-	shared_info_t *si = HYPERVISOR_shared_info;
-	uint32_t xen_wc_version;
-	hrtime_t now;
-
-	ASSERT(MUTEX_HELD(&tod_lock));
-
-	/*
-	 * Pick up the wallclock base time
-	 */
-	do {
-		xen_wc_version = si->wc_version;
-
-		membar_consumer();
-
-		wcts.tv_sec = si->wc_sec;
-		wcts.tv_nsec = si->wc_nsec;
-
-		membar_consumer();
-
-	} while ((si->wc_version & 1) | (xen_wc_version ^ si->wc_version));
-
-	/*
-	 * Compute the TOD as the wallclock (boot) time plus time-since-boot
-	 * (/not/ hrtime!) and normalize.
-	 */
-	now = xpv_getsystime() +
-	    (hrtime_t)wcts.tv_nsec + (hrtime_t)wcts.tv_sec * NANOSEC;
-	ts.tv_sec = (time_t)(now / NANOSEC);
-	ts.tv_nsec = (long)(now % NANOSEC);
-
-	/*
-	 * Apply GMT lag correction from /etc/rtc_config to get UTC time
-	 */
-	ts.tv_sec += ggmtl();
-
-	/*
-	 * Validate the TOD in case of total insanity
-	 */
-	tod = utc_to_tod(ts.tv_sec);
-	if (tod.tod_year < 69) {
-		static int range_warn = 1;	/* warn only once */
-
-		if (range_warn) {
-			/*
-			 * If we're dom0, go invoke the underlying driver; the
-			 * routine should complain if it discovers something
-			 * wrong.
-			 */
-			if (DOMAIN_IS_INITDOMAIN(xen_info))
-				(void) TODOP_GET(top->tod_next);
-
-			/*
-			 * Check the virtual hardware.
-			 */
-			if (tod.tod_year > 38)
-				cmn_err(CE_WARN,
-				    "hypervisor wall clock is out "
-				    "of range -- time needs to be reset");
-			range_warn = 0;
-		}
-		tod.tod_year += 100;
-		ts.tv_sec = tod_to_utc(tod);
-	}
-
-	return (ts);
-}
-
-/*
- * On dom0, invoke the underlying driver to update the physical RTC,
- * and tell the hypervisor to update its idea of global time.
- *
- * On domU, we don't have permission to update the machine's physical RTC,
- * so quietly ignore the attempt.
- */
-static void
-todxen_set(tod_ops_t *top, timestruc_t ts)
-{
-	xen_platform_op_t op;
-
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		ASSERT(MUTEX_HELD(&tod_lock));
-		TODOP_SET(top->tod_next, ts);
-
-		op.cmd = XENPF_settime;
-		op.interface_version = XENPF_INTERFACE_VERSION;
-		op.u.settime.secs = ts.tv_sec - ggmtl();
-		op.u.settime.nsecs = ts.tv_nsec;
-		op.u.settime.system_time = xpv_getsystime();
-		(void) HYPERVISOR_platform_op(&op);
-	}
-}
-
-static tod_ops_t todxen_ops = {
-	TOD_OPS_VERSION,
-	todxen_get,
-	todxen_set,
-	NULL
-};
-
-static struct modlmisc modlmisc = {
-	&mod_miscops,
-	"TOD module for i86xpv"
-};
-
-static struct modlinkage modl = {
-	MODREV_1,
-	&modlmisc
-};
-
-int
-_init(void)
-{
-	/*
-	 * In future we might need to do something more sophisticated
-	 * for versioning, i.e. dealing with older hardware TOD modules
-	 * underneath us, but for now, anything else but "same" is a
-	 * fatal error.
-	 */
-	if (tod_ops->tod_version != todxen_ops.tod_version)
-		panic("TOD module version mismatch");
-
-	/*
-	 * Stitch the ops vector linkage together, with this module
-	 * sitting on the "front" of the ops list.
-	 */
-	todxen_ops.tod_next = tod_ops;
-	tod_ops = &todxen_ops;
-
-	return (mod_install(&modl));
-}
-
-int
-_fini(void)
-{
-	return (EBUSY);
-}
-
-int
-_info(struct modinfo *modinfo)
-{
-	return (mod_info(&modl, modinfo));
-}
--- old/usr/src/uts/i86xpv/ioat/Makefile	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,100 +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
-#
-#
-# uts/i86xpv/ioat/Makefile
-#
-# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the ioat driver kernel
-#	module.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= ioat
-OBJECTS		= $(IOAT_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(IOAT_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR     = $(UTSBASE)/i86pc/io/ioat
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY) $(SRC_CONFILE)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-CERRWARN	+= -_gcc=-Wno-unused-label
-CERRWARN	+= -_gcc=-Wno-uninitialized
-
-#
-#	Dependency
-#
-LDFLAGS		+= -dy -Nmisc/dcopy
-
-#
-#	Override defaults to build a unique, local modstubs.o.
-#
-MODSTUBS_DIR	 = $(OBJS_DIR)
-CLEANFILES	+= $(MODSTUBS_O)
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
-
--- old/usr/src/uts/i86xpv/isa/Makefile	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,132 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-#	This makefile drives the production of the ISA nexus driver
-#
-#	i86xpv 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		= isa
-OBJECTS		= $(ISANEXUS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(ISANEXUS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-INC_PATH        += -I$(UTSBASE)/i86pc/sys/acpi
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-$(OBJS_DIR)/isa.o :=	CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-# lint pass one enforcement
-#
-CFLAGS += $(CCVERBOSE)
-
-#
-#       Dependency
-LDFLAGS         += -dy -Nmisc/acpica -Nmisc/busra -Nmisc/pci_autoconfig
-
-#
-# Define our version of dma_engine and i8237A interfaces
-#
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_init=$(MODULE)_i_dmae_init
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_acquire=$(MODULE)_i_dmae_acquire
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_free=$(MODULE)_i_dmae_free
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_get_best_mode=$(MODULE)_i_dmae_get_best_mode
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -D_dmae_nxcookie=$(MODULE)__dmae_nxcookie
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_prog=$(MODULE)_i_dmae_prog
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_swsetup=$(MODULE)_i_dmae_swsetup
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_swsetup=$(MODULE)_i_dmae_swsetup
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_swstart=$(MODULE)_i_dmae_swstart
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_stop=$(MODULE)_i_dmae_stop
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_enable=$(MODULE)_i_dmae_enable
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_disable=$(MODULE)_i_dmae_disable
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Di_dmae_get_chan_stat=$(MODULE)_i_dmae_get_chan_stat
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_init=$(MODULE)_d37A_init
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_valid=$(MODULE)_d37A_dma_valid
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_release=$(MODULE)_d37A_dma_release
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_disable=$(MODULE)_d37A_dma_disable
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_enable=$(MODULE)_d37A_dma_enable
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_get_best_mode=$(MODULE)_d37A_get_best_mode
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_intr=$(MODULE)_d37A_intr
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -DdEISA_setchain=$(MODULE)_dEISA_setchain
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_prog_chan=$(MODULE)_d37A_prog_chan
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_swsetup=$(MODULE)_d37A_dma_swsetup
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_swstart=$(MODULE)_d37A_dma_swstart
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_dma_stop=$(MODULE)_d37A_dma_stop
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_get_chan_stat=$(MODULE)_d37A_get_chan_stat
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_set_mode=$(MODULE)_d37A_set_mode
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_write_addr=$(MODULE)_d37A_write_addr
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_read_addr=$(MODULE)_d37A_read_addr
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_write_count=$(MODULE)_d37A_write_count
-$(OBJECTS) $(LINTS)	:= CPPFLAGS += -Dd37A_read_count=$(MODULE)_d37A_read_count
-
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-CERRWARN	+= -_gcc=-Wno-unused-variable
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/ml/amd64.il	Fri Aug 10 23:19:20 2018
+++ /dev/null	Fri Aug 10 23:19:20 2018
@@ -1,88 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/
-/ Inline functions for the x64 kernel running on the hypervisor
-/
-
-	.inline	__hypercall0, 0
-	movq	%rdi, %rax
-	syscall
-	.end
-
-	.inline	__hypercall1, 0
-	movq	%rdi, %rax
-	movq	%rsi, %rdi		/ arg 1 
-	syscall
-	.end
-
-	.inline	__hypercall2, 0
-	movq	%rdi, %rax
-	movq	%rsi, %rdi		/ arg 1
-	movq	%rdx, %rsi		/ arg 2
-	syscall
-	.end
-
-	.inline	__hypercall3, 0
-	movq	%rdi, %rax
-	movq	%rsi, %rdi		/ arg 1
-	movq	%rdx, %rsi		/ arg 2
-	movq	%rcx, %rdx		/ arg 3
-	syscall
-	.end
-
-/*  XXPV studio bug  r10 is changed to eax by compiler */
-	.inline	__hypercall4_broken, 0
-	movq	%rdi, %rax
-	movq	%rsi, %rdi		/ arg 1
-	movq	%rdx, %rsi		/ arg 2
-	movq	%rcx, %rdx		/ arg 3
-	movq	%r8, %r10		/ r10 = 4th arg
-	syscall
-	.end
-
-	.inline	__hypercall5_broken, 0
-	movq	%rdi, %rax
-	movq	%rsi, %rdi		/ arg 1
-	movq	%rdx, %rsi		/ arg 2
-	movq	%rcx, %rdx		/ arg 3
-	movq	%r8, %r10		/ r10 = 4th arg
-	movq	%r9, %r8		/ arg 5
-	syscall
-	.end
-
-/*
- * Read the -real- TSC.
- * This is difficult to virtualize on the hypervisor given there is
- * no way to prevent preemption; thus this inline function
- * should only be used in the middle of the paravirtualized
- * implementation of tsc_read.
- */
-	.inline	__rdtsc_insn, 0
-	rdtsc
-	shlq	$32, %rdx
-	orq	%rdx, %rax
-	.end
--- old/usr/src/uts/i86xpv/ml/hyperevent.s	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,249 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma	ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/asm_linkage.h>
-#include <sys/hypervisor.h>
-#include <sys/privregs.h>
-#include <sys/segments.h>
-#include <sys/traptrace.h>
-#include <sys/trap.h>
-#include <sys/psw.h>
-#include <sys/x86_archext.h>
-#include <sys/asm_misc.h>
-
-#if !defined(__lint)
-#include "assym.h"
-#endif
-
-#if defined(__lint)
-
-void
-xen_failsafe_callback(void)
-{}
-
-void
-xen_callback(void)
-{}
-
-#else	/* __lint */
-
-	/*
-	 * The stack frame for events is exactly that of an x86 hardware
-	 * interrupt.
-	 *
-	 * The stack frame for a failsafe callback is augmented with saved
-	 * values for segment registers:
-	 *
-	 * i386
-	 *	%ds, %es, %fs, %gs, %eip, %cs, %eflags [, %oldesp, %oldss ]
-	 *
-	 * On amd64 the stack frame for events is exactly that of an hardware
-	 * interrupt with the addition of rcx and r11.
-	 * 
-	 * The stack frame for a failsafe callback is augmented with saved
-	 * values for segment registers:
-	 * 
-	 * amd64
-	 *	%rcx, %r11, %ds, %es, %fs, %gs, %rip, %cs, %rflags,
-	 *      [, %oldrsp, %oldss ]
-	 *
-	 * The hypervisor  does this to allow the guest OS to handle returns
-	 * to processes which have bad segment registers.
-	 *
-	 * [See comments in xen/arch/x86/[x86_64,x86_32]/entry.S]
-	 *
-	 * We will construct a fully fledged 'struct regs' and call trap
-	 * with a #gp fault.
-	 */
-
-#if defined(__amd64)
-
-	ENTRY(xen_failsafe_callback)
-
-	/*
-	 * The saved values of rcx and r11 are on the top of the stack.
-	 * pop them and let INTR_PUSH save them. We drop ds, es, fs and
-	 * gs since the hypervisor will have already loaded these for us.
-	 * If any were bad and faulted the hypervisor would have loaded
-	 * them with the null selctor.
-	 */
-	XPV_TRAP_POP	/* rcx, r11 */
-
-	/*
-	 * XXPV
-	 * If the current segregs are provided for us on the stack by
-	 * the hypervisor then we should simply move them into their proper
-	 * location in the regs struct?
-	 */
-	addq    $_CONST(_MUL(4, CLONGSIZE)), %rsp
-
-	/*
-	 * XXPV
-	 * It would be nice to somehow figure out which selector caused
-	 * #gp fault.
-	 */
-
-	pushq	$0	/* dummy error */
-	pushq	$T_GPFLT
-
-	INTR_PUSH
-	INTGATE_INIT_KERNEL_FLAGS
-
-	/*
-	 * We're here because HYPERVISOR_IRET to userland failed due to a
-	 * bad %cs value. Rewrite %cs, %ss and %rip on the stack so trap
-	 * will know to handle this with kern_gpfault and kill the currently
-	 * running process.
-	 */
-	movq	$KCS_SEL, REGOFF_CS(%rsp)
-	movq	$KDS_SEL, REGOFF_SS(%rsp)
-	leaq	nopop_sys_rtt_syscall(%rip), %rdi
-	movq	%rdi, REGOFF_RIP(%rsp)
-
-	TRACE_PTR(%rdi, %rbx, %ebx, %rcx, $TT_EVENT) /* Uses labels 8 and 9 */
-	TRACE_REGS(%rdi, %rsp, %rbx, %rcx)	/* Uses label 9 */
-	TRACE_STAMP(%rdi)		/* Clobbers %eax, %edx, uses 9 */
-
-	movq	%rsp, %rbp
-
-	TRACE_STACK(%rdi)
-
-	movq	%rbp, %rdi
-
-	ENABLE_INTR_FLAGS
-
-	movq	%rbp, %rdi
-	xorl	%esi, %esi
-	movl	%gs:CPU_ID, %edx
-	call	trap		/* trap(rp, addr, cpuid) handles all trap */
-	jmp	_sys_rtt
-	SET_SIZE(xen_failsafe_callback)
-
-#elif defined(__i386)
-
-	ENTRY(xen_failsafe_callback)
-
-	/*
-	 * drop ds, es, fs and gs
-	 */
-	addl    $_CONST(_MUL(4, CLONGSIZE)), %esp /* see comment for 64-bit */
-
-	pushl	$0	/* dummy error (see comment for 64-bit) */
-	pushl	$T_GPFLT
-
-	INTR_PUSH
-	INTGATE_INIT_KERNEL_FLAGS	/* (set kernel flag values) */
-
-	/*
-	 * The fact were here is because HYPERVISOR_IRET to userland
-	 * failed due to a bad %cs value. Rewrite %cs, %ss and %eip
-	 * on the stack so trap will know to handle this with
-	 * kern_gpfault and kill the currently running process.
-	 */
-	movl	$KCS_SEL, REGOFF_CS(%esp)
-	movl	$KDS_SEL, REGOFF_SS(%esp)
-	leal	nopop_sys_rtt_syscall, %edi
-	movl	%edi, REGOFF_EIP(%esp)
-
-	TRACE_PTR(%edi, %ebx, %ebx, %ecx, $TT_EVENT) /* Uses labels 8 and 9 */
-	TRACE_REGS(%edi, %esp, %ebx, %ecx)	/* Uses label 9 */
-	TRACE_STAMP(%edi)		/* Clobbers %eax, %edx, uses 9 */
-
-	movl	%esp, %ebp
-
-	TRACE_STACK(%edi)
-
-	ENABLE_INTR_FLAGS
-
-	pushl	%gs:CPU_ID
-	pushl	$0
-	pushl	%ebp
-	call	trap		/* trap(rp, addr, cpuid) handles all traps */
-	addl	$12, %esp
-	jmp	_sys_rtt
-	SET_SIZE(xen_failsafe_callback)
-
-#endif	/* __i386 */
-
-#if defined(__amd64)
-
-	ENTRY(xen_callback)
-	XPV_TRAP_POP
-
-	pushq	$0			/* dummy error */
-	pushq	$T_AST
-
-	INTR_PUSH
-	INTGATE_INIT_KERNEL_FLAGS	/* (set kernel flag values) */
-
-	TRACE_PTR(%rdi, %rbx, %ebx, %rcx, $TT_EVENT) /* Uses labels 8 and 9 */
-	TRACE_REGS(%rdi, %rsp, %rbx, %rcx)	/* Uses label 9 */
-	TRACE_STAMP(%rdi)		/* Clobbers %eax, %edx, uses 9 */
-
-	movq	%rsp, %rbp
-
-	TRACE_STACK(%rdi)
-
-	movq	%rdi, %rsi		/* rsi = trap trace recode pointer */
-	movq	%rbp, %rdi		/* rdi = struct regs pointer */
-	call	xen_callback_handler
-
-	jmp	_sys_rtt_ints_disabled
-	/*NOTREACHED*/
-
-	SET_SIZE(xen_callback)
-
-#elif defined(__i386)
-
-	ENTRY(xen_callback)
-	pushl	$0			/* dummy error */
-	pushl	$T_AST
-
-	INTR_PUSH
-	INTGATE_INIT_KERNEL_FLAGS	/* (set kernel flag values) */
-
-	TRACE_PTR(%edi, %ebx, %ebx, %ecx, $TT_EVENT) /* Uses labels 8 and 9 */
-	TRACE_REGS(%edi, %esp, %ebx, %ecx)	/* Uses label 9 */
-	TRACE_STAMP(%edi)		/* Clobbers %eax, %edx, uses 9 */
-
-	movl	%esp, %ebp
-
-	TRACE_STACK(%edi)
-
-	pushl	%edi			/* pass trap trace record pointer */
-	pushl	%ebp			/* pass struct regs pointer */
-	call	xen_callback_handler
-	addl	$8, %esp
-
-	jmp	_sys_rtt_ints_disabled
-	/*NOTREACHED*/
-
-	SET_SIZE(xen_callback)
-
-#endif	/* __i386 */
-#endif	/* __lint */
--- old/usr/src/uts/i86xpv/ml/ia32.il	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,101 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/
-/ Inline functions for the x86 kernel running on the hypervisor
-/
-
-	.inline	__hypercall0, 4
-	movl	(%esp), %eax
-	int	$0x82
-	.end
-
-	.inline	__hypercall1, 8
-	pushl	%ebx
-	movl	4(%esp), %eax
-	movl	8(%esp), %ebx
-	int	$0x82
-	popl	%ebx
-	.end
-
-	.inline	__hypercall2, 12
-	pushl	%ebx
-	movl	4(%esp), %eax
-	movl	8(%esp), %ebx
-	movl	12(%esp), %ecx
-	int	$0x82
-	popl	%ebx
-	.end
-
-	.inline	__hypercall3, 16
-	pushl	%ebx
-	movl	4(%esp), %eax
-	movl	8(%esp), %ebx
-	movl	12(%esp), %ecx
-	movl	16(%esp), %edx
-	int	$0x82
-	popl	%ebx
-	.end
-
-	.inline	__hypercall4, 20
-	pushl	%ebx
-	pushl	%esi
-	movl	8(%esp), %eax
-	movl	12(%esp), %ebx
-	movl	16(%esp), %ecx
-	movl	20(%esp), %edx
-	movl	24(%esp), %esi
-	int	$0x82
-	popl	%esi
-	popl	%ebx
-	.end
-
-	.inline	__hypercall5, 24
-	pushl	%ebx
-	pushl	%esi
-	pushl	%edi
-	movl	12(%esp), %eax
-	movl	16(%esp), %ebx
-	movl	20(%esp), %ecx
-	movl	24(%esp), %edx
-	movl	28(%esp), %esi
-	movl	32(%esp), %edi
-	int	$0x82
-	popl	%edi
-	popl	%esi
-	popl	%ebx
-	.end
-
-/*
- * Read the -real- TSC.
- * This is difficult to virtualize on the hypervisor given there is
- * no way to prevent preemption; thus this inline function
- * should only be used in the middle of the paravirtualized
- * implementation of tsc_read.
- */
-	.inline	__rdtsc_insn, 0
-	rdtsc
-	.end
--- old/usr/src/uts/i86xpv/ml/panic_asm.s	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,395 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma	ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/asm_linkage.h>
-#include <sys/hypervisor.h>
-#include <sys/privregs.h>
-#include <sys/segments.h>
-#include <sys/traptrace.h>
-#include <sys/trap.h>
-#include <sys/psw.h>
-#include <sys/x86_archext.h>
-#include <sys/asm_misc.h>
-#include <sys/panic.h>
-
-#if !defined(__lint)
-#include "assym.h"
-#endif
-
-#if defined(__lint)
-
-void
-xpv_panic_callback(void)
-{}
-
-/* ARGSUSED */
-void
-xpv_panic_setcr3(ulong_t cr3)
-{}
-
-void
-xpv_panic_reload_cr3(void)
-{}
-
-void
-xpv_resetgs(void)
-{}
-
-#else	/* __lint */
-
-#if defined(__amd64)
-	ENTRY_NP(xpv_panic_getcr3)
-	movq	%cr3, %rax
-	ret
-	SET_SIZE(xpv_panic_getcr3)
-
-	ENTRY_NP(xpv_panic_setcr3)
-	movq	%rdi, %cr3
-	ret
-	SET_SIZE(xpv_panic_setcr3)
-
-	ENTRY(xpv_panic_reload_cr3)
-	movq	%cr3, %rdi
-	movq	%rdi, %cr3
-	ret
-	SET_SIZE(xpv_panic_reload_cr3)
-
-	ENTRY_NP(xpv_panic_prep)
-	pushq   %rbp
-	movq	%rsp, %rbp
-
-	subq	$REGSIZE, %rsp
-	movq	%rax, REGOFF_RAX(%rsp)
-	movq	%rbx, REGOFF_RBX(%rsp)
-	movq	%rsp, %rax
-	addq	$REGSIZE, %rax
-	movq	(%rax), %rbx
-	movq	%rbx, REGOFF_RBP(%rsp)
-	movq	8(%rax), %rbx
-	movq	%rbx, REGOFF_TRAPNO(%rsp)
-	movq	16(%rax), %rbx
-	movq	%rbx, REGOFF_ERR(%rsp)
-	movq	24(%rax), %rbx
-	movq	%rbx, REGOFF_RIP(%rsp)
-	movq	32(%rax), %rbx
-	movq	%rbx, REGOFF_CS(%rsp)
-	movq	40(%rax), %rbx
-	movq	%rbx, REGOFF_RFL(%rsp)
-	addq	$56, %rax
-	movq	%rax, REGOFF_RSP(%rsp)
-	xorl	%eax, %eax
-	movw	%gs, %ax
-	mov	%rax, REGOFF_GS(%rsp)
-	movw	%fs, %ax
-	mov	%rax, REGOFF_FS(%rsp)
-	movw	%es, %ax
-	mov	%rax, REGOFF_ES(%rsp)
-	movw	%ds, %ax
-	mov	%rax, REGOFF_DS(%rsp)
-	movw	%ss, %ax
-	mov	%rax, REGOFF_SS(%rsp)
-	movq	%rcx, REGOFF_RCX(%rsp)
-	movq	%rdx, REGOFF_RDX(%rsp)
-	movq	%rdi, REGOFF_RDI(%rsp)
-	movq	%rsi, REGOFF_RSI(%rsp)
-	movq	%r8, REGOFF_R8(%rsp)
-	movq	%r9, REGOFF_R9(%rsp)
-	movq	%r10, REGOFF_R10(%rsp)
-	movq	%r11, REGOFF_R11(%rsp)
-	movq	%r12, REGOFF_R12(%rsp)
-	movq	%r13, REGOFF_R13(%rsp)
-	movq	%r14, REGOFF_R14(%rsp)
-	movq	%r15, REGOFF_R15(%rsp)
-
-	movq	%rsp, %rdi
-	call	xpv_die
-	SET_SIZE(xpv_panic_prep)
-
-	/*
-	 * Switch to the Solaris panic stack and jump into the Xen panic
-	 * handling code.
-	 */
-	ENTRY_NP(xpv_panic_hdlr)
-	leaq	panic_stack(%rip), %rsp
-	addq	$PANICSTKSIZE, %rsp
-	call	xpv_do_panic
-	SET_SIZE(xpv_panic_hdlr)
-
-	ENTRY_NP(xpv_surprise_intr)
-	pushq   %rbp
-	movq	%rsp, %rbp
-	subq	$REGOFF_TRAPNO, %rsp
-	__SAVE_REGS
-	movq	%rsp, %rdi
-	addq	$REGOFF_TRAPNO, %rdi
-	call	xpv_interrupt
-	__RESTORE_REGS
-	addq	$REGOFF_TRAPNO, %rsp
-	popq	%rbp
-	iretq
-	SET_SIZE(xpv_surprise_intr)
-
-	ENTRY_NP(xpv_timer_trap)
-	pushq   %rbp
-	movq	%rsp, %rbp
-	subq	$REGOFF_TRAPNO, %rsp
-	__SAVE_REGS
-	movq	%rsp, %rdi
-	addq	$REGOFF_TRAPNO, %rdi
-	call	xpv_timer_tick
-	__RESTORE_REGS
-	addq	$REGOFF_TRAPNO, %rsp
-	popq	%rbp
-	iretq
-	SET_SIZE(xpv_timer_trap)
-
-#elif defined(__i386)
-
-	ENTRY_NP(xpv_panic_setcr3)
-	movl	4(%esp), %eax
-	movl	%eax, %cr3
-	ret
-	SET_SIZE(xpv_panic_setcr3)
-
-	ENTRY(xpv_panic_reload_cr3)
-	movl    %cr3, %eax
-	movl    %eax, %cr3
-	ret
-	SET_SIZE(xpv_panic_reload_cr3)
-
-	/*
-	 * Stack on entry:
-	 *  +------------+
-	 *  |   EFLAGS  |
-	 *  |   CS      |
-	 *  |   EIP     |
-	 *  |   Error   |
-	 *  |   Trap    |   <---- %esp
-	 *  +------------+
-	 */
-	ENTRY_NP(xpv_panic_prep)
-	pushl   %ebp
-	movl	%esp, %ebp
-
-	subl	$REGSIZE, %esp
-	movl	%eax, REGOFF_EAX(%esp)
-	movl	%ebx, REGOFF_EBX(%esp)
-	movl	%esp, %eax
-	addl	$REGSIZE, %eax
-	movl	(%eax), %ebx
-	movl	%ebx, REGOFF_EBP(%esp)
-	movl	4(%eax), %ebx
-	movl	%ebx, REGOFF_TRAPNO(%esp)
-	movl	8(%eax), %ebx
-	movl	%ebx, REGOFF_ERR(%esp)
-	movl	12(%eax), %ebx
-	movl	%ebx, REGOFF_EIP(%esp)
-	movl	16(%eax), %ebx
-	movl	%ebx, REGOFF_CS(%esp)
-	movl	20(%eax), %ebx
-	movl	%ebx, REGOFF_EFL(%esp)
-	addl	$28, %eax
-	movl	%eax, REGOFF_ESP(%esp)
-	xorl	%eax, %eax
-	movw	%gs, %ax
-	mov	%eax, REGOFF_GS(%esp)
-	movw	%fs, %ax
-	mov	%eax, REGOFF_FS(%esp)
-	movw	%es, %ax
-	mov	%eax, REGOFF_ES(%esp)
-	movw	%ds, %ax
-	mov	%eax, REGOFF_DS(%esp)
-	movw	%ss, %ax
-	mov	%eax, REGOFF_SS(%esp)
-	movl	%ecx, REGOFF_ECX(%esp)
-	movl	%edx, REGOFF_EDX(%esp)
-	movl	%edi, REGOFF_EDI(%esp)
-	movl	%esi, REGOFF_ESI(%esp)
-	pushl  	%esp
-	call	xpv_die
-	SET_SIZE(xpv_panic_prep)
-
-	/*
-	 * Switch to the Solaris panic stack and jump into the Xen panic
-	 * handling code.
-	 */
-	ENTRY_NP(xpv_panic_hdlr)
-	movl	4(%esp), %eax
-	lea	panic_stack, %esp
-	add	$PANICSTKSIZE, %esp
-	pushl	%eax
-	call	xpv_do_panic
-	SET_SIZE(xpv_panic_hdlr)
-
-	ENTRY_NP(xpv_surprise_intr)
-	push	%ebp
-	movl	%esp, %ebp
-	pusha
-	call	xpv_interrupt
-	popa
-	pop	%ebp
-	iret
-	SET_SIZE(xpv_surprise_intr)
-
-	ENTRY_NP(xpv_timer_trap)
-	push	%ebp
-	movl	%esp, %ebp
-	pusha
-	call	xpv_timer_tick
-	popa
-	pop	%ebp
-	iret
-	SET_SIZE(xpv_timer_trap)
-
-#endif	/* __i386 */
-
-	ENTRY_NP(xpv_panic_sti)
-	sti
-	ret
-	SET_SIZE(xpv_panic_sti)
-
-	ENTRY_NP(xpv_panic_halt)
-	sti
-	hlt
-	ret
-	SET_SIZE(xpv_panic_halt)
-
-	ENTRY_NP(xpv_panic_resetgs)
-	movl	$KGS_SEL, %eax
-	movw	%ax, %gs
-	ret
-	SET_SIZE(xpv_panic_resetgs)
-
-	ENTRY_NP(xpv_invaltrap)
-	push	$0xbad0
-	push	$0x0bad
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_invaltrap) 
-
-	ENTRY_NP(xpv_div0trap)
-	push	$0
-	push	$T_ZERODIV
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_div0trap)
-
-	ENTRY_NP(xpv_dbgtrap)
-	push	$0
-	push	$T_SGLSTP
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_dbgtrap)
-
-	ENTRY_NP(xpv_nmiint)
-	push	$0
-	push	$T_NMIFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_nmiint)
-
-	ENTRY_NP(xpv_brktrap)
-	/* XXX: check for error */
-	push	$T_BPTFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_brktrap)
-
-	ENTRY_NP(xpv_ovflotrap)
-	push	$0
-	push	$T_OVFLW
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_ovflotrap)
-
-	ENTRY_NP(xpv_boundstrap)
-	push	$0
-	push	$T_BOUNDFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_boundstrap)
-
-	ENTRY_NP(xpv_invoptrap)
-	push	$T_ILLINST
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_invoptrap)
-
-	ENTRY_NP(xpv_ndptrap)
-	push	$0
-	push	$T_NOEXTFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_ndptrap)
-
-	ENTRY_NP(xpv_syserrtrap)
-	/* XXX: check for error */
-	push	$T_DBLFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_syserrtrap)
-
-	ENTRY_NP(xpv_invtsstrap)
-	push	$T_TSSFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_invtsstrap)
-
-	ENTRY_NP(xpv_segnptrap)
-	push	$T_SEGFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_segnptrap)
-
-	ENTRY_NP(xpv_stktrap)
-	push	$T_STKFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_stktrap)
-
-	ENTRY_NP(xpv_gptrap)
-	push	$T_GPFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_gptrap)
-
-	ENTRY_NP(xpv_pftrap)
-	push	$T_PGFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_pftrap)
-
-	ENTRY_NP(xpv_ndperr)
-	push	$0
-	push	$T_EXTERRFLT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_ndperr)
-
-	ENTRY_NP(xpv_achktrap)
-	push	$T_ALIGNMENT
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_achktrap)
-
-	ENTRY_NP(xpv_mcetrap)
-	push	$0
-	push	$T_MCE
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_mcetrap)
-
-	ENTRY_NP(xpv_xmtrap)
-	push	$0
-	push	$T_SIMDFPE
-	jmp	xpv_panic_prep
-	SET_SIZE(xpv_xmtrap)
-
-#endif	/* __lint */
--- old/usr/src/uts/i86xpv/ml/xenguest.s	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,67 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#if defined(__lint)
-
-/*
- * Stop lint complaining about an empty compilation unit!
- * Sigh.  There should be a better way to handle this.
- */
-int __lint_xen_guest;
-
-#else	/* __lint */
-
-#include <xen/public/elfnote.h>
-
-/*
- * A note is a name/value pair that belongs to some class.
- */
-#define NOTE(class, id, type, value)	\
-	.align	4;			\
-	.4byte	2f - 1f;		\
-	.4byte	4f - 3f;		\
-	.4byte	id;			\
-1: ;					\
-	.string class;			\
-2: ;					\
-	.align	4;			\
-3: ;					\
-	type	value;			\
-4: ;
-
-	.section .note
-	NOTE("Xen", XEN_ELFNOTE_LOADER, .string, "generic")
-	NOTE("Xen", XEN_ELFNOTE_XEN_VERSION, .string, "xen-3.0")
-	NOTE("Xen", XEN_ELFNOTE_GUEST_OS, .string, "Solaris")
-	NOTE("Xen", XEN_ELFNOTE_VIRT_BASE, .4byte, 0x40000000)
-	NOTE("Xen", XEN_ELFNOTE_PADDR_OFFSET, .4byte, 0x40000000)
-#if defined(__i386)
-	NOTE("Xen", XEN_ELFNOTE_PAE_MODE, .string, "yes,bimodal")
-#endif
-
-#endif /* __lint */
--- old/usr/src/uts/i86xpv/npe/Makefile	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,105 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-#	This makefile drives the production of the PCI-E nexus driver
-#
-#	i86xpv 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		= npe
-OBJECTS		= $(PCI_E_NEXUS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(PCI_E_NEXUS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-# depends on misc/acpica and misc/pcie
-#
-# acpica supplies ACPI access routines
-#
-# pcie supplies PCI Express fabric error support
-#
-LDFLAGS	+= -dy -Nmisc/acpica -Nmisc/pcie
-
-#
-# Name of the module is needed by the source, to distinguish from other
-# PCI/PCI-express nexi
-#
-CFLAGS		+= -D_MODULE_NAME="\"$(MODULE)\""
-LINTFLAGS	+= -D_MODULE_NAME="\"$(MODULE)\""
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/os/balloon.c	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,1061 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- * Copyright 2016 PALO, Richard.
- */
-
-#include <sys/balloon_impl.h>
-#include <sys/hypervisor.h>
-#include <xen/sys/xenbus_impl.h>
-#include <sys/atomic.h>
-#include <sys/cmn_err.h>
-#include <sys/disp.h>
-#include <sys/callb.h>
-#include <xen/public/memory.h>
-#include <vm/hat.h>
-#include <sys/promif.h>
-#include <vm/seg_kmem.h>
-#include <sys/memnode.h>
-#include <sys/param.h>
-#include <vm/vm_dep.h>
-#include <sys/mman.h>
-#include <sys/memlist.h>
-#include <sys/sysmacros.h>
-#include <sys/machsystm.h>
-#include <sys/sdt.h>
-
-/*
- * This file implements a balloon thread, which controls a domain's memory
- * reservation, or the amount of memory a domain is currently allocated.
- * The hypervisor provides the current memory reservation through xenbus,
- * so we register a watch on this.  We will then be signalled when the
- * reservation changes.  If it goes up, we map the new mfn's to our pfn's
- * (allocating page_t's if necessary), and release them into the system.
- * If the reservation goes down, we grab pages and release them back to
- * the hypervisor, saving the page_t's for later use.
- */
-
-/*
- * Various structures needed by the balloon thread
- */
-static bln_stats_t bln_stats;
-static kthread_t *bln_thread;
-static kmutex_t bln_mutex;
-static kcondvar_t bln_cv;
-static struct xenbus_watch bln_watch;
-static mfn_t new_high_mfn;
-
-/*
- * For holding spare page_t structures - keep a singly-linked list.
- * The list may hold both valid (pagenum < mfn_count) and invalid
- * (pagenum >= mfn_count) page_t's.  Valid page_t's should be inserted
- * at the front, and invalid page_t's at the back.  Removal should
- * always be from the front.  This is a singly-linked list using
- * p_next, so p_prev is always NULL.
- */
-static page_t *bln_spare_list_front, *bln_spare_list_back;
-
-int balloon_zero_memory = 1;
-size_t balloon_minkmem = (8 * 1024 * 1024);
-
-/*
- * reassign_pfn() calls update_contig_pfnlist(), which can cause a large
- * slowdown when calling multiple times.  If we're reassigning less than the
- * quota defined here, we just accept the slowdown.  If the count is greater
- * than the quota, we tell the contig alloc code to stop its accounting until
- * we're done.  Setting the quota to less than 2 is not supported.
- *
- * Note that we define our own wrapper around the external
- * clear_and_lock_contig_pfnlist(), but we just use the version of
- * unlock_contig_pfnlist() in vm_machdep.c.
- */
-uint_t bln_contig_list_quota = 50;
-
-extern void clear_and_lock_contig_pfnlist(void);
-extern void unlock_contig_pfnlist(void);
-
-/*
- * Lock the pfnlist if necessary (see above), and return whether we locked it.
- */
-static int
-balloon_lock_contig_pfnlist(int count)
-{
-	if (count > bln_contig_list_quota) {
-		clear_and_lock_contig_pfnlist();
-		return (1);
-	} else {
-		return (0);
-	}
-}
-
-/*
- * The page represented by pp is being given back to the hypervisor.
- * Add the page_t structure to our spare list.
- */
-static void
-balloon_page_add(page_t *pp)
-{
-	/*
-	 * We need to keep the page exclusively locked
-	 * to prevent swrand from grabbing it.
-	 */
-	ASSERT(PAGE_EXCL(pp));
-	ASSERT(MUTEX_HELD(&bln_mutex));
-
-	pp->p_prev = NULL;
-	if (bln_spare_list_front == NULL) {
-		bln_spare_list_front = bln_spare_list_back = pp;
-		pp->p_next = NULL;
-	} else if (pp->p_pagenum >= mfn_count) {
-		/*
-		 * The pfn is invalid, so add at the end of list.  Since these
-		 * adds should *only* be done by balloon_init_new_pages(), and
-		 * that does adds in order, the following ASSERT should
-		 * never trigger.
-		 */
-		ASSERT(pp->p_pagenum > bln_spare_list_back->p_pagenum);
-		bln_spare_list_back->p_next = pp;
-		pp->p_next = NULL;
-		bln_spare_list_back = pp;
-	} else {
-		/* Add at beginning of list */
-		pp->p_next = bln_spare_list_front;
-		bln_spare_list_front = pp;
-	}
-}
-
-/*
- * Return a page_t structure from our spare list, or NULL if none are available.
- */
-static page_t *
-balloon_page_sub(void)
-{
-	page_t *pp;
-
-	ASSERT(MUTEX_HELD(&bln_mutex));
-	if (bln_spare_list_front == NULL) {
-		return (NULL);
-	}
-
-	pp = bln_spare_list_front;
-	ASSERT(PAGE_EXCL(pp));
-	ASSERT(pp->p_pagenum <= mfn_count);
-	if (pp->p_pagenum == mfn_count) {
-		return (NULL);
-	}
-
-	bln_spare_list_front = pp->p_next;
-	if (bln_spare_list_front == NULL)
-		bln_spare_list_back = NULL;
-	pp->p_next = NULL;
-	return (pp);
-}
-
-/*
- * NOTE: We currently do not support growing beyond the boot memory size,
- * so the following function will not be called.  It is left in here with
- * the hope that someday this restriction can be lifted, and this code can
- * be used.
- */
-
-/*
- * This structure is placed at the start of every block of new pages
- */
-typedef struct {
-	struct memseg	memseg;
-	struct memlist	memlist;
-	page_t		pages[1];
-} mem_structs_t;
-
-/*
- * To make the math below slightly less confusing, we calculate the first
- * two parts here.  page_t's are handled separately, so they are not included.
- */
-#define	MEM_STRUCT_SIZE	(sizeof (struct memseg) + sizeof (struct memlist))
-
-/*
- * We want to add memory, but have no spare page_t structures.  Use some of
- * our new memory for the page_t structures.
- *
- * Somewhat similar to kphysm_add_memory_dynamic(), but simpler.
- */
-static int
-balloon_init_new_pages(mfn_t framelist[], pgcnt_t count)
-{
-	pgcnt_t	metapgs, totalpgs, num_pages;
-	paddr_t	metasz;
-	pfn_t	meta_start;
-	page_t	*page_array;
-	caddr_t	va;
-	int	i, rv, locked;
-	mem_structs_t *mem;
-	struct memseg *segp;
-
-	/* Calculate the number of pages we're going to add */
-	totalpgs = bln_stats.bln_new_target - bln_stats.bln_current_pages;
-
-	/*
-	 * The following calculates the number of "meta" pages -- the pages
-	 * that will be required to hold page_t structures for all new pages.
-	 * Proof of this calculation is left up to the reader.
-	 */
-	metapgs = totalpgs - (((uint64_t)(totalpgs) << PAGESHIFT) /
-	    (PAGESIZE + sizeof (page_t)));
-
-	/*
-	 * Given the number of page_t structures we need, is there also
-	 * room in our meta pages for a memseg and memlist struct?
-	 * If not, we'll need one more meta page.
-	 */
-	if ((metapgs << PAGESHIFT) < (totalpgs * sizeof (page_t) +
-	    MEM_STRUCT_SIZE))
-		metapgs++;
-
-	/*
-	 * metapgs is calculated from totalpgs, which may be much larger than
-	 * count.  If we don't have enough pages, all of the pages in this
-	 * batch will be made meta pages, and a future trip through
-	 * balloon_inc_reservation() will add the rest of the meta pages.
-	 */
-	if (metapgs > count)
-		metapgs = count;
-
-	/*
-	 * Figure out the number of page_t structures that can fit in metapgs
-	 *
-	 * This will cause us to initialize more page_t structures than we
-	 * need - these may be used in future memory increases.
-	 */
-	metasz = pfn_to_pa(metapgs);
-	num_pages = (metasz - MEM_STRUCT_SIZE) / sizeof (page_t);
-
-	DTRACE_PROBE3(balloon__alloc__stats, pgcnt_t, totalpgs, pgcnt_t,
-	    num_pages, pgcnt_t, metapgs);
-
-	/*
-	 * We only increment mfn_count by count, not num_pages, to keep the
-	 * space of all valid pfns contiguous.  This means we create page_t
-	 * structures with invalid pagenums -- we deal with this situation
-	 * in balloon_page_sub.
-	 */
-	mfn_count += count;
-
-	/*
-	 * Get a VA for the pages that will hold page_t and other structures.
-	 * The memseg and memlist structures will go at the beginning, with
-	 * the page_t structures following.
-	 */
-	va = (caddr_t)vmem_alloc(heap_arena, metasz, VM_SLEEP);
-	/* LINTED: improper alignment */
-	mem = (mem_structs_t *)va;
-	page_array = mem->pages;
-
-	meta_start = bln_stats.bln_max_pages;
-
-	/*
-	 * Set the mfn to pfn mapping for the meta pages.
-	 */
-	locked = balloon_lock_contig_pfnlist(metapgs);
-	for (i = 0; i < metapgs; i++) {
-		reassign_pfn(bln_stats.bln_max_pages + i, framelist[i]);
-	}
-	if (locked)
-		unlock_contig_pfnlist();
-
-	/*
-	 * For our meta pages, map them in and zero the page.
-	 * This will be the first time touching the new pages.
-	 */
-	hat_devload(kas.a_hat, va, metasz, bln_stats.bln_max_pages,
-	    PROT_READ | PROT_WRITE,
-	    HAT_LOAD | HAT_LOAD_LOCK | HAT_LOAD_NOCONSIST);
-	bzero(va, metasz);
-
-	/*
-	 * Initialize the page array for the new pages.
-	 */
-	for (i = 0; i < metapgs; i++) {
-		page_array[i].p_pagenum = bln_stats.bln_max_pages++;
-		page_array[i].p_offset = (u_offset_t)-1;
-		page_iolock_init(&page_array[i]);
-		rv = page_lock(&page_array[i], SE_EXCL, NULL, P_NO_RECLAIM);
-		ASSERT(rv == 1);
-	}
-
-	/*
-	 * For the rest of the pages, initialize the page_t struct and
-	 * add them to the free list
-	 */
-	for (i = metapgs; i < num_pages; i++) {
-		page_array[i].p_pagenum = bln_stats.bln_max_pages++;
-		page_array[i].p_offset = (u_offset_t)-1;
-		page_iolock_init(&page_array[i]);
-		rv = page_lock(&page_array[i], SE_EXCL, NULL, P_NO_RECLAIM);
-		ASSERT(rv == 1);
-		balloon_page_add(&page_array[i]);
-	}
-
-	/*
-	 * Remember where I said that we don't call this function?  The missing
-	 * code right here is why.  We need to set up kpm mappings for any new
-	 * pages coming in.  However, if someone starts up a domain with small
-	 * memory, then greatly increases it, we could get in some horrible
-	 * deadlock situations as we steal page tables for kpm use, and
-	 * userland applications take them right back before we can use them
-	 * to set up our new memory.  Once a way around that is found, and a
-	 * few other changes are made, we'll be able to enable this code.
-	 */
-
-	/*
-	 * Update kernel structures, part 1: memsegs list
-	 */
-	mem->memseg.pages_base = meta_start;
-	mem->memseg.pages_end = bln_stats.bln_max_pages - 1;
-	mem->memseg.pages = &page_array[0];
-	mem->memseg.epages = &page_array[num_pages - 1];
-	mem->memseg.next = NULL;
-	memsegs_lock(1);
-	for (segp = memsegs; segp->next != NULL; segp = segp->next)
-		;
-	segp->next = &mem->memseg;
-	memsegs_unlock(1);
-
-	/*
-	 * Update kernel structures, part 2: mem_node array
-	 */
-	mem_node_add_slice(meta_start, bln_stats.bln_max_pages);
-
-	/*
-	 * Update kernel structures, part 3: phys_install array
-	 * (*sigh* how many of these things do we need?)
-	 */
-	memlist_write_lock();
-	memlist_add(pfn_to_pa(meta_start), num_pages, &mem->memlist,
-	    &phys_install);
-	memlist_write_unlock();
-
-	build_pfn_hash();
-
-	return (metapgs);
-}
-
-/* How many ulong_t's can we fit on a page? */
-#define	FRAME_ARRAY_SIZE	(PAGESIZE / sizeof (ulong_t))
-
-/*
- * These are too large to declare on the stack, so we make them static instead
- */
-static ulong_t	mfn_frames[FRAME_ARRAY_SIZE];
-static pfn_t	pfn_frames[FRAME_ARRAY_SIZE];
-
-/*
- * This function is called when our reservation is increasing.  Make a
- * hypervisor call to get our new pages, then integrate them into the system.
- */
-static spgcnt_t
-balloon_inc_reservation(ulong_t credit)
-{
-	int	i, cnt, locked;
-	int	meta_pg_start, meta_pg_end;
-	long	rv;
-	page_t	*pp;
-	page_t	*new_list_front, *new_list_back;
-
-	/* Make sure we're single-threaded. */
-	ASSERT(MUTEX_HELD(&bln_mutex));
-
-	rv = 0;
-	new_list_front = new_list_back = NULL;
-	meta_pg_start = meta_pg_end = 0;
-	bzero(mfn_frames, PAGESIZE);
-
-	if (credit > FRAME_ARRAY_SIZE)
-		credit = FRAME_ARRAY_SIZE;
-
-	xen_block_migrate();
-	rv = balloon_alloc_pages(credit, mfn_frames);
-
-	if (rv < 0) {
-		xen_allow_migrate();
-		return (0);
-	}
-	for (i = 0; i < rv; i++) {
-		if (mfn_frames[i] > new_high_mfn)
-			new_high_mfn = mfn_frames[i];
-
-		pp = balloon_page_sub();
-		if (pp == NULL) {
-			/*
-			 * We pass the index into the current mfn array,
-			 * then move the counter past the mfns we used
-			 */
-			meta_pg_start = i;
-			cnt = balloon_init_new_pages(&mfn_frames[i], rv - i);
-			i += cnt;
-			meta_pg_end = i;
-			if (i < rv) {
-				pp = balloon_page_sub();
-			} else {
-				ASSERT(i == rv);
-			}
-		}
-		if (pp == NULL) {
-			break;
-		}
-
-		if (new_list_back == NULL) {
-			new_list_front = new_list_back = pp;
-		} else {
-			new_list_back->p_next = pp;
-			new_list_back = pp;
-		}
-		pp->p_next = NULL;
-	}
-	cnt = i;
-	locked = balloon_lock_contig_pfnlist(cnt);
-	for (i = 0, pp = new_list_front; i < meta_pg_start;
-	    i++, pp = pp->p_next) {
-		reassign_pfn(pp->p_pagenum, mfn_frames[i]);
-	}
-	for (i = meta_pg_end; i < cnt; i++, pp = pp->p_next) {
-		reassign_pfn(pp->p_pagenum, mfn_frames[i]);
-	}
-	if (locked)
-		unlock_contig_pfnlist();
-
-	/*
-	 * Make sure we don't allow pages without pfn->mfn mappings
-	 * into the system.
-	 */
-	ASSERT(pp == NULL);
-
-	while (new_list_front != NULL) {
-		pp = new_list_front;
-		new_list_front = pp->p_next;
-		page_free(pp, 1);
-	}
-
-	/*
-	 * Variable review: at this point, rv contains the number of pages
-	 * the hypervisor gave us.  cnt contains the number of pages for which
-	 * we had page_t structures.  i contains the number of pages
-	 * where we set up pfn <-> mfn mappings.  If this ASSERT trips, that
-	 * means we somehow lost page_t's from our local list.
-	 */
-	ASSERT(cnt == i);
-	if (cnt < rv) {
-		/*
-		 * We couldn't get page structures.
-		 *
-		 * This shouldn't happen, but causes no real harm if it does.
-		 * On debug kernels, we'll flag it.  On all kernels, we'll
-		 * give back the pages we couldn't assign.
-		 *
-		 * Since these pages are new to the system and haven't been
-		 * used, we don't bother zeroing them.
-		 */
-#ifdef DEBUG
-		cmn_err(CE_WARN, "Could only assign %d of %ld pages", cnt, rv);
-#endif	/* DEBUG */
-
-		(void) balloon_free_pages(rv - cnt, &mfn_frames[i], NULL, NULL);
-
-		rv = cnt;
-	}
-
-	xen_allow_migrate();
-	page_unresv(rv - (meta_pg_end - meta_pg_start));
-	return (rv);
-}
-
-/*
- * This function is called when we want to decrease the memory reservation
- * of our domain.  Allocate the memory and make a hypervisor call to give
- * it back.
- */
-static spgcnt_t
-balloon_dec_reservation(ulong_t debit)
-{
-	int	i, locked;
-	long	rv;
-	ulong_t	request;
-	page_t	*pp;
-
-	bzero(mfn_frames, sizeof (mfn_frames));
-	bzero(pfn_frames, sizeof (pfn_frames));
-
-	if (debit > FRAME_ARRAY_SIZE) {
-		debit = FRAME_ARRAY_SIZE;
-	}
-	request = debit;
-
-	/*
-	 * Don't bother if there isn't a safe amount of kmem left.
-	 */
-	if (kmem_avail() < balloon_minkmem) {
-		kmem_reap();
-		if (kmem_avail() < balloon_minkmem)
-			return (0);
-	}
-
-	if (page_resv(request, KM_NOSLEEP) == 0) {
-		return (0);
-	}
-	xen_block_migrate();
-	for (i = 0; i < debit; i++) {
-		pp = page_get_high_mfn(new_high_mfn);
-		new_high_mfn = 0;
-		if (pp == NULL) {
-			/*
-			 * Call kmem_reap(), then try once more,
-			 * but only if there is a safe amount of
-			 * kmem left.
-			 */
-			kmem_reap();
-			if (kmem_avail() < balloon_minkmem ||
-			    (pp = page_get_high_mfn(0)) == NULL) {
-				debit = i;
-				break;
-			}
-		}
-		ASSERT(PAGE_EXCL(pp));
-		ASSERT(!hat_page_is_mapped(pp));
-
-		balloon_page_add(pp);
-		pfn_frames[i] = pp->p_pagenum;
-		mfn_frames[i] = pfn_to_mfn(pp->p_pagenum);
-	}
-	if (debit == 0) {
-		xen_allow_migrate();
-		page_unresv(request);
-		return (0);
-	}
-
-	/*
-	 * We zero all the pages before we start reassigning them in order to
-	 * minimize the time spent holding the lock on the contig pfn list.
-	 */
-	if (balloon_zero_memory) {
-		for (i = 0; i < debit; i++) {
-			pfnzero(pfn_frames[i], 0, PAGESIZE);
-		}
-	}
-
-	/*
-	 * Remove all mappings for the pfns from the system
-	 */
-	locked = balloon_lock_contig_pfnlist(debit);
-	for (i = 0; i < debit; i++) {
-		reassign_pfn(pfn_frames[i], MFN_INVALID);
-	}
-	if (locked)
-		unlock_contig_pfnlist();
-
-	rv = balloon_free_pages(debit, mfn_frames, NULL, NULL);
-
-	if (rv < 0) {
-		cmn_err(CE_WARN, "Attempt to return pages to the hypervisor "
-		    "failed - up to %lu pages lost (error = %ld)", debit, rv);
-		rv = 0;
-	} else if (rv != debit) {
-		panic("Unexpected return value (%ld) from decrease reservation "
-		    "hypervisor call", rv);
-	}
-
-	xen_allow_migrate();
-	if (debit != request)
-		page_unresv(request - debit);
-	return (rv);
-}
-
-/*
- * This function is the callback which is called when the memory/target
- * node is changed.  When it is fired, we will read a new reservation
- * target for our domain and signal the worker thread to make the change.
- *
- * If the reservation is larger than we can handle, we issue a warning.  dom0
- * does this automatically every boot, so we skip the first warning on dom0.
- */
-/*ARGSUSED*/
-static void
-balloon_handler(struct xenbus_watch *watch, const char **vec, uint_t len)
-{
-	ulong_t new_target_kb;
-	pgcnt_t	new_target_pages;
-	int rv;
-	static uchar_t warning_cnt = 0;
-
-	rv = xenbus_scanf(0, "memory", "target", "%lu", &new_target_kb);
-	if (rv != 0) {
-		return;
-	}
-
-	/* new_target is in kB - change this to pages */
-	new_target_pages = kbtop(new_target_kb);
-
-	DTRACE_PROBE1(balloon__new__target, pgcnt_t, new_target_pages);
-
-	/*
-	 * Unfortunately, dom0 may give us a target that is larger than
-	 * our max limit.  Re-check the limit, and, if the new target is
-	 * too large, adjust it downwards.
-	 */
-	mutex_enter(&bln_mutex);
-	if (new_target_pages > bln_stats.bln_max_pages) {
-		DTRACE_PROBE2(balloon__target__too__large, pgcnt_t,
-		    new_target_pages, pgcnt_t, bln_stats.bln_max_pages);
-		if (!DOMAIN_IS_INITDOMAIN(xen_info) || warning_cnt != 0) {
-			cmn_err(CE_WARN, "New balloon target (0x%lx pages) is "
-			    "larger than original memory size (0x%lx pages). "
-			    "Ballooning beyond original memory size is not "
-			    "allowed.",
-			    new_target_pages, bln_stats.bln_max_pages);
-		}
-		warning_cnt = 1;
-		bln_stats.bln_new_target = bln_stats.bln_max_pages;
-	} else {
-		bln_stats.bln_new_target = new_target_pages;
-	}
-
-	mutex_exit(&bln_mutex);
-	cv_signal(&bln_cv);
-}
-
-/*
- * bln_wait_sec can be used to throttle the hv calls, but by default it's
- * turned off.  If a balloon attempt fails, the wait time is forced on, and
- * then is exponentially increased as further attempts fail.
- */
-uint_t bln_wait_sec = 0;
-uint_t bln_wait_shift = 1;
-
-/*
- * This is the main balloon thread.  Wait on the cv.  When woken, if our
- * reservation has changed, call the appropriate function to adjust the
- * reservation.
- */
-static void
-balloon_worker_thread(void)
-{
-	uint_t		bln_wait;
-	callb_cpr_t	cprinfo;
-	spgcnt_t	rv;
-
-	bln_wait = bln_wait_sec;
-
-	CALLB_CPR_INIT(&cprinfo, &bln_mutex, callb_generic_cpr, "balloon");
-	for (;;) {
-		rv = 0;
-
-		mutex_enter(&bln_mutex);
-		CALLB_CPR_SAFE_BEGIN(&cprinfo);
-		if (bln_stats.bln_new_target != bln_stats.bln_current_pages) {
-			/*
-			 * We weren't able to fully complete the request
-			 * last time through, so try again.
-			 */
-			(void) cv_reltimedwait(&bln_cv, &bln_mutex,
-			    (bln_wait * hz), TR_CLOCK_TICK);
-		} else {
-			cv_wait(&bln_cv, &bln_mutex);
-		}
-		CALLB_CPR_SAFE_END(&cprinfo, &bln_mutex);
-
-		if (bln_stats.bln_new_target != bln_stats.bln_current_pages) {
-			if (bln_stats.bln_new_target <
-			    bln_stats.bln_current_pages) {
-				/* reservation shrunk */
-				rv = -balloon_dec_reservation(
-				    bln_stats.bln_current_pages -
-				    bln_stats.bln_new_target);
-			} else if (bln_stats.bln_new_target >
-			    bln_stats.bln_current_pages) {
-				/* reservation grew */
-				rv = balloon_inc_reservation(
-				    bln_stats.bln_new_target -
-				    bln_stats.bln_current_pages);
-			}
-		}
-		if (rv == 0) {
-			if (bln_wait == 0) {
-				bln_wait = 1;
-			} else {
-				bln_wait <<= bln_wait_shift;
-			}
-		} else {
-			bln_stats.bln_current_pages += rv;
-			bln_wait = bln_wait_sec;
-		}
-		if (bln_stats.bln_current_pages < bln_stats.bln_low)
-			bln_stats.bln_low = bln_stats.bln_current_pages;
-		else if (bln_stats.bln_current_pages > bln_stats.bln_high)
-			bln_stats.bln_high = bln_stats.bln_current_pages;
-		mutex_exit(&bln_mutex);
-	}
-}
-
-/*
- * Called after balloon_init(), which is below.  The xenbus thread is up
- * and running, so we can register our watch and create the balloon thread.
- */
-static void
-balloon_config_watch(int state)
-{
-	if (state != XENSTORE_UP)
-		return;
-
-	bln_watch.node = "memory/target";
-	bln_watch.callback = balloon_handler;
-	if (register_xenbus_watch(&bln_watch)) {
-		cmn_err(CE_WARN, "Failed to register balloon watcher; balloon "
-		    "thread will be disabled");
-		return;
-	}
-
-	if (bln_thread == NULL)
-		bln_thread = thread_create(NULL, 0, balloon_worker_thread,
-		    NULL, 0, &p0, TS_RUN, minclsyspri);
-}
-
-/*
- * Basic initialization of the balloon thread.  Set all of our variables,
- * and register a callback for later when we can register a xenbus watch.
- */
-void
-balloon_init(pgcnt_t nr_pages)
-{
-	domid_t domid = DOMID_SELF;
-
-	bln_stats.bln_current_pages = bln_stats.bln_low = nr_pages;
-	bln_stats.bln_new_target = bln_stats.bln_high = nr_pages;
-	bln_stats.bln_max_pages = nr_pages;
-	cv_init(&bln_cv, NULL, CV_DEFAULT, NULL);
-
-	bln_stats.bln_hard_limit = (spgcnt_t)HYPERVISOR_memory_op(
-	    XENMEM_maximum_reservation, &domid);
-
-	(void) xs_register_xenbus_callback(balloon_config_watch);
-}
-
-/*
- * These functions are called from the network drivers when they gain a page
- * or give one away.  We simply update our count.  Note that the counter
- * tracks the number of pages we give away, so we need to subtract any
- * amount passed to balloon_drv_added.
- */
-void
-balloon_drv_added(int64_t delta)
-{
-	atomic_add_long((ulong_t *)&bln_stats.bln_hv_pages, -delta);
-}
-
-void
-balloon_drv_subtracted(int64_t delta)
-{
-	atomic_add_long((ulong_t *)&bln_stats.bln_hv_pages, delta);
-}
-
-/*
- * balloon_alloc_pages()
- *	Allocate page_cnt mfns.  mfns storage provided by the caller.  Returns
- *	the number of pages allocated, which could be less than page_cnt, or
- *	a negative number if an error occurred.
- */
-long
-balloon_alloc_pages(uint_t page_cnt, mfn_t *mfns)
-{
-	xen_memory_reservation_t memres;
-	long rv;
-
-	bzero(&memres, sizeof (memres));
-	/*LINTED: constant in conditional context*/
-	set_xen_guest_handle(memres.extent_start, mfns);
-	memres.domid = DOMID_SELF;
-	memres.nr_extents = page_cnt;
-
-	rv = HYPERVISOR_memory_op(XENMEM_increase_reservation, &memres);
-	if (rv > 0)
-		atomic_add_long((ulong_t *)&bln_stats.bln_hv_pages, -rv);
-	return (rv);
-}
-
-/*
- * balloon_free_pages()
- *    free page_cnt pages, using any combination of mfns, pfns, and kva as long
- *    as they refer to the same mapping.  If an array of mfns is passed in, we
- *    assume they were already cleared.  Otherwise, we need to zero the pages
- *    before giving them back to the hypervisor. kva space is not free'd up in
- *    case the caller wants to re-use it.
- */
-long
-balloon_free_pages(uint_t page_cnt, mfn_t *mfns, caddr_t kva, pfn_t *pfns)
-{
-	xen_memory_reservation_t memdec;
-	mfn_t mfn;
-	pfn_t pfn;
-	uint_t i;
-	long e;
-
-
-#if DEBUG
-	/* make sure kva is page aligned and maps to first pfn */
-	if (kva != NULL) {
-		ASSERT(((uintptr_t)kva & PAGEOFFSET) == 0);
-		if (pfns != NULL) {
-			ASSERT(hat_getpfnum(kas.a_hat, kva) == pfns[0]);
-		}
-	}
-#endif
-
-	/* if we have a kva, we can clean all pages with just one bzero */
-	if ((kva != NULL) && balloon_zero_memory) {
-		bzero(kva, (page_cnt * PAGESIZE));
-	}
-
-	/* if we were given a kva and/or a pfn */
-	if ((kva != NULL) || (pfns != NULL)) {
-
-		/*
-		 * All the current callers only pass 1 page when using kva or
-		 * pfns, and use mfns when passing multiple pages.  If that
-		 * assumption is changed, the following code will need some
-		 * work.  The following ASSERT() guarantees we're respecting
-		 * the io locking quota.
-		 */
-		ASSERT(page_cnt < bln_contig_list_quota);
-
-		/* go through all the pages */
-		for (i = 0; i < page_cnt; i++) {
-
-			/* get the next pfn */
-			if (pfns == NULL) {
-				pfn = hat_getpfnum(kas.a_hat,
-				    (kva + (PAGESIZE * i)));
-			} else {
-				pfn = pfns[i];
-			}
-
-			/*
-			 * if we didn't already zero this page, do it now. we
-			 * need to do this *before* we give back the MFN
-			 */
-			if ((kva == NULL) && (balloon_zero_memory)) {
-				pfnzero(pfn, 0, PAGESIZE);
-			}
-
-			/*
-			 * unmap the pfn. We don't free up the kva vmem space
-			 * so the caller can re-use it. The page must be
-			 * unmapped before it is given back to the hypervisor.
-			 */
-			if (kva != NULL) {
-				hat_unload(kas.a_hat, (kva + (PAGESIZE * i)),
-				    PAGESIZE, HAT_UNLOAD_UNMAP);
-			}
-
-			/* grab the mfn before the pfn is marked as invalid */
-			mfn = pfn_to_mfn(pfn);
-
-			/* mark the pfn as invalid */
-			reassign_pfn(pfn, MFN_INVALID);
-
-			/*
-			 * if we weren't given an array of MFNs, we need to
-			 * free them up one at a time. Otherwise, we'll wait
-			 * until later and do it in one hypercall
-			 */
-			if (mfns == NULL) {
-				bzero(&memdec, sizeof (memdec));
-				/*LINTED: constant in conditional context*/
-				set_xen_guest_handle(memdec.extent_start, &mfn);
-				memdec.domid = DOMID_SELF;
-				memdec.nr_extents = 1;
-				e = HYPERVISOR_memory_op(
-				    XENMEM_decrease_reservation, &memdec);
-				if (e != 1) {
-					cmn_err(CE_PANIC, "balloon: unable to "
-					    "give a page back to the "
-					    "hypervisor.\n");
-				}
-			}
-		}
-	}
-
-	/*
-	 * if we were passed in MFNs, we haven't free'd them up yet. We can
-	 * do it with one call.
-	 */
-	if (mfns != NULL) {
-		bzero(&memdec, sizeof (memdec));
-		/*LINTED: constant in conditional context*/
-		set_xen_guest_handle(memdec.extent_start, mfns);
-		memdec.domid = DOMID_SELF;
-		memdec.nr_extents = page_cnt;
-		e = HYPERVISOR_memory_op(XENMEM_decrease_reservation, &memdec);
-		if (e != page_cnt) {
-			cmn_err(CE_PANIC, "balloon: unable to give pages back "
-			    "to the hypervisor.\n");
-		}
-	}
-
-	atomic_add_long((ulong_t *)&bln_stats.bln_hv_pages, page_cnt);
-	return (page_cnt);
-}
-
-
-/*
- * balloon_replace_pages()
- *	Try to replace nextexts blocks of 2^order pages.  addr_bits specifies
- *	how many bits of address the pages must be within (i.e. 16 would mean
- *	that the pages cannot have an address > 64k).  The constrints are on
- *	what the hypervisor gives us -- we are free to give any pages in
- *	exchange.  The array pp is the pages we are giving away.  The caller
- *	provides storage space for mfns, which hold the new physical pages.
- */
-long
-balloon_replace_pages(uint_t nextents, page_t **pp, uint_t addr_bits,
-    uint_t order, mfn_t *mfns)
-{
-	xen_memory_reservation_t memres;
-	long fallback_cnt;
-	long cnt;
-	uint_t i, j, page_cnt, extlen;
-	long e;
-	int locked;
-
-
-	/*
-	 * we shouldn't be allocating constrained pages on a guest. It doesn't
-	 * make any sense. They won't be constrained after a migration.
-	 */
-	ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
-
-	extlen = 1 << order;
-	page_cnt = nextents * extlen;
-	/* Give back the current pages to the hypervisor */
-	for (i = 0; i < page_cnt; i++) {
-		cnt = balloon_free_pages(1, NULL, NULL, &pp[i]->p_pagenum);
-		if (cnt != 1) {
-			cmn_err(CE_PANIC, "balloon: unable to give a page back "
-			    "to the hypervisor.\n");
-		}
-	}
-
-	/*
-	 * try to allocate the new pages using addr_bits and order. If we can't
-	 * get all of the pages, try to get the remaining pages with no
-	 * constraints and, if that was successful, return the number of
-	 * constrained pages we did allocate.
-	 */
-	bzero(&memres, sizeof (memres));
-	/*LINTED: constant in conditional context*/
-	set_xen_guest_handle(memres.extent_start, mfns);
-	memres.domid = DOMID_SELF;
-	memres.nr_extents = nextents;
-	memres.mem_flags = XENMEMF_address_bits(addr_bits);
-	memres.extent_order = order;
-	cnt = HYPERVISOR_memory_op(XENMEM_increase_reservation, &memres);
-	/* assign the new MFNs to the current PFNs */
-	locked = balloon_lock_contig_pfnlist(cnt * extlen);
-	for (i = 0; i < cnt; i++) {
-		for (j = 0; j < extlen; j++) {
-			reassign_pfn(pp[i * extlen + j]->p_pagenum,
-			    mfns[i] + j);
-		}
-	}
-	if (locked)
-		unlock_contig_pfnlist();
-	if (cnt != nextents) {
-		if (cnt < 0) {
-			cnt = 0;
-		}
-
-		/*
-		 * We couldn't get enough memory to satisfy our requirements.
-		 * The above loop will assign the parts of the request that
-		 * were successful (this part may be 0).  We need to fill
-		 * in the rest.  The bzero below clears out extent_order and
-		 * address_bits, so we'll take anything from the hypervisor
-		 * to replace the pages we gave away.
-		 */
-		fallback_cnt = page_cnt - cnt * extlen;
-		bzero(&memres, sizeof (memres));
-		/*LINTED: constant in conditional context*/
-		set_xen_guest_handle(memres.extent_start, mfns);
-		memres.domid = DOMID_SELF;
-		memres.nr_extents = fallback_cnt;
-		e = HYPERVISOR_memory_op(XENMEM_increase_reservation, &memres);
-		if (e != fallback_cnt) {
-			cmn_err(CE_PANIC, "balloon: unable to recover from "
-			    "failed increase_reservation.\n");
-		}
-		locked = balloon_lock_contig_pfnlist(fallback_cnt);
-		for (i = 0; i < fallback_cnt; i++) {
-			uint_t offset = page_cnt - fallback_cnt;
-
-			/*
-			 * We already used pp[0...(cnt * extlen)] before,
-			 * so start at the next entry in the pp array.
-			 */
-			reassign_pfn(pp[i + offset]->p_pagenum, mfns[i]);
-		}
-		if (locked)
-			unlock_contig_pfnlist();
-	}
-
-	/*
-	 * balloon_free_pages increments our counter.  Decrement it here.
-	 */
-	atomic_add_long((ulong_t *)&bln_stats.bln_hv_pages, -(long)page_cnt);
-
-	/*
-	 * return the number of extents we were able to replace. If we got
-	 * this far, we know all the pp's are valid.
-	 */
-	return (cnt);
-}
-
-
-/*
- * Called from the driver - return the requested stat.
- */
-size_t
-balloon_values(int cmd)
-{
-	switch (cmd) {
-	case BLN_IOCTL_CURRENT:
-		return (ptokb(bln_stats.bln_current_pages));
-	case BLN_IOCTL_TARGET:
-		return (ptokb(bln_stats.bln_new_target));
-	case BLN_IOCTL_LOW:
-		return (ptokb(bln_stats.bln_low));
-	case BLN_IOCTL_HIGH:
-		return (ptokb(bln_stats.bln_high));
-	case BLN_IOCTL_LIMIT:
-		return (ptokb(bln_stats.bln_hard_limit));
-	default:
-		panic("Unexpected cmd %d in balloon_values()\n", cmd);
-	}
-	/*NOTREACHED*/
-}
--- old/usr/src/uts/i86xpv/os/evtchn.c	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,1605 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * evtchn.c
- *
- * Communication via hypervisor event channels.
- *
- * Copyright (c) 2002-2005, K A Fraser
- *
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-/* some parts derived from netbsd's hypervisor_machdep.c 1.2.2.2 */
-
-/*
- *
- * Copyright (c) 2004 Christian Limpach.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. This section intentionally left blank.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * Section 3 of the above license was updated in response to bug 6379571.
- */
-
-#include <sys/types.h>
-#include <sys/hypervisor.h>
-#include <sys/machsystm.h>
-#include <sys/mutex.h>
-#include <sys/evtchn_impl.h>
-#include <sys/ddi_impldefs.h>
-#include <sys/avintr.h>
-#include <sys/cpuvar.h>
-#include <sys/smp_impldefs.h>
-#include <sys/archsystm.h>
-#include <sys/sysmacros.h>
-#include <sys/cmn_err.h>
-#include <sys/promif.h>
-#include <sys/debug.h>
-#include <sys/psm.h>
-#include <sys/privregs.h>
-#include <sys/trap.h>
-#include <sys/atomic.h>
-#include <sys/cpu.h>
-#include <sys/psw.h>
-#include <sys/traptrace.h>
-#include <sys/stack.h>
-#include <sys/x_call.h>
-#include <xen/public/physdev.h>
-
-/*
- * This file manages our association between hypervisor event channels and
- * Solaris's IRQs.  This is a one-to-one mapping, with the exception of
- * IPI IRQs, for which there is one event channel per CPU participating
- * in the IPI, and the clock VIRQ which also has an event channel per cpu
- * and the IRQ for /dev/xen/evtchn. The IRQ types are:
- *
- * IRQT_VIRQ:
- *	The hypervisor's standard virtual IRQ, used for the clock timer, for
- *	example.  This code allows any cpu to bind to one of these, although
- *	some are treated specially (i.e. VIRQ_DEBUG).
- *	Event channel binding is done via EVTCHNOP_bind_virq.
- *
- * IRQT_PIRQ:
- *	These associate a physical IRQ with an event channel via
- *	EVTCHNOP_bind_pirq.
- *
- * IRQT_IPI:
- *	A cross-call IRQ. Maps to "ncpus" event channels, each of which is
- *	bound to exactly one of the vcpus.  We do not currently support
- *	unbinding of IPIs (since Solaris doesn't need it). Uses
- *	EVTCHNOP_bind_ipi.
- *
- * IRQT_EVTCHN:
- *	A "normal" binding to an event channel, typically used by the frontend
- *      drivers to bind to the their backend event channel.
- *
- * IRQT_DEV_EVTCHN:
- *	This is a one-time IRQ used by /dev/xen/evtchn. Unlike other IRQs, we
- *	have a one-IRQ to many-evtchn mapping. We only track evtchn->irq for
- *	these event channels, which are managed via ec_irq_add/rm_evtchn().
- *	We enforce that IRQT_DEV_EVTCHN's representative evtchn (->ii_evtchn)
- *	is zero, and make any calls to irq_evtchn() an error, to prevent
- *	accidentally attempting to use the illegal evtchn 0.
- *
- * Suspend/resume
- *
- *	During a suspend/resume cycle, we need to tear down the event channels.
- *	All other mapping data is kept. The drivers will remove their own event
- *	channels via xendev on receiving a DDI_SUSPEND.  This leaves us with
- *	the IPIs and VIRQs, which we handle in ec_suspend() and ec_resume()
- *	below.
- *
- * CPU binding
- *
- *	When an event channel is bound to a CPU, we set a bit in a mask present
- *	in the machcpu (evt_affinity) to indicate that this CPU can accept this
- *	event channel.  For both IPIs and VIRQs, this binding is fixed at
- *	allocation time and we never modify it.  All other event channels are
- *	bound via the PSM either as part of add_avintr(), or interrupt
- *	redistribution (xen_psm_dis/enable_intr()) as a result of CPU
- *	offline/online.
- *
- * Locking
- *
- *	Updates are done holding the ec_lock.  The xen_callback_handler()
- *	routine reads the mapping data in a lockless fashion.  Additionally
- *	suspend takes ec_lock to prevent update races during a suspend/resume
- *	cycle.  The IPI info is also examined without the lock; this is OK
- *	since we only ever change IPI info during initial setup and resume.
- */
-
-#define	IRQ_IS_CPUPOKE(irq) (ipi_info[XC_CPUPOKE_PIL].mi_irq == (irq))
-
-#define	EVTCHN_MASKED(ev) \
-	(HYPERVISOR_shared_info->evtchn_mask[(ev) >> EVTCHN_SHIFT] & \
-	(1ul << ((ev) & ((1ul << EVTCHN_SHIFT) - 1))))
-
-static short evtchn_to_irq[NR_EVENT_CHANNELS];
-static cpuset_t evtchn_cpus[NR_EVENT_CHANNELS];
-static int	evtchn_owner[NR_EVENT_CHANNELS];
-#ifdef DEBUG
-static kthread_t *evtchn_owner_thread[NR_EVENT_CHANNELS];
-#endif
-
-static irq_info_t irq_info[NR_IRQS];
-static mec_info_t ipi_info[MAXIPL];
-static mec_info_t virq_info[NR_VIRQS];
-
-/*
- * See the locking description above.
- */
-kmutex_t ec_lock;
-
-/*
- * Bitmap indicating which PIRQs require the hypervisor to be notified
- * on unmask.
- */
-static unsigned long pirq_needs_eoi[NR_PIRQS / (sizeof (unsigned long) * NBBY)];
-
-static int ec_debug_irq = INVALID_IRQ;
-int ec_dev_irq = INVALID_IRQ;
-
-int
-xen_bind_virq(unsigned int virq, processorid_t cpu, int *port)
-{
-	evtchn_bind_virq_t bind;
-	int err;
-
-	bind.virq = virq;
-	bind.vcpu = cpu;
-	if ((err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &bind)) == 0)
-		*port = bind.port;
-	else
-		err = xen_xlate_errcode(err);
-	return (err);
-}
-
-int
-xen_bind_interdomain(int domid, int remote_port, int *port)
-{
-	evtchn_bind_interdomain_t bind;
-	int err;
-
-	bind.remote_dom  = domid;
-	bind.remote_port = remote_port;
-	if ((err = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain,
-	    &bind)) == 0)
-		*port = bind.local_port;
-	else
-		err = xen_xlate_errcode(err);
-	return (err);
-}
-
-int
-xen_alloc_unbound_evtchn(int domid, int *evtchnp)
-{
-	evtchn_alloc_unbound_t alloc;
-	int err;
-
-	alloc.dom = DOMID_SELF;
-	alloc.remote_dom = domid;
-
-	if ((err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound,
-	    &alloc)) == 0) {
-		*evtchnp = alloc.port;
-		/* ensure evtchn is masked till we're ready to use it */
-		(void) ec_mask_evtchn(*evtchnp);
-	} else {
-		err = xen_xlate_errcode(err);
-	}
-
-	return (err);
-}
-
-static int
-xen_close_evtchn(int evtchn)
-{
-	evtchn_close_t close;
-	int err;
-
-	close.port = evtchn;
-	err = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
-	if (err)
-		err = xen_xlate_errcode(err);
-	return (err);
-}
-
-static int
-xen_bind_ipi(processorid_t cpu)
-{
-	evtchn_bind_ipi_t bind;
-
-	ASSERT(MUTEX_HELD(&ec_lock));
-
-	bind.vcpu = cpu;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, &bind) != 0)
-		panic("xen_bind_ipi() failed");
-	return (bind.port);
-}
-
-/* Send future instances of this interrupt to other vcpu. */
-static void
-xen_bind_vcpu(int evtchn, int cpu)
-{
-	evtchn_bind_vcpu_t bind;
-
-	ASSERT(MUTEX_HELD(&ec_lock));
-
-	bind.port = evtchn;
-	bind.vcpu = cpu;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind) != 0)
-		panic("xen_bind_vcpu() failed");
-}
-
-static int
-xen_bind_pirq(int pirq)
-{
-	evtchn_bind_pirq_t bind;
-	int ret;
-
-	bind.pirq = pirq;
-	bind.flags = BIND_PIRQ__WILL_SHARE;
-	if ((ret = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &bind)) != 0)
-		panic("xen_bind_pirq() failed (err %d)", ret);
-	return (bind.port);
-}
-
-/* unmask an evtchn and send upcall to appropriate vcpu if pending bit is set */
-static void
-xen_evtchn_unmask(int evtchn)
-{
-	evtchn_unmask_t unmask;
-
-	unmask.port = evtchn;
-	if (HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask) != 0)
-		panic("xen_evtchn_unmask() failed");
-}
-
-static void
-update_evtchn_affinity(int evtchn)
-{
-	cpu_t *cp;
-	struct xen_evt_data *cpe;
-
-	ASSERT(evtchn_to_irq[evtchn] != INVALID_IRQ);
-	ASSERT(MUTEX_HELD(&ec_lock));
-
-	/*
-	 * Use lockless search of cpu_list, similar to mutex_vector_enter().
-	 */
-	kpreempt_disable();
-	cp = cpu_list;
-	do {
-		cpe = cp->cpu_m.mcpu_evt_pend;
-		if (CPU_IN_SET(evtchn_cpus[evtchn], cp->cpu_id))
-			SET_EVTCHN_BIT(evtchn, cpe->evt_affinity);
-		else
-			CLEAR_EVTCHN_BIT(evtchn, cpe->evt_affinity);
-	} while ((cp = cp->cpu_next) != cpu_list);
-	kpreempt_enable();
-}
-
-static void
-bind_evtchn_to_cpuset(int evtchn, cpuset_t cpus)
-{
-	ASSERT(evtchn_to_irq[evtchn] != INVALID_IRQ);
-
-	CPUSET_ZERO(evtchn_cpus[evtchn]);
-	CPUSET_OR(evtchn_cpus[evtchn], cpus);
-	update_evtchn_affinity(evtchn);
-}
-
-static void
-clear_evtchn_affinity(int evtchn)
-{
-	CPUSET_ZERO(evtchn_cpus[evtchn]);
-	update_evtchn_affinity(evtchn);
-}
-
-static void
-alloc_irq_evtchn(int irq, int index, int evtchn, int cpu)
-{
-	irq_info_t *irqp = &irq_info[irq];
-
-	switch (irqp->ii_type) {
-	case IRQT_IPI:
-		ipi_info[index].mi_evtchns[cpu] = evtchn;
-		irqp->ii_u.index = index;
-		break;
-	case IRQT_VIRQ:
-		virq_info[index].mi_evtchns[cpu] = evtchn;
-		irqp->ii_u.index = index;
-		break;
-	default:
-		irqp->ii_u.evtchn = evtchn;
-		break;
-	}
-
-	evtchn_to_irq[evtchn] = irq;
-
-	/*
-	 * If a CPU is not specified, we expect to bind it to a CPU later via
-	 * the PSM.
-	 */
-	if (cpu != -1) {
-		cpuset_t tcpus;
-		CPUSET_ONLY(tcpus, cpu);
-		bind_evtchn_to_cpuset(evtchn, tcpus);
-	}
-}
-
-static int
-alloc_irq(int type, int index, int evtchn, int cpu)
-{
-	int irq;
-	irq_info_t *irqp;
-
-	ASSERT(MUTEX_HELD(&ec_lock));
-	ASSERT(type != IRQT_IPI || cpu != -1);
-
-	for (irq = 0; irq < NR_IRQS; irq++) {
-		if (irq_info[irq].ii_type == IRQT_UNBOUND)
-			break;
-	}
-
-	if (irq == NR_IRQS)
-		panic("No available IRQ to bind to: increase NR_IRQS!\n");
-
-	irqp = &irq_info[irq];
-
-	irqp->ii_type = type;
-	/*
-	 * Set irq/has_handler field to zero which means handler not installed
-	 */
-	irqp->ii_u2.has_handler = 0;
-
-	alloc_irq_evtchn(irq, index, evtchn, cpu);
-	return (irq);
-}
-
-static int
-irq_evtchn(irq_info_t *irqp)
-{
-	int evtchn;
-
-	ASSERT(irqp->ii_type != IRQT_DEV_EVTCHN);
-
-	switch (irqp->ii_type) {
-	case IRQT_IPI:
-		ASSERT(irqp->ii_u.index != 0);
-		evtchn = ipi_info[irqp->ii_u.index].mi_evtchns[CPU->cpu_id];
-		break;
-	case IRQT_VIRQ:
-		evtchn = virq_info[irqp->ii_u.index].mi_evtchns[CPU->cpu_id];
-		break;
-	default:
-		evtchn = irqp->ii_u.evtchn;
-		break;
-	}
-
-	return (evtchn);
-}
-
-int
-ec_is_edge_pirq(int irq)
-{
-	return (irq_info[irq].ii_type == IRQT_PIRQ &&
-	    !TEST_EVTCHN_BIT(irq, &pirq_needs_eoi[0]));
-}
-
-static void
-unbind_evtchn(ushort_t *evtchnp)
-{
-	int err;
-
-	ASSERT(MUTEX_HELD(&ec_lock));
-
-	ASSERT(*evtchnp != 0);
-
-	err = xen_close_evtchn(*evtchnp);
-	ASSERT(err == 0);
-	clear_evtchn_affinity(*evtchnp);
-	evtchn_to_irq[*evtchnp] = INVALID_IRQ;
-	*evtchnp = 0;
-}
-
-static void
-pirq_unmask_notify(int pirq)
-{
-	struct physdev_eoi eoi;
-
-	if (TEST_EVTCHN_BIT(pirq, &pirq_needs_eoi[0])) {
-		eoi.irq = pirq;
-		(void) HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi);
-	}
-}
-
-static void
-pirq_query_unmask(int pirq)
-{
-	struct physdev_irq_status_query irq_status;
-
-	irq_status.irq = pirq;
-	(void) HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status);
-	CLEAR_EVTCHN_BIT(pirq, &pirq_needs_eoi[0]);
-	if (irq_status.flags & XENIRQSTAT_needs_eoi)
-		SET_EVTCHN_BIT(pirq, &pirq_needs_eoi[0]);
-}
-
-static void
-end_pirq(int irq)
-{
-	int evtchn = irq_evtchn(&irq_info[irq]);
-
-	/*
-	 * If it is an edge-triggered interrupt we have already unmasked
-	 */
-	if (TEST_EVTCHN_BIT(irq, &pirq_needs_eoi[0])) {
-		ec_unmask_evtchn(evtchn);
-		pirq_unmask_notify(IRQ_TO_PIRQ(irq));
-	}
-}
-
-/*
- * Bind an event channel to a vcpu
- */
-void
-ec_bind_vcpu(int evtchn, int cpu)
-{
-	mutex_enter(&ec_lock);
-	xen_bind_vcpu(evtchn, cpu);
-	mutex_exit(&ec_lock);
-}
-
-/*
- * Set up a physical device irq to be associated with an event channel.
- */
-void
-ec_setup_pirq(int irq, int ipl, cpuset_t *cpusp)
-{
-	int evtchn;
-	irq_info_t *irqp = &irq_info[irq];
-
-	/*
-	 * Test if this PIRQ is already bound to an evtchn,
-	 * which means it is a shared IRQ and we don't want to
-	 * bind and do some initial setup that has already been
-	 * done for this irq on a previous trip through this code.
-	 */
-	if (irqp->ii_u.evtchn == INVALID_EVTCHN) {
-		evtchn = xen_bind_pirq(irq);
-
-		pirq_query_unmask(IRQ_TO_PIRQ(irq));
-
-		irqp->ii_type = IRQT_PIRQ;
-		irqp->ii_u.evtchn = evtchn;
-
-		evtchn_to_irq[evtchn] = irq;
-		irqp->ii_u2.ipl = ipl;
-		ec_set_irq_affinity(irq, *cpusp);
-		ec_enable_irq(irq);
-		pirq_unmask_notify(IRQ_TO_PIRQ(irq));
-	} else {
-		ASSERT(irqp->ii_u2.ipl != 0);
-		cmn_err(CE_NOTE, "!IRQ%d is shared", irq);
-		if (ipl > irqp->ii_u2.ipl)
-			irqp->ii_u2.ipl = ipl;
-		*cpusp = evtchn_cpus[irqp->ii_u.evtchn];
-	}
-}
-
-void
-ec_unbind_irq(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-	mec_info_t *virqp;
-	int drop_lock = 0;
-	int type, i;
-
-	/*
-	 * Nasty, but we need this during suspend.
-	 */
-	if (mutex_owner(&ec_lock) != curthread) {
-		mutex_enter(&ec_lock);
-		drop_lock = 1;
-	}
-
-	type = irqp->ii_type;
-
-	ASSERT((type == IRQT_EVTCHN) || (type == IRQT_PIRQ) ||
-	    (type == IRQT_VIRQ));
-
-	if ((type == IRQT_EVTCHN) || (type == IRQT_PIRQ)) {
-		/* There's only one event channel associated with this irq */
-		unbind_evtchn(&irqp->ii_u.evtchn);
-	} else if (type == IRQT_VIRQ) {
-		/*
-		 * Each cpu on the system can have it's own event channel
-		 * associated with a virq.  Unbind them all.
-		 */
-		virqp = &virq_info[irqp->ii_u.index];
-		for (i = 0; i < NCPU; i++) {
-			if (virqp->mi_evtchns[i] != 0)
-				unbind_evtchn(&virqp->mi_evtchns[i]);
-		}
-		/* Mark the virq structure as invalid. */
-		virqp->mi_irq = INVALID_IRQ;
-	}
-
-	bzero(irqp, sizeof (*irqp));
-	/* Re-reserve PIRQ. */
-	if (type == IRQT_PIRQ)
-		irqp->ii_type = IRQT_PIRQ;
-
-	if (drop_lock)
-		mutex_exit(&ec_lock);
-}
-
-/*
- * Rebind an event channel for delivery to a CPU.
- */
-void
-ec_set_irq_affinity(int irq, cpuset_t dest)
-{
-	int evtchn, tcpu;
-	irq_info_t *irqp = &irq_info[irq];
-
-	mutex_enter(&ec_lock);
-
-	ASSERT(irq < NR_IRQS);
-	ASSERT(irqp->ii_type != IRQT_UNBOUND);
-
-	/*
-	 * Binding is done at allocation time for these types, so we should
-	 * never modify them.
-	 */
-	if (irqp->ii_type == IRQT_IPI || irqp->ii_type == IRQT_VIRQ ||
-	    irqp->ii_type == IRQT_DEV_EVTCHN) {
-		mutex_exit(&ec_lock);
-		return;
-	}
-
-	CPUSET_FIND(dest, tcpu);
-	ASSERT(tcpu != CPUSET_NOTINSET);
-
-	evtchn = irq_evtchn(irqp);
-
-	xen_bind_vcpu(evtchn, tcpu);
-
-	bind_evtchn_to_cpuset(evtchn, dest);
-
-	mutex_exit(&ec_lock);
-
-	/*
-	 * Now send the new target processor a NOP IPI.
-	 * It will check for any pending interrupts, and so service any that
-	 * got delivered to the wrong processor by mistake.
-	 */
-	if (ncpus > 1)
-		poke_cpu(tcpu);
-}
-
-int
-ec_set_irq_priority(int irq, int pri)
-{
-	irq_info_t *irqp;
-
-	if (irq >= NR_IRQS)
-		return (-1);
-
-	irqp = &irq_info[irq];
-
-	if (irqp->ii_type == IRQT_UNBOUND)
-		return (-1);
-
-	irqp->ii_u2.ipl = pri;
-
-	return (0);
-}
-
-void
-ec_clear_irq_priority(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-
-	ASSERT(irq < NR_IRQS);
-	ASSERT(irqp->ii_type != IRQT_UNBOUND);
-
-	irqp->ii_u2.ipl = 0;
-}
-
-int
-ec_bind_evtchn_to_irq(int evtchn)
-{
-	mutex_enter(&ec_lock);
-
-	ASSERT(evtchn_to_irq[evtchn] == INVALID_IRQ);
-
-	(void) alloc_irq(IRQT_EVTCHN, 0, evtchn, -1);
-
-	mutex_exit(&ec_lock);
-	return (evtchn_to_irq[evtchn]);
-}
-
-int
-ec_bind_virq_to_irq(int virq, int cpu)
-{
-	int err;
-	int evtchn;
-	mec_info_t *virqp;
-
-	virqp = &virq_info[virq];
-	mutex_enter(&ec_lock);
-
-	err = xen_bind_virq(virq, cpu, &evtchn);
-	ASSERT(err == 0);
-
-	ASSERT(evtchn_to_irq[evtchn] == INVALID_IRQ);
-
-	if (virqp->mi_irq == INVALID_IRQ) {
-		virqp->mi_irq = alloc_irq(IRQT_VIRQ, virq, evtchn, cpu);
-	} else {
-		alloc_irq_evtchn(virqp->mi_irq, virq, evtchn, cpu);
-	}
-
-	mutex_exit(&ec_lock);
-
-	return (virqp->mi_irq);
-}
-
-int
-ec_bind_ipi_to_irq(int ipl, int cpu)
-{
-	int evtchn;
-	ulong_t flags;
-	mec_info_t *ipip;
-
-	mutex_enter(&ec_lock);
-
-	ipip = &ipi_info[ipl];
-
-	evtchn = xen_bind_ipi(cpu);
-
-	ASSERT(evtchn_to_irq[evtchn] == INVALID_IRQ);
-
-	if (ipip->mi_irq == INVALID_IRQ) {
-		ipip->mi_irq = alloc_irq(IRQT_IPI, ipl, evtchn, cpu);
-	} else {
-		alloc_irq_evtchn(ipip->mi_irq, ipl, evtchn, cpu);
-	}
-
-	/*
-	 * Unmask the new evtchn so that it can be seen by the target cpu
-	 */
-	flags = intr_clear();
-	ec_unmask_evtchn(evtchn);
-	intr_restore(flags);
-
-	mutex_exit(&ec_lock);
-	return (ipip->mi_irq);
-}
-
-/*
- * When bringing up a CPU, bind to all the IPIs that CPU0 bound.
- */
-void
-ec_bind_cpu_ipis(int cpu)
-{
-	int i;
-
-	for (i = 0; i < MAXIPL; i++) {
-		mec_info_t *ipip = &ipi_info[i];
-		if (ipip->mi_irq == INVALID_IRQ)
-			continue;
-
-		(void) ec_bind_ipi_to_irq(i, cpu);
-	}
-}
-
-/*
- * Can this IRQ be rebound to another CPU?
- */
-int
-ec_irq_rebindable(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-
-	if (irqp->ii_u.evtchn == 0)
-		return (0);
-
-	return (irqp->ii_type == IRQT_EVTCHN || irqp->ii_type == IRQT_PIRQ);
-}
-
-/*
- * Should this IRQ be unbound from this CPU (which is being offlined) to
- * another?
- */
-int
-ec_irq_needs_rebind(int irq, int cpu)
-{
-	irq_info_t *irqp = &irq_info[irq];
-
-	return (ec_irq_rebindable(irq) &&
-	    CPU_IN_SET(evtchn_cpus[irqp->ii_u.evtchn], cpu));
-}
-
-void
-ec_send_ipi(int ipl, int cpu)
-{
-	mec_info_t *ipip = &ipi_info[ipl];
-
-	ASSERT(ipip->mi_irq != INVALID_IRQ);
-
-	ec_notify_via_evtchn(ipip->mi_evtchns[cpu]);
-}
-
-void
-ec_try_ipi(int ipl, int cpu)
-{
-	mec_info_t *ipip = &ipi_info[ipl];
-
-	if (ipip->mi_irq == INVALID_IRQ || ipip->mi_irq == 0)
-		return;
-
-	ec_notify_via_evtchn(ipip->mi_evtchns[cpu]);
-}
-
-void
-ec_irq_add_evtchn(int irq, int evtchn)
-{
-	mutex_enter(&ec_lock);
-
-	/*
-	 * See description of IRQT_DEV_EVTCHN above.
-	 */
-	ASSERT(irq == ec_dev_irq);
-
-	alloc_irq_evtchn(irq, 0, evtchn, 0);
-	/*
-	 * We enforce that the representative event channel for IRQT_DEV_EVTCHN
-	 * is zero, so PSM operations on it have no effect.
-	 */
-	irq_info[irq].ii_u.evtchn = 0;
-	mutex_exit(&ec_lock);
-}
-
-void
-ec_irq_rm_evtchn(int irq, int evtchn)
-{
-	ushort_t ec = evtchn;
-
-	mutex_enter(&ec_lock);
-	ASSERT(irq == ec_dev_irq);
-	unbind_evtchn(&ec);
-	mutex_exit(&ec_lock);
-}
-
-/*
- * Allocate an /dev/xen/evtchn IRQ.  See the big comment at the top
- * for an explanation.
- */
-int
-ec_dev_alloc_irq(void)
-{
-	int i;
-	irq_info_t *irqp;
-
-	for (i = 0; i < NR_IRQS; i++) {
-		if (irq_info[i].ii_type == IRQT_UNBOUND)
-			break;
-	}
-
-	ASSERT(i != NR_IRQS);
-
-	irqp = &irq_info[i];
-	irqp->ii_type = IRQT_DEV_EVTCHN;
-	irqp->ii_u2.ipl = IPL_EVTCHN;
-	/*
-	 * Force the evtchn to zero for the special evtchn device irq
-	 */
-	irqp->ii_u.evtchn = 0;
-	return (i);
-}
-
-void
-ec_enable_irq(unsigned int irq)
-{
-	ulong_t flag;
-	irq_info_t *irqp = &irq_info[irq];
-
-	if (irqp->ii_type == IRQT_DEV_EVTCHN)
-		return;
-
-	flag = intr_clear();
-	ec_unmask_evtchn(irq_evtchn(irqp));
-	intr_restore(flag);
-}
-
-void
-ec_disable_irq(unsigned int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-
-	if (irqp->ii_type == IRQT_DEV_EVTCHN)
-		return;
-
-	/*
-	 * Spin till we are the one to mask the evtchn
-	 * Ensures no one else can be servicing this evtchn.
-	 */
-	while (!ec_mask_evtchn(irq_evtchn(irqp)))
-		SMT_PAUSE();
-}
-
-static int
-ec_evtchn_pending(uint_t ev)
-{
-	uint_t evi;
-	shared_info_t *si = HYPERVISOR_shared_info;
-
-	evi = ev >> EVTCHN_SHIFT;
-	ev &= (1ul << EVTCHN_SHIFT) - 1;
-	return ((si->evtchn_pending[evi] & (1ul << ev)) != 0);
-}
-
-int
-ec_pending_irq(unsigned int irq)
-{
-	int evtchn = irq_evtchn(&irq_info[irq]);
-
-	return (ec_evtchn_pending(evtchn));
-}
-
-void
-ec_clear_irq(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-	int evtchn;
-
-	if (irqp->ii_type == IRQT_DEV_EVTCHN)
-		return;
-
-	ASSERT(irqp->ii_type != IRQT_UNBOUND);
-
-	evtchn = irq_evtchn(irqp);
-
-	ASSERT(EVTCHN_MASKED(evtchn));
-	ec_clear_evtchn(evtchn);
-}
-
-void
-ec_unmask_irq(int irq)
-{
-	ulong_t flags;
-	irq_info_t *irqp = &irq_info[irq];
-
-	flags = intr_clear();
-	switch (irqp->ii_type) {
-	case IRQT_PIRQ:
-		end_pirq(irq);
-		break;
-	case IRQT_DEV_EVTCHN:
-		break;
-	default:
-		ec_unmask_evtchn(irq_evtchn(irqp));
-		break;
-	}
-	intr_restore(flags);
-}
-
-void
-ec_try_unmask_irq(int irq)
-{
-	ulong_t flags;
-	irq_info_t *irqp = &irq_info[irq];
-	int evtchn;
-
-	flags = intr_clear();
-	switch (irqp->ii_type) {
-	case IRQT_PIRQ:
-		end_pirq(irq);
-		break;
-	case IRQT_DEV_EVTCHN:
-		break;
-	default:
-		if ((evtchn = irq_evtchn(irqp)) != 0)
-			ec_unmask_evtchn(evtchn);
-		break;
-	}
-	intr_restore(flags);
-}
-
-/*
- * Poll until an event channel is ready or 'check_func' returns true.  This can
- * only be used in a situation where interrupts are masked, otherwise we have a
- * classic time-of-check vs. time-of-use race.
- */
-void
-ec_wait_on_evtchn(int evtchn, int (*check_func)(void *), void *arg)
-{
-	if (DOMAIN_IS_INITDOMAIN(xen_info)) {
-		while (!check_func(arg))
-			(void) HYPERVISOR_yield();
-		return;
-	}
-
-	ASSERT(CPU->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask != 0);
-
-	for (;;) {
-		evtchn_port_t ports[1];
-
-		ports[0] = evtchn;
-
-		ec_clear_evtchn(evtchn);
-
-		if (check_func(arg))
-			return;
-
-		(void) HYPERVISOR_poll(ports, 1, 0);
-	}
-}
-
-void
-ec_wait_on_ipi(int ipl, int (*check_func)(void *), void *arg)
-{
-	mec_info_t *ipip = &ipi_info[ipl];
-
-	if (ipip->mi_irq == INVALID_IRQ || ipip->mi_irq == 0)
-		return;
-
-	ec_wait_on_evtchn(ipip->mi_evtchns[CPU->cpu_id], check_func, arg);
-}
-
-void
-ec_suspend(void)
-{
-	irq_info_t *irqp;
-	ushort_t *evtchnp;
-	int i;
-	int c;
-
-	ASSERT(MUTEX_HELD(&ec_lock));
-
-	for (i = 0; i < MAXIPL; i++) {
-		if (ipi_info[i].mi_irq == INVALID_IRQ)
-			continue;
-
-		for (c = 0; c < NCPU; c++) {
-			if (cpu[c] == NULL)
-				continue;
-
-			if (CPU_IN_SET(cpu_suspend_lost_set, c))
-				continue;
-
-			evtchnp = &ipi_info[i].mi_evtchns[c];
-			ASSERT(*evtchnp != 0);
-			unbind_evtchn(evtchnp);
-		}
-	}
-
-	for (i = 0; i < NR_VIRQS; i++) {
-		if (virq_info[i].mi_irq == INVALID_IRQ)
-			continue;
-
-		/*
-		 * If we're sharing a single event channel across all CPUs, we
-		 * should only unbind once.
-		 */
-		if (virq_info[i].mi_shared) {
-			evtchnp = &virq_info[i].mi_evtchns[0];
-			unbind_evtchn(evtchnp);
-			for (c = 1; c < NCPU; c++)
-				virq_info[i].mi_evtchns[c] = 0;
-		} else {
-			for (c = 0; c < NCPU; c++) {
-				if (cpu[c] == NULL)
-					continue;
-
-				evtchnp = &virq_info[i].mi_evtchns[c];
-				if (*evtchnp != 0)
-					unbind_evtchn(evtchnp);
-			}
-		}
-	}
-
-	for (i = 0; i < NR_IRQS; i++) {
-		irqp = &irq_info[i];
-
-		switch (irqp->ii_type) {
-		case IRQT_EVTCHN:
-		case IRQT_DEV_EVTCHN:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-			break;
-		case IRQT_PIRQ:
-			if (irqp->ii_u.evtchn != 0)
-				(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-			break;
-		default:
-			break;
-		}
-	}
-}
-
-/*
- * The debug irq is special, we only have one evtchn and irq but we allow all
- * cpus to service it.  It's marked as shared and we propogate the event
- * channel into all CPUs by hand.
- */
-static void
-share_virq(mec_info_t *virqp)
-{
-	int evtchn = virqp->mi_evtchns[0];
-	cpuset_t tset;
-	int i;
-
-	ASSERT(evtchn != 0);
-
-	virqp->mi_shared = 1;
-
-	for (i = 1; i < NCPU; i++)
-		virqp->mi_evtchns[i] = evtchn;
-	CPUSET_ALL(tset);
-	bind_evtchn_to_cpuset(evtchn, tset);
-}
-
-static void
-virq_resume(int virq)
-{
-	mec_info_t *virqp = &virq_info[virq];
-	int evtchn;
-	int i, err;
-
-	for (i = 0; i < NCPU; i++) {
-		cpuset_t tcpus;
-
-		if (cpu[i] == NULL || CPU_IN_SET(cpu_suspend_lost_set, i))
-			continue;
-
-		err = xen_bind_virq(virq, i, &evtchn);
-		ASSERT(err == 0);
-
-		virqp->mi_evtchns[i] = evtchn;
-		evtchn_to_irq[evtchn] = virqp->mi_irq;
-		CPUSET_ONLY(tcpus, i);
-		bind_evtchn_to_cpuset(evtchn, tcpus);
-		ec_unmask_evtchn(evtchn);
-		/*
-		 * only timer VIRQ is bound to all cpus
-		 */
-		if (virq != VIRQ_TIMER)
-			break;
-	}
-
-	if (virqp->mi_shared)
-		share_virq(virqp);
-}
-
-static void
-ipi_resume(int ipl)
-{
-	mec_info_t *ipip = &ipi_info[ipl];
-	int i;
-
-	for (i = 0; i < NCPU; i++) {
-		cpuset_t tcpus;
-		int evtchn;
-
-		if (cpu[i] == NULL || CPU_IN_SET(cpu_suspend_lost_set, i))
-			continue;
-
-		evtchn = xen_bind_ipi(i);
-		ipip->mi_evtchns[i] = evtchn;
-		evtchn_to_irq[evtchn] = ipip->mi_irq;
-		CPUSET_ONLY(tcpus, i);
-		bind_evtchn_to_cpuset(evtchn, tcpus);
-		ec_unmask_evtchn(evtchn);
-	}
-}
-
-void
-ec_resume(void)
-{
-	int i;
-
-	/* New event-channel space is not 'live' yet. */
-	for (i = 0; i < NR_EVENT_CHANNELS; i++)
-		(void) ec_mask_evtchn(i);
-
-	for (i = 0; i < MAXIPL; i++) {
-		if (ipi_info[i].mi_irq == INVALID_IRQ)
-			continue;
-		ipi_resume(i);
-	}
-
-	for (i = 0; i < NR_VIRQS; i++) {
-		if (virq_info[i].mi_irq == INVALID_IRQ)
-			continue;
-		virq_resume(i);
-	}
-}
-
-int
-ec_init(void)
-{
-	int i;
-	mutex_init(&ec_lock, NULL, MUTEX_SPIN, (void *)ipltospl(SPL7));
-
-	for (i = 0; i < NR_EVENT_CHANNELS; i++) {
-		CPUSET_ZERO(evtchn_cpus[i]);
-		evtchn_to_irq[i] = INVALID_IRQ;
-		(void) ec_mask_evtchn(i);
-	}
-
-	for (i = 0; i < MAXIPL; i++)
-		ipi_info[i].mi_irq = INVALID_IRQ;
-
-	for (i = 0; i < NR_VIRQS; i++)
-		virq_info[i].mi_irq = INVALID_IRQ;
-
-	/*
-	 * Phys IRQ space is statically bound (1:1 mapping), grab the IRQs
-	 * now.
-	 */
-	for (i = PIRQ_BASE; i < NR_PIRQS; i++) {
-		irq_info[PIRQ_TO_IRQ(i)].ii_type = IRQT_PIRQ;
-	}
-
-	return (0);
-}
-
-void
-ec_init_debug_irq()
-{
-	int irq;
-
-	irq = ec_bind_virq_to_irq(VIRQ_DEBUG, 0);
-	(void) add_avintr(NULL, IPL_DEBUG, (avfunc)xen_debug_handler,
-	    "debug", irq, NULL, NULL, NULL, NULL);
-
-	mutex_enter(&ec_lock);
-	share_virq(&virq_info[irq_info[irq].ii_u.index]);
-	mutex_exit(&ec_lock);
-	ec_debug_irq = irq;
-}
-
-#define	UNBLOCKED_EVENTS(si, ix, cpe, cpu_id) \
-	((si)->evtchn_pending[ix] & ~(si)->evtchn_mask[ix] & \
-		(cpe)->evt_affinity[ix])
-
-
-/*
- * This is the entry point for processing events from xen
- *
- * (See the commentary associated with the shared_info_st structure
- * in hypervisor-if.h)
- *
- * Since the event channel mechanism doesn't really implement the
- * concept of priority like hardware interrupt controllers, we simulate
- * that in software here using the cpu priority field and the pending
- * interrupts field.  Events/interrupts that are not able to be serviced
- * now because they are at a lower priority than the current cpu priority
- * cause a level bit to be recorded in the pending interrupts word.  When
- * the priority is lowered (either by spl or interrupt exit code) the pending
- * levels are checked and an upcall is scheduled if there are events/interrupts
- * that have become deliverable.
- */
-void
-xen_callback_handler(struct regs *rp, trap_trace_rec_t *ttp)
-{
-	ulong_t pending_sels, pe, selbit;
-	int i, j, port, pri, curpri, irq, sipri;
-	uint16_t pending_ints, sip;
-	struct cpu *cpu = CPU;
-	volatile shared_info_t *si = HYPERVISOR_shared_info;
-	volatile vcpu_info_t *vci = cpu->cpu_m.mcpu_vcpu_info;
-	volatile struct xen_evt_data *cpe = cpu->cpu_m.mcpu_evt_pend;
-	volatile uint16_t *cpu_ipp = &cpu->cpu_m.mcpu_intr_pending;
-	extern void dosoftint(struct regs *);
-
-	ASSERT(rp->r_trapno == T_AST && rp->r_err == 0);
-	ASSERT(&si->vcpu_info[cpu->cpu_id] == vci);
-	ASSERT_STACK_ALIGNED();
-
-	vci->evtchn_upcall_pending = 0;
-
-	/*
-	 * To expedite scanning of pending notifications, any 0->1
-	 * pending transition on an unmasked channel causes a
-	 * corresponding bit in evtchn_pending_sel to be set.
-	 * Each bit in the selector covers a 32-bit word in
-	 * the evtchn_pending[] array.
-	 */
-	membar_enter();
-	do {
-		pending_sels = vci->evtchn_pending_sel;
-	} while (atomic_cas_ulong((volatile ulong_t *)&vci->evtchn_pending_sel,
-	    pending_sels, 0) != pending_sels);
-
-	pending_ints = *cpu_ipp;
-	while ((i = ffs(pending_sels)) != 0) {
-		i--;
-		selbit = 1ul << i;
-		pending_sels &= ~selbit;
-
-		membar_enter();
-		while ((pe = UNBLOCKED_EVENTS(si, i, cpe, cpu->cpu_id)) != 0) {
-			j = ffs(pe) - 1;
-			pe &= ~(1ul << j);
-
-			port = (i << EVTCHN_SHIFT) + j;
-
-			irq = evtchn_to_irq[port];
-
-			/*
-			 * If no irq set, just ignore the event.
-			 * On e.g. netbsd they call evtchn_device_upcall(port)
-			 * We require the evtchn driver to install a handler
-			 * so there will be an irq associated with user mode
-			 * evtchns.
-			 */
-			if (irq == INVALID_IRQ) {
-				ec_clear_evtchn(port);
-				continue;
-			}
-
-			/*
-			 * If there's no handler, it could be a poke, so just
-			 * accept the event and continue.
-			 */
-			if (!irq_info[irq].ii_u2.has_handler) {
-#ifdef TRAPTRACE
-				ttp->ttr_ipl = 0xff;
-				if (IRQ_IS_CPUPOKE(irq)) {
-					ttp->ttr_ipl = XC_CPUPOKE_PIL;
-					ttp->ttr_marker = TT_INTERRUPT;
-				}
-				ttp->ttr_pri = cpu->cpu_pri;
-				ttp->ttr_spl = cpu->cpu_base_spl;
-				ttp->ttr_vector = 0xff;
-#endif /* TRAPTRACE */
-				if (ec_mask_evtchn(port)) {
-					ec_clear_evtchn(port);
-					ec_unmask_evtchn(port);
-					continue;
-				}
-			}
-
-			pri = irq_info[irq].ii_u2.ipl;
-
-			/*
-			 * If we are the cpu that successfully masks
-			 * the event, then record it as a pending event
-			 * for this cpu to service
-			 */
-			if (ec_mask_evtchn(port)) {
-				if (ec_evtchn_pending(port)) {
-					cpe->pending_sel[pri] |= selbit;
-					cpe->pending_evts[pri][i] |= (1ul << j);
-					pending_ints |= 1 << pri;
-					/*
-					 * We have recorded a pending interrupt
-					 * for this cpu.  If it is an edge
-					 * triggered interrupt then we go ahead
-					 * and clear the pending and mask bits
-					 * from the shared info to avoid having
-					 * the hypervisor see the pending event
-					 * again and possibly disabling the
-					 * interrupt.  This should also help
-					 * keep us from missing an interrupt.
-					 */
-					if (ec_is_edge_pirq(irq)) {
-						ec_clear_evtchn(port);
-						ec_unmask_evtchn(port);
-					}
-				} else {
-					/*
-					 * another cpu serviced this event
-					 * before us, clear the mask.
-					 */
-					ec_unmask_evtchn(port);
-				}
-			}
-		}
-	}
-	*cpu_ipp = pending_ints;
-	if (pending_ints == 0)
-		return;
-	/*
-	 * We have gathered all the pending events/interrupts,
-	 * go service all the ones we can from highest priority to lowest.
-	 * Note: This loop may not actually complete and service all
-	 * pending interrupts since one of the interrupt threads may
-	 * block and the pinned thread runs.  In that case, when we
-	 * exit the interrupt thread that blocked we will check for
-	 * any unserviced interrupts and re-post an upcall to process
-	 * any unserviced pending events.
-	 */
-restart:
-	curpri = cpu->cpu_pri;
-	pri = bsrw_insn(*cpu_ipp);
-	while (pri > curpri) {
-		while ((pending_sels = cpe->pending_sel[pri]) != 0) {
-			i = ffs(pending_sels) - 1;
-			while ((pe = cpe->pending_evts[pri][i]) != 0) {
-				j = ffs(pe) - 1;
-				port = (i << EVTCHN_SHIFT) + j;
-				pe &= ~(1ul << j);
-				cpe->pending_evts[pri][i] = pe;
-				if (pe == 0) {
-					/*
-					 * Must reload pending selector bits
-					 * here as they could have changed on
-					 * a previous trip around the inner loop
-					 * while we were interrupt enabled
-					 * in a interrupt service routine.
-					 */
-					pending_sels = cpe->pending_sel[pri];
-					pending_sels &= ~(1ul << i);
-					cpe->pending_sel[pri] = pending_sels;
-					if (pending_sels == 0)
-						*cpu_ipp &= ~(1 << pri);
-				}
-				irq = evtchn_to_irq[port];
-				if (irq == INVALID_IRQ) {
-					/*
-					 * No longer a handler for this event
-					 * channel.  Clear the event and
-					 * ignore it, unmask the event.
-					 */
-					ec_clear_evtchn(port);
-					ec_unmask_evtchn(port);
-					continue;
-				}
-				if (irq == ec_dev_irq) {
-					ASSERT(cpu->cpu_m.mcpu_ec_mbox == 0);
-					cpu->cpu_m.mcpu_ec_mbox = port;
-				}
-				/*
-				 * Set up the regs struct to
-				 * look like a normal hardware int
-				 * and do normal interrupt handling.
-				 */
-				rp->r_trapno = irq;
-				do_interrupt(rp, ttp);
-				/*
-				 * Check for cpu priority change
-				 * Can happen if int thread blocks
-				 */
-				if (cpu->cpu_pri != curpri)
-					goto restart;
-			}
-		}
-		/*
-		 * Dispatch any soft interrupts that are
-		 * higher priority than any hard ones remaining.
-		 */
-		pri = bsrw_insn(*cpu_ipp);
-		sip = (uint16_t)cpu->cpu_softinfo.st_pending;
-		if (sip != 0) {
-			sipri = bsrw_insn(sip);
-			if (sipri > pri && sipri > cpu->cpu_pri) {
-				dosoftint(rp);
-				/*
-				 * Check for cpu priority change
-				 * Can happen if softint thread blocks
-				 */
-				if (cpu->cpu_pri != curpri)
-					goto restart;
-			}
-		}
-	}
-	/*
-	 * Deliver any pending soft interrupts.
-	 */
-	if (cpu->cpu_softinfo.st_pending)
-		dosoftint(rp);
-}
-
-
-void
-ec_unmask_evtchn(unsigned int ev)
-{
-	uint_t evi, evb;
-	volatile shared_info_t *si = HYPERVISOR_shared_info;
-	volatile vcpu_info_t *vci = CPU->cpu_m.mcpu_vcpu_info;
-	volatile ulong_t *ulp;
-
-	ASSERT(!interrupts_enabled());
-	/*
-	 * Check if we need to take slow path
-	 */
-	if (!CPU_IN_SET(evtchn_cpus[ev], CPU->cpu_id)) {
-		xen_evtchn_unmask(ev);
-		return;
-	}
-	evi = ev >> EVTCHN_SHIFT;
-	evb = ev & ((1ul << EVTCHN_SHIFT) - 1);
-	ulp = (volatile ulong_t *)&si->evtchn_mask[evi];
-	atomic_and_ulong(ulp, ~(1ul << evb));
-	/*
-	 * The following is basically the equivalent of
-	 * 'hw_resend_irq'. Just like a real IO-APIC we 'lose the
-	 * interrupt edge' if the channel is masked.
-	 * XXPV - slight race if upcall was about to be set, we may get
-	 * an extra upcall.
-	 */
-	membar_enter();
-	if (si->evtchn_pending[evi] & (1ul << evb)) {
-		membar_consumer();
-		ulp = (volatile ulong_t *)&vci->evtchn_pending_sel;
-		if (!(*ulp & (1ul << evi))) {
-			atomic_or_ulong(ulp, (1ul << evi));
-		}
-		vci->evtchn_upcall_pending = 1;
-	}
-}
-
-/*
- * Set a bit in an evtchan mask word, return true if we are the cpu that
- * set the bit.
- */
-int
-ec_mask_evtchn(unsigned int ev)
-{
-	uint_t evi, evb;
-	ulong_t new, old, bit;
-	volatile shared_info_t *si = HYPERVISOR_shared_info;
-	volatile ulong_t *maskp;
-	int masked;
-
-	kpreempt_disable();
-	evi = ev >> EVTCHN_SHIFT;
-	evb = ev & ((1ul << EVTCHN_SHIFT) - 1);
-	bit = 1ul << evb;
-	maskp = (volatile ulong_t *)&si->evtchn_mask[evi];
-	do {
-		old = si->evtchn_mask[evi];
-		new = old | bit;
-	} while (atomic_cas_ulong(maskp, old, new) != old);
-	masked = (old & bit) == 0;
-	if (masked) {
-		evtchn_owner[ev] = CPU->cpu_id;
-#ifdef DEBUG
-		evtchn_owner_thread[ev] = curthread;
-#endif
-	}
-	kpreempt_enable();
-	return (masked);
-}
-
-void
-ec_clear_evtchn(unsigned int ev)
-{
-	uint_t evi;
-	shared_info_t *si = HYPERVISOR_shared_info;
-	volatile ulong_t *pendp;
-
-	evi = ev >> EVTCHN_SHIFT;
-	ev &= (1ul << EVTCHN_SHIFT) - 1;
-	pendp = (volatile ulong_t *)&si->evtchn_pending[evi];
-	atomic_and_ulong(pendp, ~(1ul << ev));
-}
-
-void
-ec_notify_via_evtchn(unsigned int port)
-{
-	evtchn_send_t send;
-
-	ASSERT(port != INVALID_EVTCHN);
-
-	send.port = port;
-	(void) HYPERVISOR_event_channel_op(EVTCHNOP_send, &send);
-}
-
-int
-ec_block_irq(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-	int evtchn;
-
-
-	evtchn = irq_evtchn(irqp);
-	(void) ec_mask_evtchn(evtchn);
-	return (evtchn_owner[evtchn]);
-}
-
-/*
- * Make a event that is pending for delivery on the current cpu  "go away"
- * without servicing the interrupt.
- */
-void
-ec_unpend_irq(int irq)
-{
-	irq_info_t *irqp = &irq_info[irq];
-	int pri = irqp->ii_u2.ipl;
-	ulong_t flags;
-	uint_t evtchn, evi, bit;
-	unsigned long pe, pending_sels;
-	struct xen_evt_data *cpe;
-
-	/*
-	 * The evtchn must be masked
-	 */
-	evtchn = irq_evtchn(irqp);
-	ASSERT(EVTCHN_MASKED(evtchn));
-	evi = evtchn >> EVTCHN_SHIFT;
-	bit = evtchn & (1ul << EVTCHN_SHIFT) - 1;
-	flags = intr_clear();
-	cpe = CPU->cpu_m.mcpu_evt_pend;
-	pe = cpe->pending_evts[pri][evi] & ~(1ul << bit);
-	cpe->pending_evts[pri][evi] = pe;
-	if (pe == 0) {
-		pending_sels = cpe->pending_sel[pri];
-		pending_sels &= ~(1ul << evi);
-		cpe->pending_sel[pri] = pending_sels;
-		if (pending_sels == 0)
-			CPU->cpu_m.mcpu_intr_pending &= ~(1 << pri);
-	}
-	intr_restore(flags);
-}
--- old/usr/src/uts/i86xpv/os/mach_kdi.c	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-/*
- * Kernel/Debugger Interface (KDI) routines.  Called during debugger under
- * various system states (boot, while running, while the debugger has control).
- * Functions intended for use while the debugger has control may not grab any
- * locks or perform any functions that assume the availability of other system
- * services.
- */
-
-#include <sys/systm.h>
-#include <sys/x86_archext.h>
-#include <sys/kdi_impl.h>
-#include <sys/smp_impldefs.h>
-#include <sys/psm_types.h>
-#include <sys/segments.h>
-#include <sys/archsystm.h>
-#include <sys/controlregs.h>
-#include <sys/trap.h>
-#include <sys/kobj.h>
-#include <sys/kobj_impl.h>
-#include <sys/hypervisor.h>
-#include <sys/bootconf.h>
-#include <sys/bootinfo.h>
-#include <sys/promif.h>
-#include <sys/evtchn_impl.h>
-#include <sys/cpu.h>
-#include <vm/kboot_mmu.h>
-#include <vm/hat_pte.h>
-
-static volatile int kdi_slaves_go;
-
-/*
- * These are not safe against dropping into kmdb when fbt::: is active. This is
- * also broken on i86pc...
- */
-
-void
-kdi_idtr_write(desctbr_t *idtr)
-{
-	gate_desc_t *idt = (gate_desc_t *)idtr->dtr_base;
-	uint_t nidt = (idtr->dtr_limit + 1) / sizeof (*idt);
-	uint_t vec;
-
-	for (vec = 0; vec < nidt; vec++, idt++)
-		xen_idt_write(idt, vec);
-}
-
-void
-kdi_idt_write(gate_desc_t *gate, uint_t vec)
-{
-	gate_desc_t *idt = CPU->cpu_m.mcpu_idt;
-
-	/*
-	 * See kdi_idtr_set().
-	 */
-	if (idt != NULL)
-		idt[vec] = *gate;
-
-	xen_idt_write(gate, vec);
-}
-
-ulong_t
-kdi_dreg_get(int reg)
-{
-	return (__hypercall1(__HYPERVISOR_get_debugreg, (long)reg));
-}
-
-void
-kdi_dreg_set(int reg, ulong_t value)
-{
-	(void) __hypercall2(__HYPERVISOR_set_debugreg, (long)reg, value);
-}
-
-void
-kdi_flush_caches(void)
-{
-}
-
-/*
- * To avoid domains sucking up CPU while sitting in kmdb, we make all the slave
- * CPUs wait for a wake-up evtchn.  The master CPU, meanwhile, sleeps for
- * console activity.
- */
-
-extern void kdi_slave_entry(void);
-
-void
-kdi_stop_slaves(int cpu, int doxc)
-{
-	if (doxc)
-		kdi_xc_others(cpu, kdi_slave_entry);
-	kdi_slaves_go = 0;
-}
-
-void
-kdi_start_slaves(void)
-{
-	int c;
-
-	kdi_slaves_go = 1;
-
-	for (c = 0; c < NCPU; c++) {
-		if (cpu[c] == NULL || !(cpu[c]->cpu_flags & CPU_READY))
-			continue;
-		ec_try_ipi(XC_CPUPOKE_PIL, c);
-	}
-}
-
-/*ARGSUSED*/
-static int
-check_slave(void *arg)
-{
-	return (kdi_slaves_go == 1);
-}
-
-void
-kdi_slave_wait(void)
-{
-	if (!(cpu[CPU->cpu_id]->cpu_flags & CPU_READY))
-		return;
-
-	ec_wait_on_ipi(XC_CPUPOKE_PIL, check_slave, NULL);
-}
-
-/*
- * Caution.
- * These routines are called -extremely- early, during kmdb initialization.
- *
- * Many common kernel functions assume that %gs has been initialized,
- * and fail horribly if it hasn't.  At this point, the boot code has
- * reserved a descriptor for us (KMDBGS_SEL) in it's GDT; arrange for it
- * to point at a dummy cpu_t, temporarily at least.
- *
- * Note that kmdb entry relies on the fake cpu_t having zero cpu_idt/cpu_id.
- */
-
-#if defined(__amd64)
-
-void *
-boot_kdi_tmpinit(void)
-{
-	cpu_t *cpu = kobj_zalloc(sizeof (*cpu), KM_TMP);
-	user_desc_t *bgdt;
-	uint64_t gdtpa;
-	ulong_t ma[1];
-
-	cpu->cpu_self = cpu;
-
-	/*
-	 * (Note that we had better switch to a -new- GDT before
-	 * we discard the KM_TMP mappings, or disaster will ensue.)
-	 */
-	bgdt = kobj_zalloc(PAGESIZE, KM_TMP);
-	ASSERT(((uintptr_t)bgdt & PAGEOFFSET) == 0);
-
-	init_boot_gdt(bgdt);
-
-	gdtpa = pfn_to_pa(va_to_pfn(bgdt));
-	ma[0] = (ulong_t)(pa_to_ma(gdtpa) >> PAGESHIFT);
-	kbm_read_only((uintptr_t)bgdt, gdtpa);
-	if (HYPERVISOR_set_gdt(ma, PAGESIZE / sizeof (user_desc_t)))
-		panic("boot_kdi_tmpinit:HYPERVISOR_set_gdt() failed");
-
-	load_segment_registers(B64CODE_SEL, 0, 0, B32DATA_SEL);
-
-	/*
-	 * Now point %gsbase to our temp cpu structure.
-	 */
-	xen_set_segment_base(SEGBASE_GS_KERNEL, (ulong_t)cpu);
-	return (0);
-}
-
-/*ARGSUSED*/
-void
-boot_kdi_tmpfini(void *old)
-{
-	/*
-	 * This breaks, why do we need it anyway?
-	 */
-#if 0	/* XXPV */
-	load_segment_registers(B64CODE_SEL, 0, KMDBGS_SEL, B32DATA_SEL);
-#endif
-}
-
-#elif defined(__i386)
-
-/*
- * Sigh.  We're called before we've initialized the kernels GDT, living
- * off the hypervisor's default GDT.  For kmdb's sake, we switch now to
- * a GDT that looks like dboot's GDT; very shortly we'll initialize and
- * switch to the kernel's GDT.
- */
-
-void *
-boot_kdi_tmpinit(void)
-{
-	cpu_t *cpu = kobj_zalloc(sizeof (*cpu), KM_TMP);
-	user_desc_t *bgdt;
-	uint64_t gdtpa;
-	ulong_t ma[1];
-
-	cpu->cpu_self = cpu;
-
-	/*
-	 * (Note that we had better switch to a -new- GDT before
-	 * we discard the KM_TMP mappings, or disaster will ensue.)
-	 */
-	bgdt = kobj_zalloc(PAGESIZE, KM_TMP);
-
-	ASSERT(((uintptr_t)bgdt & PAGEOFFSET) == 0);
-	gdtpa = pfn_to_pa(va_to_pfn(bgdt));
-
-	init_boot_gdt(bgdt);
-
-	set_usegd(&bgdt[GDT_BGSTMP],
-	    cpu, sizeof (*cpu), SDT_MEMRWA, SEL_KPL, SDP_BYTES, SDP_OP32);
-
-	ma[0] = (ulong_t)(pa_to_ma(gdtpa) >> PAGESHIFT);
-	kbm_read_only((uintptr_t)bgdt, gdtpa);
-	if (HYPERVISOR_set_gdt(ma, PAGESIZE / sizeof (user_desc_t)))
-		panic("boot_kdi_tmpinit:HYPERVISOR_set_gdt() failed");
-
-	load_segment_registers(B32CODE_SEL, B32DATA_SEL, B32DATA_SEL, 0,
-	    KMDBGS_SEL, B32DATA_SEL);
-	return (0);
-}
-
-/*ARGSUSED*/
-void
-boot_kdi_tmpfini(void *old)
-{
-	load_segment_registers(B32CODE_SEL, B32DATA_SEL, B32DATA_SEL, 0,
-	    0, B32DATA_SEL);
-}
-
-#endif	/* __i386 */
--- old/usr/src/uts/i86xpv/os/mp_xen.c	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,1059 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Virtual CPU management.
- *
- * VCPUs can be controlled in one of two ways; through the domain itself
- * (psradm, p_online(), etc.), and via changes in xenstore (vcpu_config()).
- * Unfortunately, the terminology is used in different ways; they work out as
- * follows:
- *
- * P_ONLINE: the VCPU is up and running, taking interrupts and running threads
- *
- * P_OFFLINE: the VCPU is up and running, but quiesced (i.e. blocked in the
- * hypervisor on the idle thread).  It must be up since a downed VCPU cannot
- * receive interrupts, and we require this for offline CPUs in Solaris.
- *
- * P_POWEROFF: the VCPU is down (we never called xen_vcpu_up(), or called
- * xen_vcpu_down() for it).  It can't take interrupts or run anything, though
- * if it has run previously, its software state (cpu_t, machcpu structures, IPI
- * event channels, etc.) will still exist.
- *
- * The hypervisor has two notions of CPU states as represented in the store:
- *
- * "offline": the VCPU is down.  Corresponds to P_POWEROFF.
- *
- * "online": the VCPU is running.  Corresponds to a CPU state other than
- * P_POWEROFF.
- *
- * Currently, only a notification via xenstore can bring a CPU into a
- * P_POWEROFF state, and only the domain can change between P_ONLINE, P_NOINTR,
- * P_OFFLINE, etc.  We need to be careful to treat xenstore notifications
- * idempotently, as we'll get 'duplicate' entries when we resume a domain.
- *
- * Note that the xenstore configuration is strictly advisory, in that a domain
- * can choose to ignore it and still power up a VCPU in the offline state. To
- * play nice, we don't allow it. Thus, any attempt to power on/off a CPU is
- * ENOTSUP from within Solaris.
- *
- * Powering off a VCPU and suspending the domain use similar code. The
- * difficulty here is that we must ensure that each VCPU is in a stable
- * state: it must have a saved PCB, and not be responding to interrupts
- * (since we are just about to remove its ability to run on a real CPU,
- * possibly forever).  However, an offline CPU in Solaris can take
- * cross-call interrupts, as mentioned, so we must go through a
- * two-stage process.  First, we use the standard Solaris pause_cpus().
- * This ensures that all CPUs are either in mach_cpu_pause() or
- * mach_cpu_idle(), and nothing will cross-call them.
- *
- * Powered-off-CPUs are already safe, as we own the cpu_lock needed to
- * bring them back up, and in state CPU_PHASE_POWERED_OFF.
- *
- * Running CPUs are spinning in mach_cpu_pause() waiting for either
- * PAUSE_IDLE or CPU_PHASE_WAIT_SAFE.
- *
- * Offline CPUs are either running the idle thread and periodically
- * checking for CPU_PHASE_WAIT_SAFE, or blocked in the hypervisor.
- *
- * Thus, we set CPU_PHASE_WAIT_SAFE for every powered-on CPU, as well as
- * poking them to make sure they're not blocked[1]. When every CPU has
- * responded by reaching a safe state and setting CPU_PHASE_SAFE, we
- * know we can suspend, or power-off a CPU, without problems.
- *
- * [1] note that we have to repeatedly poke offline CPUs: it's the only
- * way to ensure that the CPU doesn't miss the state change before
- * dropping into HYPERVISOR_block().
- */
-
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/param.h>
-#include <sys/taskq.h>
-#include <sys/cmn_err.h>
-#include <sys/archsystm.h>
-#include <sys/machsystm.h>
-#include <sys/segments.h>
-#include <sys/cpuvar.h>
-#include <sys/x86_archext.h>
-#include <sys/controlregs.h>
-#include <sys/hypervisor.h>
-#include <sys/xpv_panic.h>
-#include <sys/mman.h>
-#include <sys/psw.h>
-#include <sys/cpu.h>
-#include <sys/sunddi.h>
-#include <util/sscanf.h>
-#include <vm/hat_i86.h>
-#include <vm/hat.h>
-#include <vm/as.h>
-
-#include <xen/public/io/xs_wire.h>
-#include <xen/sys/xenbus_impl.h>
-#include <xen/public/vcpu.h>
-
-extern cpuset_t cpu_ready_set;
-
-#define	CPU_PHASE_NONE 0
-#define	CPU_PHASE_WAIT_SAFE 1
-#define	CPU_PHASE_SAFE 2
-#define	CPU_PHASE_POWERED_OFF 3
-
-/*
- * We can only poke CPUs during barrier enter 256 times a second at
- * most.
- */
-#define	POKE_TIMEOUT (NANOSEC / 256)
-
-static taskq_t *cpu_config_tq;
-static int cpu_phase[NCPU];
-
-static void vcpu_config_event(struct xenbus_watch *, const char **, uint_t);
-static int xen_vcpu_initialize(processorid_t, vcpu_guest_context_t *);
-
-/*
- * Return whether or not the vcpu is actually running on a pcpu
- */
-int
-vcpu_on_pcpu(processorid_t cpu)
-{
-	struct vcpu_runstate_info runstate;
-	int	ret = VCPU_STATE_UNKNOWN;
-
-	ASSERT(cpu < NCPU);
-	/*
-	 * Don't bother with hypercall if we are asking about ourself
-	 */
-	if (cpu == CPU->cpu_id)
-		return (VCPU_ON_PCPU);
-	if (HYPERVISOR_vcpu_op(VCPUOP_get_runstate_info, cpu, &runstate) != 0)
-		goto out;
-
-	switch (runstate.state) {
-	case RUNSTATE_running:
-		ret = VCPU_ON_PCPU;
-		break;
-
-	case RUNSTATE_runnable:
-	case RUNSTATE_offline:
-	case RUNSTATE_blocked:
-		ret = VCPU_NOT_ON_PCPU;
-		break;
-
-	default:
-		break;
-	}
-
-out:
-	return (ret);
-}
-
-/*
- * These routines allocate any global state that might be needed
- * while starting cpus.  For virtual cpus, there is no such state.
- */
-int
-mach_cpucontext_init(void)
-{
-	return (0);
-}
-
-void
-do_cpu_config_watch(int state)
-{
-	static struct xenbus_watch cpu_config_watch;
-
-	if (state != XENSTORE_UP)
-		return;
-	cpu_config_watch.node = "cpu";
-	cpu_config_watch.callback = vcpu_config_event;
-	if (register_xenbus_watch(&cpu_config_watch)) {
-		taskq_destroy(cpu_config_tq);
-		cmn_err(CE_WARN, "do_cpu_config_watch: "
-		    "failed to set vcpu config watch");
-	}
-
-}
-
-/*
- * This routine is called after all the "normal" MP startup has
- * been done; a good place to start watching xen store for virtual
- * cpu hot plug events.
- */
-void
-mach_cpucontext_fini(void)
-{
-
-	cpu_config_tq = taskq_create("vcpu config taskq", 1,
-	    maxclsyspri - 1, 1, 1, TASKQ_PREPOPULATE);
-
-	(void) xs_register_xenbus_callback(do_cpu_config_watch);
-}
-
-/*
- * Fill in the remaining CPU context and initialize it.
- */
-static int
-mp_set_cpu_context(vcpu_guest_context_t *vgc, cpu_t *cp)
-{
-	uint_t vec, iopl;
-
-	vgc->flags = VGCF_IN_KERNEL;
-
-	/*
-	 * fpu_ctx we leave as zero; on first fault we'll store
-	 * sse_initial into it anyway.
-	 */
-
-#if defined(__amd64)
-	vgc->user_regs.cs = KCS_SEL | SEL_KPL;	/* force to ring 3 */
-#else
-	vgc->user_regs.cs = KCS_SEL;
-#endif
-	vgc->user_regs.ds = KDS_SEL;
-	vgc->user_regs.es = KDS_SEL;
-	vgc->user_regs.ss = KDS_SEL;
-	vgc->kernel_ss = KDS_SEL;
-
-	/*
-	 * Allow I/O privilege level for Dom0 kernel.
-	 */
-	if (DOMAIN_IS_INITDOMAIN(xen_info))
-		iopl = (PS_IOPL & 0x1000); /* ring 1 */
-	else
-		iopl = 0;
-
-#if defined(__amd64)
-	vgc->user_regs.fs = 0;
-	vgc->user_regs.gs = 0;
-	vgc->user_regs.rflags = F_OFF | iopl;
-#elif defined(__i386)
-	vgc->user_regs.fs = KFS_SEL;
-	vgc->user_regs.gs = KGS_SEL;
-	vgc->user_regs.eflags = F_OFF | iopl;
-	vgc->event_callback_cs = vgc->user_regs.cs;
-	vgc->failsafe_callback_cs = vgc->user_regs.cs;
-#endif
-
-	/*
-	 * Initialize the trap_info_t from the IDT
-	 */
-#if !defined(__lint)
-	ASSERT(NIDT == sizeof (vgc->trap_ctxt) / sizeof (vgc->trap_ctxt[0]));
-#endif
-	for (vec = 0; vec < NIDT; vec++) {
-		trap_info_t *ti = &vgc->trap_ctxt[vec];
-
-		if (xen_idt_to_trap_info(vec,
-		    &cp->cpu_m.mcpu_idt[vec], ti) == 0) {
-			ti->cs = KCS_SEL;
-			ti->vector = vec;
-		}
-	}
-
-	/*
-	 * No LDT
-	 */
-
-	/*
-	 * (We assert in various places that the GDT is (a) aligned on a
-	 * page boundary and (b) one page long, so this really should fit..)
-	 */
-#ifdef CRASH_XEN
-	vgc->gdt_frames[0] = pa_to_ma(mmu_btop(cp->cpu_m.mcpu_gdtpa));
-#else
-	vgc->gdt_frames[0] = pfn_to_mfn(mmu_btop(cp->cpu_m.mcpu_gdtpa));
-#endif
-	vgc->gdt_ents = NGDT;
-
-	vgc->ctrlreg[0] = CR0_ENABLE_FPU_FLAGS(getcr0());
-
-#if defined(__i386)
-	if (mmu.pae_hat)
-		vgc->ctrlreg[3] =
-		    xen_pfn_to_cr3(pfn_to_mfn(kas.a_hat->hat_htable->ht_pfn));
-	else
-#endif
-		vgc->ctrlreg[3] =
-		    pa_to_ma(mmu_ptob(kas.a_hat->hat_htable->ht_pfn));
-
-	vgc->ctrlreg[4] = getcr4();
-
-	vgc->event_callback_eip = (uintptr_t)xen_callback;
-	vgc->failsafe_callback_eip = (uintptr_t)xen_failsafe_callback;
-	vgc->flags |= VGCF_failsafe_disables_events;
-
-#if defined(__amd64)
-	/*
-	 * XXPV should this be moved to init_cpu_syscall?
-	 */
-	vgc->syscall_callback_eip = (uintptr_t)sys_syscall;
-	vgc->flags |= VGCF_syscall_disables_events;
-
-	ASSERT(vgc->user_regs.gs == 0);
-	vgc->gs_base_kernel = (uintptr_t)cp;
-#endif
-
-	return (xen_vcpu_initialize(cp->cpu_id, vgc));
-}
-
-/*
- * Create a guest virtual cpu context so that the virtual cpu
- * springs into life in the domain just about to call mp_startup()
- *
- * Virtual CPUs must be initialized once in the lifetime of the domain;
- * after that subsequent attempts to start them will fail with X_EEXIST.
- *
- * Thus 'alloc' -really- creates and initializes the virtual
- * CPU context just once. Once the initialisation succeeds, we never
- * free it, nor the regular cpu_t to which it refers.
- */
-void *
-mach_cpucontext_alloc(struct cpu *cp)
-{
-	kthread_t *tp = cp->cpu_thread;
-	vcpu_guest_context_t vgc;
-
-	int err = 1;
-
-	/*
-	 * First, augment the incoming cpu structure
-	 * - vcpu pointer reference
-	 * - pending event storage area
-	 * - physical address of GDT
-	 */
-	cp->cpu_m.mcpu_vcpu_info =
-	    &HYPERVISOR_shared_info->vcpu_info[cp->cpu_id];
-	cp->cpu_m.mcpu_evt_pend = kmem_zalloc(
-	    sizeof (struct xen_evt_data), KM_SLEEP);
-	cp->cpu_m.mcpu_gdtpa =
-	    mmu_ptob(hat_getpfnum(kas.a_hat, (caddr_t)cp->cpu_gdt));
-
-	if ((err = xen_gdt_setprot(cp, PROT_READ)) != 0)
-		goto done;
-
-	/*
-	 * Now set up the vcpu context so that we can start this vcpu
-	 * in the kernel at tp->t_pc (mp_startup).  Note that the
-	 * thread will thread_exit() shortly after performing the
-	 * initialization; in particular, we will *never* take a
-	 * privilege transition on this thread.
-	 */
-
-	bzero(&vgc, sizeof (vgc));
-
-#ifdef __amd64
-	vgc.user_regs.rip = tp->t_pc;
-	vgc.user_regs.rsp = tp->t_sp;
-	vgc.user_regs.rbp = tp->t_sp - 2 * sizeof (greg_t);
-#else
-	vgc.user_regs.eip = tp->t_pc;
-	vgc.user_regs.esp = tp->t_sp;
-	vgc.user_regs.ebp = tp->t_sp - 2 * sizeof (greg_t);
-#endif
-	/*
-	 * XXPV	Fix resume, if Russ didn't already fix it.
-	 *
-	 * Note that resume unconditionally puts t->t_stk + sizeof (regs)
-	 * into kernel_sp via HYPERVISOR_stack_switch. This anticipates
-	 * that only lwps take traps that switch to the kernel stack;
-	 * part of creating an lwp adjusts the stack by subtracting
-	 * sizeof (struct regs) off t_stk.
-	 *
-	 * The more interesting question is, why do we do all the work
-	 * of a fully fledged lwp for a plain thread?  In particular
-	 * we don't have to call HYPERVISOR_stack_switch for lwp-less threads
-	 * or futz with the LDT.  This should probably all be done with
-	 * an lwp context operator to keep pure thread context switch fast.
-	 */
-	vgc.kernel_sp = (ulong_t)tp->t_stk;
-
-	err = mp_set_cpu_context(&vgc, cp);
-
-done:
-	if (err) {
-		mach_cpucontext_free(cp, NULL, err);
-		return (NULL);
-	}
-	return (cp);
-}
-
-/*
- * By the time we are called either we have successfully started
- * the cpu, or our attempt to start it has failed.
- */
-
-/*ARGSUSED*/
-void
-mach_cpucontext_free(struct cpu *cp, void *arg, int err)
-{
-	switch (err) {
-	case 0:
-		break;
-	case ETIMEDOUT:
-		/*
-		 * The vcpu context is loaded into the hypervisor, and
-		 * we've tried to start it, but the vcpu has not been set
-		 * running yet, for whatever reason.  We arrange to -not-
-		 * free any data structures it may be referencing.  In
-		 * particular, we've already told the hypervisor about
-		 * the GDT, and so we can't map it read-write again.
-		 */
-		break;
-	default:
-		(void) xen_gdt_setprot(cp, PROT_READ | PROT_WRITE);
-		kmem_free(cp->cpu_m.mcpu_evt_pend,
-		    sizeof (struct xen_evt_data));
-		break;
-	}
-}
-
-/*
- * Reset this CPU's context.  Clear out any pending evtchn data, since event
- * channel numbers will all change when we resume.
- */
-void
-mach_cpucontext_reset(cpu_t *cp)
-{
-	bzero(cp->cpu_m.mcpu_evt_pend, sizeof (struct xen_evt_data));
-	/* mcpu_intr_pending ? */
-}
-
-static void
-pcb_to_user_regs(label_t *pcb, vcpu_guest_context_t *vgc)
-{
-#ifdef __amd64
-	vgc->user_regs.rip = pcb->val[REG_LABEL_PC];
-	vgc->user_regs.rsp = pcb->val[REG_LABEL_SP];
-	vgc->user_regs.rbp = pcb->val[REG_LABEL_BP];
-	vgc->user_regs.rbx = pcb->val[REG_LABEL_RBX];
-	vgc->user_regs.r12 = pcb->val[REG_LABEL_R12];
-	vgc->user_regs.r13 = pcb->val[REG_LABEL_R13];
-	vgc->user_regs.r14 = pcb->val[REG_LABEL_R14];
-	vgc->user_regs.r15 = pcb->val[REG_LABEL_R15];
-#else /* __amd64 */
-	vgc->user_regs.eip = pcb->val[REG_LABEL_PC];
-	vgc->user_regs.esp = pcb->val[REG_LABEL_SP];
-	vgc->user_regs.ebp = pcb->val[REG_LABEL_BP];
-	vgc->user_regs.ebx = pcb->val[REG_LABEL_EBX];
-	vgc->user_regs.esi = pcb->val[REG_LABEL_ESI];
-	vgc->user_regs.edi = pcb->val[REG_LABEL_EDI];
-#endif /* __amd64 */
-}
-
-/*
- * Restore the context of a CPU during resume.  This context is always
- * inside enter_safe_phase(), below.
- */
-void
-mach_cpucontext_restore(cpu_t *cp)
-{
-	vcpu_guest_context_t vgc;
-	int err;
-
-	ASSERT(cp->cpu_thread == cp->cpu_pause_thread ||
-	    cp->cpu_thread == cp->cpu_idle_thread);
-
-	bzero(&vgc, sizeof (vgc));
-
-	pcb_to_user_regs(&cp->cpu_thread->t_pcb, &vgc);
-
-	/*
-	 * We're emulating a longjmp() here: in particular, we need to bump the
-	 * stack pointer to account for the pop of xIP that returning from
-	 * longjmp() normally would do, and set the return value in xAX to 1.
-	 */
-#ifdef __amd64
-	vgc.user_regs.rax = 1;
-	vgc.user_regs.rsp += sizeof (ulong_t);
-#else
-	vgc.user_regs.eax = 1;
-	vgc.user_regs.esp += sizeof (ulong_t);
-#endif
-
-	vgc.kernel_sp = cp->cpu_thread->t_sp;
-
-	err = mp_set_cpu_context(&vgc, cp);
-
-	ASSERT(err == 0);
-}
-
-/*
- * Reach a point at which the CPU can be safely powered-off or
- * suspended.  Nothing can wake this CPU out of the loop.
- */
-static void
-enter_safe_phase(void)
-{
-	ulong_t flags = intr_clear();
-
-	if (setjmp(&curthread->t_pcb) == 0) {
-		cpu_phase[CPU->cpu_id] = CPU_PHASE_SAFE;
-		while (cpu_phase[CPU->cpu_id] == CPU_PHASE_SAFE)
-			SMT_PAUSE();
-	}
-
-	ASSERT(!interrupts_enabled());
-
-	intr_restore(flags);
-}
-
-/*
- * Offline CPUs run this code even under a pause_cpus(), so we must
- * check if we need to enter the safe phase.
- */
-void
-mach_cpu_idle(void)
-{
-	if (IN_XPV_PANIC()) {
-		xpv_panic_halt();
-	} else  {
-		(void) HYPERVISOR_block();
-		if (cpu_phase[CPU->cpu_id] == CPU_PHASE_WAIT_SAFE)
-			enter_safe_phase();
-	}
-}
-
-/*
- * Spin until either start_cpus() wakes us up, or we get a request to
- * enter the safe phase (followed by a later start_cpus()).
- */
-void
-mach_cpu_pause(volatile char *safe)
-{
-	*safe = PAUSE_WAIT;
-	membar_enter();
-
-	while (*safe != PAUSE_IDLE) {
-		if (cpu_phase[CPU->cpu_id] == CPU_PHASE_WAIT_SAFE)
-			enter_safe_phase();
-		SMT_PAUSE();
-	}
-}
-
-void
-mach_cpu_halt(char *msg)
-{
-	if (msg)
-		prom_printf("%s\n", msg);
-	(void) xen_vcpu_down(CPU->cpu_id);
-}
-
-/*ARGSUSED*/
-int
-mp_cpu_poweron(struct cpu *cp)
-{
-	return (ENOTSUP);
-}
-
-/*ARGSUSED*/
-int
-mp_cpu_poweroff(struct cpu *cp)
-{
-	return (ENOTSUP);
-}
-
-void
-mp_enter_barrier(void)
-{
-	hrtime_t last_poke_time = 0;
-	int poke_allowed = 0;
-	int done = 0;
-	int i;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-
-	pause_cpus(NULL, NULL);
-
-	while (!done) {
-		done = 1;
-		poke_allowed = 0;
-
-		if (xpv_gethrtime() - last_poke_time > POKE_TIMEOUT) {
-			last_poke_time = xpv_gethrtime();
-			poke_allowed = 1;
-		}
-
-		for (i = 0; i < NCPU; i++) {
-			cpu_t *cp = cpu_get(i);
-
-			if (cp == NULL || cp == CPU)
-				continue;
-
-			switch (cpu_phase[i]) {
-			case CPU_PHASE_NONE:
-				cpu_phase[i] = CPU_PHASE_WAIT_SAFE;
-				poke_cpu(i);
-				done = 0;
-				break;
-
-			case CPU_PHASE_WAIT_SAFE:
-				if (poke_allowed)
-					poke_cpu(i);
-				done = 0;
-				break;
-
-			case CPU_PHASE_SAFE:
-			case CPU_PHASE_POWERED_OFF:
-				break;
-			}
-		}
-
-		SMT_PAUSE();
-	}
-}
-
-void
-mp_leave_barrier(void)
-{
-	int i;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-
-	for (i = 0; i < NCPU; i++) {
-		cpu_t *cp = cpu_get(i);
-
-		if (cp == NULL || cp == CPU)
-			continue;
-
-		switch (cpu_phase[i]) {
-		/*
-		 * If we see a CPU in one of these phases, something has
-		 * gone badly wrong with the guarantees
-		 * mp_enter_barrier() is supposed to provide.  Rather
-		 * than attempt to stumble along (and since we can't
-		 * panic properly in this context), we tell the
-		 * hypervisor we've crashed.
-		 */
-		case CPU_PHASE_NONE:
-		case CPU_PHASE_WAIT_SAFE:
-			(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-			break;
-
-		case CPU_PHASE_POWERED_OFF:
-			break;
-
-		case CPU_PHASE_SAFE:
-			cpu_phase[i] = CPU_PHASE_NONE;
-		}
-	}
-
-	start_cpus();
-}
-
-static int
-poweroff_vcpu(struct cpu *cp)
-{
-	int error;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-
-	ASSERT(CPU->cpu_id != cp->cpu_id);
-	ASSERT(cp->cpu_flags & CPU_QUIESCED);
-
-	mp_enter_barrier();
-
-	if ((error = xen_vcpu_down(cp->cpu_id)) == 0) {
-		ASSERT(cpu_phase[cp->cpu_id] == CPU_PHASE_SAFE);
-
-		CPUSET_DEL(cpu_ready_set, cp->cpu_id);
-
-		cp->cpu_flags |= CPU_POWEROFF | CPU_OFFLINE;
-		cp->cpu_flags &=
-		    ~(CPU_RUNNING | CPU_READY | CPU_EXISTS | CPU_ENABLE);
-
-		cpu_phase[cp->cpu_id] = CPU_PHASE_POWERED_OFF;
-
-		cpu_set_state(cp);
-	}
-
-	mp_leave_barrier();
-
-	return (error);
-}
-
-static int
-vcpu_config_poweroff(processorid_t id)
-{
-	int oldstate;
-	int error;
-	cpu_t *cp;
-
-	mutex_enter(&cpu_lock);
-
-	if ((cp = cpu_get(id)) == NULL) {
-		mutex_exit(&cpu_lock);
-		return (ESRCH);
-	}
-
-	if (cpu_get_state(cp) == P_POWEROFF) {
-		mutex_exit(&cpu_lock);
-		return (0);
-	}
-
-	mutex_exit(&cpu_lock);
-
-	do {
-		error = p_online_internal(id, P_OFFLINE,
-		    &oldstate);
-
-		if (error != 0)
-			break;
-
-		/*
-		 * So we just changed it to P_OFFLINE.  But then we dropped
-		 * cpu_lock, so now it is possible for another thread to change
-		 * the cpu back to a different, non-quiesced state e.g.
-		 * P_ONLINE.
-		 */
-		mutex_enter(&cpu_lock);
-		if ((cp = cpu_get(id)) == NULL)
-			error = ESRCH;
-		else {
-			if (cp->cpu_flags & CPU_QUIESCED)
-				error = poweroff_vcpu(cp);
-			else
-				error = EBUSY;
-		}
-		mutex_exit(&cpu_lock);
-	} while (error == EBUSY);
-
-	return (error);
-}
-
-/*
- * Add a new virtual cpu to the domain.
- */
-static int
-vcpu_config_new(processorid_t id)
-{
-	extern int start_cpu(processorid_t);
-	int error;
-
-	if (ncpus == 1) {
-		printf("cannot (yet) add cpus to a single-cpu domain\n");
-		return (ENOTSUP);
-	}
-
-	affinity_set(CPU_CURRENT);
-	error = start_cpu(id);
-	affinity_clear();
-	return (error);
-}
-
-static int
-poweron_vcpu(struct cpu *cp)
-{
-	int error;
-
-	ASSERT(MUTEX_HELD(&cpu_lock));
-
-	if (HYPERVISOR_vcpu_op(VCPUOP_is_up, cp->cpu_id, NULL) != 0) {
-		printf("poweron_vcpu: vcpu%d is not available!\n",
-		    cp->cpu_id);
-		return (ENXIO);
-	}
-
-	if ((error = xen_vcpu_up(cp->cpu_id)) == 0) {
-		CPUSET_ADD(cpu_ready_set, cp->cpu_id);
-		cp->cpu_flags |= CPU_EXISTS | CPU_READY | CPU_RUNNING;
-		cp->cpu_flags &= ~CPU_POWEROFF;
-		/*
-		 * There are some nasty races possible here.
-		 * Tell the vcpu it's up one more time.
-		 * XXPV	Is this enough?  Is this safe?
-		 */
-		(void) xen_vcpu_up(cp->cpu_id);
-
-		cpu_phase[cp->cpu_id] = CPU_PHASE_NONE;
-
-		cpu_set_state(cp);
-	}
-	return (error);
-}
-
-static int
-vcpu_config_poweron(processorid_t id)
-{
-	cpu_t *cp;
-	int oldstate;
-	int error;
-
-	if (id >= ncpus)
-		return (vcpu_config_new(id));
-
-	mutex_enter(&cpu_lock);
-
-	if ((cp = cpu_get(id)) == NULL) {
-		mutex_exit(&cpu_lock);
-		return (ESRCH);
-	}
-
-	if (cpu_get_state(cp) != P_POWEROFF) {
-		mutex_exit(&cpu_lock);
-		return (0);
-	}
-
-	if ((error = poweron_vcpu(cp)) != 0) {
-		mutex_exit(&cpu_lock);
-		return (error);
-	}
-
-	mutex_exit(&cpu_lock);
-
-	return (p_online_internal(id, P_ONLINE, &oldstate));
-}
-
-#define	REPORT_LEN	128
-
-static void
-vcpu_config_report(processorid_t id, uint_t newstate, int error)
-{
-	char *report = kmem_alloc(REPORT_LEN, KM_SLEEP);
-	size_t len;
-	char *ps;
-
-	switch (newstate) {
-	case P_ONLINE:
-		ps = PS_ONLINE;
-		break;
-	case P_POWEROFF:
-		ps = PS_POWEROFF;
-		break;
-	default:
-		cmn_err(CE_PANIC, "unknown state %u\n", newstate);
-		break;
-	}
-
-	len = snprintf(report, REPORT_LEN,
-	    "cpu%d: externally initiated %s", id, ps);
-
-	if (!error) {
-		cmn_err(CE_CONT, "!%s\n", report);
-		kmem_free(report, REPORT_LEN);
-		return;
-	}
-
-	len += snprintf(report + len, REPORT_LEN - len,
-	    " failed, error %d: ", error);
-	switch (error) {
-	case EEXIST:
-		len += snprintf(report + len, REPORT_LEN - len,
-		    "cpu already %s", ps ? ps : "?");
-		break;
-	case ESRCH:
-		len += snprintf(report + len, REPORT_LEN - len,
-		    "cpu not found");
-		break;
-	case EINVAL:
-	case EALREADY:
-		break;
-	case EPERM:
-		len += snprintf(report + len, REPORT_LEN - len,
-		    "insufficient privilege (0x%x)", id);
-		break;
-	case EBUSY:
-		switch (newstate) {
-		case P_ONLINE:
-			/*
-			 * This return comes from mp_cpu_start -
-			 * we cannot 'start' the boot CPU.
-			 */
-			len += snprintf(report + len, REPORT_LEN - len,
-			    "already running");
-			break;
-		case P_POWEROFF:
-			len += snprintf(report + len, REPORT_LEN - len,
-			    "bound lwps?");
-			break;
-		default:
-			break;
-		}
-	default:
-		break;
-	}
-
-	cmn_err(CE_CONT, "%s\n", report);
-	kmem_free(report, REPORT_LEN);
-}
-
-static void
-vcpu_config(void *arg)
-{
-	int id = (int)(uintptr_t)arg;
-	int error;
-	char dir[16];
-	char *state;
-
-	if ((uint_t)id >= max_ncpus) {
-		cmn_err(CE_WARN,
-		    "vcpu_config: cpu%d does not fit in this domain", id);
-		return;
-	}
-
-	(void) snprintf(dir, sizeof (dir), "cpu/%d", id);
-	state = kmem_alloc(MAXPATHLEN, KM_SLEEP);
-	if (xenbus_scanf(XBT_NULL, dir, "availability", "%s", state) == 0) {
-		if (strcmp(state, "online") == 0) {
-			error = vcpu_config_poweron(id);
-			vcpu_config_report(id, P_ONLINE, error);
-		} else if (strcmp(state, "offline") == 0) {
-			error = vcpu_config_poweroff(id);
-			vcpu_config_report(id, P_POWEROFF, error);
-		} else {
-			cmn_err(CE_WARN,
-			    "cpu%d: unknown target state '%s'", id, state);
-		}
-	} else
-		cmn_err(CE_WARN,
-		    "cpu%d: unable to read target state from xenstore", id);
-
-	kmem_free(state, MAXPATHLEN);
-}
-
-/*ARGSUSED*/
-static void
-vcpu_config_event(struct xenbus_watch *watch, const char **vec, uint_t len)
-{
-	const char *path = vec[XS_WATCH_PATH];
-	processorid_t id;
-	char *s;
-
-	if ((s = strstr(path, "cpu/")) != NULL &&
-	    sscanf(s, "cpu/%d", &id) == 1) {
-		/*
-		 * Run the virtual CPU configuration on a separate thread to
-		 * avoid blocking on this event for too long (and for now,
-		 * to ensure configuration requests are serialized.)
-		 */
-		(void) taskq_dispatch(cpu_config_tq,
-		    vcpu_config, (void *)(uintptr_t)id, 0);
-	}
-}
-
-static int
-xen_vcpu_initialize(processorid_t id, vcpu_guest_context_t *vgc)
-{
-	int err;
-
-	if ((err = HYPERVISOR_vcpu_op(VCPUOP_initialise, id, vgc)) != 0) {
-		char *str;
-		int level = CE_WARN;
-
-		switch (err) {
-		case -X_EINVAL:
-			/*
-			 * This interface squashes multiple error sources
-			 * to one error code.  In particular, an X_EINVAL
-			 * code can mean:
-			 *
-			 * -	the vcpu id is out of range
-			 * -	cs or ss are in ring 0
-			 * -	cr3 is wrong
-			 * -	an entry in the new gdt is above the
-			 *	reserved entry
-			 * -	a frame underneath the new gdt is bad
-			 */
-			str = "something is wrong :(";
-			break;
-		case -X_ENOENT:
-			str = "no such cpu";
-			break;
-		case -X_ENOMEM:
-			str = "no mem to copy ctxt";
-			break;
-		case -X_EFAULT:
-			str = "bad address";
-			break;
-		case -X_EEXIST:
-			/*
-			 * Hmm.  This error is returned if the vcpu has already
-			 * been initialized once before in the lifetime of this
-			 * domain.  This is a logic error in the kernel.
-			 */
-			level = CE_PANIC;
-			str = "already initialized";
-			break;
-		default:
-			level = CE_PANIC;
-			str = "<unexpected>";
-			break;
-		}
-
-		cmn_err(level, "vcpu%d: failed to init: error %d: %s",
-		    id, -err, str);
-	}
-	return (err);
-}
-
-long
-xen_vcpu_up(processorid_t id)
-{
-	long err;
-
-	if ((err = HYPERVISOR_vcpu_op(VCPUOP_up, id, NULL)) != 0) {
-		char *str;
-
-		switch (err) {
-		case -X_ENOENT:
-			str = "no such cpu";
-			break;
-		case -X_EINVAL:
-			/*
-			 * Perhaps this is diagnostic overkill.
-			 */
-			if (HYPERVISOR_vcpu_op(VCPUOP_is_up, id, NULL) < 0)
-				str = "bad cpuid";
-			else
-				str = "not initialized";
-			break;
-		default:
-			str = "<unexpected>";
-			break;
-		}
-
-		printf("vcpu%d: failed to start: error %d: %s\n",
-		    id, -(int)err, str);
-		return (EBFONT);	/* deliberately silly */
-	}
-	return (err);
-}
-
-long
-xen_vcpu_down(processorid_t id)
-{
-	long err;
-
-	if ((err = HYPERVISOR_vcpu_op(VCPUOP_down, id, NULL)) != 0) {
-		/*
-		 * X_ENOENT:	no such cpu
-		 * X_EINVAL:	bad cpuid
-		 */
-		panic("vcpu%d: failed to stop: error %d", id, -(int)err);
-	}
-
-	return (err);
-}
--- old/usr/src/uts/i86xpv/os/xen_machdep.c	Fri Aug 10 23:19:21 2018
+++ /dev/null	Fri Aug 10 23:19:21 2018
@@ -1,1397 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-/* derived from netbsd's xen_machdep.c 1.1.2.1 */
-
-/*
- *
- * Copyright (c) 2004 Christian Limpach.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. This section intentionally left blank.
- * 4. The name of the author may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * Section 3 of the above license was updated in response to bug 6379571.
- */
-
-#include <sys/xpv_user.h>
-
-/* XXX 3.3. TODO remove this include */
-#include <xen/public/arch-x86/xen-mca.h>
-
-#include <sys/ctype.h>
-#include <sys/types.h>
-#include <sys/cmn_err.h>
-#include <sys/trap.h>
-#include <sys/segments.h>
-#include <sys/hypervisor.h>
-#include <sys/xen_mmu.h>
-#include <sys/machsystm.h>
-#include <sys/promif.h>
-#include <sys/bootconf.h>
-#include <sys/bootinfo.h>
-#include <sys/cpr.h>
-#include <sys/taskq.h>
-#include <sys/uadmin.h>
-#include <sys/evtchn_impl.h>
-#include <sys/archsystm.h>
-#include <xen/sys/xenbus_impl.h>
-#include <sys/mach_mmu.h>
-#include <vm/hat_i86.h>
-#include <sys/gnttab.h>
-#include <sys/reboot.h>
-#include <sys/stack.h>
-#include <sys/clock.h>
-#include <sys/bitmap.h>
-#include <sys/processor.h>
-#include <sys/xen_errno.h>
-#include <sys/xpv_panic.h>
-#include <sys/smp_impldefs.h>
-#include <sys/cpu.h>
-#include <sys/balloon_impl.h>
-#include <sys/ddi.h>
-
-#ifdef DEBUG
-#define	SUSPEND_DEBUG if (xen_suspend_debug) xen_printf
-#else
-#define	SUSPEND_DEBUG(...)
-#endif
-
-int cpr_debug;
-cpuset_t cpu_suspend_lost_set;
-static int xen_suspend_debug;
-
-uint_t xen_phys_ncpus;
-xen_mc_logical_cpu_t *xen_phys_cpus;
-int xen_physinfo_debug = 0;
-
-/*
- * Determine helpful version information.
- *
- * (And leave copies in the data segment so we can look at them later
- * with e.g. kmdb.)
- */
-
-typedef enum xen_version {
-	XENVER_BOOT_IDX,
-	XENVER_CURRENT_IDX
-} xen_version_t;
-
-struct xenver {
-	ulong_t xv_major;
-	ulong_t xv_minor;
-	ulong_t xv_revision;
-	xen_extraversion_t xv_ver;
-	ulong_t xv_is_xvm;
-	xen_changeset_info_t xv_chgset;
-	xen_compile_info_t xv_build;
-	xen_capabilities_info_t xv_caps;
-} xenver[2];
-
-#define	XENVER_BOOT(m)	(xenver[XENVER_BOOT_IDX].m)
-#define	XENVER_CURRENT(m)	(xenver[XENVER_CURRENT_IDX].m)
-
-/*
- * Update the xenver data. We maintain two copies, boot and
- * current. If we are setting the boot, then also set current.
- */
-static void
-xen_set_version(xen_version_t idx)
-{
-	ulong_t ver;
-
-	bzero(&xenver[idx], sizeof (xenver[idx]));
-
-	ver = HYPERVISOR_xen_version(XENVER_version, 0);
-
-	xenver[idx].xv_major = BITX(ver, 31, 16);
-	xenver[idx].xv_minor = BITX(ver, 15, 0);
-
-	(void) HYPERVISOR_xen_version(XENVER_extraversion, &xenver[idx].xv_ver);
-
-	/*
-	 * The revision is buried in the extraversion information that is
-	 * maintained by the hypervisor. For our purposes we expect that
-	 * the revision number is:
-	 * 	- the second character in the extraversion information
-	 *	- one character long
-	 *	- numeric digit
-	 * If it isn't then we can't extract the revision and we leave it
-	 * set to 0.
-	 */
-	if (strlen(xenver[idx].xv_ver) > 1 && isdigit(xenver[idx].xv_ver[1]))
-		xenver[idx].xv_revision = xenver[idx].xv_ver[1] - '0';
-	else
-		cmn_err(CE_WARN, "Cannot extract revision on this hypervisor "
-		    "version: v%s, unexpected version format",
-		    xenver[idx].xv_ver);
-
-	xenver[idx].xv_is_xvm = 0;
-
-	if (strstr(xenver[idx].xv_ver, "-xvm") != NULL)
-		xenver[idx].xv_is_xvm = 1;
-
-	(void) HYPERVISOR_xen_version(XENVER_changeset,
-	    &xenver[idx].xv_chgset);
-
-	(void) HYPERVISOR_xen_version(XENVER_compile_info,
-	    &xenver[idx].xv_build);
-	/*
-	 * Capabilities are a set of space separated ascii strings
-	 * e.g. 'xen-3.1-x86_32p' or 'hvm-3.2-x86_64'
-	 */
-	(void) HYPERVISOR_xen_version(XENVER_capabilities,
-	    &xenver[idx].xv_caps);
-
-	cmn_err(CE_CONT, "?v%lu.%lu%s chgset '%s'\n", xenver[idx].xv_major,
-	    xenver[idx].xv_minor, xenver[idx].xv_ver, xenver[idx].xv_chgset);
-
-	if (idx == XENVER_BOOT_IDX)
-		bcopy(&xenver[XENVER_BOOT_IDX], &xenver[XENVER_CURRENT_IDX],
-		    sizeof (xenver[XENVER_BOOT_IDX]));
-}
-
-typedef enum xen_hypervisor_check {
-	XEN_RUN_CHECK,
-	XEN_SUSPEND_CHECK
-} xen_hypervisor_check_t;
-
-/*
- * To run the hypervisor must be 3.0.4 or better. To suspend/resume
- * we need 3.0.4 or better and if it is 3.0.4. then it must be provided
- * by the Solaris xVM project.
- * Checking can be disabled for testing purposes by setting the
- * xen_suspend_debug variable.
- */
-static int
-xen_hypervisor_supports_solaris(xen_hypervisor_check_t check)
-{
-	if (xen_suspend_debug == 1)
-		return (1);
-	if (XENVER_CURRENT(xv_major) < 3)
-		return (0);
-	if (XENVER_CURRENT(xv_major) > 3)
-		return (1);
-	if (XENVER_CURRENT(xv_minor) > 0)
-		return (1);
-	if (XENVER_CURRENT(xv_revision) < 4)
-		return (0);
-	if (check == XEN_SUSPEND_CHECK && XENVER_CURRENT(xv_revision) == 4 &&
-	    !XENVER_CURRENT(xv_is_xvm))
-		return (0);
-
-	return (1);
-}
-
-/*
- * If the hypervisor is -xvm, or 3.1.2 or higher, we don't need the
- * workaround.
- */
-static void
-xen_pte_workaround(void)
-{
-#if defined(__amd64)
-	extern int pt_kern;
-
-	if (XENVER_CURRENT(xv_major) != 3)
-		return;
-	if (XENVER_CURRENT(xv_minor) > 1)
-		return;
-	if (XENVER_CURRENT(xv_minor) == 1 &&
-	    XENVER_CURRENT(xv_revision) > 1)
-		return;
-	if (XENVER_CURRENT(xv_is_xvm))
-		return;
-
-	pt_kern = PT_USER;
-#endif
-}
-
-void
-xen_set_callback(void (*func)(void), uint_t type, uint_t flags)
-{
-	struct callback_register cb;
-
-	bzero(&cb, sizeof (cb));
-#if defined(__amd64)
-	cb.address = (ulong_t)func;
-#elif defined(__i386)
-	cb.address.cs = KCS_SEL;
-	cb.address.eip = (ulong_t)func;
-#endif
-	cb.type = type;
-	cb.flags = flags;
-
-	/*
-	 * XXPV always ignore return value for NMI
-	 */
-	if (HYPERVISOR_callback_op(CALLBACKOP_register, &cb) != 0 &&
-	    type != CALLBACKTYPE_nmi)
-		panic("HYPERVISOR_callback_op failed");
-}
-
-void
-xen_init_callbacks(void)
-{
-	/*
-	 * register event (interrupt) handler.
-	 */
-	xen_set_callback(xen_callback, CALLBACKTYPE_event, 0);
-
-	/*
-	 * failsafe handler.
-	 */
-	xen_set_callback(xen_failsafe_callback, CALLBACKTYPE_failsafe,
-	    CALLBACKF_mask_events);
-
-	/*
-	 * NMI handler.
-	 */
-	xen_set_callback(nmiint, CALLBACKTYPE_nmi, 0);
-
-	/*
-	 * system call handler
-	 * XXPV move to init_cpu_syscall?
-	 */
-#if defined(__amd64)
-	xen_set_callback(sys_syscall, CALLBACKTYPE_syscall,
-	    CALLBACKF_mask_events);
-#endif	/* __amd64 */
-}
-
-
-/*
- * cmn_err() followed by a 1/4 second delay; this gives the
- * logging service a chance to flush messages and helps avoid
- * intermixing output from prom_printf().
- * XXPV: doesn't exactly help us on UP though.
- */
-/*PRINTFLIKE2*/
-void
-cpr_err(int ce, const char *fmt, ...)
-{
-	va_list adx;
-
-	va_start(adx, fmt);
-	vcmn_err(ce, fmt, adx);
-	va_end(adx);
-	drv_usecwait(MICROSEC >> 2);
-}
-
-void
-xen_suspend_devices(void)
-{
-	int rc;
-
-	SUSPEND_DEBUG("xen_suspend_devices\n");
-
-	if ((rc = cpr_suspend_devices(ddi_root_node())) != 0)
-		panic("failed to suspend devices: %d", rc);
-}
-
-void
-xen_resume_devices(void)
-{
-	int rc;
-
-	SUSPEND_DEBUG("xen_resume_devices\n");
-
-	if ((rc = cpr_resume_devices(ddi_root_node(), 0)) != 0)
-		panic("failed to resume devices: %d", rc);
-}
-
-/*
- * The list of mfn pages is out of date.  Recompute it.
- */
-static void
-rebuild_mfn_list(void)
-{
-	int i = 0;
-	size_t sz;
-	size_t off;
-	pfn_t pfn;
-
-	SUSPEND_DEBUG("rebuild_mfn_list\n");
-
-	sz = ((mfn_count * sizeof (mfn_t)) + MMU_PAGEOFFSET) & MMU_PAGEMASK;
-
-	for (off = 0; off < sz; off += MMU_PAGESIZE) {
-		size_t j = mmu_btop(off);
-		if (((j * sizeof (mfn_t)) & MMU_PAGEOFFSET) == 0) {
-			pfn = hat_getpfnum(kas.a_hat,
-			    (caddr_t)&mfn_list_pages[j]);
-			mfn_list_pages_page[i++] = pfn_to_mfn(pfn);
-		}
-
-		pfn = hat_getpfnum(kas.a_hat, (caddr_t)mfn_list + off);
-		mfn_list_pages[j] = pfn_to_mfn(pfn);
-	}
-
-	pfn = hat_getpfnum(kas.a_hat, (caddr_t)mfn_list_pages_page);
-	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list
-	    = pfn_to_mfn(pfn);
-}
-
-static void
-suspend_cpus(void)
-{
-	int i;
-
-	SUSPEND_DEBUG("suspend_cpus\n");
-
-	mp_enter_barrier();
-
-	for (i = 1; i < ncpus; i++) {
-		if (!CPU_IN_SET(cpu_suspend_lost_set, i)) {
-			SUSPEND_DEBUG("xen_vcpu_down %d\n", i);
-			(void) xen_vcpu_down(i);
-		}
-
-		mach_cpucontext_reset(cpu[i]);
-	}
-}
-
-static void
-resume_cpus(void)
-{
-	int i;
-
-	for (i = 1; i < ncpus; i++) {
-		if (cpu[i] == NULL)
-			continue;
-
-		if (!CPU_IN_SET(cpu_suspend_lost_set, i)) {
-			SUSPEND_DEBUG("xen_vcpu_up %d\n", i);
-			mach_cpucontext_restore(cpu[i]);
-			(void) xen_vcpu_up(i);
-		}
-	}
-
-	mp_leave_barrier();
-}
-
-/*
- * Top level routine to direct suspend/resume of a domain.
- */
-void
-xen_suspend_domain(void)
-{
-	extern void rtcsync(void);
-	extern hrtime_t hres_last_tick;
-	mfn_t start_info_mfn;
-	ulong_t flags;
-	pfn_t pfn;
-	int i;
-
-	/*
-	 * Check that we are happy to suspend on this hypervisor.
-	 */
-	if (xen_hypervisor_supports_solaris(XEN_SUSPEND_CHECK) == 0) {
-		cpr_err(CE_WARN, "Cannot suspend on this hypervisor "
-		    "version: v%lu.%lu%s, need at least version v3.0.4 or "
-		    "-xvm based hypervisor", XENVER_CURRENT(xv_major),
-		    XENVER_CURRENT(xv_minor), XENVER_CURRENT(xv_ver));
-		return;
-	}
-
-	/*
-	 * XXPV - Are we definitely OK to suspend by the time we've connected
-	 * the handler?
-	 */
-
-	cpr_err(CE_NOTE, "Domain suspending for save/migrate");
-
-	SUSPEND_DEBUG("xen_suspend_domain\n");
-
-	/*
-	 * suspend interrupts and devices
-	 * XXPV - we use suspend/resume for both save/restore domains (like sun
-	 * cpr) and for migration.  Would be nice to know the difference if
-	 * possible.  For save/restore where down time may be a long time, we
-	 * may want to do more of the things that cpr does.  (i.e. notify user
-	 * processes, shrink memory footprint for faster restore, etc.)
-	 */
-	xen_suspend_devices();
-	SUSPEND_DEBUG("xenbus_suspend\n");
-	xenbus_suspend();
-
-	pfn = hat_getpfnum(kas.a_hat, (caddr_t)xen_info);
-	start_info_mfn = pfn_to_mfn(pfn);
-
-	/*
-	 * XXPV: cpu hotplug can hold this under a xenbus watch. Are we safe
-	 * wrt xenbus being suspended here?
-	 */
-	mutex_enter(&cpu_lock);
-
-	/*
-	 * Suspend must be done on vcpu 0, as no context for other CPUs is
-	 * saved.
-	 *
-	 * XXPV - add to taskq API ?
-	 */
-	thread_affinity_set(curthread, 0);
-	kpreempt_disable();
-
-	SUSPEND_DEBUG("xen_start_migrate\n");
-	xen_start_migrate();
-	if (ncpus > 1)
-		suspend_cpus();
-
-	/*
-	 * We can grab the ec_lock as it's a spinlock with a high SPL. Hence
-	 * any holder would have dropped it to get through suspend_cpus().
-	 */
-	mutex_enter(&ec_lock);
-
-	/*
-	 * From here on in, we can't take locks.
-	 */
-	SUSPEND_DEBUG("ec_suspend\n");
-	ec_suspend();
-	SUSPEND_DEBUG("gnttab_suspend\n");
-	gnttab_suspend();
-
-	flags = intr_clear();
-
-	xpv_time_suspend();
-
-	/*
-	 * Currently, the hypervisor incorrectly fails to bring back
-	 * powered-down VCPUs.  Thus we need to record any powered-down VCPUs
-	 * to prevent any attempts to operate on them.  But we have to do this
-	 * *after* the very first time we do ec_suspend().
-	 */
-	for (i = 1; i < ncpus; i++) {
-		if (cpu[i] == NULL)
-			continue;
-
-		if (cpu_get_state(cpu[i]) == P_POWEROFF)
-			CPUSET_ATOMIC_ADD(cpu_suspend_lost_set, i);
-	}
-
-	/*
-	 * The dom0 save/migrate code doesn't automatically translate
-	 * these into PFNs, but expects them to be, so we do it here.
-	 * We don't use mfn_to_pfn() because so many OS services have
-	 * been disabled at this point.
-	 */
-	xen_info->store_mfn = mfn_to_pfn_mapping[xen_info->store_mfn];
-	xen_info->console.domU.mfn =
-	    mfn_to_pfn_mapping[xen_info->console.domU.mfn];
-
-	if (CPU->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask == 0) {
-		prom_printf("xen_suspend_domain(): "
-		    "CPU->cpu_m.mcpu_vcpu_info->evtchn_upcall_mask not set\n");
-		(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-	}
-
-	if (HYPERVISOR_update_va_mapping((uintptr_t)HYPERVISOR_shared_info,
-	    0, UVMF_INVLPG)) {
-		prom_printf("xen_suspend_domain(): "
-		    "HYPERVISOR_update_va_mapping() failed\n");
-		(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-	}
-
-	SUSPEND_DEBUG("HYPERVISOR_suspend\n");
-
-	/*
-	 * At this point we suspend and sometime later resume.
-	 */
-	if (HYPERVISOR_suspend(start_info_mfn)) {
-		prom_printf("xen_suspend_domain(): "
-		    "HYPERVISOR_suspend() failed\n");
-		(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-	}
-
-	/*
-	 * Point HYPERVISOR_shared_info to its new value.
-	 */
-	if (HYPERVISOR_update_va_mapping((uintptr_t)HYPERVISOR_shared_info,
-	    xen_info->shared_info | PT_NOCONSIST | PT_VALID | PT_WRITABLE,
-	    UVMF_INVLPG))
-		(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-
-	if (xen_info->nr_pages != mfn_count) {
-		prom_printf("xen_suspend_domain(): number of pages"
-		    " changed, was 0x%lx, now 0x%lx\n", mfn_count,
-		    xen_info->nr_pages);
-		(void) HYPERVISOR_shutdown(SHUTDOWN_crash);
-	}
-
-	xpv_time_resume();
-
-	cached_max_mfn = 0;
-
-	SUSPEND_DEBUG("gnttab_resume\n");
-	gnttab_resume();
-
-	/* XXPV: add a note that this must be lockless. */
-	SUSPEND_DEBUG("ec_resume\n");
-	ec_resume();
-
-	intr_restore(flags);
-
-	if (ncpus > 1)
-		resume_cpus();
-
-	mutex_exit(&ec_lock);
-	xen_end_migrate();
-	mutex_exit(&cpu_lock);
-
-	/*
-	 * Now we can take locks again.
-	 */
-
-	/*
-	 * Force the tick value used for tv_nsec in hres_tick() to be up to
-	 * date. rtcsync() will reset the hrestime value appropriately.
-	 */
-	hres_last_tick = xpv_gethrtime();
-
-	/*
-	 * XXPV: we need to have resumed the CPUs since this takes locks, but
-	 * can remote CPUs see bad state? Presumably yes. Should probably nest
-	 * taking of todlock inside of cpu_lock, or vice versa, then provide an
-	 * unlocked version.  Probably need to call clkinitf to reset cpu freq
-	 * and re-calibrate if we migrated to a different speed cpu.  Also need
-	 * to make a (re)init_cpu_info call to update processor info structs
-	 * and device tree info.  That remains to be written at the moment.
-	 */
-	rtcsync();
-
-	rebuild_mfn_list();
-
-	SUSPEND_DEBUG("xenbus_resume\n");
-	xenbus_resume();
-	SUSPEND_DEBUG("xenbus_resume_devices\n");
-	xen_resume_devices();
-
-	thread_affinity_clear(curthread);
-	kpreempt_enable();
-
-	SUSPEND_DEBUG("finished xen_suspend_domain\n");
-
-	/*
-	 * We have restarted our suspended domain, update the hypervisor
-	 * details. NB: This must be done at the end of this function,
-	 * since we need the domain to be completely resumed before
-	 * these functions will work correctly.
-	 */
-	xen_set_version(XENVER_CURRENT_IDX);
-
-	/*
-	 * We can check and report a warning, but we don't stop the
-	 * process.
-	 */
-	if (xen_hypervisor_supports_solaris(XEN_SUSPEND_CHECK) == 0)
-		cmn_err(CE_WARN, "Found hypervisor version: v%lu.%lu%s "
-		    "but need at least version v3.0.4",
-		    XENVER_CURRENT(xv_major), XENVER_CURRENT(xv_minor),
-		    XENVER_CURRENT(xv_ver));
-
-	cmn_err(CE_NOTE, "domain restore/migrate completed");
-}
-
-/*ARGSUSED*/
-int
-xen_debug_handler(void *arg)
-{
-	debug_enter("External debug event received");
-
-	/*
-	 * If we've not got KMDB loaded, output some stuff difficult to capture
-	 * from a domain core.
-	 */
-	if (!(boothowto & RB_DEBUG)) {
-		shared_info_t *si = HYPERVISOR_shared_info;
-		int i;
-
-		prom_printf("evtchn_pending [ ");
-		for (i = 0; i < 8; i++)
-			prom_printf("%lx ", si->evtchn_pending[i]);
-		prom_printf("]\nevtchn_mask [ ");
-		for (i = 0; i < 8; i++)
-			prom_printf("%lx ", si->evtchn_mask[i]);
-		prom_printf("]\n");
-
-		for (i = 0; i < ncpus; i++) {
-			vcpu_info_t *vcpu = &si->vcpu_info[i];
-			if (cpu[i] == NULL)
-				continue;
-			prom_printf("CPU%d pending %d mask %d sel %lx\n",
-			    i, vcpu->evtchn_upcall_pending,
-			    vcpu->evtchn_upcall_mask,
-			    vcpu->evtchn_pending_sel);
-		}
-	}
-
-	return (0);
-}
-
-/*ARGSUSED*/
-static void
-xen_sysrq_handler(struct xenbus_watch *watch, const char **vec,
-    unsigned int len)
-{
-	xenbus_transaction_t xbt;
-	char key = '\0';
-	int ret;
-
-retry:
-	if (xenbus_transaction_start(&xbt)) {
-		cmn_err(CE_WARN, "failed to start sysrq transaction");
-		return;
-	}
-
-	if ((ret = xenbus_scanf(xbt, "control", "sysrq", "%c", &key)) != 0) {
-		/*
-		 * ENOENT happens in response to our own xenbus_rm.
-		 * XXPV - this happens spuriously on boot?
-		 */
-		if (ret != ENOENT)
-			cmn_err(CE_WARN, "failed to read sysrq: %d", ret);
-		goto out;
-	}
-
-	if ((ret = xenbus_rm(xbt, "control", "sysrq")) != 0) {
-		cmn_err(CE_WARN, "failed to reset sysrq: %d", ret);
-		goto out;
-	}
-
-	if (xenbus_transaction_end(xbt, 0) == EAGAIN)
-		goto retry;
-
-	/*
-	 * Somewhat arbitrary - on Linux this means 'reboot'. We could just
-	 * accept any key, but this might increase the risk of sending a
-	 * harmless sysrq to the wrong domain...
-	 */
-	if (key == 'b')
-		(void) xen_debug_handler(NULL);
-	else
-		cmn_err(CE_WARN, "Ignored sysrq %c", key);
-	return;
-
-out:
-	(void) xenbus_transaction_end(xbt, 1);
-}
-
-taskq_t *xen_shutdown_tq;
-
-#define	SHUTDOWN_INVALID	-1
-#define	SHUTDOWN_POWEROFF	0
-#define	SHUTDOWN_REBOOT		1
-#define	SHUTDOWN_SUSPEND	2
-#define	SHUTDOWN_HALT		3
-#define	SHUTDOWN_MAX		4
-
-#define	SHUTDOWN_TIMEOUT_SECS (60 * 5)
-
-static const char *cmd_strings[SHUTDOWN_MAX] = {
-	"poweroff",
-	"reboot",
-	"suspend",
-	"halt"
-};
-
-static void
-xen_dirty_shutdown(void *arg)
-{
-	int cmd = (uintptr_t)arg;
-
-	cmn_err(CE_WARN, "Externally requested shutdown failed or "
-	    "timed out.\nShutting down.\n");
-
-	switch (cmd) {
-	case SHUTDOWN_HALT:
-	case SHUTDOWN_POWEROFF:
-		(void) kadmin(A_SHUTDOWN, AD_POWEROFF, NULL, kcred);
-		break;
-	case SHUTDOWN_REBOOT:
-		(void) kadmin(A_REBOOT, AD_BOOT, NULL, kcred);
-		break;
-	}
-}
-
-static void
-xen_shutdown(void *arg)
-{
-	int cmd = (uintptr_t)arg;
-	proc_t *initpp;
-
-	ASSERT(cmd > SHUTDOWN_INVALID && cmd < SHUTDOWN_MAX);
-
-	if (cmd == SHUTDOWN_SUSPEND) {
-		xen_suspend_domain();
-		return;
-	}
-
-	switch (cmd) {
-	case SHUTDOWN_POWEROFF:
-		force_shutdown_method = AD_POWEROFF;
-		break;
-	case SHUTDOWN_HALT:
-		force_shutdown_method = AD_HALT;
-		break;
-	case SHUTDOWN_REBOOT:
-		force_shutdown_method = AD_BOOT;
-		break;
-	}
-
-	/*
-	 * If we're still booting and init(1) isn't set up yet, simply halt.
-	 */
-	mutex_enter(&pidlock);
-	initpp = prfind(P_INITPID);
-	mutex_exit(&pidlock);
-	if (initpp == NULL) {
-		extern void halt(char *);
-		halt("Power off the System");   /* just in case */
-	}
-
-	/*
-	 * else, graceful shutdown with inittab and all getting involved
-	 */
-	psignal(initpp, SIGPWR);
-
-	(void) timeout(xen_dirty_shutdown, arg,
-	    SHUTDOWN_TIMEOUT_SECS * drv_usectohz(MICROSEC));
-}
-
-/*ARGSUSED*/
-static void
-xen_shutdown_handler(struct xenbus_watch *watch, const char **vec,
-	unsigned int len)
-{
-	char *str;
-	xenbus_transaction_t xbt;
-	int err, shutdown_code = SHUTDOWN_INVALID;
-	unsigned int slen;
-
-again:
-	err = xenbus_transaction_start(&xbt);
-	if (err)
-		return;
-	if (xenbus_read(xbt, "control", "shutdown", (void *)&str, &slen)) {
-		(void) xenbus_transaction_end(xbt, 1);
-		return;
-	}
-
-	SUSPEND_DEBUG("%d: xen_shutdown_handler: \"%s\"\n", CPU->cpu_id, str);
-
-	/*
-	 * If this is a watch fired from our write below, check out early to
-	 * avoid an infinite loop.
-	 */
-	if (strcmp(str, "") == 0) {
-		(void) xenbus_transaction_end(xbt, 0);
-		kmem_free(str, slen);
-		return;
-	} else if (strcmp(str, "poweroff") == 0) {
-		shutdown_code = SHUTDOWN_POWEROFF;
-	} else if (strcmp(str, "reboot") == 0) {
-		shutdown_code = SHUTDOWN_REBOOT;
-	} else if (strcmp(str, "suspend") == 0) {
-		shutdown_code = SHUTDOWN_SUSPEND;
-	} else if (strcmp(str, "halt") == 0) {
-		shutdown_code = SHUTDOWN_HALT;
-	} else {
-		printf("Ignoring shutdown request: %s\n", str);
-	}
-
-	/*
-	 * XXPV	Should we check the value of xenbus_write() too, or are all
-	 *	errors automatically folded into xenbus_transaction_end() ??
-	 */
-	(void) xenbus_write(xbt, "control", "shutdown", "");
-	err = xenbus_transaction_end(xbt, 0);
-	if (err == EAGAIN) {
-		SUSPEND_DEBUG("%d: trying again\n", CPU->cpu_id);
-		kmem_free(str, slen);
-		goto again;
-	}
-
-	kmem_free(str, slen);
-	if (shutdown_code != SHUTDOWN_INVALID) {
-		(void) taskq_dispatch(xen_shutdown_tq, xen_shutdown,
-		    (void *)(intptr_t)shutdown_code, 0);
-	}
-}
-
-static struct xenbus_watch shutdown_watch;
-static struct xenbus_watch sysrq_watch;
-
-void
-xen_late_startup(void)
-{
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		xen_shutdown_tq = taskq_create("shutdown_taskq", 1,
-		    maxclsyspri - 1, 1, 1, TASKQ_PREPOPULATE);
-		shutdown_watch.node = "control/shutdown";
-		shutdown_watch.callback = xen_shutdown_handler;
-		if (register_xenbus_watch(&shutdown_watch))
-			cmn_err(CE_WARN, "Failed to set shutdown watcher");
-
-		sysrq_watch.node = "control/sysrq";
-		sysrq_watch.callback = xen_sysrq_handler;
-		if (register_xenbus_watch(&sysrq_watch))
-			cmn_err(CE_WARN, "Failed to set sysrq watcher");
-	}
-	balloon_init(xen_info->nr_pages);
-}
-
-#ifdef DEBUG
-#define	XEN_PRINTF_BUFSIZE	1024
-
-char xen_printf_buffer[XEN_PRINTF_BUFSIZE];
-
-/*
- * Printf function that calls hypervisor directly.  For DomU it only
- * works when running on a xen hypervisor built with debug on.  Works
- * always since no I/O ring interaction is needed.
- */
-/*PRINTFLIKE1*/
-void
-xen_printf(const char *fmt, ...)
-{
-	va_list	ap;
-
-	va_start(ap, fmt);
-	(void) vsnprintf(xen_printf_buffer, XEN_PRINTF_BUFSIZE, fmt, ap);
-	va_end(ap);
-
-	(void) HYPERVISOR_console_io(CONSOLEIO_write,
-	    strlen(xen_printf_buffer), xen_printf_buffer);
-}
-#else
-void
-xen_printf(const char *fmt, ...)
-{
-}
-#endif	/* DEBUG */
-
-void
-startup_xen_version(void)
-{
-	xen_set_version(XENVER_BOOT_IDX);
-	if (xen_hypervisor_supports_solaris(XEN_RUN_CHECK) == 0)
-		cmn_err(CE_WARN, "Found hypervisor version: v%lu.%lu%s "
-		    "but need at least version v3.0.4",
-		    XENVER_CURRENT(xv_major), XENVER_CURRENT(xv_minor),
-		    XENVER_CURRENT(xv_ver));
-	xen_pte_workaround();
-}
-
-int xen_mca_simulate_mc_physinfo_failure = 0;
-
-void
-startup_xen_mca(void)
-{
-	if (!DOMAIN_IS_INITDOMAIN(xen_info))
-		return;
-
-	xen_phys_ncpus = 0;
-	xen_phys_cpus = NULL;
-
-	if (xen_mca_simulate_mc_physinfo_failure ||
-	    xen_get_mc_physcpuinfo(NULL, &xen_phys_ncpus) != 0) {
-		cmn_err(CE_WARN,
-		    "%sxen_get_mc_physinfo failure during xen MCA startup: "
-		    "there will be no machine check support",
-		    xen_mca_simulate_mc_physinfo_failure ? "(simulated) " : "");
-		return;
-	}
-
-	xen_phys_cpus = kmem_alloc(xen_phys_ncpus *
-	    sizeof (xen_mc_logical_cpu_t), KM_NOSLEEP);
-
-	if (xen_phys_cpus == NULL) {
-		cmn_err(CE_WARN,
-		    "xen_get_mc_physinfo failure: can't allocate CPU array");
-		return;
-	}
-
-	if (xen_get_mc_physcpuinfo(xen_phys_cpus, &xen_phys_ncpus) != 0) {
-		cmn_err(CE_WARN, "xen_get_mc_physinfo failure: no "
-		    "physical CPU info");
-		kmem_free(xen_phys_cpus,
-		    xen_phys_ncpus * sizeof (xen_mc_logical_cpu_t));
-		xen_phys_ncpus = 0;
-		xen_phys_cpus = NULL;
-	}
-
-	if (xen_physinfo_debug) {
-		xen_mc_logical_cpu_t *xcp;
-		unsigned i;
-
-		cmn_err(CE_NOTE, "xvm mca: %u physical cpus:\n",
-		    xen_phys_ncpus);
-		for (i = 0; i < xen_phys_ncpus; i++) {
-			xcp = &xen_phys_cpus[i];
-			cmn_err(CE_NOTE, "cpu%u: (%u, %u, %u) apid %u",
-			    xcp->mc_cpunr, xcp->mc_chipid, xcp->mc_coreid,
-			    xcp->mc_threadid, xcp->mc_apicid);
-		}
-	}
-}
-
-/*
- * Miscellaneous hypercall wrappers with slightly more verbose diagnostics.
- */
-
-void
-xen_set_gdt(ulong_t *frame_list, int entries)
-{
-	int err;
-	if ((err = HYPERVISOR_set_gdt(frame_list, entries)) != 0) {
-		/*
-		 * X_EINVAL:	reserved entry or bad frames
-		 * X_EFAULT:	bad address
-		 */
-		panic("xen_set_gdt(%p, %d): error %d",
-		    (void *)frame_list, entries, -(int)err);
-	}
-}
-
-void
-xen_set_ldt(user_desc_t *ldt, uint_t nsels)
-{
-	struct mmuext_op	op;
-	long			err;
-
-	op.cmd = MMUEXT_SET_LDT;
-	op.arg1.linear_addr = (uintptr_t)ldt;
-	op.arg2.nr_ents = nsels;
-
-	if ((err = HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF)) != 0) {
-		panic("xen_set_ldt(%p, %d): error %d",
-		    (void *)ldt, nsels, -(int)err);
-	}
-}
-
-void
-xen_stack_switch(ulong_t ss, ulong_t esp)
-{
-	long err;
-
-	if ((err = HYPERVISOR_stack_switch(ss, esp)) != 0) {
-		/*
-		 * X_EPERM:	bad selector
-		 */
-		panic("xen_stack_switch(%lx, %lx): error %d", ss, esp,
-		    -(int)err);
-	}
-}
-
-long
-xen_set_trap_table(trap_info_t *table)
-{
-	long err;
-
-	if ((err = HYPERVISOR_set_trap_table(table)) != 0) {
-		/*
-		 * X_EFAULT:	bad address
-		 * X_EPERM:	bad selector
-		 */
-		panic("xen_set_trap_table(%p): error %d", (void *)table,
-		    -(int)err);
-	}
-	return (err);
-}
-
-#if defined(__amd64)
-void
-xen_set_segment_base(int reg, ulong_t value)
-{
-	long err;
-
-	if ((err = HYPERVISOR_set_segment_base(reg, value)) != 0) {
-		/*
-		 * X_EFAULT:	bad address
-		 * X_EINVAL:	bad type
-		 */
-		panic("xen_set_segment_base(%d, %lx): error %d",
-		    reg, value, -(int)err);
-	}
-}
-#endif	/* __amd64 */
-
-/*
- * Translate a hypervisor errcode to a Solaris error code.
- */
-int
-xen_xlate_errcode(int error)
-{
-	switch (-error) {
-
-	/*
-	 * Translate hypervisor errno's into native errno's
-	 */
-
-#define	CASE(num)	case X_##num: error = num; break
-
-	CASE(EPERM);	CASE(ENOENT);	CASE(ESRCH);
-	CASE(EINTR);	CASE(EIO);	CASE(ENXIO);
-	CASE(E2BIG);	CASE(ENOMEM);	CASE(EACCES);
-	CASE(EFAULT);	CASE(EBUSY);	CASE(EEXIST);
-	CASE(ENODEV);	CASE(EISDIR);	CASE(EINVAL);
-	CASE(ENOSPC);	CASE(ESPIPE);	CASE(EROFS);
-	CASE(ENOSYS);	CASE(ENOTEMPTY); CASE(EISCONN);
-	CASE(ENODATA);	CASE(EAGAIN);
-
-#undef CASE
-
-	default:
-		panic("xen_xlate_errcode: unknown error %d", error);
-	}
-
-	return (error);
-}
-
-/*
- * Raise PS_IOPL on current vcpu to user level.
- * Caller responsible for preventing kernel preemption.
- */
-void
-xen_enable_user_iopl(void)
-{
-	physdev_set_iopl_t set_iopl;
-	set_iopl.iopl = 3;		/* user ring 3 */
-	(void) HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
-}
-
-/*
- * Drop PS_IOPL on current vcpu to kernel level
- */
-void
-xen_disable_user_iopl(void)
-{
-	physdev_set_iopl_t set_iopl;
-	set_iopl.iopl = 1;		/* kernel pseudo ring 1 */
-	(void) HYPERVISOR_physdev_op(PHYSDEVOP_set_iopl, &set_iopl);
-}
-
-int
-xen_gdt_setprot(cpu_t *cp, uint_t prot)
-{
-	int err;
-#if defined(__amd64)
-	int pt_bits = PT_VALID;
-	if (prot & PROT_WRITE)
-		pt_bits |= PT_WRITABLE;
-#endif
-
-	if ((err = as_setprot(&kas, (caddr_t)cp->cpu_gdt,
-	    MMU_PAGESIZE, prot)) != 0)
-		goto done;
-
-#if defined(__amd64)
-	err = xen_kpm_page(mmu_btop(cp->cpu_m.mcpu_gdtpa), pt_bits);
-#endif
-
-done:
-	if (err) {
-		cmn_err(CE_WARN, "cpu%d: xen_gdt_setprot(%s) failed: error %d",
-		    cp->cpu_id, (prot & PROT_WRITE) ? "writable" : "read-only",
-		    err);
-	}
-
-	return (err);
-}
-
-int
-xen_ldt_setprot(user_desc_t *ldt, size_t lsize, uint_t prot)
-{
-	int err;
-	caddr_t	lva = (caddr_t)ldt;
-#if defined(__amd64)
-	int pt_bits = PT_VALID;
-	pgcnt_t npgs;
-	if (prot & PROT_WRITE)
-		pt_bits |= PT_WRITABLE;
-#endif	/* __amd64 */
-
-	if ((err = as_setprot(&kas, (caddr_t)ldt, lsize, prot)) != 0)
-		goto done;
-
-#if defined(__amd64)
-
-	ASSERT(IS_P2ALIGNED(lsize, PAGESIZE));
-	npgs = mmu_btop(lsize);
-	while (npgs--) {
-		if ((err = xen_kpm_page(hat_getpfnum(kas.a_hat, lva),
-		    pt_bits)) != 0)
-			break;
-		lva += PAGESIZE;
-	}
-#endif	/* __amd64 */
-
-done:
-	if (err) {
-		cmn_err(CE_WARN, "xen_ldt_setprot(%p, %s) failed: error %d",
-		    (void *)lva,
-		    (prot & PROT_WRITE) ? "writable" : "read-only", err);
-	}
-
-	return (err);
-}
-
-int
-xen_get_mc_physcpuinfo(xen_mc_logical_cpu_t *log_cpus, uint_t *ncpus)
-{
-	xen_mc_t xmc;
-	struct xen_mc_physcpuinfo *cpi = &xmc.u.mc_physcpuinfo;
-
-	cpi->ncpus = *ncpus;
-	/*LINTED: constant in conditional context*/
-	set_xen_guest_handle(cpi->info, log_cpus);
-
-	if (HYPERVISOR_mca(XEN_MC_physcpuinfo, &xmc) != 0)
-		return (-1);
-
-	*ncpus = cpi->ncpus;
-	return (0);
-}
-
-void
-print_panic(const char *str)
-{
-	xen_printf(str);
-}
-
-/*
- * Interfaces to iterate over real cpu information, but only that info
- * which we choose to expose here.  These are of interest to dom0
- * only (and the backing hypercall should not work for domu).
- */
-
-xen_mc_lcpu_cookie_t
-xen_physcpu_next(xen_mc_lcpu_cookie_t cookie)
-{
-	xen_mc_logical_cpu_t *xcp = (xen_mc_logical_cpu_t *)cookie;
-
-	if (!DOMAIN_IS_INITDOMAIN(xen_info))
-		return (NULL);
-
-	if (cookie == NULL)
-		return ((xen_mc_lcpu_cookie_t)xen_phys_cpus);
-
-	if (xcp == xen_phys_cpus + xen_phys_ncpus - 1)
-		return (NULL);
-	else
-		return ((xen_mc_lcpu_cookie_t)++xcp);
-}
-
-#define	COOKIE2XCP(c) ((xen_mc_logical_cpu_t *)(c))
-
-const char *
-xen_physcpu_vendorstr(xen_mc_lcpu_cookie_t cookie)
-{
-	xen_mc_logical_cpu_t *xcp = COOKIE2XCP(cookie);
-
-	return ((const char *)&xcp->mc_vendorid[0]);
-}
-
-int
-xen_physcpu_family(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_family);
-}
-
-int
-xen_physcpu_model(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_model);
-}
-
-int
-xen_physcpu_stepping(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_step);
-}
-
-id_t
-xen_physcpu_chipid(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_chipid);
-}
-
-id_t
-xen_physcpu_coreid(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_coreid);
-}
-
-id_t
-xen_physcpu_strandid(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_threadid);
-}
-
-id_t
-xen_physcpu_initial_apicid(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_clusterid);
-}
-
-id_t
-xen_physcpu_logical_id(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_cpunr);
-}
-
-boolean_t
-xen_physcpu_is_cmt(xen_mc_lcpu_cookie_t cookie)
-{
-	return (COOKIE2XCP(cookie)->mc_nthreads > 1);
-}
-
-uint64_t
-xen_physcpu_mcg_cap(xen_mc_lcpu_cookie_t cookie)
-{
-	xen_mc_logical_cpu_t *xcp = COOKIE2XCP(cookie);
-
-	/*
-	 * Need to #define the indices, or search through the array.
-	 */
-	return (xcp->mc_msrvalues[0].value);
-}
-
-int
-xen_map_gref(uint_t cmd, gnttab_map_grant_ref_t *mapop, uint_t count,
-    boolean_t uvaddr)
-{
-	long rc;
-	uint_t i;
-
-	ASSERT(cmd == GNTTABOP_map_grant_ref);
-
-#if !defined(_BOOT)
-	if (uvaddr == B_FALSE) {
-		for (i = 0; i < count; ++i) {
-			mapop[i].flags |= (PT_FOREIGN <<_GNTMAP_guest_avail0);
-		}
-	}
-#endif
-
-	rc = HYPERVISOR_grant_table_op(cmd, mapop, count);
-
-	return (rc);
-}
-
-static int
-xpv_get_physinfo(xen_sysctl_physinfo_t *pi)
-{
-	xen_sysctl_t op;
-	struct sp { void *p; } *sp = (struct sp *)&op.u.physinfo.cpu_to_node;
-	int ret;
-
-	bzero(&op, sizeof (op));
-	op.cmd = XEN_SYSCTL_physinfo;
-	op.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
-	/*LINTED: constant in conditional context*/
-	set_xen_guest_handle(*sp, NULL);
-
-	ret = HYPERVISOR_sysctl(&op);
-
-	if (ret != 0)
-		return (xen_xlate_errcode(ret));
-
-	bcopy(&op.u.physinfo, pi, sizeof (op.u.physinfo));
-	return (0);
-}
-
-/*
- * On dom0, we can determine the number of physical cpus on the machine.
- * This number is important when figuring out what workarounds are
- * appropriate, so compute it now.
- */
-uint_t
-xpv_nr_phys_cpus(void)
-{
-	static uint_t nphyscpus = 0;
-
-	ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
-
-	if (nphyscpus == 0) {
-		xen_sysctl_physinfo_t pi;
-		int ret;
-
-		if ((ret = xpv_get_physinfo(&pi)) != 0)
-			panic("xpv_get_physinfo() failed: %d\n", ret);
-		nphyscpus = pi.nr_cpus;
-	}
-	return (nphyscpus);
-}
-
-pgcnt_t
-xpv_nr_phys_pages(void)
-{
-	xen_sysctl_physinfo_t pi;
-	int ret;
-
-	ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
-
-	if ((ret = xpv_get_physinfo(&pi)) != 0)
-		panic("xpv_get_physinfo() failed: %d\n", ret);
-
-	return ((pgcnt_t)pi.total_pages);
-}
-
-uint64_t
-xpv_cpu_khz(void)
-{
-	xen_sysctl_physinfo_t pi;
-	int ret;
-
-	ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
-
-	if ((ret = xpv_get_physinfo(&pi)) != 0)
-		panic("xpv_get_physinfo() failed: %d\n", ret);
-	return ((uint64_t)pi.cpu_khz);
-}
--- old/usr/src/uts/i86xpv/os/xen_mmu.c	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,453 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-
-#include <sys/mach_mmu.h>
-#include <sys/machsystm.h>
-#include <sys/cmn_err.h>
-#include <sys/promif.h>
-#include <sys/hypervisor.h>
-#include <sys/bootconf.h>
-#include <sys/ontrap.h>
-#include <sys/rwlock.h>
-#include <sys/sysmacros.h>
-#include <vm/seg_kmem.h>
-#include <vm/kboot_mmu.h>
-#include <vm/hat_pte.h>
-#include <vm/hat.h>
-#include <vm/htable.h>
-#include <vm/hat_i86.h>
-
-start_info_t *xen_info;
-ulong_t mfn_count;
-mfn_t *mfn_list;
-mfn_t *mfn_list_pages;		/* pages that make a table of mfn's */
-				/* that make up the pa_to_ma table */
-mfn_t *mfn_list_pages_page;	/* page of mfn's for mfn_list_pages */
-mfn_t cached_max_mfn;
-uintptr_t xen_virt_start;
-pfn_t *mfn_to_pfn_mapping;
-caddr_t xb_addr;		/* virtual addr for the store_mfn page */
-
-
-/*
- * We need to prevent migration or suspension of a domU while it's
- * manipulating MFN values, as the MFN values will spontaneously
- * change. The next 4 routines provide a mechanism for that.
- * The basic idea is to use reader/writer mutex, readers are any thread
- * that is manipulating MFNs. Only the thread which is going to actually call
- * HYPERVISOR_suspend() will become a writer.
- *
- * Since various places need to manipulate MFNs and also call the HAT,
- * we track if a thread acquires reader status and allow it to recursively
- * do so again. This prevents deadlocks if a migration request
- * is started and waits for some reader, but then the previous reader needs
- * to call into the HAT.
- */
-#define	NUM_M2P_LOCKS 128
-static struct {
-	krwlock_t m2p_rwlock;
-	char m2p_pad[64 - sizeof (krwlock_t)];	/* 64 byte cache line size */
-} m2p_lock[NUM_M2P_LOCKS];
-
-#define	XM2P_HASH	((uintptr_t)curthread->t_tid & (NUM_M2P_LOCKS - 1))
-
-void
-xen_block_migrate(void)
-{
-	if (!DOMAIN_IS_INITDOMAIN(xen_info) &&
-	    ++curthread->t_xpvcntr == 1)
-		rw_enter(&m2p_lock[XM2P_HASH].m2p_rwlock, RW_READER);
-}
-
-void
-xen_allow_migrate(void)
-{
-	if (!DOMAIN_IS_INITDOMAIN(xen_info) &&
-	    --curthread->t_xpvcntr == 0)
-		rw_exit(&m2p_lock[XM2P_HASH].m2p_rwlock);
-}
-
-void
-xen_start_migrate(void)
-{
-	int i;
-
-	ASSERT(curthread->t_xpvcntr == 0);
-	++curthread->t_xpvcntr; /* this allows calls into HAT */
-	for (i = 0; i < NUM_M2P_LOCKS; ++i)
-		rw_enter(&m2p_lock[i].m2p_rwlock, RW_WRITER);
-}
-
-void
-xen_end_migrate(void)
-{
-	int i;
-
-	for (i = 0; i < NUM_M2P_LOCKS; ++i)
-		rw_exit(&m2p_lock[i].m2p_rwlock);
-	ASSERT(curthread->t_xpvcntr == 1);
-	--curthread->t_xpvcntr;
-}
-
-/*ARGSUSED*/
-void
-set_pteval(paddr_t table, uint_t index, uint_t level, x86pte_t pteval)
-{
-	mmu_update_t t;
-	maddr_t mtable = pa_to_ma(table);
-	int retcnt;
-
-	t.ptr = (mtable + index * pte_size) | MMU_NORMAL_PT_UPDATE;
-	t.val = pteval;
-	if (HYPERVISOR_mmu_update(&t, 1, &retcnt, DOMID_SELF) || retcnt != 1)
-		bop_panic("HYPERVISOR_mmu_update() failed");
-}
-
-/*
- * The start_info_t and mfn_list are initially mapped in low "boot" memory.
- * Each has a page aligned address and size. We relocate them up into the
- * kernel's normal address space at this point in time. We also create
- * the arrays that let the hypervisor suspend/resume a domain.
- */
-void
-xen_relocate_start_info(void)
-{
-	maddr_t mach_addr;
-	size_t sz;
-	size_t sz2;
-	offset_t off;
-	uintptr_t addr;
-	uintptr_t old;
-	int i, j;
-
-	/*
-	 * In dom0, we have to account for the console_info structure
-	 * which might immediately follow the start_info in memory.
-	 */
-	sz = sizeof (start_info_t);
-	if (DOMAIN_IS_INITDOMAIN(xen_info) &&
-	    xen_info->console.dom0.info_off >= sizeof (start_info_t)) {
-		sz += xen_info->console.dom0.info_off - sizeof (start_info_t) +
-		    xen_info->console.dom0.info_size;
-	}
-	sz = P2ROUNDUP(sz, MMU_PAGESIZE);
-	addr = (uintptr_t)vmem_alloc(heap_arena, sz, VM_SLEEP);
-	for (off = 0; off < sz; off += MMU_PAGESIZE) {
-		mach_addr = pa_to_ma(pfn_to_pa(va_to_pfn(
-		    (caddr_t)xen_info + off)));
-		kbm_map_ma(mach_addr + off, addr + off, 0);
-	}
-	boot_mapin((caddr_t)addr, sz);
-	old = (uintptr_t)xen_info;
-	xen_info = (start_info_t *)addr;
-	for (off = 0; off < sz; off += MMU_PAGESIZE)
-		kbm_unmap(old + off);
-
-	/*
-	 * Relocate the mfn_list, any number of pages.
-	 */
-	sz = P2ROUNDUP(mfn_count * sizeof (mfn_t), MMU_PAGESIZE);
-	addr = (uintptr_t)vmem_xalloc(heap_arena, sz, MMU_PAGESIZE, 0,
-	    0, 0, 0, VM_SLEEP);
-	for (off = 0; off < sz; off += MMU_PAGESIZE) {
-		mach_addr =
-		    pa_to_ma(pfn_to_pa(va_to_pfn((caddr_t)mfn_list + off)));
-		kbm_map_ma(mach_addr, addr + off, 0);
-	}
-	boot_mapin((caddr_t)addr, sz);
-	old = (uintptr_t)mfn_list;
-	mfn_list = (mfn_t *)addr;
-	xen_info->mfn_list = (mfn_t)addr;
-	for (off = 0; off < sz; off += MMU_PAGESIZE)
-		kbm_unmap(old + off);
-
-	/*
-	 * Create the lists of mfn_list pages needed by suspend/resume.
-	 * Note we skip this for domain 0 as it can't suspend/resume.
-	 */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		sz2 = P2ROUNDUP(mmu_btop(sz) * sizeof (mfn_t), MMU_PAGESIZE);
-		mfn_list_pages = kmem_zalloc(sz2, VM_SLEEP);
-		mfn_list_pages_page = kmem_zalloc(MMU_PAGESIZE, VM_SLEEP);
-		i = 0;
-		for (off = 0; off < sz; off += MMU_PAGESIZE) {
-			j = mmu_btop(off);
-			if (((j * sizeof (mfn_t)) & MMU_PAGEOFFSET) == 0) {
-				mfn_list_pages_page[i++] =
-				    pfn_to_mfn(va_to_pfn(&mfn_list_pages[j]));
-			}
-			mfn_list_pages[j] =
-			    pfn_to_mfn(va_to_pfn((caddr_t)mfn_list + off));
-		}
-		HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
-		    pfn_to_mfn(va_to_pfn(mfn_list_pages_page));
-		HYPERVISOR_shared_info->arch.max_pfn = xen_info->nr_pages;
-	}
-
-	/*
-	 * Remap the shared info (for I/O) into high memory, too.
-	 */
-	sz = MMU_PAGESIZE;
-	addr = (uintptr_t)vmem_alloc(heap_arena, sz, VM_SLEEP);
-	kbm_map_ma(xen_info->shared_info, addr, 0);
-	/* shared info has no PFN so don't do: boot_mapin((caddr_t)addr, sz) */
-	old = (uintptr_t)HYPERVISOR_shared_info;
-	HYPERVISOR_shared_info = (void *)addr;
-	kbm_unmap(old);
-
-	/*
-	 * Remap the console info into high memory, too.
-	 */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		sz = MMU_PAGESIZE;
-		addr = (uintptr_t)vmem_alloc(heap_arena, sz, VM_SLEEP);
-		kbm_map_ma(pfn_to_pa(xen_info->console.domU.mfn), addr, 0);
-		boot_mapin((caddr_t)addr, sz);
-		old = (uintptr_t)HYPERVISOR_console_page;
-		HYPERVISOR_console_page = (void *)addr;
-		kbm_unmap(old);
-	} else {
-		HYPERVISOR_console_page = NULL;
-	}
-
-	/*
-	 * On domUs we need to have the xenbus page (store_mfn) mapped into
-	 * the kernel. This is referenced as xb_addr.
-	 */
-	if (!DOMAIN_IS_INITDOMAIN(xen_info)) {
-		xb_addr = vmem_alloc(heap_arena, MMU_PAGESIZE, VM_SLEEP);
-		kbm_map_ma(mfn_to_ma(xen_info->store_mfn),
-		    (uintptr_t)xb_addr, 0);
-		boot_mapin(xb_addr, MMU_PAGESIZE);
-	}
-}
-
-/*
- * Generate the pfn value to use for a foreign mfn.
- */
-pfn_t
-xen_assign_pfn(mfn_t mfn)
-{
-	pfn_t pfn;
-
-#ifdef DEBUG
-	/*
-	 * make sure this MFN isn't in our list of MFNs
-	 */
-	on_trap_data_t otd;
-	uint_t	on_trap_ready = (t0.t_stk != NULL);
-
-	if (on_trap_ready) {
-		if (on_trap(&otd, OT_DATA_ACCESS) == 0) {
-			pfn = mfn_to_pfn_mapping[mfn];
-			if (pfn < mfn_count && mfn_list[pfn] == mfn)
-				panic("xen_assign_pfn() mfn belongs to us");
-		}
-		no_trap();
-	}
-#endif /* DEBUG */
-
-	if (mfn == MFN_INVALID)
-		panic("xen_assign_pfn(MFN_INVALID) not allowed");
-	pfn = (pfn_t)mfn | PFN_IS_FOREIGN_MFN;
-	if (pfn == mfn)
-		panic("xen_assign_pfn(mfn) PFN_IS_FOREIGN_MFN bit already set");
-	return (pfn);
-}
-
-void
-xen_release_pfn(pfn_t pfn)
-{
-	if (pfn == PFN_INVALID)
-		panic("xen_release_pfn(PFN_INVALID) not allowed");
-	if ((pfn & PFN_IS_FOREIGN_MFN) == 0)
-		panic("mfn high bit not set");
-}
-
-uint_t
-pfn_is_foreign(pfn_t pfn)
-{
-	if (pfn == PFN_INVALID)
-		return (0);
-	return ((pfn & PFN_IS_FOREIGN_MFN) != 0);
-}
-
-pfn_t
-pte2pfn(x86pte_t pte, level_t l)
-{
-	mfn_t mfn = PTE2MFN(pte, l);
-
-	if ((pte & PT_SOFTWARE) >= PT_FOREIGN)
-		return ((pfn_t)mfn | PFN_IS_FOREIGN_MFN);
-	return (mfn_to_pfn(mfn));
-}
-
-mfn_t
-pfn_to_mfn(pfn_t pfn)
-{
-	if (pfn == PFN_INVALID)
-		panic("pfn_to_mfn(PFN_INVALID) not allowed");
-
-	if (pfn & PFN_IS_FOREIGN_MFN)
-		return (pfn & ~PFN_IS_FOREIGN_MFN);
-
-	if (pfn >= mfn_count)
-		panic("pfn_to_mfn(): illegal PFN 0x%lx", pfn);
-
-	return (mfn_list[pfn]);
-}
-
-/*
- * This routine translates an MFN back into the corresponding PFN value.
- * It has to be careful since the mfn_to_pfn_mapping[] might fault
- * as that table is sparse. It also has to check for non-faulting, but out of
- * range that exceed the table.
- */
-pfn_t
-mfn_to_pfn(mfn_t mfn)
-{
-	pfn_t pfn;
-	on_trap_data_t otd;
-	uint_t	on_trap_ready = (t0.t_stk != NULL);
-
-	/*
-	 * Cleared at a suspend or migrate
-	 */
-	if (cached_max_mfn == 0)
-		cached_max_mfn =
-		    HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
-
-	if (cached_max_mfn < mfn)
-		return ((pfn_t)mfn | PFN_IS_FOREIGN_MFN);
-
-	if (on_trap_ready && on_trap(&otd, OT_DATA_ACCESS)) {
-		pfn = (pfn_t)mfn | PFN_IS_FOREIGN_MFN;
-	} else {
-		pfn = mfn_to_pfn_mapping[mfn];
-
-		if (pfn == PFN_INVALID || pfn >= mfn_count ||
-		    pfn_to_mfn(pfn) != mfn)
-			pfn = (pfn_t)mfn | PFN_IS_FOREIGN_MFN;
-	}
-
-	if (on_trap_ready)
-		no_trap();
-
-	/*
-	 * If khat_running is set then we should be checking
-	 * in domUs that migration is blocked while using the
-	 * mfn_to_pfn_mapping[] table.
-	 */
-	ASSERT(!khat_running || DOMAIN_IS_INITDOMAIN(xen_info) ||
-	    rw_read_held(&m2p_lock[XM2P_HASH].m2p_rwlock));
-
-	return (pfn);
-}
-
-/*
- * From a pseudo-physical address, find the corresponding machine address.
- */
-maddr_t
-pa_to_ma(paddr_t pa)
-{
-	mfn_t mfn = pfn_to_mfn(mmu_btop(pa));
-
-	if (mfn == MFN_INVALID)
-		panic("pa_to_ma() got MFN_INVALID");
-	return (mfn_to_ma(mfn) + (pa & MMU_PAGEOFFSET));
-}
-
-/*
- * From a machine address, find the corresponding pseudo-physical address.
- */
-paddr_t
-ma_to_pa(maddr_t ma)
-{
-	pfn_t pfn = mfn_to_pfn(mmu_btop(ma));
-
-	if (pfn == PFN_INVALID)
-		panic("ma_to_pa() got PFN_INVALID");
-	return (pfn_to_pa(pfn) + (ma & MMU_PAGEOFFSET));
-}
-
-/*
- * When calling reassign_pfn(), the page must be (at least) read locked
- * to make sure swrand does not try to grab it.
- */
-#ifdef DEBUG
-#define	CHECK_PAGE_LOCK(pfn)	{			\
-	page_t *pp = page_numtopp_nolock(pfn);		\
-	if ((pp != NULL) && (!PAGE_LOCKED(pp))) {	\
-		panic("reassign_pfn() called with unlocked page (pfn 0x%lx)", \
-		    pfn);				\
-	}						\
-}
-#else	/* DEBUG */
-#define	CHECK_PAGE_LOCK(pfn)
-#endif	/* DEBUG */
-
-/*
- * Reassign a new machine page to back a physical address.
- */
-void
-reassign_pfn(pfn_t pfn, mfn_t mfn)
-{
-	int mmu_update_return;
-	mmu_update_t t;
-	extern void update_contig_pfnlist(pfn_t, mfn_t, mfn_t);
-
-	ASSERT(pfn != PFN_INVALID);
-	ASSERT(!pfn_is_foreign(pfn));
-
-	ASSERT(pfn < mfn_count);
-	update_contig_pfnlist(pfn, mfn_list[pfn], mfn);
-	if (mfn == MFN_INVALID) {
-		CHECK_PAGE_LOCK(pfn);
-		if (kpm_vbase != NULL && xen_kpm_page(pfn, 0) < 0)
-			panic("reassign_pfn(): failed to remove kpm mapping");
-		mfn_list[pfn] = mfn;
-		return;
-	}
-
-	/*
-	 * Verify that previously given away pages are still page locked.
-	 */
-	if (mfn_list[pfn] == MFN_INVALID) {
-		CHECK_PAGE_LOCK(pfn);
-	}
-	mfn_list[pfn] = mfn;
-
-	t.ptr = mfn_to_ma(mfn) | MMU_MACHPHYS_UPDATE;
-	t.val = pfn;
-
-	if (HYPERVISOR_mmu_update(&t, 1, &mmu_update_return, DOMID_SELF))
-		panic("HYPERVISOR_mmu_update() failed");
-	ASSERT(mmu_update_return == 1);
-
-	if (kpm_vbase != NULL && xen_kpm_page(pfn, PT_VALID | PT_WRITABLE) < 0)
-		panic("reassign_pfn(): failed to enable kpm mapping");
-}
--- old/usr/src/uts/i86xpv/os/xpv_panic.c	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,1029 +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 (c) 2012 Gary Mills
- * Copyright 2016 PALO, Richard.
- *
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- *
- * Copyright 2018 Joyent, Inc.
- */
-
-#include <sys/types.h>
-#include <sys/clock.h>
-#include <sys/psm.h>
-#include <sys/archsystm.h>
-#include <sys/machsystm.h>
-#include <sys/compress.h>
-#include <sys/modctl.h>
-#include <sys/trap.h>
-#include <sys/panic.h>
-#include <sys/regset.h>
-#include <sys/frame.h>
-#include <sys/kobj.h>
-#include <sys/apic.h>
-#include <sys/apic_timer.h>
-#include <sys/dumphdr.h>
-#include <sys/mem.h>
-#include <sys/x86_archext.h>
-#include <sys/xpv_panic.h>
-#include <sys/boot_console.h>
-#include <sys/bootsvcs.h>
-#include <sys/consdev.h>
-#include <vm/hat_pte.h>
-#include <vm/hat_i86.h>
-
-/* XXX: need to add a PAE version too, if we ever support both PAE and non */
-#if defined(__i386)
-#define	XPV_FILENAME	"/boot/xen-syms"
-#else
-#define	XPV_FILENAME	"/boot/amd64/xen-syms"
-#endif
-#define	XPV_MODNAME	"xpv"
-
-int xpv_panicking = 0;
-
-struct module *xpv_module;
-struct modctl *xpv_modctl;
-
-#define	ALIGN(x, a)	((a) == 0 ? (uintptr_t)(x) : \
-	(((uintptr_t)(x) + (uintptr_t)(a) - 1l) & ~((uintptr_t)(a) - 1l)))
-
-/* Pointer to the xpv_panic_info structure handed to us by Xen.  */
-static struct panic_info *xpv_panic_info = NULL;
-
-/* Timer support */
-#define	NSEC_SHIFT 5
-#define	T_XPV_TIMER	0xd1
-#define	XPV_TIMER_INTERVAL	1000	/* 1000 microseconds */
-static uint32_t *xpv_apicadr = NULL;
-static uint_t	nsec_scale;
-
-/* IDT support */
-#pragma	align	16(xpv_panic_idt)
-static gate_desc_t	xpv_panic_idt[NIDT];	/* interrupt descriptor table */
-
-/* Xen pagetables mapped into our HAT's ptable windows */
-static pfn_t ptable_pfn[MAX_NUM_LEVEL];
-
-/* Number of MMU_PAGESIZE pages we're adding to the Solaris dump */
-static int xpv_dump_pages;
-
-/*
- * There are up to two large swathes of RAM that we don't want to include
- * in the dump: those that comprise the Xen version of segkpm.  On 32-bit
- * systems there is no such region of memory.  On 64-bit systems, there
- * should be just a single contiguous region that corresponds to all of
- * physical memory.  The tricky bit is that Xen's heap sometimes lives in
- * the middle of their segkpm, and is mapped using only kpm-like addresses.
- * In that case, we need to skip the swathes before and after Xen's heap.
- */
-uintptr_t kpm1_low = 0;
-uintptr_t kpm1_high = 0;
-uintptr_t kpm2_low = 0;
-uintptr_t kpm2_high = 0;
-
-/*
- * Some commonly used values that we don't want to recompute over and over.
- */
-static int xpv_panic_nptes[MAX_NUM_LEVEL];
-static ulong_t xpv_panic_cr3;
-static uintptr_t xpv_end;
-
-static void xpv_panic_console_print(const char *fmt, ...);
-static void (*xpv_panic_printf)(const char *, ...) = xpv_panic_console_print;
-
-#define	CONSOLE_BUF_SIZE	256
-static char console_buffer[CONSOLE_BUF_SIZE];
-static boolean_t use_polledio;
-
-/*
- * Pointers to machine check panic info (if any).
- */
-xpv_mca_panic_data_t *xpv_mca_panic_data = NULL;
-
-static void
-xpv_panic_putc(int m)
-{
-	struct cons_polledio *c = cons_polledio;
-
-	/* This really shouldn't happen */
-	if (boot_console_type(NULL) == CONS_HYPERVISOR)
-		return;
-
-	if (use_polledio == B_TRUE)
-		c->cons_polledio_putchar(c->cons_polledio_argument, m);
-	else
-		bcons_putchar(m);
-}
-
-static void
-xpv_panic_puts(char *msg)
-{
-	char *m;
-
-	dump_timeleft = dump_timeout;
-	for (m = msg; *m; m++)
-		xpv_panic_putc((int)*m);
-}
-
-static void
-xpv_panic_console_print(const char *fmt, ...)
-{
-	va_list ap;
-
-	va_start(ap, fmt);
-	(void) vsnprintf(console_buffer, sizeof (console_buffer), fmt, ap);
-	va_end(ap);
-
-	xpv_panic_puts(console_buffer);
-}
-
-static void
-xpv_panic_map(int level, pfn_t pfn)
-{
-	x86pte_t pte, *pteptr;
-
-	/*
-	 * The provided pfn represents a level 'level' page table.  Map it
-	 * into the 'level' slot in the list of page table windows.
-	 */
-	pteptr = (x86pte_t *)PWIN_PTE_VA(level);
-	pte = pfn_to_pa(pfn) | PT_VALID;
-
-	XPV_ALLOW_PAGETABLE_UPDATES();
-	if (mmu.pae_hat)
-		*pteptr = pte;
-	else
-		*(x86pte32_t *)pteptr = pte;
-	XPV_DISALLOW_PAGETABLE_UPDATES();
-
-	mmu_flush_tlb_page((uintptr_t)PWIN_VA(level));
-}
-
-/*
- * Walk the page tables to find the pfn mapped by the given va.
- */
-static pfn_t
-xpv_va_walk(uintptr_t *vaddr)
-{
-	int l, idx;
-	pfn_t pfn;
-	x86pte_t pte;
-	x86pte_t *ptep;
-	uintptr_t va = *vaddr;
-	uintptr_t scan_va;
-	caddr_t ptable_window;
-	static pfn_t toplevel_pfn;
-	static uintptr_t lastva;
-
-	/*
-	 * If we do anything other than a simple scan through memory, don't
-	 * trust the mapped page tables.
-	 */
-	if (va != lastva + MMU_PAGESIZE)
-		for (l = mmu.max_level; l >= 0; l--)
-			ptable_pfn[l] = PFN_INVALID;
-
-	toplevel_pfn = mmu_btop(xpv_panic_cr3);
-
-	while (va < xpv_end && va >= *vaddr) {
-		/* Find the lowest table with any entry for va */
-		pfn = toplevel_pfn;
-		for (l = mmu.max_level; l >= 0; l--) {
-			if (ptable_pfn[l] != pfn) {
-				xpv_panic_map(l, pfn);
-				ptable_pfn[l] = pfn;
-			}
-
-			/*
-			 * Search this pagetable for any mapping to an
-			 * address >= va.
-			 */
-			ptable_window = PWIN_VA(l);
-			if (l == mmu.max_level && mmu.pae_hat)
-				ptable_window +=
-				    (xpv_panic_cr3 & MMU_PAGEOFFSET);
-
-			idx = (va >> LEVEL_SHIFT(l)) & (xpv_panic_nptes[l] - 1);
-			scan_va = va;
-			while (idx < xpv_panic_nptes[l] && scan_va < xpv_end &&
-			    scan_va >= *vaddr) {
-				ptep = (x86pte_t *)(ptable_window +
-				    (idx << mmu.pte_size_shift));
-				pte = GET_PTE(ptep);
-				if (pte & PTE_VALID)
-					break;
-				idx++;
-				scan_va += mmu.level_size[l];
-			}
-
-			/*
-			 * If there are no valid mappings in this table, we
-			 * can skip to the end of the VA range it covers.
-			 */
-			if (idx == xpv_panic_nptes[l]) {
-				va = NEXT_ENTRY_VA(va, l + 1);
-				break;
-			}
-
-			va = scan_va;
-			/*
-			 * See if we've hit the end of the range.
-			 */
-			if (va >= xpv_end || va < *vaddr)
-				break;
-
-			/*
-			 * If this mapping is for a pagetable, we drop down
-			 * to the next level in the hierarchy and look for
-			 * a mapping in it.
-			 */
-			pfn = PTE2MFN(pte, l);
-			if (!PTE_ISPAGE(pte, l))
-				continue;
-
-			/*
-			 * The APIC page is magic.  Nothing to see here;
-			 * move along.
-			 */
-			if (((uintptr_t)xpv_apicadr & MMU_PAGEMASK) ==
-			    (va & MMU_PAGEMASK)) {
-				va += MMU_PAGESIZE;
-				break;
-			}
-
-			/*
-			 * See if the address is within one of the two
-			 * kpm-like regions we want to skip.
-			 */
-			if (va >= kpm1_low && va < kpm1_high) {
-				va = kpm1_high;
-				break;
-			}
-			if (va >= kpm2_low && va < kpm2_high) {
-				va = kpm2_high;
-				break;
-			}
-
-			/*
-			 * The Xen panic code only handles small pages.  If
-			 * this mapping is for a large page, we need to
-			 * identify the consituent page that covers the
-			 * specific VA we were looking for.
-			 */
-			if (l > 0) {
-				if (l > 1)
-					panic("Xen panic can't cope with "
-					    "giant pages.");
-				idx = (va >> LEVEL_SHIFT(0)) &
-				    (xpv_panic_nptes[0] - 1);
-				pfn += idx;
-			}
-
-			*vaddr = va;
-			lastva = va;
-			return (pfn | PFN_IS_FOREIGN_MFN);
-		}
-	}
-	return (PFN_INVALID);
-}
-
-/*
- * Walk through the Xen VA space, finding pages that are mapped in.
- *
- * These pages all have MFNs rather than PFNs, meaning they may be outside
- * the physical address space the kernel knows about, or they may collide
- * with PFNs the kernel is using.
- *
- * The obvious trick of just adding the PFN_IS_FOREIGN_MFN bit to the MFNs
- * to avoid collisions doesn't work.  The pages need to be written to disk
- * in PFN-order or savecore gets confused.  We can't allocate memory to
- * contruct a sorted pfn->VA reverse mapping, so we have to write the pages
- * to disk in VA order.
- *
- * To square this circle, we simply make up PFNs for each of Xen's pages.
- * We assign each mapped page a fake PFN in ascending order.  These fake
- * PFNs each have the FOREIGN bit set, ensuring that they fall outside the
- * range of Solaris PFNs written by the kernel.
- */
-int
-dump_xpv_addr()
-{
-	uintptr_t va;
-	mem_vtop_t mem_vtop;
-
-	xpv_dump_pages = 0;
-	va = xen_virt_start;
-
-	while (xpv_va_walk(&va) != PFN_INVALID) {
-		mem_vtop.m_as = &kas;
-		mem_vtop.m_va = (void *)va;
-		mem_vtop.m_pfn = (pfn_t)xpv_dump_pages | PFN_IS_FOREIGN_MFN;
-
-		dumpvp_write(&mem_vtop, sizeof (mem_vtop_t));
-		xpv_dump_pages++;
-
-		va += MMU_PAGESIZE;
-	}
-
-	/*
-	 * Add the shared_info page.  This page actually ends up in the
-	 * dump twice: once for the Xen va and once for the Solaris va.
-	 * This isn't ideal, but we don't know the address Xen is using for
-	 * the page, so we can't share it.
-	 */
-	mem_vtop.m_as = &kas;
-	mem_vtop.m_va = HYPERVISOR_shared_info;
-	mem_vtop.m_pfn = (pfn_t)xpv_dump_pages | PFN_IS_FOREIGN_MFN;
-	dumpvp_write(&mem_vtop, sizeof (mem_vtop_t));
-	xpv_dump_pages++;
-
-	return (xpv_dump_pages);
-}
-
-void
-dump_xpv_pfn()
-{
-	pfn_t pfn;
-	int cnt;
-
-	for (cnt = 0; cnt < xpv_dump_pages; cnt++) {
-		pfn = (pfn_t)cnt | PFN_IS_FOREIGN_MFN;
-		dumpvp_write(&pfn, sizeof (pfn));
-	}
-}
-
-int
-dump_xpv_data(void *dump_cbuf)
-{
-	uintptr_t va;
-	uint32_t csize;
-	int cnt = 0;
-
-	/*
-	 * XXX: we should probably run this data through a UE check.  The
-	 * catch is that the UE code relies on on_trap() and getpfnum()
-	 * working.
-	 */
-	va = xen_virt_start;
-
-	while (xpv_va_walk(&va) != PFN_INVALID) {
-		csize = (uint32_t)compress((void *)va, dump_cbuf, PAGESIZE);
-		dumpvp_write(&csize, sizeof (uint32_t));
-		dumpvp_write(dump_cbuf, csize);
-		if (dump_ioerr) {
-			dumphdr->dump_flags &= ~DF_COMPLETE;
-			return (cnt);
-		}
-		cnt++;
-		va += MMU_PAGESIZE;
-	}
-
-	/*
-	 * Finally, dump the shared_info page
-	 */
-	csize = (uint32_t)compress((void *)HYPERVISOR_shared_info, dump_cbuf,
-	    PAGESIZE);
-	dumpvp_write(&csize, sizeof (uint32_t));
-	dumpvp_write(dump_cbuf, csize);
-	if (dump_ioerr)
-		dumphdr->dump_flags &= ~DF_COMPLETE;
-	cnt++;
-
-	return (cnt);
-}
-
-static void *
-showstack(void *fpreg, int xpv_only)
-{
-	struct frame *fpp;
-	ulong_t off;
-	char *sym;
-	uintptr_t pc, fp, lastfp;
-	uintptr_t minaddr = min(KERNELBASE, xen_virt_start);
-
-	fp = (uintptr_t)fpreg;
-	if (fp < minaddr) {
-		xpv_panic_printf("Bad frame ptr: 0x%p\n", fpreg);
-		return (fpreg);
-	}
-
-	do {
-		fpp = (struct frame *)fp;
-		pc = fpp->fr_savpc;
-
-		if ((xpv_only != 0) &&
-		    (fp > xpv_end || fp < xen_virt_start))
-			break;
-		if ((sym = kobj_getsymname(pc, &off)) != NULL)
-			xpv_panic_printf("%08lx %s:%s+%lx\n", fp,
-			    mod_containing_pc((caddr_t)pc), sym, off);
-		else if ((pc >= xen_virt_start) && (pc <= xpv_end))
-			xpv_panic_printf("%08lx 0x%lx (in Xen)\n", fp, pc);
-		else
-			xpv_panic_printf("%08lx %lx\n", fp, pc);
-
-		lastfp = fp;
-		fp = fpp->fr_savfp;
-
-		/*
-		 * Xen marks an exception frame by inverting the frame
-		 * pointer.
-		 */
-		if (fp < lastfp) {
-			if ((~fp > minaddr) && ((~fp) ^ lastfp) < 0xfff)
-				fp = ~fp;
-		}
-	} while (fp > lastfp);
-	return ((void *)fp);
-}
-
-void *
-xpv_traceback(void *fpreg)
-{
-	return (showstack(fpreg, 1));
-}
-
-#if defined(__amd64)
-static void
-xpv_panic_hypercall(ulong_t call)
-{
-	panic("Illegally issued hypercall %d during panic!\n", (int)call);
-}
-#endif
-
-void
-xpv_die(struct regs *rp)
-{
-	struct panic_trap_info ti;
-	struct cregs creg;
-
-	ti.trap_regs = rp;
-	ti.trap_type = rp->r_trapno;
-
-	curthread->t_panic_trap = &ti;
-	if (ti.trap_type == T_PGFLT) {
-		getcregs(&creg);
-		ti.trap_addr = (caddr_t)creg.cr_cr2;
-		panic("Fatal pagefault at 0x%lx.  fault addr=0x%p  rp=0x%p",
-		    rp->r_pc, (void *)ti.trap_addr, (void *)rp);
-	} else {
-		ti.trap_addr = (caddr_t)rp->r_pc;
-		panic("Fatal trap %ld at 0x%lx.  rp=0x%p", rp->r_trapno,
-		    rp->r_pc, (void *)rp);
-	}
-}
-
-/*
- * Build IDT to handle a Xen panic
- */
-static void
-switch_to_xpv_panic_idt()
-{
-	int i;
-	desctbr_t idtr;
-	gate_desc_t *idt = xpv_panic_idt;
-	selector_t cs = get_cs_register();
-
-	for (i = 0; i < 32; i++)
-		set_gatesegd(&idt[i], &xpv_invaltrap, cs, SDT_SYSIGT, TRP_XPL,
-		    0);
-
-	set_gatesegd(&idt[T_ZERODIV], &xpv_div0trap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_SGLSTP], &xpv_dbgtrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_NMIFLT], &xpv_nmiint, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_BOUNDFLT], &xpv_boundstrap, cs, SDT_SYSIGT,
-	    TRP_XPL, 0);
-	set_gatesegd(&idt[T_ILLINST], &xpv_invoptrap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_NOEXTFLT], &xpv_ndptrap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_TSSFLT], &xpv_invtsstrap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_SEGFLT], &xpv_segnptrap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_STKFLT], &xpv_stktrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_GPFLT], &xpv_gptrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_PGFLT], &xpv_pftrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_EXTERRFLT], &xpv_ndperr, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_ALIGNMENT], &xpv_achktrap, cs, SDT_SYSIGT, TRP_XPL,
-	    0);
-	set_gatesegd(&idt[T_MCE], &xpv_mcetrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-	set_gatesegd(&idt[T_SIMDFPE], &xpv_xmtrap, cs, SDT_SYSIGT, TRP_XPL, 0);
-
-	/*
-	 * We have no double fault handler.  Any single fault represents a
-	 * catastrophic failure for us, so there is no attempt to handle
-	 * them cleanly: we just print a message and reboot.  If we
-	 * encounter a second fault while doing that, there is nothing
-	 * else we can do.
-	 */
-
-	/*
-	 * Be prepared to absorb any stray device interrupts received
-	 * while writing the core to disk.
-	 */
-	for (i = 33; i < NIDT; i++)
-		set_gatesegd(&idt[i], &xpv_surprise_intr, cs, SDT_SYSIGT,
-		    TRP_XPL, 0);
-
-	/* The one interrupt we expect to get is from the APIC timer.  */
-	set_gatesegd(&idt[T_XPV_TIMER], &xpv_timer_trap, cs, SDT_SYSIGT,
-	    TRP_XPL, 0);
-
-	idtr.dtr_base = (uintptr_t)xpv_panic_idt;
-	idtr.dtr_limit = sizeof (xpv_panic_idt) - 1;
-	wr_idtr(&idtr);
-
-#if defined(__amd64)
-	/* Catch any hypercalls. */
-	wrmsr(MSR_AMD_LSTAR, (uintptr_t)xpv_panic_hypercall);
-	wrmsr(MSR_AMD_CSTAR, (uintptr_t)xpv_panic_hypercall);
-#endif
-}
-
-static void
-xpv_apic_clkinit()
-{
-	uint_t		apic_ticks = 0;
-
-	/*
-	 * Measure how many APIC ticks there are within a fixed time
-	 * period.  We're going to be fairly coarse here.  This timer is
-	 * just being used to detect a stalled panic, so as long as we have
-	 * the right order of magnitude, everything should be fine.
-	 */
-	xpv_apicadr[APIC_SPUR_INT_REG] = AV_UNIT_ENABLE | APIC_SPUR_INTR;
-	xpv_apicadr[APIC_LOCAL_TIMER] = AV_MASK;
-	xpv_apicadr[APIC_INT_VECT0] = AV_MASK;	/* local intr reg 0 */
-
-	xpv_apicadr[APIC_DIVIDE_REG] = 0;
-	xpv_apicadr[APIC_INIT_COUNT] = APIC_MAXVAL;
-	drv_usecwait(XPV_TIMER_INTERVAL);
-	apic_ticks = APIC_MAXVAL - xpv_apicadr[APIC_CURR_COUNT];
-
-	/*
-	 * apic_ticks now represents roughly how many apic ticks comprise
-	 * one timeout interval.  Program the timer to send us an interrupt
-	 * every time that interval expires.
-	 */
-	xpv_apicadr[APIC_LOCAL_TIMER] = T_XPV_TIMER | AV_PERIODIC;
-	xpv_apicadr[APIC_INIT_COUNT] = apic_ticks;
-	xpv_apicadr[APIC_EOI_REG] = 0;
-}
-
-void
-xpv_timer_tick(void)
-{
-	static int ticks = 0;
-
-	if (ticks++ >= MICROSEC / XPV_TIMER_INTERVAL) {
-		ticks = 0;
-		if (dump_timeleft && (--dump_timeleft == 0))
-			panic("Xen panic timeout\n");
-	}
-	xpv_apicadr[APIC_EOI_REG] = 0;
-}
-
-void
-xpv_interrupt(void)
-{
-#ifdef	DEBUG
-	static int cnt = 0;
-
-	if (cnt++ < 10)
-		xpv_panic_printf("Unexpected interrupt received.\n");
-	if ((cnt < 1000) && ((cnt % 100) == 0))
-		xpv_panic_printf("%d unexpected interrupts received.\n", cnt);
-#endif
-
-	xpv_apicadr[APIC_EOI_REG] = 0;
-}
-
-/*
- * Managing time in panic context is trivial.  We only have a single CPU,
- * we never get rescheduled, we never get suspended.  We just need to
- * convert clock ticks into nanoseconds.
- */
-static hrtime_t
-xpv_panic_gethrtime(void)
-{
-	hrtime_t tsc, hrt;
-	unsigned int *l = (unsigned int *)&(tsc);
-
-	tsc = __rdtsc_insn();
-	hrt = (mul32(l[1], nsec_scale) << NSEC_SHIFT) +
-	    (mul32(l[0], nsec_scale) >> (32 - NSEC_SHIFT));
-
-	return (hrt);
-}
-
-static void
-xpv_panic_time_init()
-{
-	nsec_scale =
-	    CPU->cpu_m.mcpu_vcpu_info->time.tsc_to_system_mul >> NSEC_SHIFT;
-
-	gethrtimef = xpv_panic_gethrtime;
-}
-
-static void
-xpv_panicsys(struct regs *rp, char *fmt, ...)
-{
-	extern void panicsys(const char *, va_list, struct regs *, int);
-	va_list alist;
-
-	va_start(alist, fmt);
-	panicsys(fmt, alist, rp, 1);
-	va_end(alist);
-}
-
-void
-xpv_do_panic(void *arg)
-{
-	struct panic_info *pip = (struct panic_info *)arg;
-	int l;
-	struct cregs creg;
-#if defined(__amd64)
-	extern uintptr_t postbootkernelbase;
-#endif
-
-	if (xpv_panicking++ > 0)
-		panic("multiple calls to xpv_do_panic()");
-
-	/*
-	 * Indicate to the underlying panic framework that a panic has been
-	 * initiated.  This is ordinarily done as part of vpanic().  Since
-	 * we already have all the register state saved by the hypervisor,
-	 * we skip that and jump straight into the panic processing code.
-	 *
-	 * XXX If another thread grabs and wins the panic_quiesce trigger
-	 * then we'll have two threads in panicsys believing they are in
-	 * charge of the panic attempt!
-	 */
-	(void) panic_trigger(&panic_quiesce);
-
-#if defined(__amd64)
-	/*
-	 * bzero() and bcopy() get unhappy when asked to operate on
-	 * addresses outside of the kernel.  At this point Xen is really a
-	 * part of the kernel, so we update the routines' notion of where
-	 * the kernel starts.
-	 */
-	postbootkernelbase = xen_virt_start;
-#endif
-
-#if defined(HYPERVISOR_VIRT_END)
-	xpv_end = HYPERVISOR_VIRT_END;
-#else
-	xpv_end = (uintptr_t)UINTPTR_MAX - sizeof (uintptr_t);
-#endif
-
-	/*
-	 * If we were redirecting console output to the hypervisor, we have
-	 * to stop.
-	 */
-	use_polledio = B_FALSE;
-	if (boot_console_type(NULL) == CONS_HYPERVISOR) {
-		bcons_device_change(CONS_HYPERVISOR);
-	} else if (cons_polledio != NULL &&
-	    cons_polledio->cons_polledio_putchar != NULL)  {
-		if (cons_polledio->cons_polledio_enter != NULL)
-			cons_polledio->cons_polledio_enter(
-			    cons_polledio->cons_polledio_argument);
-		use_polledio = 1;
-	}
-
-	/* Make sure we handle all console output from here on. */
-	sysp->bsvc_putchar = xpv_panic_putc;
-
-	/*
-	 * If we find an unsupported panic_info structure, there's not much
-	 * we can do other than complain, plow on, and hope for the best.
-	 */
-	if (pip->pi_version != PANIC_INFO_VERSION)
-		xpv_panic_printf("Warning: Xen is using an unsupported "
-		    "version of the panic_info structure.\n");
-
-	xpv_panic_info = pip;
-
-#if defined(__amd64)
-	kpm1_low = (uintptr_t)xpv_panic_info->pi_ram_start;
-	if (xpv_panic_info->pi_xen_start == NULL) {
-		kpm1_high = (uintptr_t)xpv_panic_info->pi_ram_end;
-	} else {
-		kpm1_high = (uintptr_t)xpv_panic_info->pi_xen_start;
-		kpm2_low = (uintptr_t)xpv_panic_info->pi_xen_end;
-		kpm2_high = (uintptr_t)xpv_panic_info->pi_ram_end;
-	}
-#endif
-
-	/*
-	 * Make sure we are running on the Solaris %gs.  The Xen panic code
-	 * should already have set up the GDT properly.
-	 */
-	xpv_panic_resetgs();
-#if defined(__amd64)
-	wrmsr(MSR_AMD_GSBASE, (uint64_t)&cpus[0]);
-#endif
-
-	xpv_panic_time_init();
-
-	/*
-	 * Switch to our own IDT, avoiding any accidental returns to Xen
-	 * world.
-	 */
-	switch_to_xpv_panic_idt();
-
-	/*
-	 * Initialize the APIC timer, which is used to detect a hung dump
-	 * attempt.
-	 */
-	xpv_apicadr = pip->pi_apic;
-	xpv_apic_clkinit();
-
-	/*
-	 * Set up a few values that we'll need repeatedly.
-	 */
-	getcregs(&creg);
-	xpv_panic_cr3 = creg.cr_cr3;
-	for (l = mmu.max_level; l >= 0; l--)
-		xpv_panic_nptes[l] = mmu.ptes_per_table;
-#ifdef __i386
-	if (mmu.pae_hat)
-		xpv_panic_nptes[mmu.max_level] = 4;
-#endif
-
-	/* Add the fake Xen module to the module list */
-	if (xpv_module != NULL) {
-		extern int last_module_id;
-
-		xpv_modctl->mod_id = last_module_id++;
-		xpv_modctl->mod_next = &modules;
-		xpv_modctl->mod_prev = modules.mod_prev;
-		modules.mod_prev->mod_next = xpv_modctl;
-		modules.mod_prev = xpv_modctl;
-	}
-
-	if (pip->pi_mca.mpd_magic == MCA_PANICDATA_MAGIC)
-		xpv_mca_panic_data = &pip->pi_mca;
-
-	xpv_panic_printf = printf;
-	xpv_panicsys((struct regs *)pip->pi_regs, pip->pi_panicstr);
-	xpv_panic_printf("Failed to reboot following panic.\n");
-	for (;;)
-		;
-}
-
-/*
- * Set up the necessary data structures to pretend that the Xen hypervisor
- * is a loadable module, allowing mdb to find the Xen symbols in a crash
- * dump.  Since these symbols all map to VA space Solaris doesn't normally
- * have access to, we don't link these structures into the kernel's lists
- * until/unless we hit a Xen panic.
- *
- * The observant reader will note a striking amount of overlap between this
- * code and that found in krtld.  While it would be handy if we could just
- * ask krtld to do this work for us, it's not that simple.  Among the
- * complications: we're not actually loading the text here (grub did it at
- * boot), the .text section is writable, there are no relocations to do,
- * none of the module text/data is in readable memory, etc.  Training krtld
- * to deal with this weird module is as complicated, and more risky, than
- * reimplementing the necessary subset of it here.
- */
-static void
-init_xen_module()
-{
-	struct _buf *file = NULL;
-	struct module *mp;
-	struct modctl *mcp;
-	int i, shn;
-	Shdr *shp, *ctf_shp;
-	char *names = NULL;
-	size_t n, namesize, text_align, data_align;
-#if defined(__amd64)
-	const char machine = EM_AMD64;
-#else
-	const char machine = EM_386;
-#endif
-
-	/* Allocate and init the module structure */
-	mp = kmem_zalloc(sizeof (*mp), KM_SLEEP);
-	mp->filename = kobj_zalloc(strlen(XPV_FILENAME) + 1, KM_SLEEP);
-	(void) strcpy(mp->filename, XPV_FILENAME);
-
-	/* Allocate and init the modctl structure */
-	mcp = kmem_zalloc(sizeof (*mcp), KM_SLEEP);
-	mcp->mod_modname = kobj_zalloc(strlen(XPV_MODNAME) + 1, KM_SLEEP);
-	(void) strcpy(mcp->mod_modname, XPV_MODNAME);
-	mcp->mod_filename = kobj_zalloc(strlen(XPV_FILENAME) + 1, KM_SLEEP);
-	(void) strcpy(mcp->mod_filename, XPV_FILENAME);
-	mcp->mod_inprogress_thread = (kthread_id_t)-1;
-	mcp->mod_ref = 1;
-	mcp->mod_loaded = 1;
-	mcp->mod_loadcnt = 1;
-	mcp->mod_mp = mp;
-
-	/*
-	 * Try to open a Xen image that hasn't had its symbol and CTF
-	 * information stripped off.
-	 */
-	file = kobj_open_file(XPV_FILENAME);
-	if (file == (struct _buf *)-1) {
-		file = NULL;
-		goto err;
-	}
-
-	/*
-	 * Read the header and ensure that this is an ELF file for the
-	 * proper ISA.  If it's not, somebody has done something very
-	 * stupid.  Why bother?  See Mencken.
-	 */
-	if (kobj_read_file(file, (char *)&mp->hdr, sizeof (mp->hdr), 0) < 0)
-		goto err;
-	for (i = 0; i < SELFMAG; i++)
-		if (mp->hdr.e_ident[i] != ELFMAG[i])
-			goto err;
-	if ((mp->hdr.e_ident[EI_DATA] != ELFDATA2LSB) ||
-	    (mp->hdr.e_machine != machine))
-		goto err;
-
-	/* Read in the section headers */
-	n = mp->hdr.e_shentsize * mp->hdr.e_shnum;
-	mp->shdrs = kmem_zalloc(n, KM_SLEEP);
-	if (kobj_read_file(file, mp->shdrs, n, mp->hdr.e_shoff) < 0)
-		goto err;
-
-	/* Read the section names */
-	shp = (Shdr *)(mp->shdrs + mp->hdr.e_shstrndx * mp->hdr.e_shentsize);
-	namesize = shp->sh_size;
-	names = kmem_zalloc(shp->sh_size, KM_SLEEP);
-	if (kobj_read_file(file, names, shp->sh_size, shp->sh_offset) < 0)
-		goto err;
-
-	/*
-	 * Fill in the text and data size fields.
-	 */
-	ctf_shp = NULL;
-	text_align = data_align = 0;
-	for (shn = 1; shn < mp->hdr.e_shnum; shn++) {
-		shp = (Shdr *)(mp->shdrs + shn * mp->hdr.e_shentsize);
-
-		/* Sanity check the offset of the section name */
-		if (shp->sh_name >= namesize)
-			continue;
-
-		/* If we find the symtab section, remember it for later. */
-		if (shp->sh_type == SHT_SYMTAB) {
-			mp->symtbl_section = shn;
-			mp->symhdr = shp;
-			continue;
-		}
-
-		/* If we find the CTF section, remember it for later. */
-		if ((shp->sh_size != 0) &&
-		    (strcmp(names + shp->sh_name, ".SUNW_ctf") == 0)) {
-			ctf_shp = shp;
-			continue;
-		}
-
-		if (!(shp->sh_flags & SHF_ALLOC))
-			continue;
-
-		/*
-		 * Xen marks its text section as writable, so we need to
-		 * look for the name - not just the flag.
-		 */
-		if ((strcmp(&names[shp->sh_name], ".text") != 0) &&
-		    (shp->sh_flags & SHF_WRITE) != 0) {
-			if (shp->sh_addralign > data_align)
-				data_align = shp->sh_addralign;
-			mp->data_size = ALIGN(mp->data_size, data_align);
-			mp->data_size += ALIGN(shp->sh_size, 8);
-			if (mp->data == NULL || mp->data > (char *)shp->sh_addr)
-				mp->data = (char *)shp->sh_addr;
-		} else {
-			if (shp->sh_addralign > text_align)
-				text_align = shp->sh_addralign;
-			mp->text_size = ALIGN(mp->text_size, text_align);
-			mp->text_size += ALIGN(shp->sh_size, 8);
-			if (mp->text == NULL || mp->text > (char *)shp->sh_addr)
-				mp->text = (char *)shp->sh_addr;
-		}
-	}
-	kmem_free(names, namesize);
-	names = NULL;
-	shp = NULL;
-	mcp->mod_text = mp->text;
-	mcp->mod_text_size = mp->text_size;
-
-	/*
-	 * If we have symbol table and string table sections, read them in
-	 * now.  If we don't, we just plow on.  We'll still get a valid
-	 * core dump, but finding anything useful will be just a bit
-	 * harder.
-	 *
-	 * Note: we don't bother with a hash table.  We'll never do a
-	 * symbol lookup unless we crash, and then mdb creates its own.  We
-	 * also don't try to perform any relocations.  Xen should be loaded
-	 * exactly where the ELF file indicates, and the symbol information
-	 * in the file should be complete and correct already.  Static
-	 * linking ain't all bad.
-	 */
-	if ((mp->symhdr != NULL) && (mp->symhdr->sh_link < mp->hdr.e_shnum)) {
-		mp->strhdr = (Shdr *)
-		    (mp->shdrs + mp->symhdr->sh_link * mp->hdr.e_shentsize);
-		mp->nsyms = mp->symhdr->sh_size / mp->symhdr->sh_entsize;
-
-		/* Allocate space for the symbol table and strings.  */
-		mp->symsize = mp->symhdr->sh_size +
-		    mp->nsyms * sizeof (symid_t) + mp->strhdr->sh_size;
-		mp->symspace = kmem_zalloc(mp->symsize, KM_SLEEP);
-		mp->symtbl = mp->symspace;
-		mp->strings = (char *)(mp->symtbl + mp->symhdr->sh_size);
-
-		if ((kobj_read_file(file, mp->symtbl,
-		    mp->symhdr->sh_size, mp->symhdr->sh_offset) < 0) ||
-		    (kobj_read_file(file, mp->strings,
-		    mp->strhdr->sh_size, mp->strhdr->sh_offset) < 0))
-			goto err;
-	}
-
-	/*
-	 * Read in the CTF section
-	 */
-	if ((ctf_shp != NULL) && ((moddebug & MODDEBUG_NOCTF) == 0)) {
-		mp->ctfdata = kmem_zalloc(ctf_shp->sh_size, KM_SLEEP);
-		mp->ctfsize = ctf_shp->sh_size;
-		if (kobj_read_file(file, mp->ctfdata, mp->ctfsize,
-		    ctf_shp->sh_offset) < 0)
-			goto err;
-	}
-
-	kobj_close_file(file);
-
-	xpv_module = mp;
-	xpv_modctl = mcp;
-	return;
-
-err:
-	cmn_err(CE_WARN, "Failed to initialize xpv module.");
-	if (file != NULL)
-		kobj_close_file(file);
-
-	kmem_free(mp->filename, strlen(XPV_FILENAME) + 1);
-	if (mp->shdrs != NULL)
-		kmem_free(mp->shdrs, mp->hdr.e_shentsize * mp->hdr.e_shnum);
-	if (mp->symspace != NULL)
-		kmem_free(mp->symspace, mp->symsize);
-	if (mp->ctfdata != NULL)
-		kmem_free(mp->ctfdata, mp->ctfsize);
-	kmem_free(mp, sizeof (*mp));
-	kmem_free(mcp->mod_filename, strlen(XPV_FILENAME) + 1);
-	kmem_free(mcp->mod_modname, strlen(XPV_MODNAME) + 1);
-	kmem_free(mcp, sizeof (*mcp));
-	if (names != NULL)
-		kmem_free(names, namesize);
-}
-
-void
-xpv_panic_init()
-{
-	xen_platform_op_t op;
-	int i;
-
-	ASSERT(DOMAIN_IS_INITDOMAIN(xen_info));
-
-	for (i = 0; i < mmu.num_level; i++)
-		ptable_pfn[i] = PFN_INVALID;
-
-	/* Let Xen know where to jump if/when it panics. */
-	op.cmd = XENPF_panic_init;
-	op.interface_version = XENPF_INTERFACE_VERSION;
-	op.u.panic_init.panic_addr = (unsigned long)xpv_panic_hdlr;
-
-	(void) HYPERVISOR_platform_op(&op);
-
-	init_xen_module();
-}
--- old/usr/src/uts/i86xpv/os/xpv_timestamp.c	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,172 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- * Copyright 2016 Joyent, Inc.
- */
-
-#include <sys/types.h>
-#include <sys/clock.h>
-#include <sys/panic.h>
-#include <sys/atomic.h>
-#include <sys/hypervisor.h>
-
-#include <sys/archsystm.h>
-
-/*
- * On the hypervisor, we have a virtualized system time based upon the
- * information provided for each VCPU, which is updated every time it is
- * scheduled onto a real CPU.  Thus, none of the traditional code in
- * i86pc/os/timestamp.c applies, our gethrtime() implementation is run through
- * the PSM, and there is no scaling step to apply.
- *
- * However, the platform does not guarantee monotonicity; thus we have to fake
- * this up, which is a deeply unpleasant thing to have to do.
- *
- * Note that the virtualized interface still relies on the current TSC to
- * calculate the time in nanoseconds since the VCPU was scheduled, and is thus
- * subject to all the problems with that.  For the most part, the hypervisor is
- * supposed to deal with them.
- *
- * Another wrinkle involves suspend/resume/migration.  If we come back and time
- * is apparently less, we may have resumed on a different machine or on the
- * same machine after a reboot.  In this case we need to maintain an addend to
- * ensure time continues reasonably.  Otherwise we could end up taking a very
- * long time to expire cyclics in the heap.  Thus we have two functions:
- *
- * xpv_getsystime()
- *
- *	The unadulterated system time from the hypervisor.  This is only to be
- *	used when programming the hypervisor (setting a timer or calculating
- *	the TOD).
- *
- * xpv_gethrtime()
- *
- *	This is the monotonic hrtime counter to be used by everything else such
- *	as the cyclic subsystem.  We should never pass an hrtime directly into
- *	a hypervisor interface, as hrtime_addend may well be non-zero.
- */
-
-int hrtime_fake_mt = 1;
-static volatile hrtime_t hrtime_last;
-static hrtime_t hrtime_suspend_time;
-static hrtime_t hrtime_addend;
-
-volatile uint32_t hres_lock;
-hrtime_t hres_last_tick;
-int64_t hrestime_adj;
-volatile timestruc_t hrestime;
-
-/*
- * These functions are used in DTrace probe context, and must be removed from
- * fbt consideration.  Currently fbt ignores all weak symbols, so this will
- * achieve that.
- */
-#pragma weak xpv_gethrtime = dtrace_xpv_gethrtime
-#pragma weak xpv_getsystime = dtrace_xpv_getsystime
-#pragma weak dtrace_gethrtime = dtrace_xpv_gethrtime
-#pragma weak tsc_read = dtrace_xpv_gethrtime
-
-hrtime_t
-dtrace_xpv_getsystime(void)
-{
-	vcpu_time_info_t *src;
-	vcpu_time_info_t __vti, *dst = &__vti;
-	uint64_t tsc_delta;
-	uint64_t tsc;
-	hrtime_t result;
-	uint32_t stamp;
-
-	src = &CPU->cpu_m.mcpu_vcpu_info->time;
-
-	/*
-	 * Loop until version has not been changed during our update, and a Xen
-	 * update is not under way (lowest bit is set).
-	 */
-	do {
-		dst->version = src->version;
-		stamp = CPU->cpu_m.mcpu_istamp;
-
-		membar_consumer();
-
-		dst->tsc_timestamp = src->tsc_timestamp;
-		dst->system_time = src->system_time;
-		dst->tsc_to_system_mul = src->tsc_to_system_mul;
-		dst->tsc_shift = src->tsc_shift;
-
-		/*
-		 * Note that this use of the -actual- TSC register
-		 * should probably be the SOLE one in the system on this
-		 * paravirtualized platform.
-		 */
-		tsc = __rdtsc_insn();
-		tsc_delta = tsc - dst->tsc_timestamp;
-
-		membar_consumer();
-
-	} while (((src->version & 1) | (dst->version ^ src->version)) ||
-	    CPU->cpu_m.mcpu_istamp != stamp);
-
-	if (dst->tsc_shift >= 0)
-		tsc_delta <<= dst->tsc_shift;
-	else if (dst->tsc_shift < 0)
-		tsc_delta >>= -dst->tsc_shift;
-
-	result = dst->system_time +
-	    ((uint64_t)(tsc_delta * (uint64_t)dst->tsc_to_system_mul) >> 32);
-
-	return (result);
-}
-
-hrtime_t
-dtrace_xpv_gethrtime(void)
-{
-	hrtime_t result = xpv_getsystime() + hrtime_addend;
-
-	if (hrtime_fake_mt) {
-		hrtime_t last;
-		do {
-			last = hrtime_last;
-			if (result < last)
-				result = last + 1;
-		} while (atomic_cas_64((volatile uint64_t *)&hrtime_last,
-		    last, result) != last);
-	}
-
-	return (result);
-}
-
-void
-xpv_time_suspend(void)
-{
-	hrtime_suspend_time = xpv_getsystime();
-}
-
-void
-xpv_time_resume(void)
-{
-	hrtime_t delta = xpv_getsystime() - hrtime_suspend_time;
-
-	if (delta < 0)
-		hrtime_addend += -delta;
-}
--- old/usr/src/uts/i86xpv/pci-ide/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,97 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-
-#
-#	This makefile drives the production of the pci-ide "drv"
-#	kernel module.
-#
-#	i86xpv 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		= pci-ide
-OBJECTS		= $(PCIIDE_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(PCIIDE_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR	= $(UTSBASE)/common/io/pci-ide
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY) $(CONFMOD)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-#
-#	Overrides.
-#
-DEBUG_FLGS	=
-DEBUG_DEFS	+= $(DEBUG_FLGS)
-
-INC_PATH	+= -I$(UTSBASE)/common/io/pci-ide
-
-CERRWARN	+= -_gcc=-Wno-switch
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/pci/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,103 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-
-#
-#	This makefile drives the production of the PCI nexus driver
-#
-#	i86xpv 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		= pci
-OBJECTS		= $(PCINEXUS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(PCINEXUS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-# depends on misc/pci_autoconfig misc/pcihp
-#
-LDFLAGS		+= -dy -Nmisc/pcihp
-
-#
-# Name of the module is needed by the source, to distinguish from other
-# PCI/PCI-express nexi
-#
-CFLAGS		+= -D_MODULE_NAME="\"$(MODULE)\""
-LINTFLAGS	+= -D_MODULE_NAME="\"$(MODULE)\""
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/pit_beep/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,85 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-# uts/intel/pit_beep/Makefile
-#
-# This makefile drives the production of the pit_beep driver.
-#
-# i86xpv 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		= pit_beep
-OBJECTS		= $(PIT_BEEP_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(PIT_BEEP_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR     = $(UTSBASE)/intel/io
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-# lint pass one enforcement
-#
-CFLAGS += $(CCVERBOSE)
-
-#
-#	Define targets
-#
-ALL_TARGET      = $(BINARY) $(CONFMOD)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET  = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-.KEEP_STATE:
-
-all:		$(ALL_DEPS)
-
-def:		$(DEF_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/privcmd/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,87 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the privcmd
-#	driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= privcmd
-OBJECTS		= $(PRIVCMD_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(PRIVCMD_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-
-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)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/rootnex/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,97 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-
-#
-#	This makefile drives the production of the rootnex driver
-#
-#	i86xpv 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		= rootnex
-OBJECTS		= $(ROOTNEX_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(ROOTNEX_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides.
-#
-LDFLAGS		+= -dy
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-unused-label
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/sys/Makefile	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:22 2018
@@ -1,70 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-UTSBASE = ../..
-
-#
-# include global definitions
-#
-include ../Makefile.i86xpv
-
-#
-# Override defaults.
-#
-FILEMODE = 644
-
-HDRS=  \
-	balloon.h	\
-	machprivregs.h	\
-	xen_mmu.h \
-	xpv_impl.h
-
-ROOTHDRS=	$(HDRS:%=$(USR_PSM_ISYS_DIR)/%)
-
-ROOTDIR=	$(ROOT)/usr/share/src
-ROOTDIRS=	$(ROOTDIR)/uts $(ROOTDIR)/uts/$(PLATFORM)
-
-ROOTLINK=	$(ROOTDIR)/uts/$(PLATFORM)/sys
-LINKDEST=	../../../../platform/$(PLATFORM)/include/sys
-
-CHECKHDRS=	$(HDRS:%.h=%.check)
-
-.KEEP_STATE:
-
-.PARALLEL:	$(CHECKHDRS) $(ROOTHDRS)
-
-install_h:	$(ROOTDIRS) .WAIT $(ROOTHDRS) $(ROOTLINK)
-
-check:		$(CHECKHDRS)
-
-$(ROOTDIRS):
-	$(INS.dir)
-
-$(ROOTLINK):	$(ROOTDIRS)
-	-$(RM) -r $@; $(SYMLINK) $(LINKDEST) $@
-
-FRC:
-
-include ../../Makefile.targ
--- old/usr/src/uts/i86xpv/sys/balloon.h	Fri Aug 10 23:19:22 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,57 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_BALLOON_H
-#define	_SYS_BALLOON_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define	BALLOON_DEV_NAME	"balloon"
-#define	BALLOON_PATHNAME	"xen/" BALLOON_DEV_NAME
-
-#define	BALLOON_DRIVER_NAME	"balloon"
-
-#define	BLN_IOCTL_BASE		('B' << 24) | ('A' << 16)
-
-/*
- * To return the desired value.  These defines are copied in balloon.py
- * in the hypervisor gate, so woe befall anyone who changes these.
- */
-#define	BLN_IOCTL_CURRENT	(BLN_IOCTL_BASE | 0x1)
-#define	BLN_IOCTL_TARGET	(BLN_IOCTL_BASE | 0x2)
-#define	BLN_IOCTL_LOW		(BLN_IOCTL_BASE | 0x3)
-#define	BLN_IOCTL_HIGH		(BLN_IOCTL_BASE | 0x4)
-#define	BLN_IOCTL_LIMIT		(BLN_IOCTL_BASE | 0x5)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_BALLOON_H */
--- old/usr/src/uts/i86xpv/sys/balloon_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,76 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_SYS_BALLOON_IMPL_H
-#define	_SYS_BALLOON_IMPL_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/balloon.h>
-#include <sys/types.h>
-#include <vm/page.h>
-#include <sys/xen_mmu.h>	/* to get typedef of mfn_t */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This file contains interfaces for both the balloon kernel thread
- * and the balloon driver.  The balloon device is installed under /dev/xen,
- * and can be used with the ioctl values in balloon.h to get the balloon
- * memory status.
- */
-
-/* balloon thread declarations */
-void balloon_init(pgcnt_t);
-size_t balloon_values(int);
-void balloon_drv_added(int64_t);
-void balloon_drv_subtracted(int64_t);
-long balloon_alloc_pages(uint_t, mfn_t *);
-long balloon_free_pages(uint_t, mfn_t *, caddr_t, pfn_t *);
-long balloon_replace_pages(uint_t, page_t **, uint_t, uint_t, mfn_t *);
-
-/* balloon driver information */
-#define	BALLOON_MINOR		0
-
-/*
- * Critical stats for the balloon thread.  All values are in pages.
- */
-typedef struct {
-	pgcnt_t bln_current_pages;	/* current reservation */
-	pgcnt_t bln_new_target;		/* target value for reservation */
-	pgcnt_t bln_max_pages;	/* first pfn for which we don't have a page_t */
-	pgcnt_t bln_low;	/* lowest value of reservation since boot */
-	pgcnt_t bln_high;	/* highest value of reservation since boot */
-	spgcnt_t bln_hv_pages;	/* number of total pages given to hypervisor */
-	spgcnt_t bln_hard_limit;	/* domain's max-mem limit */
-} bln_stats_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_BALLOON_IMPL_H */
--- old/usr/src/uts/i86xpv/sys/cpr_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,59 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_SYS_CPR_IMPL_H
-#define	_SYS_CPR_IMPL_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef	__cplusplus
-extern "C" {
-#endif
-
-
-#ifndef _ASM
-
-#include <sys/machparam.h>
-#include <sys/vnode.h>
-#include <sys/pte.h>
-
-
-typedef uint64_t cpr_ptr;
-typedef uint64_t cpr_ext;
-
-struct cpr_map_info {
-	cpr_ptr	virt;
-	cpr_ext	phys;
-	uint_t	size;
-};
-
-#endif /* _ASM */
-
-#ifdef	__cplusplus
-}
-#endif
-
-#endif	/* _SYS_CPR_IMPL_H */
--- old/usr/src/uts/i86xpv/sys/domcaps_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,54 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_SYS_DOMCAPS_IMPL_H
-#define	_SYS_DOMCAPS_IMPL_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * /dev names:
- *	/dev/xen/			- containing directory
- *		capabilities		- domain properties
- */
-
-#define	DOMCAPS_DRIVER_NAME	"domcaps"
-
-#define	DOMCAPS_MINOR		0
-
-#define	DOMCAPS_DEV_NAME	"capabilities"
-#define	DOMCAPS_PATHNAME	"xen/" DOMCAPS_DEV_NAME
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_DOMCAPS_IMPL_H */
--- old/usr/src/uts/i86xpv/sys/evtchn_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,199 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * evtchn.h (renamed to evtchn_impl.h)
- *
- * Communication via Xen event channels.
- * Also definitions for the device that demuxes notifications to userspace.
- *
- * Copyright (c) 2004-2005, K A Fraser
- *
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- */
-
-#ifndef _SYS_EVTCHN_H
-#define	_SYS_EVTCHN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <sys/privregs.h>
-#include <sys/systm.h>
-#include <sys/traptrace.h>
-#include <sys/ddi_intr.h>
-#include <sys/ddi_intr_impl.h>
-#include <sys/avintr.h>
-#include <sys/cpuvar.h>
-#include <sys/hypervisor.h>
-
-/* evtchn binding types */
-#define	IRQT_UNBOUND	0	/* unassigned irq */
-#define	IRQT_PIRQ	1	/* IRQ from phys hdw device */
-#define	IRQT_VIRQ	2	/* Virtual IRQ from Xen */
-#define	IRQT_IPI	3	/* Inter VCPU interrupt IRQ */
-#define	IRQT_EVTCHN	4	/* Virtual device IRQ */
-#define	IRQT_DEV_EVTCHN	5	/* Special evtchn device IRQ */
-
-#define	SET_EVTCHN_BIT(bit, arrayp) \
-	((arrayp)[bit >> EVTCHN_SHIFT] |= \
-	(1ul << ((bit) & ((1ul << EVTCHN_SHIFT) - 1))))
-#define	CLEAR_EVTCHN_BIT(bit, arrayp) \
-	((arrayp)[bit >> EVTCHN_SHIFT] &= \
-		~((1ul << ((bit) & ((1ul << EVTCHN_SHIFT) - 1)))))
-#define	TEST_EVTCHN_BIT(bit, arrayp) \
-	((arrayp)[bit >> EVTCHN_SHIFT] & \
-		(1ul << ((bit) & ((1ul << EVTCHN_SHIFT) - 1))))
-
-/* Xen will never allocate port zero for any purpose. */
-#define	INVALID_EVTCHN	0
-
-/* XXPV - should these defines be somewhere else? xenos.h perhaps? */
-
-#define	IPL_DEBUG	15	/* domain debug interrupt */
-#define	IPL_CONS	9
-#define	IPL_VIF		6
-#define	IPL_VBD		5
-#define	IPL_EVTCHN	1
-
-#define	PIRQ_BASE	0	/* base of pirq range */
-#define	NR_PIRQS	256	/* Number of supported physical irqs */
-#define	DYNIRQ_BASE	(PIRQ_BASE + NR_PIRQS) /* base of dynamic irq range */
-#define	NR_DYNIRQS	256	/* Number of dynamic irqs */
-#define	NR_IRQS		(NR_PIRQS + NR_DYNIRQS) /* total irq count */
-
-#define	PIRQ_TO_IRQ(pirq)	((pirq) + PIRQ_BASE)
-#define	IRQ_TO_PIRQ(irq)	((irq) - PIRQ_BASE)
-
-#define	DYNIRQ_TO_IRQ(dirq)	((dirq) + DYNIRQ_BASE)
-#define	IRQ_TO_DYNIRQ(irq)	((irq) - DYNIRQ_BASE)
-
-#if defined(_LP64)
-#define	EVTCHN_SHIFT	6	/* log2(NBBY * sizeof (ulong_t)) */
-#else
-#define	EVTCHN_SHIFT	5	/* log2(NBBY * sizeof (ulong_t)) */
-#endif
-
-#define	INVALID_IRQ -1
-
-extern int ec_dev_irq;
-extern kmutex_t ec_lock;
-
-typedef struct mec_info {
-	ushort_t mi_evtchns[NCPU];	/* event channels for this IRQ */
-	short mi_irq;			/* the IRQ, or INVALID_IRQ */
-	char mi_shared;			/* one evtchn for all CPUs? */
-} mec_info_t;
-
-/*
- * Careful: ii_ipl is /only/ set if there's a handler for this IRQ.
- */
-typedef struct irq_info {
-	union {
-		ushort_t evtchn;	/* event channel */
-		ushort_t index;		/* index to next table if mec */
-	} ii_u;
-	uchar_t ii_type;		/* IRQ type as above */
-	union {
-		uchar_t ipl;		/* IPL of IRQ, != 0 => has handler */
-		uchar_t	has_handler;	/* alternate name for ipl */
-	} ii_u2;
-} irq_info_t;
-
-extern int ec_is_edge_pirq(int);
-extern int ec_init(void);
-extern void ec_init_debug_irq(void);
-extern void ec_suspend(void);
-extern void ec_resume(void);
-extern void ec_wait_on_evtchn(int, int (*)(void *), void *);
-extern void ec_wait_on_ipi(int, int (*)(void *), void *);
-
-extern void ec_setup_pirq(int, int, cpuset_t *);
-extern void ec_set_irq_affinity(int, cpuset_t);
-extern int ec_set_irq_priority(int, int);
-
-extern int ec_bind_ipi_to_irq(int, int);
-extern void ec_bind_cpu_ipis(int);
-extern int ec_bind_evtchn_to_irq(int);
-extern int ec_bind_virq_to_irq(int, int);
-extern void ec_unbind_irq(int irq);
-
-extern void ec_send_ipi(int, int);
-extern void ec_try_ipi(int, int);
-extern void ec_clear_irq(int);
-extern void ec_unmask_irq(int);
-extern void ec_try_unmask_irq(int);
-extern int ec_block_irq(int);
-extern void ec_unpend_irq(int);
-extern int ec_irq_needs_rebind(int, int);
-extern int ec_irq_rebindable(int);
-extern int ec_pending_irq(unsigned int);
-extern void ec_enable_irq(unsigned int);
-extern void ec_disable_irq(unsigned int);
-
-extern int xen_bind_interdomain(int, int, int *);
-extern int xen_bind_virq(unsigned int, processorid_t, int *);
-extern int xen_alloc_unbound_evtchn(int, int *);
-extern void ec_bind_vcpu(int, int);
-
-extern int ec_mask_evtchn(unsigned int);
-extern void ec_unmask_evtchn(unsigned int);
-extern void ec_clear_evtchn(unsigned int);
-
-extern void ec_notify_via_evtchn(unsigned int);
-
-/*
- * /dev/xen/evtchn handling.
- */
-extern void ec_irq_add_evtchn(int, int);
-extern void ec_irq_rm_evtchn(int, int);
-extern int ec_dev_alloc_irq(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_EVTCHN_H */
--- old/usr/src/uts/i86xpv/sys/machprivregs.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,544 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_SYS_MACHPRIVREGS_H
-#define	_SYS_MACHPRIVREGS_H
-
-#include <sys/hypervisor.h>
-
-/*
- * Platform dependent instruction sequences for manipulating
- * privileged state
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * CLI and STI are quite complex to virtualize!
- */
-
-#if defined(__amd64)
-
-#define	CURVCPU(r)					\
-	movq	%gs:CPU_VCPU_INFO, r
-
-#define	CURTHREAD(r)					\
-	movq	%gs:CPU_THREAD, r
-
-#elif defined(__i386)
-
-#define	CURVCPU(r)					\
-	movl	%gs:CPU_VCPU_INFO, r
-
-#define	CURTHREAD(r)					\
-	movl	%gs:CPU_THREAD, r
-
-#endif	/* __i386 */
-
-#define	XEN_TEST_EVENT_PENDING(r)			\
-	testb	$0xff, VCPU_INFO_EVTCHN_UPCALL_PENDING(r)
-
-#define	XEN_SET_UPCALL_MASK(r)				\
-	movb	$1, VCPU_INFO_EVTCHN_UPCALL_MASK(r)
-
-#define	XEN_GET_UPCALL_MASK(r, mask)			\
-	movb	VCPU_INFO_EVTCHN_UPCALL_MASK(r), mask
-
-#define	XEN_TEST_UPCALL_MASK(r)				\
-	testb	$1, VCPU_INFO_EVTCHN_UPCALL_MASK(r)
-
-#define	XEN_CLEAR_UPCALL_MASK(r)			\
-	ASSERT_UPCALL_MASK_IS_SET;			\
-	movb	$0, VCPU_INFO_EVTCHN_UPCALL_MASK(r)
-
-#ifdef DEBUG
-
-/*
- * Much logic depends on the upcall mask being set at
- * various points in the code; use this macro to validate.
- *
- * Need to use CURVCPU(r) to establish the vcpu pointer.
- */
-#if defined(__amd64)
-
-#define	ASSERT_UPCALL_MASK_IS_SET			\
-	pushq	%r11;					\
-	CURVCPU(%r11);					\
-	XEN_TEST_UPCALL_MASK(%r11);			\
-	jne	6f;					\
-	cmpl	$0, stistipanic(%rip);			\
-	jle	6f;					\
-	movl	$-1, stistipanic(%rip);			\
-	movq	stistimsg(%rip), %rdi;			\
-	xorl	%eax, %eax;				\
-	call	panic;					\
-6:	pushq	%rax;					\
-	pushq	%rbx;					\
-	movl	%gs:CPU_ID, %eax;			\
-	leaq	.+0(%rip), %r11;			\
-	leaq	laststi(%rip), %rbx;			\
-	movq	%r11, (%rbx, %rax, 8);			\
-	popq	%rbx;					\
-	popq	%rax;					\
-	popq	%r11
-
-#define	SAVE_CLI_LOCATION				\
-	pushq	%rax;					\
-	pushq	%rbx;					\
-	pushq	%rcx;					\
-	movl	%gs:CPU_ID, %eax;			\
-	leaq	.+0(%rip), %rcx;			\
-	leaq	lastcli, %rbx;				\
-	movq	%rcx, (%rbx, %rax, 8);			\
-	popq	%rcx;					\
-	popq	%rbx;					\
-	popq	%rax;					\
-
-#elif defined(__i386)
-
-#define	ASSERT_UPCALL_MASK_IS_SET			\
-	pushl	%ecx;					\
-	CURVCPU(%ecx);					\
-	XEN_TEST_UPCALL_MASK(%ecx);			\
-	jne	6f;					\
-	cmpl	$0, stistipanic;			\
-	jle	6f;					\
-	movl	$-1, stistipanic;			\
-	movl	stistimsg, %ecx;			\
-	pushl	%ecx;					\
-	call	panic;					\
-6:	pushl	%eax;					\
-	pushl	%ebx;					\
-	movl	%gs:CPU_ID, %eax;			\
-	leal	.+0, %ecx;				\
-	leal	laststi, %ebx;				\
-	movl	%ecx, (%ebx, %eax, 4);			\
-	popl	%ebx;					\
-	popl	%eax;					\
-	popl	%ecx
-
-#define	SAVE_CLI_LOCATION				\
-	pushl	%eax;					\
-	pushl	%ebx;					\
-	pushl	%ecx;					\
-	movl	%gs:CPU_ID, %eax;			\
-	leal	.+0, %ecx;				\
-	leal	lastcli, %ebx;				\
-	movl	%ecx, (%ebx, %eax, 4);			\
-	popl	%ecx;					\
-	popl	%ebx;					\
-	popl	%eax;					\
-
-#endif	/* __i386 */
-
-#else	/* DEBUG */
-
-#define	ASSERT_UPCALL_MASK_IS_SET	/* empty */
-#define	SAVE_CLI_LOCATION		/* empty */
-
-#endif	/* DEBUG */
-
-#define	KPREEMPT_DISABLE(t)				\
-	addb	$1, T_PREEMPT(t)
-
-#define	KPREEMPT_ENABLE_NOKP(t)				\
-	subb	$1, T_PREEMPT(t)
-
-#define	CLI(r)						\
-	CURTHREAD(r);					\
-	KPREEMPT_DISABLE(r);				\
-	CURVCPU(r);					\
-	XEN_SET_UPCALL_MASK(r);				\
-	SAVE_CLI_LOCATION;				\
-	CURTHREAD(r);					\
-	KPREEMPT_ENABLE_NOKP(r)
-
-#define	CLIRET(r, ret)					\
-	CURTHREAD(r);					\
-	KPREEMPT_DISABLE(r);				\
-	CURVCPU(r);					\
-	XEN_GET_UPCALL_MASK(r, ret);			\
-	XEN_SET_UPCALL_MASK(r);				\
-	SAVE_CLI_LOCATION;				\
-	CURTHREAD(r);					\
-	KPREEMPT_ENABLE_NOKP(r)
-
-/*
- * We use the fact that HYPERVISOR_block will clear the upcall mask
- * for us and then give us an upcall if there is a pending event
- * to achieve getting a callback on this cpu without the danger of
- * being preempted and migrating to another cpu between the upcall
- * enable and the callback delivery.
- */
-#if defined(__amd64)
-
-#define	STI_CLOBBER		/* clobbers %rax, %rdi, %r11 */		\
-	CURVCPU(%r11);							\
-	ASSERT_UPCALL_MASK_IS_SET;					\
-	movw	$0x100, %ax;	/* assume mask set, pending clear */	\
-	movw	$0, %di;	/* clear mask and pending */		\
-	lock;								\
-	cmpxchgw %di, VCPU_INFO_EVTCHN_UPCALL_PENDING(%r11);		\
-	jz	7f;		/* xchg worked, we're done */		\
-	movl	$__HYPERVISOR_sched_op, %eax; /* have pending upcall */	\
-	movl	$SCHEDOP_block, %edi;					\
-	pushq	%rsi;	/* hypercall clobbers C param regs plus r10 */	\
-	pushq	%rcx;							\
-	pushq	%rdx;							\
-	pushq	%r8;							\
-	pushq	%r9;							\
-	pushq	%r10;							\
-	TRAP_INSTR;	/* clear upcall mask, force upcall */ 		\
-	popq	%r10;							\
-	popq	%r9;							\
-	popq	%r8;							\
-	popq	%rdx;							\
-	popq	%rcx;							\
-	popq	%rsi;							\
-7:
-
-#define	STI								\
-	pushq	%r11;							\
-	pushq	%rdi;							\
-	pushq	%rax;							\
-	STI_CLOBBER;	/* clobbers %r11, %rax, %rdi */			\
-	popq	%rax;							\
-	popq	%rdi;							\
-	popq	%r11
-
-#elif defined(__i386)
-
-#define	STI_CLOBBER		/* clobbers %eax, %ebx, %ecx */		\
-	CURVCPU(%ecx);							\
-	ASSERT_UPCALL_MASK_IS_SET;					\
-	movw	$0x100, %ax;	/* assume mask set, pending clear */	\
-	movw	$0, %bx;	/* clear mask and pending */		\
-	lock;								\
-	cmpxchgw %bx, VCPU_INFO_EVTCHN_UPCALL_PENDING(%ecx);		\
-	jz	7f;		/* xchg worked, we're done */		\
-	movl	$__HYPERVISOR_sched_op, %eax; /* have pending upcall */	\
-	movl	$SCHEDOP_block, %ebx;					\
-	TRAP_INSTR;		/* clear upcall mask, force upcall */	\
-7:
-
-#define	STI						\
-	pushl	%eax;					\
-	pushl	%ebx;					\
-	pushl	%ecx;					\
-	STI_CLOBBER;	/* clobbers %eax, %ebx, %ecx */	\
-	popl	%ecx;					\
-	popl	%ebx;					\
-	popl	%eax
-
-#endif	/* __i386 */
-
-/*
- * Map the PS_IE bit to the hypervisor's event mask bit
- * To -set- the event mask, we have to do a CLI
- * To -clear- the event mask, we have to do a STI
- * (with all the accompanying pre-emption and callbacks, ick)
- *
- * And vice versa.
- */
-
-#if defined(__amd64)
-
-#define	IE_TO_EVENT_MASK(rtmp, rfl)		\
-	testq	$PS_IE, rfl;			\
-	jnz	4f;				\
-	CLI(rtmp);				\
-	jmp	5f;				\
-4:	STI;					\
-5:
-
-#define	EVENT_MASK_TO_IE(rtmp, rfl)		\
-	andq	$_BITNOT(PS_IE), rfl;		\
-	CURVCPU(rtmp);				\
-	XEN_TEST_UPCALL_MASK(rtmp);		\
-	jnz	1f;				\
-	orq	$PS_IE, rfl;			\
-1:
-
-#elif defined(__i386)
-
-#define	IE_TO_EVENT_MASK(rtmp, rfl)		\
-	testl	$PS_IE, rfl;			\
-	jnz	4f;				\
-	CLI(rtmp);				\
-	jmp	5f;				\
-4:	STI;					\
-5:
-
-#define	EVENT_MASK_TO_IE(rtmp, rfl)		\
-	andl	$_BITNOT(PS_IE), rfl;		\
-	CURVCPU(rtmp);				\
-	XEN_TEST_UPCALL_MASK(rtmp);		\
-	jnz	1f;				\
-	orl	$PS_IE, rfl;			\
-1:
-
-#endif	/* __i386 */
-
-/*
- * Used to re-enable interrupts in the body of exception handlers
- */
-
-#if defined(__amd64)
-
-#define	ENABLE_INTR_FLAGS		\
-	pushq	$F_ON;			\
-	popfq;				\
-	STI
-
-#elif defined(__i386)
-
-#define	ENABLE_INTR_FLAGS		\
-	pushl	$F_ON;			\
-	popfl;				\
-	STI
-
-#endif	/* __i386 */
-
-/*
- * Virtualize IRET and SYSRET
- */
-
-#if defined(__amd64)
-
-#if defined(DEBUG)
-
-/*
- * Die nastily with a #ud trap if we are about to switch to user
- * mode in HYPERVISOR_IRET and RUPDATE_PENDING is set.
- */
-#define	__ASSERT_NO_RUPDATE_PENDING			\
-	pushq	%r15;					\
-	cmpw	$KCS_SEL, 0x10(%rsp);			\
-	je	1f;					\
-	movq	%gs:CPU_THREAD, %r15;			\
-	movq	T_LWP(%r15), %r15;			\
-	testb	$0x1, PCB_RUPDATE(%r15);		\
-	je	1f;					\
-	ud2;						\
-1:	popq	%r15
-
-#else	/* DEBUG */
-
-#define	__ASSERT_NO_RUPDATE_PENDING
-
-#endif	/* DEBUG */
-
-/*
- * Switching from guest kernel to user mode.
- * flag == VGCF_IN_SYSCALL => return via sysret
- * flag == 0 => return via iretq
- *
- * See definition in public/arch-x86_64.h. Stack going in must be:
- * rax, r11, rcx, flags, rip, cs, rflags, rsp, ss.
- */
-#define	HYPERVISOR_IRET(flag)			\
-	__ASSERT_NO_RUPDATE_PENDING;		\
-	pushq	$flag;				\
-	pushq	%rcx;				\
-	pushq	%r11;				\
-	pushq	%rax;				\
-	movl	$__HYPERVISOR_iret, %eax;	\
-	syscall;				\
-	ud2	/* die nastily if we return! */
-
-#define	IRET	HYPERVISOR_IRET(0)
-
-/*
- * XXPV: Normally we would expect to use sysret to return from kernel to
- *       user mode when using the syscall instruction. The iret hypercall
- *       does support both iret and sysret semantics. For us to use sysret
- *	 style would require that we use the hypervisor's private descriptors
- *	 that obey syscall instruction's imposed segment selector ordering.
- *	 With iret we can use whatever %cs value we choose. We should fix
- *	 this to use sysret one day.
- */
-#define	SYSRETQ	HYPERVISOR_IRET(0)
-#define	SYSRETL	ud2		/* 32-bit syscall/sysret not supported */
-#define	SWAPGS	/* empty - handled in hypervisor */
-
-#elif defined(__i386)
-
-/*
- * Switching from guest kernel to user mode.
- * See definition in public/arch-x86_32.h. Stack going in must be:
- * eax, flags, eip, cs, eflags, esp, ss.
- */
-#define	HYPERVISOR_IRET				\
-	pushl	%eax;				\
-	movl	$__HYPERVISOR_iret, %eax;	\
-	int	$0x82;				\
-	ud2	/* die nastily if we return! */
-
-#define	IRET	HYPERVISOR_IRET
-#define	SYSRET	ud2		/* 32-bit syscall/sysret not supported */
-
-#endif	/* __i386 */
-
-
-/*
- * Xen 3.x wedges the current value of upcall_mask into unused byte of
- * saved %cs on stack at the time of passing through a trap or interrupt
- * gate.  Since Xen also updates PS_IE in %[e,r]lags as well, we always
- * mask off the saved upcall mask so the kernel and/or tools like debuggers
- * will not be confused about bits set in reserved portions of %cs slot.
- *
- * See xen/include/public/arch-x86_[32,64].h:cpu_user_regs_t for details.
- */
-#if defined(__amd64)
-
-#define	CLEAN_CS	movb	$0, REGOFF_CS+4(%rsp)
-
-#elif defined(__i386)
-
-#define	CLEAN_CS	movb	$0, REGOFF_CS+2(%esp)
-
-#endif	/* __i386 */
-
-/*
- * All exceptions for amd64 have %r11 and %rcx on the stack.
- * Just pop them back into their appropriate registers and
- * let it get saved as is running native.
- */
-#if defined(__amd64)
-
-#define	XPV_TRAP_POP	\
-	popq	%rcx;	\
-	popq	%r11
-
-#define	XPV_TRAP_PUSH	\
-	pushq	%r11;	\
-	pushq	%rcx
-
-#endif	/* __amd64 */
-
-
-/*
- * Macros for saving the original segment registers and restoring them
- * for fast traps.
- */
-#if defined(__amd64)
-
-/*
- * Smaller versions of INTR_PUSH and INTR_POP for fast traps.
- * The following registers have been pushed onto the stack by
- * hardware at this point:
- *
- *	greg_t	r_rip;
- *	greg_t	r_cs;
- *	greg_t	r_rfl;
- *	greg_t	r_rsp;
- *	greg_t	r_ss;
- *
- * This handler is executed both by 32-bit and 64-bit applications.
- * 64-bit applications allow us to treat the set (%rdi, %rsi, %rdx,
- * %rcx, %r8, %r9, %r10, %r11, %rax) as volatile across function calls.
- * However, 32-bit applications only expect (%eax, %edx, %ecx) to be volatile
- * across a function call -- in particular, %esi and %edi MUST be saved!
- *
- * We could do this differently by making a FAST_INTR_PUSH32 for 32-bit
- * programs, and FAST_INTR_PUSH for 64-bit programs, but it doesn't seem
- * particularly worth it.
- *
- */
-#define	FAST_INTR_PUSH			\
-	INTGATE_INIT_KERNEL_FLAGS;	\
-	popq	%rcx;			\
-	popq	%r11;			\
-	subq    $REGOFF_RIP, %rsp;	\
-	movq    %rsi, REGOFF_RSI(%rsp);	\
-	movq    %rdi, REGOFF_RDI(%rsp);	\
-	CLEAN_CS
-
-#define	FAST_INTR_POP			\
-	movq    REGOFF_RSI(%rsp), %rsi;	\
-	movq    REGOFF_RDI(%rsp), %rdi;	\
-	addq    $REGOFF_RIP, %rsp
-
-#define	FAST_INTR_RETURN		\
-	ASSERT_UPCALL_MASK_IS_SET;	\
-	HYPERVISOR_IRET(0)
-
-#elif defined(__i386)
-
-#define	FAST_INTR_PUSH			\
-	cld;				\
-	__SEGREGS_PUSH			\
-	__SEGREGS_LOAD_KERNEL		\
-
-#define	FAST_INTR_POP			\
-	__SEGREGS_POP
-
-#define	FAST_INTR_RETURN		\
-	IRET
-
-#endif	/* __i386 */
-
-/*
- * Handling the CR0.TS bit for floating point handling.
- *
- * When the TS bit is *set*, attempts to touch the floating
- * point hardware will result in a #nm trap.
- */
-#if defined(__amd64)
-
-#define	STTS(rtmp)				\
-	pushq	%rdi;				\
-	movl	$1, %edi;			\
-	call	HYPERVISOR_fpu_taskswitch;	\
-	popq	%rdi
-
-#define	CLTS					\
-	pushq	%rdi;				\
-	xorl	%edi, %edi;			\
-	call	HYPERVISOR_fpu_taskswitch;	\
-	popq	%rdi
-
-#elif defined(__i386)
-
-#define	STTS(r)					\
-	pushl	$1;				\
-	call	HYPERVISOR_fpu_taskswitch;	\
-	addl	$4, %esp
-
-#define	CLTS					\
-	pushl	$0;				\
-	call	HYPERVISOR_fpu_taskswitch;	\
-	addl	$4, %esp
-
-#endif	/* __i386 */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _SYS_MACHPRIVREGS_H */
--- old/usr/src/uts/i86xpv/sys/privcmd_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,61 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef	_SYS_PRIVCMD_IMPL_H
-#define	_SYS_PRIVCMD_IMPL_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#include <sys/types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * /dev names:
- *	/dev/xen/			- containing directory
- *		privcmd			- privileged commands
- */
-
-#define	PRIVCMD_DRIVER_NAME	"privcmd"
-
-#define	PRIVCMD_NODE		"privcmd"
-#define	PRIVCMD_MINOR		0
-
-#define	PRIVCMD_DEV_NAME	"privcmd"
-#define	PRIVCMD_PATHNAME	"xen/" PRIVCMD_DEV_NAME
-
-#if defined(_KERNEL)
-
-extern int do_privcmd_hypercall(void *, int, cred_t *, int *);
-
-#endif	/* _KERNEL */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_PRIVCMD_IMPL_H */
--- old/usr/src/uts/i86xpv/sys/xen_mmu.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,135 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_XEN_MMU_H
-#define	_SYS_XEN_MMU_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Platform-dependent MMU routines and types for the hypervisor.
- *
- * WARNING: this header file is used by both dboot and i86pc, so don't go using
- * normal kernel headers.
- */
-
-#if (defined(_BOOT) && defined(_BOOT_TARGET_amd64)) || \
-	(!defined(_BOOT) && defined(__amd64))
-#define	__target_amd64
-#endif
-
-typedef uint64_t maddr_t;
-#define	mfn_to_ma(mfn)	((maddr_t)(mfn) << MMU_PAGESHIFT)
-
-#ifdef __xpv
-
-#ifdef __target_amd64
-
-#define	IN_HYPERVISOR_VA(va) \
-	((va) >= HYPERVISOR_VIRT_START && (va) < HYPERVISOR_VIRT_END)
-
-#else /* __target_amd64 */
-
-#define	IN_HYPERVISOR_VA(va) ((va) >= xen_virt_start)
-
-/*
- * Do this to help catch any uses.
- */
-#undef	HYPERVISOR_VIRT_START
-#undef	machine_to_phys_mapping
-
-#endif /* __target_amd64 */
-
-#undef __target_amd64
-
-paddr_t ma_to_pa(maddr_t);
-maddr_t pa_to_ma(paddr_t);
-#endif /* __xpv */
-
-extern uintptr_t xen_virt_start;
-extern pfn_t *mfn_to_pfn_mapping;
-
-#ifndef _BOOT
-
-/*
- * On the hypervisor we need:
- * - a way to map a machine address (ie, not pseudo-physical).
- * - to relocate initial hypervisor data structures into kernel VA range.
- * - a way to translate between physical addresses and machine addresses.
- * - a way to change the machine address behind a physical address.
- */
-typedef ulong_t mfn_t;
-extern mfn_t *mfn_list;
-extern mfn_t *mfn_list_pages;
-extern mfn_t *mfn_list_pages_page;
-extern ulong_t mfn_count;
-extern mfn_t cached_max_mfn;
-
-/*
- * locks for mfn_list[] and machine_to_phys_mapping[] when migration / suspend
- * events happen
- */
-extern void xen_block_migrate(void);
-extern void xen_allow_migrate(void);
-extern void xen_start_migrate(void);
-extern void xen_end_migrate(void);
-
-/*
- * Conversion between machine (hardware) addresses and pseudo-physical
- * addresses.
- */
-#ifdef __xpv
-pfn_t mfn_to_pfn(mfn_t);
-mfn_t pfn_to_mfn(pfn_t);
-#endif
-
-struct page;
-
-void xen_relocate_start_info(void);
-
-/*
- * interfaces to create/destroy pfn_t values for devices or foreign memory
- *
- * xen_assign_pfn() creates (or looks up) a local pfn value to use for things
- * like a foreign domain memory mfn or a device mfn.
- *
- * xen_release_pfn() destroys the association between a pfn and foreign mfn.
- */
-pfn_t xen_assign_pfn(mfn_t mfn);
-void xen_release_pfn(pfn_t);
-uint_t pfn_is_foreign(pfn_t);
-void reassign_pfn(pfn_t pfn, mfn_t mfn);
-
-#define	MFN_INVALID	(-(mfn_t)1)
-
-#endif /* !_BOOT */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _SYS_XEN_MMU_H */
--- old/usr/src/uts/i86xpv/sys/xpv_impl.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,47 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_XPV_IMPL_H
-#define	_SYS_XPV_IMPL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined(_ASM)
-#include <sys/types.h>
-#endif
-
-#define	__XEN_INTERFACE_VERSION__	__XEN_LATEST_INTERFACE_VERSION__
-
-#include <xen/public/xen.h>
-#include <xen/public/arch-x86/xen-mca.h>
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_XPV_IMPL_H */
--- old/usr/src/uts/i86xpv/sys/xpv_panic.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,62 +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 2007 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_XPV_PANIC_H
-#define	_SYS_XPV_PANIC_H
-
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void xpv_panic_sti();
-extern void xpv_panic_halt();
-extern void xpv_panic_getcrs(ulong_t *);
-extern void xpv_panic_setcr3(ulong_t);
-extern void xpv_panic_reload_cr3();
-extern ulong_t xpv_panic_resetgs();
-extern void xpv_panic_init();
-extern void xpv_panic_hdlr();
-extern void *xpv_traceback(void *);
-
-extern void xpv_div0trap(), xpv_dbgtrap(), xpv_nmiint(), xpv_brktrap();
-extern void xpv_ovflotrap(), xpv_boundstrap(), xpv_invoptrap();
-extern void xpv_ndptrap(), xpv_syserrtrap(), xpv_invaltrap();
-extern void xpv_invtsstrap(), xpv_segnptrap(), xpv_stktrap();
-extern void xpv_gptrap(), xpv_pftrap(), xpv_ndperr();
-extern void xpv_overrun(), xpv_resvtrap();
-extern void xpv_achktrap(), xpv_mcetrap();
-extern void xpv_xmtrap(), xpv_timer_trap(), xpv_surprise_intr();
-
-extern int dump_xpv_addr();
-extern void dump_xpv_pfn();
-extern int dump_xpv_data(void *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _SYS_XPV_PANIC_H */
--- old/usr/src/uts/i86xpv/sys/xpv_user.h	Fri Aug 10 23:19:23 2018
+++ /dev/null	Fri Aug 10 23:19:23 2018
@@ -1,63 +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 2009 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_XPV_SYSCTL_H
-#define	_SYS_XPV_SYSCTL_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * This header file defines things needed for access to sysctl(),
- * domctl(), and other API features that are only used by userspace
- * upstream.  On Solaris, due to privcmd and a couple of other uses, we
- * need them in the kernel, so isolate their use to this file.
- */
-
-#define	__XEN_TOOLS__
-
-#include <sys/hypervisor.h>
-#include <xen/public/sysctl.h>
-#include <xen/public/xsm/acm_ops.h>
-
-
-#if !defined(__GNUC__) && defined(__i386__)
-#define	set_xen_guest_handle_u(hnd, val)  do { (hnd).u.p = val; } while (0)
-#define	get_xen_guest_handle_u(val, hnd)  do { val = (hnd).u.p; } while (0)
-#else
-#define	set_xen_guest_handle_u(hnd, val)  do { (hnd).p = val; } while (0)
-#define	get_xen_guest_handle_u(val, hnd)  do { val = (hnd).p; } while (0)
-#endif
-
-extern long HYPERVISOR_xsm_op(struct xen_acmctl *);
-extern long HYPERVISOR_sysctl(xen_sysctl_t *);
-extern long HYPERVISOR_domctl(xen_domctl_t *domctl);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _SYS_XPV_SYSCTL_H */
--- old/usr/src/uts/i86xpv/unix/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,238 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#	This makefile drives the production of unix (and unix.o).
-#
-#	i86xpv implementation architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-UNIX		= unix
-DBOOT		= dboot
-
-OBJECTS		= $(SPECIAL_OBJS:%=$(OBJS_DIR)/%) \
-		  $(CORE_OBJS:%=$(OBJS_DIR)/%) \
-		  $(KRTLD_OBJS:%=$(OBJS_DIR)/%) \
-		  $(MACH_NOT_YET_KMODS:%=$(OBJS_DIR)/%)
-
-LINTS		= $(SPECIAL_OBJS:%.o=$(LINTS_DIR)/%.ln) \
-		  $(CORE_OBJS:%.o=$(LINTS_DIR)/%.ln) \
-		  $(KRTLD_OBJS:%.o=$(LINTS_DIR)/%.ln) \
-		  $(MACH_NOT_YET_KMODS:%.o=$(LINTS_DIR)/%.ln) \
-		  $(LINTS_DIR)/vers.ln \
-		  $(LINTS_DIR)/modstubs.ln
-
-ROOTMODULE	= $(ROOT_PSM_KERN_DIR)/$(UNIX)
-
-UNIX_BIN	= $(OBJS_DIR)/$(UNIX)
-
-LIBS		= $(GENLIB)
-
-GENUNIX		= genunix
-GENUNIX_DIR	= ../../intel/$(GENUNIX)
-
-LIBOPTS		= -L $(GENUNIX_DIR)/$(OBJS_DIR) -l $(GENUNIX)
-
-CTFEXTRAOBJS	= $(OBJS_DIR)/vers.o
-
-DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
-DBOOT_OBJECTS	= $(DBOOT_OBJS:%=$(DBOOT_OBJS_DIR)/%)
-DBOOT_BIN	= $(DBOOT_OBJS_DIR)/$(DBOOT)
-DBOOT_O		= $(OBJS_DIR)/$(DBOOT).o
-DBOOT_S		= $(DBOOT_O:%.o=%.s)
-DBOOT_LINTS	= $(DBOOT_OBJS:%.o=$(DBOOT_OBJS_DIR)/%.ln)
-DBOOT_LINT	= $(LINT_$(MACH)_$(CLASS))
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(UNIX_BIN)
-LINT_TARGET	= $(LINT_LIB) $(DBOOT_LINT_LIB)
-INSTALL_TARGET	= $(UNIX_BIN) $(ROOTMODULE)
-
-#
-#	This is UNIX_DIR. Use a short path.
-#
-UNIX_DIR	= .
-
-#
-#	Overrides
-#
-CLEANFILES	+=		\
-	$(UNIX_O) $(MODSTUBS_O)	\
-	$(OBJS_DIR)/vers.c $(OBJS_DIR)/vers.o \
-	$(OBJS_DIR)/dtracestubs.s \
-	$(DTRACESTUBS_O) $(DTRACESTUBS)
-
-CLEANFILES	+=		\
-	$(DBOOT_O) $(DBOOT_S)	\
-	$(DBOOT_OBJECTS)	\
-	$(DBOOT_BIN)
-
-CLEANFILES	+=		\
-	$(DBOOT_OBJS_DIR)/$(VGATEXT_FONT).c \
-	$(OBJS_DIR)/$(VGATEXT_FONT).c
-
-CLEANFILES	+=		\
-	$(OBJS_DIR)/fb_swtch_src.o \
-	$(OBJS_DIR)/fb_swtch_src \
-	$(OBJS_DIR)/fb_swtch.s
-
-CLEANFILES	+= \
-	$(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.o) \
-	$(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.ln)
-
-CLOBBERFILES	= $(CLEANFILES) $(UNIX_BIN)
-CLEANLINTFILES	+= $(LINT_LIB) $(DBOOT_LINT_LIB) $(DBOOT_LINTS)
-
-# instr_size needs a special header
-$(OBJS_DIR)/instr_size.o :=	EXTRA_OPTIONS	= -I$(SRC)/common/dis/i386
-$(OBJS_DIR)/instr_size.ln :=	EXTRA_OPTIONS	= -I$(SRC)/common/dis/i386
-
-CFLAGS += -DDIS_MEM
-
-#
-# 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_SUSPICIOUS_COMPARISON
-LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
-LINTTAGS	+= -erroff=E_STATIC_UNUSED
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-char-subscripts
-CERRWARN	+= -_gcc=-Wno-unused-variable
-CERRWARN	+= -_gcc=-Wno-unused-function
-CERRWARN	+= -_gcc=-Wno-unused-label
-CERRWARN	+= -_gcc=-Wno-type-limits
-CERRWARN	+= -_gcc=-Wno-clobbered
-CERRWARN	+= -_gcc=-Wno-unused-value
-CERRWARN	+= -_gcc=-Wno-empty-body
-
-# Ensure that lint sees 'struct cpu' containing a fully declared
-# embedded 'struct machcpu'
-#
-LINTFLAGS	+= -D_MACHDEP -I../../i86pc
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-lint: $(LINT_DEPS)
-
-clean.lint: $(CLEAN_LINT_DEPS)
-
-install: $(INSTALL_DEPS)
-
-MAPFILE_32 = $(MAPFILE)
-MAPFILE_64 = $(MAPFILE).amd64
-
-MAPFILE_NAME = $(MAPFILE_$(CLASS))
-
-$(UNIX_BIN):	$(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
-		$(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
-	$(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
-	    $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
-	    $(DTRACESTUBS)
-	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
-	$(POST_PROCESS)
-
-$(UNIX_O):	$(OBJECTS) $(OBJS_DIR)/vers.o
-	$(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
-
-$(DBOOT_BIN):	$(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
-	$(LD) -dn -e _start -M dboot/Mapfile.dboot \
-		-o $(DBOOT_BIN) $(DBOOT_OBJECTS)
-
-$(DBOOT_O):	$(DBOOT_BIN)
-	@echo "	.data"					> $(DBOOT_S)
-	@echo "	.globl	dboot_image"			>> $(DBOOT_S)
-	@echo "dboot_image:"				>> $(DBOOT_S)
-	$(ELFEXTRACT) $(DBOOT_BIN)			>> $(DBOOT_S)
-	$(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
-
-$(DBOOT_OBJS_DIR):
-	-@mkdir -p $@ 2> /dev/null
-
-#
-#	Special rules for generating assym.h for inclusion in assembly files.
-#
-$(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:	FRC
-	@cd $(DSF_DIR); $(MAKE) all.targ
-
-#
-#	The global lint target builds the kernel lint library (llib-lunix.ln)
-#	which is equivalent to a lint of /unix.o. Then all kernel modules for
-#	this architecture are linted against the kernel lint library.
-#
-#	Note:	lint errors in the kernel lint library will be repeated for
-#		each module. It is important that the kernel lint library
-#		be clean to keep the textual output to a reasonable level.
-#
-
-$(LINT_LIB):	$(LINT_LIB_DIR) $(LINTS)
-	@pwd
-	@-$(ECHO) "\n$(UNIX): (library construction):"
-	@$(LINT) -o$(UNIX) $(LINTFLAGS) $(LINTS)
-	@$(MV) $(@F) $@
-
-$(DBOOT_LINT_LIB):	$(LINT_LIB_DIR) $(DBOOT_LINTS)
-	@pwd
-	@-$(ECHO) "\n$(DBOOT): (library construction):"
-	@$(LINT) -o$(DBOOT) $(DBOOT_LINTFLAGS) $(DBOOT_LINTS)
-	@$(MV) $(@F) $@
-
-lintlib:	$(LINT_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/unix/dboot/Mapfile.dboot	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,59 +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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-$mapfile_version 2
-
-LOAD_SEGMENT dboot {
-	NOHDR;
-	FLAGS = READ WRITE EXECUTE;
-	VADDR = 0x40800000;
-	PADDR = 0x40800000;
-	ALIGN = 0x1000;
-
-	#
-	# Make sure that dboot_xen.s`_start is the first thing in the dboot
-	# .text segment, since when we boot that's where the boot loader will
-	# start execution
-	#
-	ASSIGN_SECTION is_text {
-		IS_NAME = .text;
-		FILE_BASENAME = dboot_xen.o;
-	};
-	ASSIGN_SECTION is_progbits {
-		TYPE = PROGBITS;
-		FLAGS = ALLOC;
-	};
-	ASSIGN_SECTION is_nobits {
-		TYPE = NOBITS;
-		FLAGS = ALLOC;
-	};
-	IS_ORDER = is_text is_progbits is_nobits;
-};
-
-LOAD_SEGMENT otherstuff {
-	ASSIGN_SECTION {
-		FLAGS = ALLOC;
-	};
-};
--- old/usr/src/uts/i86xpv/vm/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,81 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# uts/i86xpv/vm/Makefile
-#
-# Compilation of .c files in this directory is driven by Makefiles in i86xpv.
-# This file only serves to install header files.
-#
-UTSBASE = ../..
-
-#
-# include global definitions
-#
-include ../Makefile.i86xpv
-
-#
-# Override defaults.
-#
-FILEMODE = 644
-
-HDRS=		seg_mf.h
-
-ROOTHDRS=	$(HDRS:%=$(USR_PSM_IVM_DIR)/%)
-
-ROOTDIR=	$(ROOT)/usr/share/src
-ROOTDIRS=	$(ROOTDIR)/uts $(ROOTDIR)/uts/$(PLATFORM)
-
-ROOTLINK=	$(ROOTDIR)/uts/$(PLATFORM)/vm
-LINKDEST=	../../../../platform/$(PLATFORM)/include/vm
-
-CHECKHDRS=	$(HDRS:%.h=%.check)
-
-.KEEP_STATE:
-
-.PARALLEL: $(CHECKHDRS) $(ROOTHDRS)
-
-install_h: $(ROOTDIRS) .WAIT $(ROOTHDRS) $(ROOTLINK)
-
-check:	$(CHECKHDRS)
-
-#
-# install rules
-#
-$(USR_PSM_IVM_DIR)/%: ../vm/% $(USR_PSM_IVM_DIR)
-	$(INS.file)
-
-$(ROOTDIRS):
-	$(INS.dir)
-
-# -r because this used to be a directory and is now a link.
-$(ROOTLINK):    $(ROOTDIRS)
-	-$(RM) -r $@; $(SYMLINK) $(LINKDEST) $@
-
-CLEANFILES=
-
-CLOBBERFILES=
-
-CLEANLINTFILES=
-
-include ../../Makefile.targ
--- old/usr/src/uts/i86xpv/vm/seg_mf.c	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,787 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- * Copyright 2018 Joyent, Inc.
- */
-
-/*
- * Machine frame segment driver.  This segment driver allows dom0 processes to
- * map pages of other domains or Xen (e.g. during save/restore).  ioctl()s on
- * the privcmd driver provide the MFN values backing each mapping, and we map
- * them into the process's address space at this time.  Demand-faulting is not
- * supported by this driver due to the requirements upon some of the ioctl()s.
- */
-
-
-#include <sys/types.h>
-#include <sys/systm.h>
-#include <sys/vmsystm.h>
-#include <sys/mman.h>
-#include <sys/errno.h>
-#include <sys/kmem.h>
-#include <sys/cmn_err.h>
-#include <sys/vnode.h>
-#include <sys/conf.h>
-#include <sys/debug.h>
-#include <sys/lgrp.h>
-#include <sys/hypervisor.h>
-
-#include <vm/page.h>
-#include <vm/hat.h>
-#include <vm/as.h>
-#include <vm/seg.h>
-
-#include <vm/hat_pte.h>
-#include <vm/hat_i86.h>
-#include <vm/seg_mf.h>
-
-#include <sys/fs/snode.h>
-
-#define	VTOCVP(vp)	(VTOS(vp)->s_commonvp)
-
-typedef struct segmf_mfn_s {
-	mfn_t		m_mfn;
-} segmf_mfn_t;
-
-/* g_flags */
-#define	SEGMF_GFLAGS_WR		0x1
-#define	SEGMF_GFLAGS_MAPPED	0x2
-typedef struct segmf_gref_s {
-	uint64_t	g_ptep;
-	grant_ref_t	g_gref;
-	uint32_t	g_flags;
-	grant_handle_t	g_handle;
-} segmf_gref_t;
-
-typedef union segmf_mu_u {
-	segmf_mfn_t	m;
-	segmf_gref_t	g;
-} segmf_mu_t;
-
-typedef enum {
-	SEGMF_MAP_EMPTY = 0,
-	SEGMF_MAP_MFN,
-	SEGMF_MAP_GREF
-} segmf_map_type_t;
-
-typedef struct segmf_map_s {
-	segmf_map_type_t	t_type;
-	segmf_mu_t		u;
-} segmf_map_t;
-
-struct segmf_data {
-	kmutex_t	lock;
-	struct vnode	*vp;
-	uchar_t		prot;
-	uchar_t		maxprot;
-	size_t		softlockcnt;
-	domid_t		domid;
-	segmf_map_t	*map;
-};
-
-static struct seg_ops segmf_ops;
-
-static int segmf_fault_gref_range(struct seg *seg, caddr_t addr, size_t len);
-
-static struct segmf_data *
-segmf_data_zalloc(struct seg *seg)
-{
-	struct segmf_data *data = kmem_zalloc(sizeof (*data), KM_SLEEP);
-
-	mutex_init(&data->lock, "segmf.lock", MUTEX_DEFAULT, NULL);
-	seg->s_ops = &segmf_ops;
-	seg->s_data = data;
-	return (data);
-}
-
-int
-segmf_create(struct seg **segpp, void *args)
-{
-	struct seg *seg = *segpp;
-	struct segmf_crargs *a = args;
-	struct segmf_data *data;
-	struct as *as = seg->s_as;
-	pgcnt_t i, npages = seg_pages(seg);
-	int error;
-
-	hat_map(as->a_hat, seg->s_base, seg->s_size, HAT_MAP);
-
-	data = segmf_data_zalloc(seg);
-	data->vp = specfind(a->dev, VCHR);
-	data->prot = a->prot;
-	data->maxprot = a->maxprot;
-
-	data->map = kmem_alloc(npages * sizeof (segmf_map_t), KM_SLEEP);
-	for (i = 0; i < npages; i++) {
-		data->map[i].t_type = SEGMF_MAP_EMPTY;
-	}
-
-	error = VOP_ADDMAP(VTOCVP(data->vp), 0, as, seg->s_base, seg->s_size,
-	    data->prot, data->maxprot, MAP_SHARED, CRED(), NULL);
-
-	if (error != 0)
-		hat_unload(as->a_hat,
-		    seg->s_base, seg->s_size, HAT_UNLOAD_UNMAP);
-	return (error);
-}
-
-/*
- * Duplicate a seg and return new segment in newseg.
- */
-static int
-segmf_dup(struct seg *seg, struct seg *newseg)
-{
-	struct segmf_data *data = seg->s_data;
-	struct segmf_data *ndata;
-	pgcnt_t npages = seg_pages(newseg);
-	size_t sz;
-
-	ndata = segmf_data_zalloc(newseg);
-
-	VN_HOLD(data->vp);
-	ndata->vp = data->vp;
-	ndata->prot = data->prot;
-	ndata->maxprot = data->maxprot;
-	ndata->domid = data->domid;
-
-	sz = npages * sizeof (segmf_map_t);
-	ndata->map = kmem_alloc(sz, KM_SLEEP);
-	bcopy(data->map, ndata->map, sz);
-
-	return (VOP_ADDMAP(VTOCVP(ndata->vp), 0, newseg->s_as,
-	    newseg->s_base, newseg->s_size, ndata->prot, ndata->maxprot,
-	    MAP_SHARED, CRED(), NULL));
-}
-
-/*
- * We only support unmapping the whole segment, and we automatically unlock
- * what we previously soft-locked.
- */
-static int
-segmf_unmap(struct seg *seg, caddr_t addr, size_t len)
-{
-	struct segmf_data *data = seg->s_data;
-	offset_t off;
-
-	if (addr < seg->s_base || addr + len > seg->s_base + seg->s_size ||
-	    (len & PAGEOFFSET) || ((uintptr_t)addr & PAGEOFFSET))
-		panic("segmf_unmap");
-
-	if (addr != seg->s_base || len != seg->s_size)
-		return (ENOTSUP);
-
-	hat_unload(seg->s_as->a_hat, addr, len,
-	    HAT_UNLOAD_UNMAP | HAT_UNLOAD_UNLOCK);
-
-	off = (offset_t)seg_page(seg, addr);
-
-	ASSERT(data->vp != NULL);
-
-	(void) VOP_DELMAP(VTOCVP(data->vp), off, seg->s_as, addr, len,
-	    data->prot, data->maxprot, MAP_SHARED, CRED(), NULL);
-
-	seg_free(seg);
-	return (0);
-}
-
-static void
-segmf_free(struct seg *seg)
-{
-	struct segmf_data *data = seg->s_data;
-	pgcnt_t npages = seg_pages(seg);
-
-	kmem_free(data->map, npages * sizeof (segmf_map_t));
-	VN_RELE(data->vp);
-	mutex_destroy(&data->lock);
-	kmem_free(data, sizeof (*data));
-}
-
-static int segmf_faultpage_debug = 0;
-/*ARGSUSED*/
-static int
-segmf_faultpage(struct hat *hat, struct seg *seg, caddr_t addr,
-    enum fault_type type, uint_t prot)
-{
-	struct segmf_data *data = seg->s_data;
-	uint_t hat_flags = HAT_LOAD_NOCONSIST;
-	mfn_t mfn;
-	x86pte_t pte;
-	segmf_map_t *map;
-	uint_t idx;
-
-
-	idx = seg_page(seg, addr);
-	map = &data->map[idx];
-	ASSERT(map->t_type == SEGMF_MAP_MFN);
-
-	mfn = map->u.m.m_mfn;
-
-	if (type == F_SOFTLOCK) {
-		mutex_enter(&freemem_lock);
-		data->softlockcnt++;
-		mutex_exit(&freemem_lock);
-		hat_flags |= HAT_LOAD_LOCK;
-	} else
-		hat_flags |= HAT_LOAD;
-
-	if (segmf_faultpage_debug > 0) {
-		uprintf("segmf_faultpage: addr %p domid %x mfn %lx prot %x\n",
-		    (void *)addr, data->domid, mfn, prot);
-		segmf_faultpage_debug--;
-	}
-
-	/*
-	 * Ask the HAT to load a throwaway mapping to page zero, then
-	 * overwrite it with our foreign domain mapping. It gets removed
-	 * later via hat_unload()
-	 */
-	hat_devload(hat, addr, MMU_PAGESIZE, (pfn_t)0,
-	    PROT_READ | HAT_UNORDERED_OK, hat_flags);
-
-	pte = mmu_ptob((x86pte_t)mfn) | PT_VALID | PT_USER | PT_FOREIGN;
-	if (prot & PROT_WRITE)
-		pte |= PT_WRITABLE;
-
-	if (HYPERVISOR_update_va_mapping_otherdomain((uintptr_t)addr, pte,
-	    UVMF_INVLPG | UVMF_ALL, data->domid) != 0) {
-		hat_flags = HAT_UNLOAD_UNMAP;
-
-		if (type == F_SOFTLOCK) {
-			hat_flags |= HAT_UNLOAD_UNLOCK;
-			mutex_enter(&freemem_lock);
-			data->softlockcnt--;
-			mutex_exit(&freemem_lock);
-		}
-
-		hat_unload(hat, addr, MMU_PAGESIZE, hat_flags);
-		return (FC_MAKE_ERR(EFAULT));
-	}
-
-	return (0);
-}
-
-static int
-seg_rw_to_prot(enum seg_rw rw)
-{
-	switch (rw) {
-	case S_READ:
-		return (PROT_READ);
-	case S_WRITE:
-		return (PROT_WRITE);
-	case S_EXEC:
-		return (PROT_EXEC);
-	case S_OTHER:
-	default:
-		break;
-	}
-	return (PROT_READ | PROT_WRITE | PROT_EXEC);
-}
-
-static void
-segmf_softunlock(struct hat *hat, struct seg *seg, caddr_t addr, size_t len)
-{
-	struct segmf_data *data = seg->s_data;
-
-	hat_unlock(hat, addr, len);
-
-	mutex_enter(&freemem_lock);
-	ASSERT(data->softlockcnt >= btopr(len));
-	data->softlockcnt -= btopr(len);
-	mutex_exit(&freemem_lock);
-
-	if (data->softlockcnt == 0) {
-		struct as *as = seg->s_as;
-
-		if (AS_ISUNMAPWAIT(as)) {
-			mutex_enter(&as->a_contents);
-			if (AS_ISUNMAPWAIT(as)) {
-				AS_CLRUNMAPWAIT(as);
-				cv_broadcast(&as->a_cv);
-			}
-			mutex_exit(&as->a_contents);
-		}
-	}
-}
-
-static int
-segmf_fault_range(struct hat *hat, struct seg *seg, caddr_t addr, size_t len,
-    enum fault_type type, enum seg_rw rw)
-{
-	struct segmf_data *data = seg->s_data;
-	int error = 0;
-	caddr_t a;
-
-	if ((data->prot & seg_rw_to_prot(rw)) == 0)
-		return (FC_PROT);
-
-	/* loop over the address range handling each fault */
-
-	for (a = addr; a < addr + len; a += PAGESIZE) {
-		error = segmf_faultpage(hat, seg, a, type, data->prot);
-		if (error != 0)
-			break;
-	}
-
-	if (error != 0 && type == F_SOFTLOCK) {
-		size_t done = (size_t)(a - addr);
-
-		/*
-		 * Undo what's been done so far.
-		 */
-		if (done > 0)
-			segmf_softunlock(hat, seg, addr, done);
-	}
-
-	return (error);
-}
-
-/*
- * We never demand-fault for seg_mf.
- */
-/*ARGSUSED*/
-static int
-segmf_fault(struct hat *hat, struct seg *seg, caddr_t addr, size_t len,
-    enum fault_type type, enum seg_rw rw)
-{
-	return (FC_MAKE_ERR(EFAULT));
-}
-
-/*ARGSUSED*/
-static int
-segmf_faulta(struct seg *seg, caddr_t addr)
-{
-	return (0);
-}
-
-/*ARGSUSED*/
-static int
-segmf_setprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
-{
-	return (EINVAL);
-}
-
-/*ARGSUSED*/
-static int
-segmf_checkprot(struct seg *seg, caddr_t addr, size_t len, uint_t prot)
-{
-	return (EINVAL);
-}
-
-/*ARGSUSED*/
-static int
-segmf_kluster(struct seg *seg, caddr_t addr, ssize_t delta)
-{
-	return (-1);
-}
-
-/*ARGSUSED*/
-static int
-segmf_sync(struct seg *seg, caddr_t addr, size_t len, int attr, uint_t flags)
-{
-	return (0);
-}
-
-/*
- * XXPV	Hmm.  Should we say that mf mapping are "in core?"
- */
-
-/*ARGSUSED*/
-static size_t
-segmf_incore(struct seg *seg, caddr_t addr, size_t len, char *vec)
-{
-	size_t v;
-
-	for (v = 0, len = (len + PAGEOFFSET) & PAGEMASK; len;
-	    len -= PAGESIZE, v += PAGESIZE)
-		*vec++ = 1;
-	return (v);
-}
-
-/*ARGSUSED*/
-static int
-segmf_lockop(struct seg *seg, caddr_t addr,
-    size_t len, int attr, int op, ulong_t *lockmap, size_t pos)
-{
-	return (0);
-}
-
-static int
-segmf_getprot(struct seg *seg, caddr_t addr, size_t len, uint_t *protv)
-{
-	struct segmf_data *data = seg->s_data;
-	pgcnt_t pgno = seg_page(seg, addr + len) - seg_page(seg, addr) + 1;
-
-	if (pgno != 0) {
-		do
-			protv[--pgno] = data->prot;
-		while (pgno != 0)
-			;
-	}
-	return (0);
-}
-
-static u_offset_t
-segmf_getoffset(struct seg *seg, caddr_t addr)
-{
-	return (addr - seg->s_base);
-}
-
-/*ARGSUSED*/
-static int
-segmf_gettype(struct seg *seg, caddr_t addr)
-{
-	return (MAP_SHARED);
-}
-
-/*ARGSUSED1*/
-static int
-segmf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
-{
-	struct segmf_data *data = seg->s_data;
-
-	*vpp = VTOCVP(data->vp);
-	return (0);
-}
-
-/*ARGSUSED*/
-static int
-segmf_advise(struct seg *seg, caddr_t addr, size_t len, uint_t behav)
-{
-	return (0);
-}
-
-/*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)
-{
-	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)
-{
-	struct segmf_data *data = seg->s_data;
-
-	memid->val[0] = (uintptr_t)VTOCVP(data->vp);
-	memid->val[1] = (uintptr_t)seg_page(seg, addr);
-	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
- * return an error in response to IOCTL_PRIVCMD_MMAPBATCH rather than faulting
- * later on a bad MFN.  Whilst this isn't necessary for the other MMAP
- * ioctl()s, we lock them too, as they should be transitory.
- */
-int
-segmf_add_mfns(struct seg *seg, caddr_t addr, mfn_t mfn,
-    pgcnt_t pgcnt, domid_t domid)
-{
-	struct segmf_data *data = seg->s_data;
-	pgcnt_t base;
-	faultcode_t fc;
-	pgcnt_t i;
-	int error = 0;
-
-	if (seg->s_ops != &segmf_ops)
-		return (EINVAL);
-
-	/*
-	 * Don't mess with dom0.
-	 *
-	 * Only allow the domid to be set once for the segment.
-	 * After that attempts to add mappings to this segment for
-	 * other domains explicitly fails.
-	 */
-
-	if (domid == 0 || domid == DOMID_SELF)
-		return (EACCES);
-
-	mutex_enter(&data->lock);
-
-	if (data->domid == 0)
-		data->domid = domid;
-
-	if (data->domid != domid) {
-		error = EINVAL;
-		goto out;
-	}
-
-	base = seg_page(seg, addr);
-
-	for (i = 0; i < pgcnt; i++) {
-		data->map[base + i].t_type = SEGMF_MAP_MFN;
-		data->map[base + i].u.m.m_mfn = mfn++;
-	}
-
-	fc = segmf_fault_range(seg->s_as->a_hat, seg, addr,
-	    pgcnt * MMU_PAGESIZE, F_SOFTLOCK, S_OTHER);
-
-	if (fc != 0) {
-		error = fc_decode(fc);
-		for (i = 0; i < pgcnt; i++) {
-			data->map[base + i].t_type = SEGMF_MAP_EMPTY;
-		}
-	}
-
-out:
-	mutex_exit(&data->lock);
-	return (error);
-}
-
-int
-segmf_add_grefs(struct seg *seg, caddr_t addr, uint_t flags,
-    grant_ref_t *grefs, uint_t cnt, domid_t domid)
-{
-	struct segmf_data *data;
-	segmf_map_t *map;
-	faultcode_t fc;
-	uint_t idx;
-	uint_t i;
-	int e;
-
-	if (seg->s_ops != &segmf_ops)
-		return (EINVAL);
-
-	/*
-	 * Don't mess with dom0.
-	 *
-	 * Only allow the domid to be set once for the segment.
-	 * After that attempts to add mappings to this segment for
-	 * other domains explicitly fails.
-	 */
-
-	if (domid == 0 || domid == DOMID_SELF)
-		return (EACCES);
-
-	data = seg->s_data;
-	idx = seg_page(seg, addr);
-	map = &data->map[idx];
-	e = 0;
-
-	mutex_enter(&data->lock);
-
-	if (data->domid == 0)
-		data->domid = domid;
-
-	if (data->domid != domid) {
-		e = EINVAL;
-		goto out;
-	}
-
-	/* store away the grefs passed in then fault in the pages */
-	for (i = 0; i < cnt; i++) {
-		map[i].t_type = SEGMF_MAP_GREF;
-		map[i].u.g.g_gref = grefs[i];
-		map[i].u.g.g_handle = 0;
-		map[i].u.g.g_flags = 0;
-		if (flags & SEGMF_GREF_WR) {
-			map[i].u.g.g_flags |= SEGMF_GFLAGS_WR;
-		}
-	}
-	fc = segmf_fault_gref_range(seg, addr, cnt);
-	if (fc != 0) {
-		e = fc_decode(fc);
-		for (i = 0; i < cnt; i++) {
-			data->map[i].t_type = SEGMF_MAP_EMPTY;
-		}
-	}
-
-out:
-	mutex_exit(&data->lock);
-	return (e);
-}
-
-int
-segmf_release_grefs(struct seg *seg, caddr_t addr, uint_t cnt)
-{
-	gnttab_unmap_grant_ref_t mapop[SEGMF_MAX_GREFS];
-	struct segmf_data *data;
-	segmf_map_t *map;
-	uint_t idx;
-	long e;
-	int i;
-	int n;
-
-
-	if (cnt > SEGMF_MAX_GREFS) {
-		return (-1);
-	}
-
-	idx = seg_page(seg, addr);
-	data = seg->s_data;
-	map = &data->map[idx];
-
-	bzero(mapop, sizeof (gnttab_unmap_grant_ref_t) * cnt);
-
-	/*
-	 * for each entry which isn't empty and is currently mapped,
-	 * set it up for an unmap then mark them empty.
-	 */
-	n = 0;
-	for (i = 0; i < cnt; i++) {
-		ASSERT(map[i].t_type != SEGMF_MAP_MFN);
-		if ((map[i].t_type == SEGMF_MAP_GREF) &&
-		    (map[i].u.g.g_flags & SEGMF_GFLAGS_MAPPED)) {
-			mapop[n].handle = map[i].u.g.g_handle;
-			mapop[n].host_addr = map[i].u.g.g_ptep;
-			mapop[n].dev_bus_addr = 0;
-			n++;
-		}
-		map[i].t_type = SEGMF_MAP_EMPTY;
-	}
-
-	/* if there's nothing to unmap, just return */
-	if (n == 0) {
-		return (0);
-	}
-
-	e = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &mapop, n);
-	if (e != 0) {
-		return (-1);
-	}
-
-	return (0);
-}
-
-
-void
-segmf_add_gref_pte(struct seg *seg, caddr_t addr, uint64_t pte_ma)
-{
-	struct segmf_data *data;
-	uint_t idx;
-
-	idx = seg_page(seg, addr);
-	data = seg->s_data;
-
-	data->map[idx].u.g.g_ptep = pte_ma;
-}
-
-
-static int
-segmf_fault_gref_range(struct seg *seg, caddr_t addr, size_t cnt)
-{
-	gnttab_map_grant_ref_t mapop[SEGMF_MAX_GREFS];
-	struct segmf_data *data;
-	segmf_map_t *map;
-	uint_t idx;
-	int e;
-	int i;
-
-
-	if (cnt > SEGMF_MAX_GREFS) {
-		return (-1);
-	}
-
-	data = seg->s_data;
-	idx = seg_page(seg, addr);
-	map = &data->map[idx];
-
-	bzero(mapop, sizeof (gnttab_map_grant_ref_t) * cnt);
-
-	ASSERT(map->t_type == SEGMF_MAP_GREF);
-
-	/*
-	 * map in each page passed in into the user apps AS. We do this by
-	 * passing the MA of the actual pte of the mapping to the hypervisor.
-	 */
-	for (i = 0; i < cnt; i++) {
-		mapop[i].host_addr = map[i].u.g.g_ptep;
-		mapop[i].dom = data->domid;
-		mapop[i].ref = map[i].u.g.g_gref;
-		mapop[i].flags = GNTMAP_host_map | GNTMAP_application_map |
-		    GNTMAP_contains_pte;
-		if (!(map[i].u.g.g_flags & SEGMF_GFLAGS_WR)) {
-			mapop[i].flags |= GNTMAP_readonly;
-		}
-	}
-	e = xen_map_gref(GNTTABOP_map_grant_ref, mapop, cnt, B_TRUE);
-	if ((e != 0) || (mapop[0].status != GNTST_okay)) {
-		return (FC_MAKE_ERR(EFAULT));
-	}
-
-	/* save handle for segmf_release_grefs() and mark it as mapped */
-	for (i = 0; i < cnt; i++) {
-		ASSERT(mapop[i].status == GNTST_okay);
-		map[i].u.g.g_handle = mapop[i].handle;
-		map[i].u.g.g_flags |= SEGMF_GFLAGS_MAPPED;
-	}
-
-	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
-};
--- old/usr/src/uts/i86xpv/vm/seg_mf.h	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,65 +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 2008 Sun Microsystems, Inc.  All rights reserved.
- * Use is subject to license terms.
- * Copyright 2018 Joyent, Inc.
- */
-
-#ifndef	_VM_SEG_MF_H
-#define	_VM_SEG_MF_H
-
-
-#include <sys/types.h>
-#include <vm/seg.h>
-#include <sys/hypervisor.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct segmf_crargs {
-	dev_t		dev;
-	uchar_t		prot;
-	uchar_t		maxprot;
-};
-
-extern int segmf_create(struct seg **, void *);
-
-extern int segmf_add_mfns(struct seg *, caddr_t, mfn_t, pgcnt_t, domid_t);
-
-/* max grefs which can be passed into segmf_add_grefs */
-#define	SEGMF_MAX_GREFS		0x10
-
-/* segmf_add_grefs flags */
-#define	SEGMF_GREF_WR		0x1	/* Map gref writable */
-
-extern int segmf_add_grefs(struct seg *, caddr_t, uint_t, grant_ref_t *,
-    uint_t, domid_t);
-extern int segmf_release_grefs(struct seg *, caddr_t, uint_t);
-extern void segmf_add_gref_pte(struct seg *, caddr_t, uint64_t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _VM_SEG_MF_H */
--- old/usr/src/uts/i86xpv/xdb/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,90 +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
-#
-
-#
-# uts/i86xpv/xdb/Makefile
-#
-# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	i86xpv architecture dependent
-#
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xdb
-OBJECTS		= $(XDB_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XDB_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-CERRWARN	+= -_gcc=-Wno-switch
-
-#
-#	Overrides
-#
-DEF_BUILDS	= $(DEF_BUILDS64)
-ALL_BUILDS	= $(ALL_BUILDS64)
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xdf/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,91 +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
-#
-
-#
-# uts/i86xpv/xdf/Makefile
-#
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	i86xpv architecture dependent
-#
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xdf
-OBJECTS		= $(XDF_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XDF_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-# Overrides
-LDFLAGS		+= -dy -Nmisc/cmlb
-
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-switch
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xdt/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,63 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-UTSBASE	= ../..
-
-MODULE		= xdt
-OBJECTS		= $(XDT_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XDT_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR	= $(UTSBASE)/common/xen/dtrace
-
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-ALL_TARGET	= $(BINARY) $(SRC_CONFFILE)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-LDFLAGS		+= -dy -Ndrv/dtrace
-
-CERRWARN	+= -_gcc=-Wno-uninitialized
-
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xenbus/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,90 +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
-#
-
-#
-# uts/i86xpv/xenbus/Makefile
-#
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the xenbus
-#	xenstore driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xenbus
-OBJECTS		= $(XENBUS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XENBUS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-unused-variable
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xencons/Makefile	Fri Aug 10 23:19:24 2018
+++ /dev/null	Fri Aug 10 23:19:24 2018
@@ -1,93 +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
-#
-
-#
-# uts/i86xpv/xencons/Makefile
-#
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the xencons
-#	console driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xencons
-OBJECTS		= $(XENCONS_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XENCONS_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR	= $(UTSBASE)/common/xen/io
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-
-CERRWARN	+= -_gcc=-Wno-unused-label
-CERRWARN	+= -_gcc=-Wno-unused-variable
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xnb/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,105 +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 2010 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of the xnb
-#	network driver support module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xnb
-OBJECTS		= $(XNB_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XNB_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MISC_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides
-#
-DEF_BUILDS	= $(DEF_BUILDS64)
-ALL_BUILDS	= $(ALL_BUILDS64)
-
-#
-# Module depends on mac.
-#
-LDFLAGS		+= -dy -N misc/mac
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-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)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xnbe/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,99 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of the xnbe
-#	network driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xnbe
-OBJECTS		= $(XNBE_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XNBE_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides
-#
-DEF_BUILDS	= $(DEF_BUILDS64)
-ALL_BUILDS	= $(ALL_BUILDS64)
-
-#
-# Driver depends on MAC and IP.
-#
-#LDFLAGS		+= -dy -N misc/mac -N drv/ip
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xnbo/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,99 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of the xnbo
-#	network driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xnbo
-OBJECTS		= $(XNBO_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XNBO_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides
-#
-DEF_BUILDS	= $(DEF_BUILDS64)
-ALL_BUILDS	= $(ALL_BUILDS64)
-
-#
-# Driver depends on xnb and mac.
-#
-LDFLAGS		+= -dy -N misc/xnb -N misc/mac
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xnbu/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,99 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-#
-#	This makefile drives the production of the xnbu
-#	network driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xnbu
-OBJECTS		= $(XNBU_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XNBU_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides
-#
-DEF_BUILDS	= $(DEF_BUILDS64)
-ALL_BUILDS	= $(ALL_BUILDS64)
-
-#
-# Driver depends on xnb and mac.
-#
-LDFLAGS		+= -dy -N misc/xnb -N misc/mac
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xnf/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,100 +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
-#
-
-#
-# uts/i86xpv/xnf/Makefile
-#
-# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of the xve
-#	network driver kernel module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xnf
-OBJECTS		= $(XNF_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XNF_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-# Driver depends on MAC & IP
-#
-LDFLAGS		+= -dy -N misc/mac -N drv/ip
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpv_autoconfig/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,83 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of the xpv autoconfiguration
-#	kernel module.
-#
-#	i86xpv platform dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xpv_autoconfig
-OBJECTS		= $(XPV_AUTOCONFIG_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPV_AUTOCONFIG_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MISC_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpv_psm/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,107 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-
-#
-#	This makefile drives the production of the xpv_psm mach
-#	kernel module.
-#
-#	i86xpv 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		= xpv_psm
-OBJECTS		= $(XPV_PSM_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPV_PSM_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MACH_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides.
-#
-DEBUG_FLGS	=
-DEBUG_DEFS	+= $(DEBUG_FLGS)
-
-#
-#
-# Depends on ACPI CA interpreter
-#
-LDFLAGS		+= -dy -N misc/acpica
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-
-CERRWARN	+= -_gcc=-Wno-type-limits
-CERRWARN	+= -_gcc=-Wno-parentheses
-CERRWARN	+= -_gcc=-Wno-uninitialized
-CERRWARN	+= -_gcc=-Wno-empty-body
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpv_uppc/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,101 +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 2008 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2016 Joyent, Inc.
-#
-#	This makefile drives the production of the xpv_uppc mach
-#	kernel module.
-#
-#	i86xpv 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		= xpv_uppc
-OBJECTS		= $(XPV_UPPC_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPV_UPPC_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_MACH_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#	Overrides.
-#
-DEBUG_FLGS	=
-DEBUG_DEFS	+= $(DEBUG_FLGS)
-
-CERRWARN	+= -_gcc=-Wno-unused-function
-
-#
-#
-# Depends on ACPI CA interpreter
-#
-LDFLAGS		+= -dy -N misc/acpica
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
-
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpvd/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,87 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the xpvd nexus driver
-#
-#	i86xpv 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		= xpvd
-OBJECTS		= $(XPVD_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPVD_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-
-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)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpvtap/Makefile	Fri Aug 10 23:19:25 2018
+++ /dev/null	Fri Aug 10 23:19:25 2018
@@ -1,104 +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 2009 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the xpvtap
-#	driver module.
-#
-#	i86xpv architecture dependent
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xpvtap
-OBJECTS		= $(XPVTAP_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPVTAP_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-#
-#       Overrides
-#
-DEF_BUILDS      = $(DEF_BUILDS64)
-ALL_BUILDS      = $(ALL_BUILDS64)
-
-LDFLAGS		+= 
-
-#
-# use Solaris specific code in xen public header files
-#
-CFLAGS		+= -D_SOLARIS
-LINTFLAGS	+= -D_SOLARIS
-
-LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
-LINTTAGS	+= -erroff=E_CONSTANT_CONDITION
-
-CERRWARN	+= -_gcc=-Wno-unused-label
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xpvtod/Makefile	Fri Aug 10 23:19:26 2018
+++ /dev/null	Fri Aug 10 23:19:26 2018
@@ -1,84 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-# ident	"%Z%%M%	%I%	%E% SMI"
-#
-#	This makefile drives the production of xpvtod kernel module.
-#
-#	i86xpv 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		= xpvtod
-OBJECTS		= $(XPVTOD_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XPVTOD_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_TOD_DIR)/$(MODULE)
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE)
-
-LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
-
-#
-#	Default build targets.
-#
-.KEEP_STATE:
-
-def:		$(DEF_DEPS)
-
-all:		$(ALL_DEPS)
-
-clean:		$(CLEAN_DEPS)
-
-clobber:	$(CLOBBER_DEPS)
-
-lint:		$(LINT_DEPS)
-
-modlintlib:	$(MODLINTLIB_DEPS)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
--- old/usr/src/uts/i86xpv/xsvc/Makefile	Fri Aug 10 23:19:26 2018
+++ /dev/null	Fri Aug 10 23:19:26 2018
@@ -1,96 +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 2007 Sun Microsystems, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-#	This makefile drives the production of the xsvc driver kernel
-#	module.
-#
-
-#
-#	Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE	= ../..
-
-#
-#	Define the module and object file sets.
-#
-MODULE		= xsvc
-OBJECTS		= $(XSVC_OBJS:%=$(OBJS_DIR)/%)
-LINTS		= $(XSVC_OBJS:%.o=$(LINTS_DIR)/%.ln)
-ROOTMODULE	= $(ROOT_PSM_DRV_DIR)/$(MODULE)
-CONF_SRCDIR	= $(UTSBASE)/i86pc/io/xsvc
-
-#
-#	Include common rules.
-#
-include $(UTSBASE)/i86xpv/Makefile.i86xpv
-
-#
-#	Define targets
-#
-ALL_TARGET	= $(BINARY) $(SRC_CONFILE)
-LINT_TARGET	= $(MODULE).lint
-INSTALL_TARGET	= $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE)
-
-#
-#	Dependency
-#
-LDFLAGS		+= -dy
-
-#
-#	Override defaults to build a unique, local modstubs.o.
-#
-MODSTUBS_DIR	 = $(OBJS_DIR)
-CLEANFILES	+= $(MODSTUBS_O)
-
-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)
-
-clean.lint:	$(CLEAN_LINT_DEPS)
-
-install:	$(INSTALL_DEPS)
-
-#
-#	Include common targets.
-#
-include $(UTSBASE)/i86xpv/Makefile.targ
-
--- old/usr/src/uts/intel/os/mach	Fri Aug 10 23:19:26 2018
+++ new/usr/src/uts/intel/os/mach	Fri Aug 10 23:19:26 2018
@@ -30,5 +30,3 @@
 #
 pcplusmp
 apix
-xpv_psm
-
