LoginSignup
0

More than 5 years have passed since last update.

QEMU上でBitVisorは動作するか? リベンジ編

Last updated at Posted at 2016-12-15

以下の記事ではQEMU上でのBitVisorの実行に見事に失敗しましたが、今回は少し環境をかえて再び挑戦します。

QEMU上でBitVisorは動作するか?
http://qiita.com/hdk_2/items/760ed04a7ca65b04ade3

実行例

先に実行例を示します。

QEMU (KVMなし)

前回、謎のFUNCTION ERROR!が出てしまったり、VMEXIT_SHUTDOWNが出てpanicしてしまったりした、KVMなしのQEMUでの実行例です。

qemu-bios-dbgsh.png

めっちゃ遅いですが、BIOS環境でBitVisorおよびDebian GNU/Linux 8を起動してdbgshでログを確認しています。

qemu-efi-1.png

qemu-efi-2.png

qemu-efi-ubu.png

めっっっっちゃ遅いですが、UEFI環境でBitVisorおよびUbuntu 15.10 Live環境が起動しています。dbgshを動かしてみたかったのですが、あまりにも遅いので諦めました。(上のUnityデスクトップのスクリーンショットを撮るのに数十分を要しています。)

QEMU (KVMあり)

qemu-bios-hang2.png

BIOS環境ではGNU GRUBが起動するところでハングアップします。

qemu-kvm-efi2-1.png

qemu-kvm-efi2-2.png

UEFI環境でBitVisorおよびUbuntu 15.10 Live環境が起動しています。

何をやったのか

環境を変えたのとBitVisorに修正を加えています。

環境

KVMなし

  • Ubuntu 14.04
  • Linux 3.13
  • QEMU 2.0.0
  • AMD A10-7870K

QEMUのバージョンが古いのがポイントのようです。試しにQEMUの最新版をビルドしてみましたが、BIOS環境ではBitVisor起動後画面が消去されたもののGNU GRUBが起動せず、UEFI環境ではBitVisor起動時に以下のようなエラーが出て停止しました。

qemu-system-x86_64: Trying to execute code outside RAM or ROM at 0x0000000100000000
This usually means one of the following happened:

(1) You told QEMU to execute a kernel for the wrong machine type, and it crashed on startup (eg trying to run a raspberry pi kernel on a versatilepb QEMU machine)
(2) You didn't give QEMU a kernel or BIOS filename at all, and QEMU executed a ROM full of no-op instructions until it fell off the end
(3) Your guest kernel has a bug and crashed by jumping off into nowhere

This is almost always one of the first two, so check your command line and that you are using the right type of kernel for this machine.
If you think option (3) is likely then you can try debugging your guest with the -d debug options; in particular -d guest_errors will cause the log to include a dump of the guest register state at this point.

Execution cannot continue; stopping here.

QEMUの起動パラメーターは以下のような感じです。

  • qemu-system-x86_64 -m 2048 -hda /data2/debian.qcow2
  • qemu-system-x86_64 -m 1024 -hda fat:_ -snapshot -cdrom /data/ubuntu-15.10-desktop-amd64.iso -bios OVMF.fd

KVMあり

  • Ubuntu 14.04
  • Linux 3.13
  • QEMU v2.8.0-rc3 a92f7fe5a82ac9e8d127e92c5dce1a84064126da
  • AMD A10-7870K

こちらはKVMなしとは対照的に、古いバージョンのQEMUではVMEXIT_SHUTDOWNが出たりハングアップしたりと、あまり良くないようです。そこで、最新版のQEMUに-cpu hostオプションをつけています。また、UEFI環境では画面が化けるので-vga qxlオプションもつけています。

  • qemu-system-x86_64 -m 2048 -hda /data2/debian.qcow2 -enable-kvm -cpu host
  • qemu-system-x86_64 -m 2048 -hda fat:_ -snapshot -cdrom /data/ubuntu-15.10-desktop-amd64.iso -bios OVMF.fd -enable-kvm -cpu host -vga qxl

BitVisorの修正

QEMU KVM環境にはなぜかSYSCFG MSRが書けないのに読めてしまうという変な問題があって、そのような変な環境ではBitVisorは正常に動かないため簡単な修正を加えてあります。差分を以下に示します。(タブがスペースになっていますのでご注意ください。)

diff --git a/core/cache.c b/core/cache.c
--- a/core/cache.c
+++ b/core/cache.c
@@ -993,6 +993,7 @@ read_syscfg (void *arg)

        ret = arg;
        asm_rdmsr64 (MSR_AMD_SYSCFG, ret);
+       asm_wrmsr64 (MSR_AMD_SYSCFG, *ret);
 }

 static void

完全にQEMU KVM対策ではありますが、特に副作用も無いと思うのでBitVisor本体に取り込まれるかも知れません。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0