From: Jack Lange Date: Fri, 28 Mar 2008 19:40:13 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: working-cdboot-physical-but-not-qemu~52 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=3f025fd4e0e535801836faa4259b94b18b94f231 *** empty log message *** --- diff --git a/palacios/build/Makefile b/palacios/build/Makefile index 1406a31..adbf8cc 100644 --- a/palacios/build/Makefile +++ b/palacios/build/Makefile @@ -1,6 +1,6 @@ # Makefile for GeekOS kernel, userspace, and tools # Copyright (c) 2004,2005 David H. Hovemeyer -# $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". @@ -85,7 +85,7 @@ KERNEL_C_SRCS := idt.c int.c trap.c irq.c io.c \ 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 diff --git a/palacios/include/geekos/vm_guest.h b/palacios/include/geekos/vm_guest.h index fe3bd1f..89dd950 100644 --- a/palacios/include/geekos/vm_guest.h +++ b/palacios/include/geekos/vm_guest.h @@ -19,7 +19,7 @@ struct guest_gprs { 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; @@ -36,6 +36,8 @@ typedef struct guest_info { vmm_io_map_t io_map; // device_map + vm_cpu_mode_t cpu_mode; + struct guest_gprs vm_regs; diff --git a/palacios/src/geekos/main.c b/palacios/src/geekos/main.c index c463f2d..9197521 100644 --- a/palacios/src/geekos/main.c +++ b/palacios/src/geekos/main.c @@ -3,7 +3,7 @@ * Copyright (c) 2001,2003,2004 David H. Hovemeyer * Copyright (c) 2003, Jeffrey K. Hollingsworth * Copyright (c) 2004, Iulian Neamtiu - * $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". @@ -311,6 +311,8 @@ void Main(struct Boot_Info* bootInfo) 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)); diff --git a/palacios/src/geekos/svm.c b/palacios/src/geekos/svm.c index f3865ca..ab2a406 100644 --- a/palacios/src/geekos/svm.c +++ b/palacios/src/geekos/svm.c @@ -43,16 +43,15 @@ int is_svm_capable() { 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"); @@ -317,7 +316,8 @@ void Init_VMCB(vmcb_t * vmcb, guest_info_t vm_info) { 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; @@ -395,14 +395,10 @@ void Init_VMCB(vmcb_t * vmcb, guest_info_t vm_info) { 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; diff --git a/palacios/src/geekos/svm_handler.c b/palacios/src/geekos/svm_handler.c index 6840ade..e9d2a90 100644 --- a/palacios/src/geekos/svm_handler.c +++ b/palacios/src/geekos/svm_handler.c @@ -1,6 +1,6 @@ #include #include - +#include @@ -12,10 +12,17 @@ int handle_svm_exit(guest_info_t * info) { 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)); @@ -27,6 +34,15 @@ int handle_svm_exit(guest_info_t * info) { 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) || @@ -37,6 +53,10 @@ int handle_svm_exit(guest_info_t * info) { } + // Update the low level state + guest_state->rip = info->rip; + guest_state->rsp = info->rsp; + return 0; } @@ -76,3 +96,6 @@ int handle_shadow_paging(guest_info_t * info) { return 0; } + + + diff --git a/palacios/src/geekos/vmm_paging.c b/palacios/src/geekos/vmm_paging.c index 9cd97d6..5daea0f 100644 --- a/palacios/src/geekos/vmm_paging.c +++ b/palacios/src/geekos/vmm_paging.c @@ -292,7 +292,7 @@ vmm_pde_t * create_passthrough_pde32_pts(shadow_map_t * map) { } if (pte_present == 0) { - VMMFree(pte); + os_hooks->free_page(pte); pde[i].present = 0; pde[i].flags = 0; diff --git a/palacios/src/geekos/vmm_stubs.c b/palacios/src/geekos/vmm_stubs.c index a9db9c6..4c37033 100644 --- a/palacios/src/geekos/vmm_stubs.c +++ b/palacios/src/geekos/vmm_stubs.c @@ -7,12 +7,12 @@ void * Identity(void *addr) { return addr; }; 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...; @@ -21,7 +21,7 @@ void * Allocate_VMM_Pages(int num_pages) { 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; }