読者です 読者をやめる 読者になる 読者になる

BHyVeビルドめも23

DragonFlyBSD BHyVe

φ(・ω・ )かきかき

vmm_dev.cのコンパイルは終わりました。さっきと同じコミット間違えしましたけど調子悪くてバファリン飲んでるし(・ε・)キニシナイ!!
と言うわけで、diffはこちらに。

diff --git a/sys/platform/pc64/vmm/vmm_dev.c b/sys/platform/pc64/vmm/vmm_dev.c
index 5afd20b..08214a5 100644
--- a/sys/platform/pc64/vmm/vmm_dev.c
+++ b/sys/platform/pc64/vmm/vmm_dev.c
@@ -161,8 +161,19 @@ vmmdev_rw(struct cdev *cdev, struct uio *uio, int flags)
 }
 
 static int
-vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
-	     struct thread *td)
+vmmdev_read(struct dev_read_args *ap)
+{
+	return vmmdev_rw(ap->a_head.a_dev, ap->a_uio, ap->a_ioflag);
+}
+
+static int 
+vmmdev_write(struct dev_write_args *ap)
+{
+	return vmmdev_rw(ap->a_head.a_dev, ap->a_uio, ap->a_ioflag);
+}
+
+static int
+vmmdev_ioctl(struct dev_ioctl_args *ap)
 {
 	int error, vcpu;
 	struct vmmdev_softc *sc;
@@ -181,9 +192,11 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
 	struct vm_nmi *vmnmi;
 	struct vm_stats *vmstats;
 	struct vm_stat_desc *statdesc;
+	caddr_t data = ap->a_data;
+	u_long cmd = ap->a_cmd;
 
 	mtx_lock(&vmmdev_mtx);
-	sc = vmmdev_lookup2(cdev);
+	sc = vmmdev_lookup2(ap->a_head.a_dev);
 	if (sc == NULL) {
 		mtx_unlock(&vmmdev_mtx);
 		return (ENXIO);
@@ -432,8 +445,8 @@ static struct dev_ops vmmdevsw = {
 	.head.maj	= D_VERSION,
 	.d_ioctl	= vmmdev_ioctl,
 	.d_mmap		= vmmdev_mmap,
-	.d_read		= vmmdev_rw,
-	.d_write	= vmmdev_rw,
+	.d_read		= vmmdev_read,
+	.d_write	= vmmdev_write,
 };
 
 static int

vmmdev_read()とvmmdev_write()の2関数を追加してます。これはvmmdev_rw()の関数プロトタイプ変えても良かったんですが、引数の構造体がこのように一応別物として扱われているので入り口の関数分けた方が良いかなというところでこうしてます。

/*
 * int d_read(cdev_t dev, struct uio *uio, int ioflag)
 */
struct dev_read_args {
	struct dev_generic_args	a_head;
	struct uio	*a_uio;
	int		a_ioflag;
};

/*
 * int d_write(cdev_t dev, struct uio *uio, int ioflag)
 */
struct dev_write_args {
	struct dev_generic_args a_head;
	struct uio 	*a_uio;
	int		a_ioflag;
};

vmdev_ioctlのほうは引数のstruct thread *tdを使って無かったおかげで割と簡単にすみました。
そして次なるファイルはvmm_ipi.cになります。

--------------------------------------------------------------
>>> Kernel build for BHYVE started on Mon Jul 23 22:06:55 JST 2012
--------------------------------------------------------------
===> BHYVE
cd /usr/src/sys/config;  PATH=/usr/obj/usr/src/ctools_x86_64_x86_64/usr/sbin:/usr/obj/usr/src/ctools_x86_64_x86_64/usr/bin:/usr/obj/usr/src/ctools_x86_64_x86_64/bin:/usr/obj/usr/src/ctools_x86_64_x86_64/usr/games:/usr/obj/usr/src/btools_x86_64/usr/sbin:/usr/obj/usr/src/btools_x86_64/usr/bin:/usr/obj/usr/src/btools_x86_64/bin:/usr/obj/usr/src/btools_x86_64/usr/games:/usr/pkg/bin  config  -d /usr/obj/usr/src/sys/BHYVE  /usr/src/sys/config/BHYVE
Kernel build directory is /usr/obj/usr/src/sys/BHYVE
cd /usr/obj/usr/src/sys/BHYVE;  MAKEOBJDIRPREFIX=/usr/obj/usr/src/world_x86_64  OBJTREE=/usr/obj  MACHINE_ARCH=x86_64  MACHINE=x86_64  MACHINE_PLATFORM=pc64  OBJFORMAT_PATH=/usr/obj/usr/src/ctools_x86_64_x86_64  HOST_CCVER=gcc44  CCVER=gcc44  BINUTILSVER=binutils221  DESTDIR=/usr/obj/usr/src/world_x86_64  INSTALL="sh /usr/src/tools/install.sh"  PATH=/usr/obj/usr/src/ctools_x86_64_x86_64/usr/sbin:/usr/obj/usr/src/ctools_x86_64_x86_64/usr/bin:/usr/obj/usr/src/ctools_x86_64_x86_64/bin:/usr/obj/usr/src/ctools_x86_64_x86_64/usr/games:/usr/obj/usr/src/btools_x86_64/usr/sbin:/usr/obj/usr/src/btools_x86_64/usr/bin:/usr/obj/usr/src/btools_x86_64/bin:/usr/obj/usr/src/btools_x86_64/usr/games:/usr/pkg/bin make KERNEL=kernel all
cc -c -O -pipe  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wold-style-definition -std=c99 -Wold-style-declaration -g -nostdinc -I. -Iinclude -I/usr/src/sys -I/usr/src/sys/../include -I/usr/obj/usr/src/sys/BHYVE -I"/usr/src/sys/dev/acpica5" -I"/usr/src/sys/contrib/dev/acpica-unix/include" -I/usr/src/sys/dev/netif/ath/hal -I/usr/src/sys/dev/netif/ath/hal/ath_hal  -D_KERNEL -include opt_global.h  -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -ffreestanding -mpreferred-stack-boundary=4 -fno-stack-protector -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a  -mno-sse5 -mno-abm -mno-aes -mno-avx -mno-pclmul -mno-popcnt -msoft-float -fno-asynchronous-unwind-tables -fno-omit-frame-pointer  /usr/src/sys/platform/pc64/vmm/vmm_dev.c -Werror
cc -c -O -pipe  -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wold-style-definition -std=c99 -Wold-style-declaration -g -nostdinc -I. -Iinclude -I/usr/src/sys -I/usr/src/sys/../include -I/usr/obj/usr/src/sys/BHYVE -I"/usr/src/sys/dev/acpica5" -I"/usr/src/sys/contrib/dev/acpica-unix/include" -I/usr/src/sys/dev/netif/ath/hal -I/usr/src/sys/dev/netif/ath/hal/ath_hal  -D_KERNEL -include opt_global.h  -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common -ffreestanding -mpreferred-stack-boundary=4 -fno-stack-protector -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -mno-sse4 -mno-sse4a  -mno-sse5 -mno-abm -mno-aes -mno-avx -mno-pclmul -mno-popcnt -msoft-float -fno-asynchronous-unwind-tables -fno-omit-frame-pointer  /usr/src/sys/platform/pc64/vmm/vmm_ipi.c -Werror
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:38:29: error: machine/apicvar.h: No such file or directory
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:51: error: 'IPI_AST' undeclared here (not in a function)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:53: error: 'APIC_SPURIOUS_INT' undeclared here (not in a function)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c: In function 'vmm_ipi_init':
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:72: error: 'APIC_IPI_INTS' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:72: error: (Each undeclared identifier is reported only once
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:72: error: for each function it appears in.)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:73: error: 'idt' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:78: error: too few arguments to function 'setidt'
cc1: warnings being treated as errors
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:84: error: implicit declaration of function 'printf'
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:84: error: nested extern declaration of 'printf'
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c: In function 'vmm_ipi_cleanup':
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:93: error: too few arguments to function 'setidt'
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c: In function 'vm_interrupt_hostcpu':
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:101: error: 'curcpu' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:102: error: implicit declaration of function 'ipi_cpu'
/usr/src/sys/platform/pc64/vmm/vmm_ipi.c:102: error: nested extern declaration of 'ipi_cpu'
*** Error code 1

Stop in /usr/obj/usr/src/sys/BHYVE.
*** Error code 1

Stop in /usr/src.
*** Error code 1

Stop in /usr/src.

/usr/src/sys/platform/pc64/conf/filesで指定したファイルを上から順にコンパイルしていっていると思うので、残りのファイルはこれらでしょうね。

platform/pc64/vmm/vmm_ipi.c             optional        vmm
platform/pc64/vmm/vmm_lapic.c           optional        vmm
platform/pc64/vmm/vmm_mem.c             optional        vmm`
platform/pc64/vmm/vmm_msr.c             optional        vmm
platform/pc64/vmm/vmm_stat.c            optional        vmm
platform/pc64/vmm/vmm_support.S         optional        vmm
platform/pc64/vmm/vmm_util.c            optional        vmm
platform/pc64/vmm/x86.c                 optional        vmm