On Tue, Aug 01, 2017 at 07:32:19AM +0800, Adam Steen wrote:
> On Tue, Aug 1, 2017 at 7:26 AM, Adam Steen <a...@adamsteen.com.au> wrote:
> > Mike Belopuhov wrote:
> >
> >> To be able to use TSC as a timecounter source on OpenBSD or Solo5
> >> you'd have to improve the in-kernel measurement of the TSC frequency
> >> first. I've tried to perform 10 measurements and take an average and
> >> it does improve accuracy, however I believe we need to poach another
> >> bit from Linux and re-calibrate TSC via HPET:
> >>
> >>  
> >> http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L409
> >>
> >> I think this is the most sane thing we can do. Here's a complete
> >> procedure that Linux kernel undertakes:
> >>
> >>  
> >> http://elixir.free-electrons.com/linux/v4.12.4/source/arch/x86/kernel/tsc.c#L751
> >>
> >> Regards,
> >> Mike
> >
> > Looks like i have more sort out!
> >
> > Mike Larkin wrote:
> >> If you point me to a bootable image that causes this failure, I might be
> >> able to figure out what vmm(4) doesn't like.
> >>
> >> Nothing in lines 122-134 of the file indicated above should cause this.
> >
> > This is where things get a little more interesting, Solo5
> > (https://github.com/adamsteen/solo5) is actually two parts Solo5 the
> > Unikernel and ukvm the userland side of a hypervisor (currently
> > running with kvm and bhyve), I have been porting to run ukvm directly
> > with vmm. I expect the cause of "vmx_handle_exit: unhandled exit
> > 2147483681 (unknown)" is the register setup in
> > https://github.com/adamsteen/solo5/blob/master/ukvm/ukvm_hv_openbsd_x86_64.c,
> > lines 118-147
> >
> > the constants are ukvm constants.
> >
> >     struct vm_resetcpu_params vrp = {
> >         .vrp_vm_id = hvb->vcp_id,
> >         .vrp_vcpu_id = hvb->vcpu_id,
> >         .vrp_init_state = {
> >             .vrs_gprs[VCPU_REGS_RFLAGS] = X86_RFLAGS_INIT,
> >             .vrs_gprs[VCPU_REGS_RIP] = gpa_ep,
> >             .vrs_gprs[VCPU_REGS_RSP] = hv->mem_size - 8,
> >             .vrs_gprs[VCPU_REGS_RDI] = X86_BOOT_INFO_BASE,
> >             .vrs_crs[VCPU_REGS_CR0] = X86_CR0_INIT,
> >             .vrs_crs[VCPU_REGS_CR3] = X86_CR3_INIT,
> >             .vrs_crs[VCPU_REGS_CR4] = X86_CR4_INIT,
> >             .vrs_sregs[VCPU_REGS_CS] = sreg_to_vsi(&ukvm_x86_sreg_code),
> >             .vrs_sregs[VCPU_REGS_DS] = sreg_to_vsi(&ukvm_x86_sreg_data),
> >             .vrs_sregs[VCPU_REGS_ES] = sreg_to_vsi(&ukvm_x86_sreg_data),
> >             .vrs_sregs[VCPU_REGS_FS] = sreg_to_vsi(&ukvm_x86_sreg_data),
> >             .vrs_sregs[VCPU_REGS_GS] = sreg_to_vsi(&ukvm_x86_sreg_data),
> >             .vrs_sregs[VCPU_REGS_SS] = sreg_to_vsi(&ukvm_x86_sreg_data),
> >             .vrs_gdtr = { 0x0, X86_GDTR_LIMIT, 0x0, X86_GDT_BASE},
> >             .vrs_idtr = { 0x0, 0xFFFF, 0x0, 0x0},
> >             .vrs_sregs[VCPU_REGS_LDTR] = 
> > sreg_to_vsi(&ukvm_x86_sreg_unusable),
> >             .vrs_sregs[VCPU_REGS_TR] = sreg_to_vsi(&ukvm_x86_sreg_tr),
> >             .vrs_msrs[VCPU_REGS_EFER] = X86_EFER_INIT,
> >             .vrs_msrs[VCPU_REGS_STAR] = 0ULL,
> >             .vrs_msrs[VCPU_REGS_LSTAR] = 0ULL,
> >             .vrs_msrs[VCPU_REGS_CSTAR] = 0ULL,
> >             .vrs_msrs[VCPU_REGS_SFMASK] = 0ULL,
> >             .vrs_msrs[VCPU_REGS_KGSBASE] = 0ULL,
> >             .vrs_crs[VCPU_REGS_XCR0] = XCR0_X87
> >         }
> >     };
> >
> > the three specific OpenBSD files are
> > https://github.com/adamsteen/solo5/blob/master/ukvm/ukvm_hv_openbsd.h
> > https://github.com/adamsteen/solo5/blob/master/ukvm/ukvm_hv_openbsd.c
> > https://github.com/adamsteen/solo5/blob/master/ukvm/ukvm_hv_openbsd_x86_64.c
> > with small changes in ukvm/ukvm_elf.c and ukvm/ukvm_module_net.c
> >
> > I could upload a binary image for you but It won't run with vmd its
> > has ukvm specific hypercalls designed to simplify things.
> >
> > Cheers
> > Adam
> >
> > ps i am currently trying to document the differences in what vmm is
> > expecting and ukvm is expecting.
> 

I'd recommend enabling VMM_DEBUG and seeing if that prints more useful
information after the unhandled exit. That error code is usually because of
invalid VMCS content, but since you're rolling your own vmm interface, it's
not clear what might have been missed. If you send me that information
(from dmesg, it will be a lot) I may be able to help.

-ml


> One more thing
> 
> Please note currently i have to build the bootable binary image of
> solo5 with a cross compiler as i have not figured out the
> discrepancies between OpenBSD's ld and solo5's linker script.
> 
> Cheers
> Adam

Reply via email to