One Final attempt to get going with our Major Project through Blogging.....

Tuesday, November 6, 2007

HVMM in PseudoCode

                

Control Flow

BIOS -> BOOTLOADER -> HVMM


HVMM Pseudo-Code
{
INITIALIZE_SVM();
HYPERVISOR();
}

LOAD_VMM_UI() {
//display text based interface listing guest OS choices
//wait for user input
}

INITIALIZE_SVM() {
ENABLE_SVM();
SETUP_HYPERVISOR();
}

ENABLE_SVM() {
EFER.SVME = 1;
}

SETUP_HYPERVISOR() {
ALLOCATE_HYPERVISOR_CODE();
LOAD_HYPERVISOR_CODE();
ALLOCATE_HOST_STATE_AREA();
}

ALLOCATE_HYPERVISOR_CODE() {
//allocate a non-paged area in kernel memory
}

LOAD_HYPERVISOR_CODE() {
//copy the hypervisor code to memory
}

ALLOCATE_HOST_STATE_AREA() {
//allocate a non-paged contiguous physical memory space for a host save area
//store the physical address to this area in the VM_HSAVE_PA register
}

HYPERVISOR() {
while (1) {
If(vmm_switch) {
LAUNCH_VMM_UI();
vmcb = GET_SELECTED_VMCB();
if(vmcb = NULL) {
vmcb = SETUP_VMCB();
ADD_ACTIVE(vmcb);
}
LAUNCH_VM_UI();
}
else {
vmcb = GET_NEXT_VMCB();
// from scheduler
}
rax = &VMCB;
VMLOAD(rax);
While(running_vm) {
VMRUN(rax);
Switch(exit_code) {
//handle interrupt in each case
If(timer_expire OR vmm_switch or power_off) break;
}
}
If(power_off) REMOVE_ACTIVE(rax);
Else VMSAVE(rax);
}
}

SETUP_VMCB() {
ALLOCATE_VMCB();
// CLGI instruction is executed to disable global interrupts
// initialize the control area of the with a set of intercept conditions that will cause execution to transfer out of the guest and
back to the hypervisor

// initialize the guest area of the VMCB with the address where guest execution should begin
}

ALLOCATE_VMCB() {
//allocate a region of physically contiguous, page-aligned, non-pageable memory
}



No comments: