From owner-svn-src-all@FreeBSD.ORG Fri May 16 19:28:24 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 41BE9E0C; Fri, 16 May 2014 19:28:24 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 234B72027; Fri, 16 May 2014 19:28:24 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4GJSOF8050227; Fri, 16 May 2014 19:28:24 GMT (envelope-from cperciva@svn.freebsd.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4GJSNBN050222; Fri, 16 May 2014 19:28:23 GMT (envelope-from cperciva@svn.freebsd.org) Message-Id: <201405161928.s4GJSNBN050222@svn.freebsd.org> From: Colin Percival Date: Fri, 16 May 2014 19:28:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r266269 - in stable/9/sys: amd64/include i386/include modules modules/xenhvm xen X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 May 2014 19:28:24 -0000 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 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 +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +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);