From: Trammell Hudson Date: Wed, 22 Oct 2008 18:50:26 +0000 (-0500) Subject: Merge branch 'kitten' of ssh://sharedev@localhost/home/sharedev/palacios into kitten X-Git-Tag: 1.0^2~4^2~2 X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=c0c9f2110ba4830893373b9471a4ff4242489f72;hp=c7a9fea1093d8000b547a394a90abe7dffc518da Merge branch 'kitten' of ssh://sharedev@localhost/home/sharedev/palacios into kitten --- diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index 82a8fc2..f7a612d 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -211,12 +211,12 @@ struct guest_info; /* This will contain function pointers that provide OS services */ struct v3_os_hooks { - void (*print_info)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); - void (*print_debug)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); - void (*print_trace)(const char * format, ...) - __attribute__ ((format (printf, 1, 2))); + void (*print_info)(const char * format, ...); + // __attribute__ ((format (printf, 1, 2))); + void (*print_debug)(const char * format, ...); + // __attribute__ ((format (printf, 1, 2))); + void (*print_trace)(const char * format, ...); + // __attribute__ ((format (printf, 1, 2))); void *(*allocate_pages)(int numPages); void (*free_page)(void * page); diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 33d878f..95bb586 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -201,11 +201,15 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info *vm_info) { PrintDebug("Creating initial shadow page table\n"); vm_info->direct_map_pt = (addr_t)V3_PAddr(create_passthrough_pde32_pts(vm_info)); - vm_info->shdw_pg_state.shadow_cr3 |= (vm_info->direct_map_pt & ~0xfff); + //vm_info->shdw_pg_state.shadow_cr3 |= (vm_info->direct_map_pt & ~0xfff); + vm_info->shdw_pg_state.shadow_cr3 = 0; vm_info->shdw_pg_state.guest_cr0 = 0x0000000000000010LL; PrintDebug("Created\n"); - guest_state->cr3 = vm_info->shdw_pg_state.shadow_cr3; + //guest_state->cr3 = vm_info->shdw_pg_state.shadow_cr3; + + guest_state->cr3 = vm_info->direct_map_pt; + //PrintDebugPageTables((pde32_t*)(vm_info->shdw_pg_state.shadow_cr3.e_reg.low)); diff --git a/palacios/src/palacios/svm_handler.c b/palacios/src/palacios/svm_handler.c index a2b942f..4c76f8a 100644 --- a/palacios/src/palacios/svm_handler.c +++ b/palacios/src/palacios/svm_handler.c @@ -190,7 +190,8 @@ int v3_handle_svm_exit(struct guest_info * info) { addr_t fault_addr = guest_ctrl->exit_info2; pf_error_t * error_code = (pf_error_t *)&(guest_ctrl->exit_info1); #ifdef DEBUG_SHADOW_PAGING - PrintDebug("PageFault at %x (error=%d)\n", fault_addr, *error_code); + PrintDebug("PageFault at %p (error=%d)\n", + (void *)fault_addr, *(uint_t *)error_code); #endif if (info->shdw_pg_mode == SHADOW_PAGING) { if (v3_handle_shadow_pagefault(info, fault_addr, *error_code) == -1) { @@ -352,12 +353,12 @@ int v3_handle_svm_exit(struct guest_info * info) { if (info->mem_mode == PHYSICAL_MEM) { - if (guest_pa_to_host_pa(info, guest_state->rip, &host_addr) == -1) { + if (guest_pa_to_host_va(info, guest_state->rip, &host_addr) == -1) { PrintError("Could not translate guest_state->rip to host address\n"); return -1; } } else if (info->mem_mode == VIRTUAL_MEM) { - if (guest_va_to_host_pa(info, guest_state->rip, &host_addr) == -1) { + if (guest_va_to_host_va(info, guest_state->rip, &host_addr) == -1) { PrintError("Could not translate guest_state->rip to host address\n"); return -1; } @@ -414,7 +415,9 @@ int v3_handle_svm_exit(struct guest_info * info) { guest_ctrl->guest_ctrl.V_IGN_TPR = 1; guest_ctrl->guest_ctrl.V_INTR_PRIO = 0xf; #ifdef DEBUG_INTERRUPTS - PrintDebug("Injecting Interrupt %d (EIP=%x)\n", guest_ctrl->guest_ctrl.V_INTR_VECTOR, info->rip); + PrintDebug("Injecting Interrupt %d (EIP=%p)\n", + guest_ctrl->guest_ctrl.V_INTR_VECTOR, + (void *)info->rip); #endif v3_injecting_intr(info, irq, EXTERNAL_IRQ); @@ -441,7 +444,9 @@ int v3_handle_svm_exit(struct guest_info * info) { guest_ctrl->EVENTINJ.valid = 1; #ifdef DEBUG_INTERRUPTS - PrintDebug("Injecting Interrupt %d (EIP=%x)\n", guest_ctrl->EVENTINJ.vector, info->rip); + PrintDebug("Injecting Interrupt %d (EIP=%p)\n", + guest_ctrl->EVENTINJ.vector, + (void *)info->rip); #endif v3_injecting_intr(info, excp, EXCEPTION); break; diff --git a/palacios/src/palacios/svm_io.c b/palacios/src/palacios/svm_io.c index c46d45a..d4af89f 100644 --- a/palacios/src/palacios/svm_io.c +++ b/palacios/src/palacios/svm_io.c @@ -170,7 +170,8 @@ int v3_handle_svm_io_ins(struct guest_info * info) { // This value should be set depending on the host register size... mask = get_gpr_mask(info); - PrintDebug("INS io_info invalid address size, mask=0x%x, io_info=0x%x\n",mask,*((uint_t*)(io_info))); + PrintDebug("INS io_info invalid address size, mask=0x%p, io_info=0x%p\n", + (void *)mask, (void *)(io_info)); // PrintDebug("INS Aborted... Check implementation\n"); //return -1; } @@ -187,7 +188,7 @@ int v3_handle_svm_io_ins(struct guest_info * info) { addr_t host_addr; dst_addr = get_addr_linear(info, info->vm_regs.rdi & mask, theseg); - PrintDebug("Writing 0x%x\n", dst_addr); + PrintDebug("Writing 0x%p\n", (void *)dst_addr); if (guest_va_to_host_va(info, dst_addr, &host_addr) == -1) { // either page fault or gpf... @@ -309,7 +310,8 @@ int v3_handle_svm_io_outs(struct guest_info * info) { // This value should be set depending on the host register size... mask = get_gpr_mask(info); - PrintDebug("OUTS io_info invalid address size, mask=0x%, io_info=0x%x\n",mask,*((uint_t*)(io_info))); + PrintDebug("OUTS io_info invalid address size, mask=0%p, io_info=0x%p\n", + (void *)mask, (void *)io_info); // PrintDebug("INS Aborted... Check implementation\n"); //return -1; // should never happen diff --git a/palacios/src/palacios/vm_guest_mem.c b/palacios/src/palacios/vm_guest_mem.c index 32d4ab6..3400b97 100644 --- a/palacios/src/palacios/vm_guest_mem.c +++ b/palacios/src/palacios/vm_guest_mem.c @@ -160,9 +160,9 @@ int guest_va_to_guest_pa(struct guest_info * guest_info, addr_t guest_va, addr_t addr_t guest_pde = 0; if (guest_info->shdw_pg_mode == SHADOW_PAGING) { - guest_pde = (addr_t)CR3_TO_PDE32((void *)(guest_info->shdw_pg_state.guest_cr3)); + guest_pde = (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)(guest_info->shdw_pg_state.guest_cr3))); } else if (guest_info->shdw_pg_mode == NESTED_PAGING) { - guest_pde = (addr_t)CR3_TO_PDE32((void *)(guest_info->ctrl_regs.cr3)); + guest_pde = (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)(guest_info->ctrl_regs.cr3))); } if (guest_pa_to_host_va(guest_info, guest_pde, (addr_t *)&pde) == -1) { diff --git a/palacios/src/palacios/vmm_ctrl_regs.c b/palacios/src/palacios/vmm_ctrl_regs.c index a6301db..1a287cd 100644 --- a/palacios/src/palacios/vmm_ctrl_regs.c +++ b/palacios/src/palacios/vmm_ctrl_regs.c @@ -120,7 +120,7 @@ int v3_handle_cr0_write(struct guest_info * info) { if (v3_get_mem_mode(info) == VIRTUAL_MEM) { struct cr3_32 * shadow_cr3 = (struct cr3_32 *)&(info->shdw_pg_state.shadow_cr3); - + PrintDebug("Setting up Shadow Page Table\n"); info->ctrl_regs.cr3 = *(addr_t*)shadow_cr3; } else { info->ctrl_regs.cr3 = *(addr_t*)&(info->direct_map_pt); @@ -261,8 +261,9 @@ int v3_handle_cr3_write(struct guest_info * info) { *(uint_t*)shadow_cr3, *(uint_t*)guest_cr3); - cached = v3_cache_page_tables32(info, (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)*(addr_t *)new_cr3))); + cached = v3_cache_page_tables32(info, (addr_t)V3_PAddr((void *)(addr_t)CR3_TO_PDE32((void *)*(addr_t *)new_cr3))); + if (cached == -1) { PrintError("CR3 Cache failed\n"); return -1; @@ -280,6 +281,7 @@ int v3_handle_cr3_write(struct guest_info * info) { PrintDebug("Reusing cached shadow Page table\n"); } + shadow_cr3->pwt = new_cr3->pwt; shadow_cr3->pcd = new_cr3->pcd; diff --git a/palacios/src/palacios/vmm_intr.c b/palacios/src/palacios/vmm_intr.c index 87fbcdb..46e1e42 100644 --- a/palacios/src/palacios/vmm_intr.c +++ b/palacios/src/palacios/vmm_intr.c @@ -88,7 +88,8 @@ int v3_hook_irq(struct guest_info * info, static int passthrough_irq_handler(struct guest_info * info, struct v3_interrupt * intr, void * priv_data) { - PrintDebug("[passthrough_irq_handler] raise_irq=%d (guest=0x%x)\n", intr->irq, info); + PrintDebug("[passthrough_irq_handler] raise_irq=%d (guest=0x%p)\n", + intr->irq, (void *)info); return v3_raise_irq(info, intr->irq); } @@ -115,7 +116,7 @@ int v3_hook_passthrough_irq(struct guest_info * info, uint_t irq) int v3_deliver_irq(struct guest_info * info, struct v3_interrupt * intr) { - PrintDebug("v3_deliver_irq: irq=%d state=0x%x, \n", intr->irq, intr); + PrintDebug("v3_deliver_irq: irq=%d state=0x%p, \n", intr->irq, (void *)intr); struct v3_irq_hook * hook = get_irq_hook(info, intr->irq); diff --git a/palacios/src/palacios/vmm_io.c b/palacios/src/palacios/vmm_io.c index d334c73..514d8e1 100644 --- a/palacios/src/palacios/vmm_io.c +++ b/palacios/src/palacios/vmm_io.c @@ -176,7 +176,9 @@ void v3_print_io_map(struct vmm_io_map * io_map) { PrintDebug("VMM IO Map (Entries=%d)\n", io_map->num_ports); while (iter) { - PrintDebug("IO Port: %hu (Read=%x) (Write=%x)\n", iter->port, iter->read, iter->write); + PrintDebug("IO Port: %hu (Read=%p) (Write=%p)\n", + iter->port, + (void *)(iter->read), (void *)(iter->write)); } } diff --git a/palacios/src/palacios/vmm_mem.c b/palacios/src/palacios/vmm_mem.c index b4a181f..1b9f16d 100644 --- a/palacios/src/palacios/vmm_mem.c +++ b/palacios/src/palacios/vmm_mem.c @@ -122,6 +122,8 @@ int handle_special_page_fault(struct guest_info * info, { struct shadow_region * reg = get_shadow_region_by_addr(&(info->mem_map), fault_gpa); + PrintDebug("Handling Special Page Fault\n"); + switch (reg->host_type) { case HOST_REGION_HOOK: return mem_hook_dispatch(info, fault_gva, fault_gpa, access_info, (struct vmm_mem_hook *)(reg->host_addr)); diff --git a/palacios/src/palacios/vmm_shadow_paging.c b/palacios/src/palacios/vmm_shadow_paging.c index 06d79f5..83ffff2 100644 --- a/palacios/src/palacios/vmm_shadow_paging.c +++ b/palacios/src/palacios/vmm_shadow_paging.c @@ -320,7 +320,7 @@ static int handle_large_pagefault32(struct guest_info * info, if (host_page_type == HOST_REGION_INVALID) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%x)\n", guest_fault_pa); + PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_fault_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -410,7 +410,7 @@ static int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr /* Was the page fault caused by the Guest's page tables? */ if (is_guest_pf(guest_pde_access, shadow_pde_access) == 1) { PrintDebug("Injecting PDE pf to guest: (guest access error=%d) (pf error code=%d)\n", - guest_pde_access, error_code); + *(uint_t *)&guest_pde_access, *(uint_t *)&error_code); inject_guest_pf(info, fault_addr, error_code); return 0; } @@ -512,7 +512,7 @@ static int handle_shadow_pagefault32(struct guest_info * info, addr_t fault_addr return 0; } - PrintDebug("Returning end of PDE function (rip=%x)\n", info->rip); + PrintDebug("Returning end of PDE function (rip=%p)\n", (void *)(info->rip)); return 0; } @@ -573,7 +573,7 @@ static int handle_shadow_pte32_fault(struct guest_info * info, if (host_page_type == HOST_REGION_INVALID) { // Inject a machine check in the guest - PrintDebug("Invalid Guest Address in page table (0x%x)\n", guest_pa); + PrintDebug("Invalid Guest Address in page table (0x%p)\n", (void *)guest_pa); v3_raise_exception(info, MC_EXCEPTION); return 0; } @@ -599,7 +599,7 @@ static int handle_shadow_pte32_fault(struct guest_info * info, if (find_pte_map(state->cached_ptes, PT32_PAGE_ADDR(guest_pa)) != NULL) { // Check if the entry is a page table... - PrintDebug("Marking page as Guest Page Table\n", shadow_pte->writable); + PrintDebug("Marking page as Guest Page Table %d\n", shadow_pte->writable); shadow_pte->vmm_info = PT32_GUEST_PT; } @@ -720,7 +720,7 @@ int v3_handle_shadow_invlpg(struct guest_info * info) { //PrintDebug("PDE Index=%d\n", PDE32_INDEX(first_operand)); //PrintDebug("FirstOperand = %x\n", first_operand); - PrintDebug("Invalidating page for %x\n", first_operand); + PrintDebug("Invalidating page for %p\n", (void *)first_operand); guest_pde = (pde32_t *)&(guest_pd[PDE32_INDEX(first_operand)]);