BHyVeビルドめも9

φ(・・*)ゞ ウーン
vmx.cのコンパイルエラーを消したのですが、これで良いのか微妙なところも。
ふと気づいたらコミットし忘れてたファイルが合ったのでコミット・pushした。

よく分かってないところとしては、TDF_ASTPENDINGをTDF_PREEMPT_LOCKに置き換えたので合っているのかどうかというところですねぇ。一番これが近そうというところで選んだので間違ってるかも(´・ω・`)

-    astpending = curthread->td_flags & TDF_ASTPENDING;
+    /*
+     * TODO: TDF_PREEMPT_LOCK is OK?
+     */
+    astpending = curthread->td_flags & TDF_PREEMPT_LOCK;

あとここはもうちょっと調べないとなと思いつつ(ry

-  error = vmwrite(VMCS_HOST_GS_BASE, (u_long)&__pcpu[mycpuid]);
+  /* TODO: It needs to check gd is ok or note. */
+  error = vmwrite(VMCS_HOST_GS_BASE, (u_long)gd);

これがどう使われてるかというとvmm_cpufunc.hのvmwriteでこんな風に使われてると。

static __inline int
vmwrite(uint64_t reg, uint64_t val)
{
	int error;

	__asm __volatile("vmwrite %0, %1" : : "r" (val), "r" (reg) : "memory");

	VMX_SET_ERROR_CODE(error);

	return (error);
}

gdの先頭アドレスを渡しさえすれば良いだけならこれで大丈夫かなぁ。
それ以外は特に問題なく直せてます。struct pcpuの__pcpuはmdcpuでアクセスすればいけるので、この辺はサクッと置き換え。
curcpuはmdcpuと同じような感じでmycpuidに置き換えれるのでこれもOK。

そして、最後にコンパイルしてみると次はPCIとかiommuまわりでファイルが無いとかヽ(`Д´)ノウワァァァン!!
PCIはPCIパススルーとかなのかな。

--------------------------------------------------------------
>>> Kernel build for BHYVE started on Thu Jul  5 22:01:42 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/intel/vtd.c -Werror
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:40:28: error: dev/pci/pcireg.h: No such file or directory
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:44:32: error: machine/pci_cfgreg.h: No such file or directory
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:46:22: error: io/iommu.h: No such file or directory
cc1: warnings being treated as errors
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'tylersburg_vtd_ident':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:142: error: implicit declaration of function 'pci_cfgregread'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:142: error: nested extern declaration of 'pci_cfgregread'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:142: error: 'PCIR_VENDOR' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:142: error: (Each undeclared identifier is reported only once
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:142: error: for each function it appears in.)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:143: error: 'PCIR_DEVICE' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:161: error: implicit declaration of function 'printf'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:161: error: nested extern declaration of 'printf'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_wbflush':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:234: error: implicit declaration of function 'pmap_invalidate_cache'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:234: error: nested extern declaration of 'pmap_invalidate_cache'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_add_device':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:378: error: 'PCI_BUSMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:379: error: 'PCI_SLOTMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:380: error: 'PCI_FUNCMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_remove_device':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:420: error: 'PCI_BUSMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:421: error: 'PCI_SLOTMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:422: error: 'PCI_FUNCMAX' undeclared (first use in this function)
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_create_mapping':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:505: error: implicit declaration of function 'malloc'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:505: error: nested extern declaration of 'malloc'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:505: error: initialization makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_create_domain':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:579: error: assignment makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:585: error: assignment makes pointer from integer without a cast
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: In function 'vtd_free_ptp':
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:612: error: implicit declaration of function 'free'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:612: error: nested extern declaration of 'free'
/usr/src/sys/platform/pc64/vmm/intel/vtd.c: At top level:
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:627: error: variable 'iommu_ops_intel' has initializer but incomplete type
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:628: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:628: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:629: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:629: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:630: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:630: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:631: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:631: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:632: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:632: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:633: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:633: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:634: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:634: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:635: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:635: error: (near initialization for 'iommu_ops_intel')
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:636: error: excess elements in struct initializer
/usr/src/sys/platform/pc64/vmm/intel/vtd.c:636: error: (near initialization for 'iommu_ops_intel')
*** 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.