X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx_assist.c;h=fa67d975461a934b16c9600aab9a74fe5a609d47;hb=a7cacea293dbc2fbbbe36421054eff95f88390d4;hp=cfea9bba73cf3811a60d71c1802902e169411ba6;hpb=40d79cccadcdeb5b4744bf965030b40b0d5cb1fb;p=palacios.git diff --git a/palacios/src/palacios/vmx_assist.c b/palacios/src/palacios/vmx_assist.c index cfea9bb..fa67d97 100644 --- a/palacios/src/palacios/vmx_assist.c +++ b/palacios/src/palacios/vmx_assist.c @@ -23,7 +23,7 @@ #include #include -#ifndef CONFIG_DEBUG_VMX +#ifndef V3_CONFIG_DEBUG_VMX #undef PrintDebug #define PrintDebug(fmt, args...) #endif @@ -111,27 +111,27 @@ int v3_vmxassist_ctx_switch(struct guest_info * info) { if (v3_gpa_to_hva(info, VMXASSIST_START, (addr_t *)&hdr) == -1) { - PrintError("Could not translate address for vmxassist header\n"); + PrintError(info->vm_info, info, "Could not translate address for vmxassist header\n"); return -1; } if (hdr->magic != VMXASSIST_MAGIC) { - PrintError("VMXASSIST_MAGIC field is invalid\n"); + PrintError(info->vm_info, info, "VMXASSIST_MAGIC field is invalid\n"); return -1; } if (v3_gpa_to_hva(info, (addr_t)(hdr->old_ctx_gpa), (addr_t *)&(old_ctx)) == -1) { - PrintError("Could not translate address for VMXASSIST old context\n"); + PrintError(info->vm_info, info, "Could not translate address for VMXASSIST old context\n"); return -1; } if (v3_gpa_to_hva(info, (addr_t)(hdr->new_ctx_gpa), (addr_t *)&(new_ctx)) == -1) { - PrintError("Could not translate address for VMXASSIST new context\n"); + PrintError(info->vm_info, info, "Could not translate address for VMXASSIST new context\n"); return -1; } - if (vmx_info->assist_state == VMXASSIST_DISABLED) { + if (vmx_info->assist_state == VMXASSIST_OFF) { /* Save the old Context */ vmx_save_world_ctx(info, old_ctx); @@ -139,13 +139,13 @@ int v3_vmxassist_ctx_switch(struct guest_info * info) { /* restore new context, vmxassist should launch the bios the first time */ vmx_restore_world_ctx(info, new_ctx); - vmx_info->assist_state = VMXASSIST_ENABLED; + vmx_info->assist_state = VMXASSIST_ON; - } else if (vmx_info->assist_state == VMXASSIST_ENABLED) { + } else if (vmx_info->assist_state == VMXASSIST_ON) { /* restore old context */ vmx_restore_world_ctx(info, old_ctx); - vmx_info->assist_state = VMXASSIST_DISABLED; + vmx_info->assist_state = VMXASSIST_OFF; } return 0; @@ -182,7 +182,7 @@ static void load_segment(struct vmx_assist_segment * vmx_assist_seg, struct v3_s static void vmx_save_world_ctx(struct guest_info * info, struct vmx_assist_context * ctx) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); - PrintDebug("Writing from RIP: 0x%p\n", (void *)(addr_t)info->rip); + PrintDebug(info->vm_info, info, "Writing from RIP: 0x%p\n", (void *)(addr_t)info->rip); ctx->eip = info->rip; ctx->esp = info->vm_regs.rsp; @@ -213,7 +213,7 @@ static void vmx_save_world_ctx(struct guest_info * info, struct vmx_assist_conte static void vmx_restore_world_ctx(struct guest_info * info, struct vmx_assist_context * ctx) { struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data); - PrintDebug("ctx rip: %p\n", (void *)(addr_t)ctx->eip); + PrintDebug(info->vm_info, info, "ctx rip: %p\n", (void *)(addr_t)ctx->eip); info->rip = ctx->eip; info->vm_regs.rsp = ctx->esp; @@ -248,13 +248,14 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { core->vm_regs.rsp = 0x80000; ((struct rflags *)&(core->ctrl_regs.rflags))->rsvd1 = 1; -#define GUEST_CR0 0x80010031 -#define GUEST_CR4 0x00002010 - core->ctrl_regs.cr0 = GUEST_CR0; - core->ctrl_regs.cr4 = GUEST_CR4; +#define GUEST_CR0_MASK 0x80010031 +#define GUEST_CR4_MASK 0x00002010 + core->ctrl_regs.cr0 |= GUEST_CR0_MASK; + core->ctrl_regs.cr4 |= GUEST_CR4_MASK; ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->pe = 1; ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->wp = 1; + ((struct cr0_32 *)&(core->shdw_pg_state.guest_cr0))->ne = 1; // Setup segment registers @@ -306,7 +307,7 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { addr_t vmxassist_gdt = 0; if (v3_gpa_to_hva(core, VMXASSIST_GDT, &vmxassist_gdt) == -1) { - PrintError("Could not find VMXASSIST GDT destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST GDT destination\n"); return -1; } @@ -337,10 +338,10 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { int i = 0; pde32_4MB_t * pde = NULL; - PrintError("Setting up internal VMXASSIST page tables\n"); + V3_Print(core->vm_info, core, "Setting up internal VMXASSIST page tables\n"); if (v3_gpa_to_hva(core, VMXASSIST_1to1_PT, (addr_t *)(&pde)) == -1) { - PrintError("Could not find VMXASSIST 1to1 PT destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST 1to1 PT destination\n"); return -1; } @@ -353,7 +354,7 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { pde[i].large_page = 1; pde[i].page_base_addr = PAGE_BASE_ADDR_4MB(i * PAGE_SIZE_4MB); - // PrintError("PDE %d: %x\n", i, *(uint32_t *)&(pde[i])); + // PrintError(core->vm_info, core, "PDE %d: %x\n", i, *(uint32_t *)&(pde[i])); } core->ctrl_regs.cr3 = VMXASSIST_1to1_PT; @@ -368,14 +369,14 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { addr_t vmxassist_dst = 0; if (v3_gpa_to_hva(core, VMXASSIST_START, &vmxassist_dst) == -1) { - PrintError("Could not find VMXASSIST destination\n"); + PrintError(core->vm_info, core, "Could not find VMXASSIST destination\n"); return -1; } memcpy((void *)vmxassist_dst, v3_vmxassist_start, v3_vmxassist_end - v3_vmxassist_start); - vmx_state->assist_state = VMXASSIST_DISABLED; + vmx_state->assist_state = VMXASSIST_OFF; }