X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=8a2e4d486f028a4075756c41c094642bb54b1eed;hb=61597ea2c5ccace036d8a65e429e32b8f8a7ed4a;hp=d5faa6cef948f111594d62c3842f725ec42d4ddb;hpb=e31890ea7a0f024ab8d0e8bf1f8446d4c714ef61;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index d5faa6c..8a2e4d4 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -23,10 +23,11 @@ #include #include #include +#include #include -v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info) { +v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { struct cr0_32 * cr0; struct efer_64 * efer; struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); @@ -35,7 +36,7 @@ v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info) { if (info->shdw_pg_mode == SHADOW_PAGING) { cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); - efer = (struct efer_64 *)&(info->guest_efer); + efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer); } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); efer = (struct efer_64 *)&(guest_state->efer); @@ -63,13 +64,16 @@ v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info) { uint_t v3_get_addr_width(struct guest_info * info) { struct cr0_32 * cr0; struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); - struct efer_64 * efer = (struct efer_64 *)&(info->guest_efer); + struct efer_64 * efer; struct v3_segment * cs = &(info->segments.cs); + vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); if (info->shdw_pg_mode == SHADOW_PAGING) { cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); + efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer); } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); + efer = (struct efer_64 *)&(guest_state->efer); } else { PrintError("Invalid Paging Mode...\n"); V3_ASSERT(0); @@ -98,7 +102,7 @@ static const uchar_t LONG_STR[] = "Long"; static const uchar_t LONG_32_COMPAT_STR[] = "32bit Compat"; static const uchar_t LONG_16_COMPAT_STR[] = "16bit Compat"; -const uchar_t * v3_cpu_mode_to_str(v3_vm_cpu_mode_t mode) { +const uchar_t * v3_cpu_mode_to_str(v3_cpu_mode_t mode) { switch (mode) { case REAL: return REAL_STR; @@ -117,7 +121,7 @@ const uchar_t * v3_cpu_mode_to_str(v3_vm_cpu_mode_t mode) { } } -v3_vm_mem_mode_t v3_get_mem_mode(struct guest_info * info) { +v3_mem_mode_t v3_get_vm_mem_mode(struct guest_info * info) { struct cr0_32 * cr0; if (info->shdw_pg_mode == SHADOW_PAGING) { @@ -140,7 +144,7 @@ v3_vm_mem_mode_t v3_get_mem_mode(struct guest_info * info) { static const uchar_t PHYS_MEM_STR[] = "Physical Memory"; static const uchar_t VIRT_MEM_STR[] = "Virtual Memory"; -const uchar_t * v3_mem_mode_to_str(v3_vm_mem_mode_t mode) { +const uchar_t * v3_mem_mode_to_str(v3_mem_mode_t mode) { switch (mode) { case PHYSICAL_MEM: return PHYS_MEM_STR; @@ -180,7 +184,7 @@ void v3_print_ctrl_regs(struct guest_info * info) { char * reg_names[] = {"CR0", "CR2", "CR3", "CR4", "CR8", "FLAGS", NULL}; vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(info->vmm_data); - reg_ptr= (v3_reg_t *)regs; + reg_ptr = (v3_reg_t *)regs; PrintDebug("32 bit Ctrl Regs:\n"); @@ -193,7 +197,29 @@ void v3_print_ctrl_regs(struct guest_info * info) { } +void v3_print_guest_state(struct guest_info * info) { + addr_t linear_addr = 0; + + PrintDebug("RIP: %p\n", (void *)(addr_t)(info->rip)); + linear_addr = get_addr_linear(info, info->rip, &(info->segments.cs)); + PrintDebug("RIP Linear: %p\n", (void *)linear_addr); + + v3_print_segments(info); + v3_print_ctrl_regs(info); + + if (info->shdw_pg_mode == SHADOW_PAGING) { + PrintDebug("Shadow Paging Guest Registers:\n"); + PrintDebug("\tGuest CR0=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_cr0)); + PrintDebug("\tGuest CR3=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_cr3)); + PrintDebug("\tGuest EFER=%p\n", (void *)(addr_t)(info->shdw_pg_state.guest_efer.value)); + // CR4 + } + v3_print_GPRs(info); +} + + #ifdef __V3_32BIT__ + void v3_print_GPRs(struct guest_info * info) { struct v3_gprs * regs = &(info->vm_regs); int i = 0; @@ -208,7 +234,9 @@ void v3_print_GPRs(struct guest_info * info) { PrintDebug("\t%s=0x%p\n", reg_names[i], (void *)(addr_t)reg_ptr[i]); } } + #elif __V3_64BIT__ + void v3_print_GPRs(struct guest_info * info) { struct v3_gprs * regs = &(info->vm_regs); int i = 0; @@ -225,6 +253,4 @@ void v3_print_GPRs(struct guest_info * info) { } } - - #endif