Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jun 2012 08:45:21 +0900
From:      Takuya ASADA <syuu@dokukino.com>
To:        soc-status@freebsd.org, Peter Grehan <grehan@freebsd.org>
Subject:   [status report #4 & #5] BHyVe BIOS emulation to boot legacy systems
Message-ID:  <CALG4x-W9e1XrH9oYDhAxKESVEa7KOF1ErBEsQAn6iKHKbd-Ntw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Sorry for delay to send report #4, I'll send #4 & #5 together now.

* project summary
The project goal is to support BIOS emulation on BHyVe, enabling boot
from disk image.
I going to focus booting FreeBSD/amd64 from disk image on this GSoC,
but final goal is to make BHyVe able to support more guest OSes.

* re-implement register initialization code on libvmmapi
In report #3, I implemented sample pseudo BIOS loader and
"unrestricted mode" enabler on bhyve command, but it caused triple
fault in guest mode.

I tried to initialize CPU registers correctly, by following Intel CPU
manuals - section 9.1.1 "Processor State After Reset", vol 3.

svn diff -r238303:238304
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios

* unset VM_ENTRY_LOAD_EFER and VM_ENTRY_GUEST_LMA flags on entry_ctls
when a client is unrestricted guest

Intel manual says, we can't enable these bits when we are in
unrestricted guest mode(real mode).
So I added a code to clear bits when client requested VM_CAP_UNRESTRICTED_GUEST.

svn diff -r238294:238295
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios

* remove unnecessary codes on bhyvebiosload
svn diff -r238302:238303
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios|

* test result
Succeeded to handle VMCALL in unrestricted guest mode.
So I can start develop pseudo BIOS from here.

$ sudo bhyvebiosload -m 128 -M 256 -h /usr/bhyve-guest/ vm0
$ sudo bhyve -m 128 -M 256 -b vm0
VMCALL handled
$ sudo vmmctl --vm=vm0 --get-all
lowmem		0x0000000100000000/134217728
highmem		0x0000000108000000/268435456
efer[0]		0x0000000000000901
cr0[0]		0x0000000000000030
cr3[0]		0x0000000000000000
cr4[0]		0x0000000000002000
dr7[0]		0x0000000000000000
rsp[0]		0x0000000000000000
rip[0]		0x0000000000000000
rax[0]		0x0000000000000000
rbx[0]		0x0000000000000000
rcx[0]		0x0000000000000000
rdx[0]		0x0000000000000f00
rsi[0]		0x0000000000000000
rdi[0]		0x0000000000000000
rbp[0]		0x0000000000000000
r8[0]		0x0000000000000000
r9[0]		0x0000000000000000
r10[0]		0x0000000000000000
r11[0]		0x0000000000000000
r12[0]		0x0000000000000000
r13[0]		0x0000000000000000
r14[0]		0x0000000000000000
r15[0]		0x0000000000000000
rflags[0]	0x0000000000000002
vcpu0
vm exits due to external interrupt	0
vcpu migration across host cpus 	1
vcpu total runtime              	15562
ds desc[0]	0x0000000000000000/0x0000ffff/0x00000093
es desc[0]	0x0000000000000000/0x0000ffff/0x00000093
fs desc[0]	0x0000000000000000/0x0000ffff/0x00000093
gs desc[0]	0x0000000000000000/0x0000ffff/0x00000093
ss desc[0]	0x0000000000000000/0x0000ffff/0x00000093
cs desc[0]	0x0000000000000000/0x0000ffff/0x00000093
tr desc[0]	0x0000000000000000/0x0000ffff/0x00000083
ldtr desc[0]	0x0000000000000000/0x0000ffff/0x00000082
gdtr[0]		0x0000000000000000/0x0000ffff
idtr[0]		0x0000000000000000/0x0000ffff
cs[0]		0x0000
ds[0]		0x0000
es[0]		0x0000
fs[0]		0x0000
gs[0]		0x0000
ss[0]		0x0000
tr[0]		0x0000
ldtr[0]		0x0000
pincpu[0]	unpinned
pinbased_ctls[0]	0x0000003f
procbased_ctls[0]	0x95006172
procbased_ctls2[0]	0x000000a2
gla[0]		0x0000000000000000
gpa[0]		0x0000000000000000
entry_interruption_info[0]	0x00000000
eptp[0]		0x000000003cf9201e
exception_bitmap[0]	0x00040000
io_bitmap_a[0]	0x00000000
io_bitmap_b[0]	0x00000000
tsc_offset[0]	0x0000000000000000
cr0_mask[0]		0xffffffff60000020
cr0_shadow[0]		0x0000000000000020
cr4_mask[0]		0x0000000000000000
cr4_shadow[0]		0x0000000000000000
cr3_target_count[0]	0x00000000
cr3_target0[0]		0x0000000000000000
cr3_target1[0]		0x0000000000000000
cr3_target2[0]		0x0000000000000000
cr3_target3[0]		0x0000000000000000
apic_access_addr[0]	0x0000000000000000
virtual_apic_addr[0]	0x0000000000000000
tpr_threshold[0]	0x00000000
msr_bitmap[0]		0x000000000b3d1000
msr 0xc0000080[0]		RW
msr 0xc0000100[0]		RW
msr 0xc0000101[0]		RW
msr 0xc0000102[0]		RW
msr 0x00000277[0]		RW
vpid[0]		0x0011
ple_window[0]		0x00000000
ple_gap[0]		0x00000000
instruction_error[0]	0x00000000
exit_ctls[0]		0x003f6ffb
entry_ctls[0]		0x000051fb
host_pat[0]		0x0001050600070406
guest_pat[0]		0x0007040600070406
host_cr0[0]		0x0000000080050033
host_cr3[0]		0x000000004bb80000
host_cr4[0]		0x00000000000026f0
host_rip[0]		0xffffffff81a12090
host_rip[0]		0xffffff8002aa5000
guest_sysenter_cs[0]	0x00000000
guest_sysenter_sp[0]	0x0000000000000000
guest_sysenter_ip[0]	0x0000000000000000
vmcs_pointer[0]	0xffffffffffffffff
vmcs_exit_reason[0]	0x0000000000000012
vmcs_exit_qualification[0]	0x0000000000000000
vmcs_exit_interruption_info[0]	0x00000000
vmcs_exit_interruption_error[0]	0x00000000
vmcs_guest_interruptibility[0]	0x00000000
errno = 22



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALG4x-W9e1XrH9oYDhAxKESVEa7KOF1ErBEsQAn6iKHKbd-Ntw>