svn commit: r266269 - in stable/9/sys: amd64/include i386/include modules modules/xenhvm xen

Colin Percival cperciva at FreeBSD.org
Fri May 16 19:28:24 UTC 2014


Author: cperciva
Date: Fri May 16 19:28:22 2014
New Revision: 266269
URL: http://svnweb.freebsd.org/changeset/base/266269

Log:
  Add xenhvm.ko, which can be loaded along with a !XENHVM kernel in order to
  provide support for the Xen/HVM environment.
  
  This code is compiled with XENHVM defined; since this would result in the
  (no longer used) "last processed" values being included in PCPU data
  structures, an additional MODXENHVM define is used to exclude those.  This
  allows KBI to be retained for both GENERIC and XENHVM kernel configurations
  (which are not KBI compatible with each other).
  
  This is a direct commit to stable/9, since stable/10 and HEAD have XENHVM
  merged into the GENERIC kernel configuration (but the changes in stable/10
  and HEAD cannot be MFCed as-is).
  
  Discussed with: royger, gjb
  Relnotes:	FreeBSD 9.3-RELEASE can run in Xen/HVM environments,
  		including Amazon EC2, using GENERIC + xenhvm.ko.

Added:
  stable/9/sys/modules/xenhvm/
  stable/9/sys/modules/xenhvm/Makefile   (contents, props changed)
  stable/9/sys/xen/xenhvm_mod.c   (contents, props changed)
Modified:
  stable/9/sys/amd64/include/pcpu.h
  stable/9/sys/i386/include/pcpu.h
  stable/9/sys/modules/Makefile

Modified: stable/9/sys/amd64/include/pcpu.h
==============================================================================
--- stable/9/sys/amd64/include/pcpu.h	Fri May 16 19:15:03 2014	(r266268)
+++ stable/9/sys/amd64/include/pcpu.h	Fri May 16 19:28:22 2014	(r266269)
@@ -42,7 +42,7 @@
 #endif
 #endif
 
-#ifdef XENHVM
+#if defined(XENHVM) && !defined(MODXENHVM)
 /* This is now unused, but remains here for KBI compatibility reasons. */
 #define PCPU_XEN_FIELDS							\
 	;								\

Modified: stable/9/sys/i386/include/pcpu.h
==============================================================================
--- stable/9/sys/i386/include/pcpu.h	Fri May 16 19:15:03 2014	(r266268)
+++ stable/9/sys/i386/include/pcpu.h	Fri May 16 19:28:22 2014	(r266269)
@@ -76,7 +76,7 @@ struct shadow_time_info {
 	int	pc_virq_to_irq[NR_VIRQS];				\
 	int	pc_ipi_to_irq[NR_IPIS]	
 
-#elif defined(XENHVM)
+#elif defined(XENHVM) && !defined(MODXENHVM)
 
 /* This is now unused, but remains here for KBI compatibility reasons. */
 #define	PCPU_XEN_FIELDS							\
@@ -84,7 +84,7 @@ struct shadow_time_info {
 	unsigned int pc_last_processed_l1i;				\
 	unsigned int pc_last_processed_l2i
 
-#else /* !XEN && !XENHVM */
+#else /* !XEN && (!XENHVM || MODXENHVM) */
 
 #define PCPU_XEN_FIELDS
 

Modified: stable/9/sys/modules/Makefile
==============================================================================
--- stable/9/sys/modules/Makefile	Fri May 16 19:15:03 2014	(r266268)
+++ stable/9/sys/modules/Makefile	Fri May 16 19:28:22 2014	(r266269)
@@ -361,6 +361,7 @@ SUBDIR=	\
 	${_wpifw} \
 	${_x86bios} \
 	${_xe} \
+	${_xenhvm} \
 	xfs \
 	xl \
 	${_zfs} \
@@ -368,6 +369,7 @@ SUBDIR=	\
 
 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
 _filemon=	filemon
+_xenhvm=	xenhvm
 .endif
 
 .if ${MACHINE_CPUARCH} != "powerpc" && ${MACHINE_CPUARCH} != "arm" && \

Added: stable/9/sys/modules/xenhvm/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/sys/modules/xenhvm/Makefile	Fri May 16 19:28:22 2014	(r266269)
@@ -0,0 +1,21 @@
+# $FreeBSD$
+
+KMOD=	xenhvm
+
+DEVXENDIR=	${.CURDIR}/../../dev/xen/
+XENDIR=	${.CURDIR}/../../xen/
+.PATH:	${DEVXENDIR}/balloon ${DEVXENDIR}/blkfront ${DEVXENDIR}/blkback \
+	${DEVXENDIR}/control ${DEVXENDIR}/netback ${DEVXENDIR}/netfront \
+	${DEVXENDIR}/xenpci ${XENDIR}/ ${XENDIR}/evtchn \
+	${XENDIR}/xenbus ${XENDIR}/xenstore
+
+SRCS=	xenhvm_mod.c	\
+	balloon.c blkfront.c blkback.c control.c netback.c netfront.c	\
+	xenpci.c evtchn.c gnttab.c features.c evtchn_dev.c		\
+	xenbus.c xenbusb.c xenbusb_front.c xenbusb_back.c		\
+	xenbus_if.c xenbus_if.h xenbusb_if.c xenbusb_if.h					\
+	xenstore.c xenstore_dev.c
+MFILES=	xen/xenbus/xenbus_if.m xen/xenbus/xenbusb_if.m
+CFLAGS+=	-DXENHVM -DMODXENHVM
+
+.include <bsd.kmod.mk>

Added: stable/9/sys/xen/xenhvm_mod.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/sys/xen/xenhvm_mod.c	Fri May 16 19:28:22 2014	(r266269)
@@ -0,0 +1,32 @@
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/systm.h>
+
+static int
+xenhvm_modevent(module_t mod, int type, void *arg)
+{
+
+	switch (type) {
+	case MOD_LOAD:
+		if (inw(0x10) == 0x49d2) {
+			if (bootverbose)
+				printf("Xen detected: disabling emulated block and network devices\n");
+			outw(0x10, 3);
+		}
+		return (0);
+	}
+
+	return (EOPNOTSUPP);
+}
+
+static moduledata_t xenhvm_mod = {
+	"xenhvm",
+	xenhvm_modevent,
+	0
+};
+
+DECLARE_MODULE(xenhvm, xenhvm_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);


More information about the svn-src-stable-9 mailing list