# Makefile for GeekOS kernel, userspace, and tools
# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.17 $
+# $Revision: 1.18 $
# This is free software. You are permitted to use,
# redistribute, and modify it as specified in the file "COPYING".
synch.c kthread.c \
serial.c reboot.c \
paging.c vmx.c vmcs_gen.c vmcs.c \
- svm.c svm_handler.c vmm.c vmm_util.c vmm_stubs.c \
+ svm.c svm_handler.c vmm.c vmm_util.c vmm_stubs.c svm_ctrl_regs.c \
vmcb.c vmm_mem.c vm_guest.c vmm_paging.c vmm_io.c vmm_debug.c \
debug.c\
main.c
typedef enum {SHADOW_PAGING, NESTED_PAGING} vm_page_mode_t;
-
+typedef enum {REAL, PROTECTED, PROTECTED_PG, PROTECTED_PAE, PROTECTED_PAE_PG, LONG, LONG_PG} vm_cpu_mode_t;
typedef struct guest_info {
ullong_t rip;
vmm_io_map_t io_map;
// device_map
+ vm_cpu_mode_t cpu_mode;
+
struct guest_gprs vm_regs;
* Copyright (c) 2001,2003,2004 David H. Hovemeyer <daveho@cs.umd.edu>
* Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
* Copyright (c) 2004, Iulian Neamtiu <neamtiu@cs.umd.edu>
- * $Revision: 1.22 $
+ * $Revision: 1.23 $
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "COPYING".
init_shadow_page_state(&(vm_info.shadow_page_state));
vm_info.page_mode = SHADOW_PAGING;
+ vm_info.cpu_mode = REAL;
+
init_vmm_io_map(&(vm_info.io_map));
Get_MSR(SVM_VM_CR_MSR, &vm_cr_high, &vm_cr_low);
+ if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 1) {
+ PrintDebug("Nested Paging not supported\n");
+ }
+
if ((vm_cr_low & SVM_VM_CR_MSR_svmdis) == 0) {
return 1;
}
ret = cpuid_edx(CPUID_SVM_REV_AND_FEATURE_IDS);
-
-
- if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_np) == 0) {
- PrintDebug("Nested Paging not supported\n");
- }
if ((ret & CPUID_SVM_REV_AND_FEATURE_IDS_edx_svml) == 0) {
PrintDebug("SVM BIOS Disabled, not unlockable\n");
guest_state->rip = vm_info.rip;
-
+ //ctrl_area->instrs.instrs.CR0 = 1;
+ ctrl_area->cr_reads.crs.cr0 = 1;
ctrl_area->cr_writes.crs.cr0 = 1;
guest_state->efer |= EFER_MSR_svm_enable;
ctrl_area->cr_reads.crs.cr3 = 1;
ctrl_area->cr_writes.crs.cr3 = 1;
- ctrl_area->cr_reads.crs.cr0 = 1;
- ctrl_area->cr_writes.crs.cr0 = 1;
+
ctrl_area->instrs.instrs.INVLPG = 1;
ctrl_area->instrs.instrs.INVLPGA = 1;
- ctrl_area->instrs.instrs.CR0 = 1;
-
-
guest_state->g_pat = 0x7040600070406ULL;
#include <geekos/svm_handler.h>
#include <geekos/vmm.h>
-
+#include <geekos/svm_ctrl_regs.h>
guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data));
guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data));
+
+ // Update the high level state
+ info->rip = guest_state->rip;
+ info->rsp = guest_state->rsp;
+
+
PrintDebug("SVM Returned: (Exit Code=%x) (VMCB=%x)\n",&(guest_ctrl->exit_code), info->vmm_data);
PrintDebug("RIP: %x\n", guest_state->rip);
-
+
+
exit_code = guest_ctrl->exit_code;
// PrintDebugVMCB((vmcb_t*)(info->vmm_data));
PrintDebug("io_info2 high = 0x%.8x\n", *(uint_t *)(((uchar_t *)&(guest_ctrl->exit_info2)) + 4));
if (exit_code == VMEXIT_IOIO) {
handle_svm_io(info);
+
+ } else if (exit_code == VMEXIT_CR0_WRITE) {
+ PrintDebug("CR0 Write\n");
+ ullong_t new_cr0 = 0;
+
+ handle_cr0_write(info, &new_cr0);
+
+ guest_state->cr0 = new_cr0;
+
} else if (( (exit_code == VMEXIT_CR3_READ) ||
(exit_code == VMEXIT_CR3_WRITE) ||
(exit_code == VMEXIT_INVLPG) ||
}
+ // Update the low level state
+ guest_state->rip = info->rip;
+ guest_state->rsp = info->rsp;
+
return 0;
}
return 0;
}
+
+
+
}
if (pte_present == 0) {
- VMMFree(pte);
+ os_hooks->free_page(pte);
pde[i].present = 0;
pde[i].flags = 0;
void * Allocate_VMM_Pages(int num_pages) {
void * start_page = Alloc_Page();
- SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
+ //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
int i = 1;
while (i < num_pages) {
void * tmp_page = Alloc_Page();
- SerialPrint("Allocating Page: %x (%d of %d)\n",tmp_page, i+1, num_pages);
+ //SerialPrint("Allocating Page: %x (%d of %d)\n",tmp_page, i+1, num_pages);
if (tmp_page != start_page + (PAGE_SIZE * i)) {
//we have to start over...;
i--;
}
start_page = Alloc_Page();
- SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
+ //SerialPrint("Allocating Page: %x (%d of %d)\n",start_page, 1, num_pages);
i = 1;
continue;
}