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

BHyVeビルドめも19

DragonFlyBSD BHyVe

φ(・・*)ゞ ウーン
vmm.cのコンパイル出来ました。今日のdiffはこちら

毎回忘れるので先にメモっておくと、FreeBSDのスレッド構造体(struct thread)はsys/proc.hで定義されてるφ(・ω・ )かきかき

今日弄ったところはvmm.cのvm_set_pinning()でスレッドをcpuにバインドしているところです。似たようなことをBHyVeビルドめも10で調べてたのでそれを思い出しつつやってみました。多分ホスト側のcpuにピンしたりの部分はそもそも動いているスレッドが他のcpuに勝手に行くことはないだろうというところで、sched_bind()等の処理をザクッと消して仮想cpuとホストのcpuがなんとなく紐付く程度にしてみました。

--- a/sys/platform/pc64/vmm/vmm.c
+++ b/sys/platform/pc64/vmm/vmm.c
@@ -469,6 +469,7 @@ vm_get_pinning(struct vm *vm, int vcpuid, int *cpuid)
 int
 vm_set_pinning(struct vm *vm, int vcpuid, int host_cpuid)
 {
+#if 0
 	struct thread *td;
 
 	if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
@@ -498,6 +499,15 @@ vm_set_pinning(struct vm *vm, int vcpuid, int host_cpuid)
 	VCPU_PIN(vm, vcpuid, host_cpuid);
 
 	return (0);
+#else
+	if (host_cpuid < 0) {
+		VCPU_UNPIN(vm, vcpuid);
+		return (0);
+	}
+
+	VCPU_PIN(vm, vcpuid, host_cpuid);
+	return (0);
+#endif
 }

もう一個の修正はホントに単純なものでcurcpuでカレントcpuのidにアクセスするところをmycpuidに変えただけです。

@@ -540,7 +550,7 @@ vm_run(struct vm *vm, struct vm_run *vmrun)
 	pcb = curthread->td_pcb;
 	set_pcb_flags(pcb, PCB_FULL_IRET);
 
-	vcpu->hostcpu = curcpu;
+	vcpu->hostcpu = mycpuid;
 
 	restore_guest_msrs(vm, vcpuid);	
 	restore_guest_fpustate(vcpu);

そして、次からはvmm_dev.cになります。

--------------------------------------------------------------
>>> Kernel build for BHYVE started on Wed Jul 18 20:29:12 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.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_dev.c -Werror
cc1: warnings being treated as errors
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: In function 'vmmdev_rw':
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:114: error: implicit declaration of function 'mtx_lock'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:114: error: nested extern declaration of 'mtx_lock'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:140: error: implicit declaration of function 'mtx_unlock'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:140: error: nested extern declaration of 'mtx_unlock'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: In function 'vmmdev_destroy':
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:384: error: implicit declaration of function 'free'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:384: error: nested extern declaration of 'free'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: At top level:
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:412: error: variable 'vmmdevsw' has initializer but incomplete type
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:413: error: unknown field 'd_name' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:413: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:413: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:414: error: unknown field 'd_version' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:414: error: 'D_VERSION' undeclared here (not in a function)
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:414: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:414: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:415: error: unknown field 'd_ioctl' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:415: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:415: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:416: error: unknown field 'd_mmap' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:416: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:416: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:417: error: unknown field 'd_read' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:417: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:417: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:418: error: unknown field 'd_write' specified in initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:418: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:418: error: (near initialization for 'vmmdevsw')
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: In function 'sysctl_vmm_create':
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:448: error: implicit declaration of function 'malloc'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:448: error: nested extern declaration of 'malloc'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:448: error: assignment makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:450: error: implicit declaration of function 'make_dev'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:450: error: nested extern declaration of 'make_dev'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:451: error: assignment makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: In function 'vmmdev_init':
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:464: error: implicit declaration of function 'mtx_init'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:464: error: nested extern declaration of 'mtx_init'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:464: error: 'MTX_DEF' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:464: error: (Each undeclared identifier is reported only once
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:464: error: for each function it appears in.)
/usr/src/sys/platform/pc64/vmm/vmm_dev.c: In function 'vmmdev_cleanup':
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:474: error: implicit declaration of function 'SLIST_FOREACH_SAFE'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:474: error: nested extern declaration of 'SLIST_FOREACH_SAFE'
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:474: error: 'link' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm_dev.c:475: error: expected ';' before 'vmmdev_destroy'
*** 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.