X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx_assist.c;h=5766b15c4f06b3d805e45cd285bcaa935f6f065e;hp=01a2f6f317a2c449d3b6be63233efd1b476a26de;hb=a34275476494aeabed460b284a70cfc9b66a9896;hpb=a686a57429dcd9fa2f701228227dadcd096df8ed diff --git a/palacios/src/palacios/vmx_assist.c b/palacios/src/palacios/vmx_assist.c index 01a2f6f..5766b15 100644 --- a/palacios/src/palacios/vmx_assist.c +++ b/palacios/src/palacios/vmx_assist.c @@ -111,23 +111,23 @@ 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; } @@ -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,10 +248,10 @@ 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; @@ -304,14 +304,10 @@ 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"); + if (v3_write_gpa_memory(core, VMXASSIST_GDT, sizeof(uint64_t)*5, (void*)gdt)!=sizeof(uint64_t)*5) { + PrintError(core->vm_info, core, "Could not write VMXASSIST GDT\n"); return -1; } - - memcpy((void *)vmxassist_gdt, gdt, sizeof(uint64_t) * 5); core->segments.gdtr.base = VMXASSIST_GDT; @@ -338,10 +334,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; } @@ -354,7 +350,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; @@ -366,15 +362,12 @@ int v3_vmxassist_init(struct guest_info * core, struct vmx_data * vmx_state) { extern uint8_t v3_vmxassist_start[]; extern uint8_t v3_vmxassist_end[]; - addr_t vmxassist_dst = 0; - if (v3_gpa_to_hva(core, VMXASSIST_START, &vmxassist_dst) == -1) { - PrintError("Could not find VMXASSIST destination\n"); + if (v3_write_gpa_memory(core, VMXASSIST_START, v3_vmxassist_end-v3_vmxassist_start,v3_vmxassist_start)!=v3_vmxassist_end-v3_vmxassist_start) { + PrintError(core->vm_info, core, "Could not write VMXASSIST\n"); return -1; } - memcpy((void *)vmxassist_dst, v3_vmxassist_start, v3_vmxassist_end - v3_vmxassist_start); - vmx_state->assist_state = VMXASSIST_OFF; }