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

BHyVeビルドめも15

DragonFlyBSD BHyVe

φ(・・*)ゞ ウーン
今日のvmm.cは結構面倒くさそうなのでちょっとずつ進める予定に><

まずは簡単なヘッダファイルの変更と、その他をちょっと

ちょっと調べたのはこれ位ですね。FreeBSDでカレントのプロセス制御ブロックの取得にPCPU_GETマクロを使ってますがDragonFlyにはそのマクロがありません。

-       pcb = PCPU_GET(curpcb);
+       pcb = curthread->td_pcb;
 

このマクロ自体はvmx.cのコンパイルエラー修正するときに探したので大体の解決方法は分かっていたので、実際に調べたのはどの変数にアクセスするべきかってところでした。それで探してみるとsys/platform/pc64/include/thread.hにDragonFlyではカレントのpcbはスレッド構造体が保持しているよと説明されていたのでカレントスレッドのtd_pcbにアクセスするように修正しました。

/*
 * note: curthread is never NULL, but curproc can be.  Also note that
 * in DragonFly, the current pcb is stored in the thread structure.
 */
#define curthread       mycpu->gd_curthread
#define curproc         curthread->td_proc

さて、コンパイルエラーはまだまだあるのですが大雑把にまとめるとfpu関連、スレッドのロックの2機能が修正対象ですね。

--------------------------------------------------------------
>>> Kernel build for BHYVE started on Wed Jul 11 22:37:24 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
cc1: warnings being treated as errors
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vcpu_cleanup':
/usr/src/sys/platform/pc64/vmm/vmm.c:147: error: implicit declaration of function 'fpu_save_area_free'
/usr/src/sys/platform/pc64/vmm/vmm.c:147: error: nested extern declaration of 'fpu_save_area_free'
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vcpu_init':
/usr/src/sys/platform/pc64/vmm/vmm.c:160: error: implicit declaration of function 'fpu_save_area_alloc'
/usr/src/sys/platform/pc64/vmm/vmm.c:160: error: nested extern declaration of 'fpu_save_area_alloc'
/usr/src/sys/platform/pc64/vmm/vmm.c:160: error: assignment makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/vmm.c:161: error: implicit declaration of function 'fpu_save_area_reset'
/usr/src/sys/platform/pc64/vmm/vmm.c:161: error: nested extern declaration of 'fpu_save_area_reset'
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vm_map_mmio':
/usr/src/sys/platform/pc64/vmm/vmm.c:287: error: 'VM_MEMATTR_UNCACHEABLE' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm.c:287: error: (Each undeclared identifier is reported only once
/usr/src/sys/platform/pc64/vmm/vmm.c:287: error: for each function it appears in.)
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vm_unmap_mmio':
/usr/src/sys/platform/pc64/vmm/vmm.c:296: error: 'VM_MEMATTR_UNCACHEABLE' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vm_malloc':
/usr/src/sys/platform/pc64/vmm/vmm.c:322: error: 'VM_MEMATTR_WRITE_BACK' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vm_set_pinning':
/usr/src/sys/platform/pc64/vmm/vmm.c:481: error: implicit declaration of function 'thread_lock'
/usr/src/sys/platform/pc64/vmm/vmm.c:481: error: nested extern declaration of 'thread_lock'
/usr/src/sys/platform/pc64/vmm/vmm.c:482: error: implicit declaration of function 'sched_unbind'
/usr/src/sys/platform/pc64/vmm/vmm.c:482: error: nested extern declaration of 'sched_unbind'
/usr/src/sys/platform/pc64/vmm/vmm.c:483: error: implicit declaration of function 'thread_unlock'
/usr/src/sys/platform/pc64/vmm/vmm.c:483: error: nested extern declaration of 'thread_unlock'
/usr/src/sys/platform/pc64/vmm/vmm.c:487: error: implicit declaration of function 'CPU_ABSENT'
/usr/src/sys/platform/pc64/vmm/vmm.c:487: error: nested extern declaration of 'CPU_ABSENT'
/usr/src/sys/platform/pc64/vmm/vmm.c:495: error: implicit declaration of function 'sched_bind'
/usr/src/sys/platform/pc64/vmm/vmm.c:495: error: nested extern declaration of 'sched_bind'
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'restore_guest_fpustate':
/usr/src/sys/platform/pc64/vmm/vmm.c:507: error: implicit declaration of function 'fpuexit'
/usr/src/sys/platform/pc64/vmm/vmm.c:507: error: nested extern declaration of 'fpuexit'
/usr/src/sys/platform/pc64/vmm/vmm.c:508: error: implicit declaration of function 'stop_emulating'
/usr/src/sys/platform/pc64/vmm/vmm.c:508: error: nested extern declaration of 'stop_emulating'
/usr/src/sys/platform/pc64/vmm/vmm.c:509: error: implicit declaration of function 'fpurestore'
/usr/src/sys/platform/pc64/vmm/vmm.c:509: error: nested extern declaration of 'fpurestore'
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'save_guest_fpustate':
/usr/src/sys/platform/pc64/vmm/vmm.c:516: error: implicit declaration of function 'fpusave'
/usr/src/sys/platform/pc64/vmm/vmm.c:516: error: nested extern declaration of 'fpusave'
/usr/src/sys/platform/pc64/vmm/vmm.c:517: error: implicit declaration of function 'start_emulating'
/usr/src/sys/platform/pc64/vmm/vmm.c:517: error: nested extern declaration of 'start_emulating'
/usr/src/sys/platform/pc64/vmm/vmm.c: In function 'vm_run':
/usr/src/sys/platform/pc64/vmm/vmm.c:540: error: implicit declaration of function 'set_pcb_flags'
/usr/src/sys/platform/pc64/vmm/vmm.c:540: error: nested extern declaration of 'set_pcb_flags'
/usr/src/sys/platform/pc64/vmm/vmm.c:540: error: 'PCB_FULL_IRET' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/vmm.c:542: error: 'curcpu' undeclared (first use in this function)
*** 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.

この中でfpu関連の部分は(fpu_save_area_free()がないとか)はDragonFly BSDに無いのはともかく、これを見るとFreeBSDにも無いんですがorz
ちなみにfpu_save_area_freeをググって(bingだと検索結果0件/(^o^)\)みたところ驟雨さんのリポジトリだと関数あるんですよね。もしかしてBHyVe用に追加された関数なのか?という気もしてきます。そうするとこの辺の処理も持ってこないといけないですね。