[status report #3] BHyVe BIOS emulation to boot legacy systems

Takuya ASADA syuu at dokukino.com
Thu Jun 14 08:27:35 UTC 2012


* 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.

* implement BIOS emulation mode on /usr/sbin/bhyve
Just does vm_set_capability(ctx, BSP, VM_CAP_UNRESTRICTED_GUEST, 1)
when passed -b argument, for now.

svn diff -r r237668:r237669
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios

* vmmctl --get-all
For more easy debugging guest environment, added a option for vmmctl.
It simply shows up ALL information which can fetch from vmmctl.

svn diff -r r237669:r237670
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios

* implement /usr/sbin/bhyvebiosload
Loads ${vm_path}/pseudo_bios.bin to 0x0 of virtual machine memory
space, initialize CPU0 as real mode state, set RIP to 0x0.
(RIP = 0x0 is just for testing)

svn diff -r r237670:r237672
https://socsvn.freebsd.org/socsvn/soc2012/syuu/bhyve-bios

* test result
Looks like a CPU looking correct memory address and could fetch VMCALL
instruction, because bhyve says "inst_length     3".
When I tried to change VMCALL intruction to NOP intruction,
inst_length had changed to 1, so probably it's okay.
Though, it's getting triple fault.
Maybe some CPU initialization is wrong , so it faults just after VMLAUNCH.
I'm trying to figure out why it's faulting...

$ sudo ./bhyvebiosload -m 128 -M 256 -h /usr/bhyve-guest/ vm0
$ cd ../bhyve
$ sudo vmmctl --get-all --vm=vm0
lowmem          0x0000000100000000/134217728
highmem         0x0000000108000000/268435456
efer[0]         0x0000000000000000
cr0[0]          0x0000000000000020
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]          0x0000000000000000
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
vcpu migration across host cpus         0
vcpu total runtime                      0
vm exits due to external interrupt      0
ds desc[0]      0x0000000000000000/0x00000000/0x00000093
es desc[0]      0x0000000000000000/0x00000000/0x00000093
fs desc[0]      0x0000000000000000/0x00000000/0x00000093
gs desc[0]      0x0000000000000000/0x00000000/0x00000093
ss desc[0]      0x0000000000000000/0x00000000/0x00000093
cs desc[0]      0x0000000000000000/0x00000000/0x0000209b
tr desc[0]      0x0000000000000000/0x00000000/0x0000008b
ldtr desc[0]    0x0000000000000000/0x00000000/0x00010000
gdtr[0]         0x0000000000005000/0x00000017
idtr[0]         0x0000000000000000/0x00000000
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]      0x00000022
gla[0]          0x0000000000000000
gpa[0]          0x0000000000000000
entry_interruption_info[0]      0x00000000
eptp[0]         0x000000007b08801e
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]           0x000000006ef31000
msr 0xc0000080[0]               RW
msr 0xc0000100[0]               RW
msr 0xc0000101[0]               RW
msr 0xc0000102[0]               RW
msr 0x00000277[0]               RW
vpid[0]         0x00c9
ple_window[0]           0x00000000
ple_gap[0]              0x00000000
instruction_error[0]    0x00000000
exit_ctls[0]            0x003f6ffb
entry_ctls[0]           0x0000d1fb
host_pat[0]             0x0001050600070406
guest_pat[0]            0x0007040600070406
host_cr0[0]             0x0000000080050033
host_cr3[0]             0x0000000000000000
host_cr4[0]             0x00000000000026f0
host_rip[0]             0xffffffff81812090
host_rip[0]             0xffffff8002aaa000
guest_sysenter_cs[0]    0x00000000
guest_sysenter_sp[0]    0x0000000000000000
guest_sysenter_ip[0]    0x0000000000000000
vmcs_pointer[0] 0xffffffffffffffff
vmcs_exit_reason[0]     0x0000000000000000
vmcs_exit_qualification[0]      0x0000000000000000
vmcs_exit_interruption_info[0]  0x00000000
vmcs_exit_interruption_error[0] 0x00000000
vmcs_guest_interruptibility[0]  0x00000000
errno = 22
$ sudo ./bhyve -m 128 -M 256 -b vm0
vm exit[0]
        reason          VMX
        rip             0x0000000000000000
        inst_length     3
        error           0
        exit_reason     2
        qualification   0x0000000000000000
$ sudo vmmctl --get-all --vm=vm0
lowmem          0x0000000100000000/134217728
highmem         0x0000000108000000/268435456
efer[0]         0x0000000000000000
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]          0x0000000000000000
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]       0x0000000000010002
vcpu0
vcpu migration across host cpus         1
vcpu total runtime                      23841
vm exits due to external interrupt      0
ds desc[0]      0x0000000000000000/0x00000000/0x00000093
es desc[0]      0x0000000000000000/0x00000000/0x00000093
fs desc[0]      0x0000000000000000/0x00000000/0x00000093
gs desc[0]      0x0000000000000000/0x00000000/0x00000093
ss desc[0]      0x0000000000000000/0x00000000/0x00000093
cs desc[0]      0x0000000000000000/0x00000000/0x0000209b
tr desc[0]      0x0000000000000000/0x00000000/0x0000008b
ldtr desc[0]    0x0000000000000000/0x00000000/0x00010000
gdtr[0]         0x0000000000005000/0x00000017
idtr[0]         0x0000000000000000/0x00000000
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]         0x000000007b08801e
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]           0x000000006ef31000
msr 0xc0000080[0]               RW
msr 0xc0000100[0]               RW
msr 0xc0000101[0]               RW
msr 0xc0000102[0]               RW
msr 0x00000277[0]               RW
vpid[0]         0x00c9
ple_window[0]           0x00000000
ple_gap[0]              0x00000000
instruction_error[0]    0x00000000
exit_ctls[0]            0x003f6ffb
entry_ctls[0]           0x0000d1fb
host_pat[0]             0x0001050600070406
guest_pat[0]            0x0007040600070406
host_cr0[0]             0x0000000080050033
host_cr3[0]             0x000000002c71c000
host_cr4[0]             0x00000000000026f0
host_rip[0]             0xffffffff81812090
host_rip[0]             0xffffff8002aaa000
guest_sysenter_cs[0]    0x00000000
guest_sysenter_sp[0]    0x0000000000000000
guest_sysenter_ip[0]    0x0000000000000000
vmcs_pointer[0] 0xffffffffffffffff
vmcs_exit_reason[0]     0x0000000000000002
vmcs_exit_qualification[0]      0x0000000000000000
vmcs_exit_interruption_info[0]  0x00000000
vmcs_exit_interruption_error[0] 0x00000000
vmcs_guest_interruptibility[0]  0x00000000
errno = 22


More information about the soc-status mailing list