G33/C2Q6600 と 690G/Athlon64 X2 5200+ の構成で、
ちょこっと触ってみたけど、FreeBSDを再起動できないな;;
そのままだと仮想マシンが停止してしまう。
そこで触らぬ神にたたりなし?ってわけでPCIアドレスレジスタを
いじらないようにする怪しげなパッチを作成してみた。
diff -aur src-orig/sys/dev/pci/pci.c src/sys/dev/pci/pci.c
--- src-orig/sys/dev/pci/pci.c 2008-08-23 12:40:49.000000000 +0900
+++ src/sys/dev/pci/pci.c 2008-10-02 23:53:03.000000000 +0900
@@ -3590,6 +3590,11 @@
struct pci_devinfo *dinfo = device_get_ivars(child);
pcicfgregs *cfg = &dinfo->cfg;
+ /* 0x1011: DEC, 0x0009: 21140, 0x10: PCIR_BARS, 0x28: PCIR_CIS */
+ if (dinfo->cfg.vendor == 0x1011 && dinfo->cfg.device == 0x0009)
+ if (reg >= 0x10 && reg < 0x28)
+ return;
+
PCIB_WRITE_CONFIG(device_get_parent(dev),
cfg->bus, cfg->slot, cfg->func, reg, val, width);
}
用意するもの:
Hyper-Vが動くCPU搭載のパソコン
Windows Server 2008 64ビット版
FreeBSDイメージ 7.1-PRERELEASE-200809-i386-disc1.iso など
パッチファイル fbs71-200809-hvpatch.bz2
FreeBSDは以下からダウンロードしておく。
ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/200809/
Windows Server 2008 をインストールして、
Windows Update をかけて最新にする。
サーバーマネージャの役割から Hyper-V を追加する。
Hyper-V マネージャから仮想マシンを作成する。
仮想マシンの設定を開いてネットワーク アダプタを削除する。
ハードウェアの追加からレガシ ネットワーク アダプタを追加する。
お好みでプロセッサ数やメモリを変更する。
FreeBSD を仮想マシンにインストールする。
パッチを適用してカーネルを更新する。
# cd /usr/src
# bzcat < /path/to/fbs71-200809-hv.patch.bz2 | patch -p1
# make buildkernel
# make installkernel
# shutdown -r now
初回カーネルを更新するまで再起動で停止してしまうので、
タスクマネージャのプロセスのタブからvmwp.exeを見つけて終了させる。
おまけ:
Windows2000もHyper-Vで動くようだけど、
ネットワークを触りにいったとたんに反応なくなります…。
フリーズしたまま5分ほど放置すると何事もなかったように動きます(汗)
以後、仮想マシンを再起動するまでは平気な模様。
Server 2003、2008、XPでは起こらないので2000固有の問題かと。
(Vistaは未確認)
追記:
vmwp.exeの終了のしかたはこちらの記事を参考にしてください。
FreeBSD 6.4 / 7.1 / 8.0 on Windows Server 2008 + Hyper-V…
もうすぐFreeBSD6.4がリリースされます。
ちょっと横道だけどFreeBSDのSecurity Advisory(08:11)が出ています。
以前ちらっと書いたけど6.3が仮想環境にあまりよくないので、
しばらく様子見しよう….
Thank you very much for this patch. It did helped me in running FreeBSD 7 and FreeBSD 8 inside Hyper-V.
There is only one problem remain. Problem witр DHCP. It is not working automaticaly on system startup but it possible to fix it using that commands.
ifconfig de0 down
ifconfig de0 up
dhclient de0
After that NIC works fine. Maybe you know solution for this issue too?
I don’t know about DHCP because I use fix IPs.
But it seems to be autoselection issue.
Please try this configuration:
ifconfig_de0=”DHCP media 100baseTX mediaopt full-duplex”
I did tried your solution and it works like magic. Now DHCP in FreeBSD 7,8 works under Hyper-V flawlessly. ;-)
Thank you very much!!! ;-)
Have we confirmed that there’s nothing that the de driver is doing that causes it to, say, go into an interrupt storm that’s causing the problems? The inability to write to the BAR register violates the PCI standard since one must do that to size the resources decoded by the register. How are the resources sized correctly with this patch?
Also, this patch would break the ability to run a de card in a system whose bios doesn’t assign a resource to the card.
Warner
The resource size is determined by normal method of PCI standard.
Did you consider when this patch affect?
I don’t know a reason why FreeBSD ignore I/O indicator of base address register and Hyper-V only accept sequence of the values of 0xffffffff and something in DEC21140 I/O MAP at BAR(0) but I noticed that FreeBSD can reboot if it did not write at BAR after setting map.
pci_add_map()@sys/dev/pci/pci.c is called for each BAR.
> map = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4);
> PCIB_WRITE_CONFIG(pcib, b, s, f, reg, 0xffffffff, 4);
> testval = PCIB_READ_CONFIG(pcib, b, s, f, reg, 4);
> PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4);
This method is correct and work on Hyper-V. FreeBSD can get the size.
> start = rman_get_start(res);
> pci_write_config(dev, reg, start, 4);
The value of start may ignore I/O indicator of map becasue rman_get_start() never includes mask bits. But it is not important in this case.pci_write_config() call pci_write_config_method() then
call PCIB_WRITE_CONFIG().
> PCIB_WRITE_CONFIG(device_get_parent(dev),
> cfg->bus, cfg->slot, cfg->func, reg, val, width);
Write sequence of the reg is
> PCIB_WRITE_CONFIG(pcib, b, s, f, reg, 0xffffffff, 4);
> PCIB_WRITE_CONFIG(pcib, b, s, f, reg, map, 4);
> PCIB_WRITE_CONFIG(device_get_parent(dev),
> cfg->bus, cfg->slot, cfg->func, reg, val, width);
This break on Hyper-V of DEC21140 I/O MAP. The patch avoid to write to BARS of DEC21140 after setting map. Of course, it will break if it write to BAR in somewhere.
Note: pci_write_config() is also called by pci_cfg_save()/restore().
>Also, this patch would break the ability to run a de card in
>a system whose bios doesn’t assign a resource to the card.
You are right. It was intended to use only within Hyper-V w/DEC 21140 and physical machine w/o DEC 21140. I think this code is dirty at first time. But I thought that it’s better than VM continued stopping all the time.
update:
I’m misunderstanding. the bit 3-0 for mem, bit 1-0 for I/O are
readonly bit. start is always valid for PCIB_WRITE_CONFIG.
[...] http://bbs.51cto.com/thread-818640-1.html FreeBSD 7.1 on Windows Server 2008 + Hyper-V http://shell.peach.ne.jp/aoyama/archives/40 FreeBSD in Hyper-V – WORKS!!! http://luka.manojlovic.net/2008/07/01/freebsd-in-hyper-v-works/ [...]