X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=8a2e4d486f028a4075756c41c094642bb54b1eed;hb=be2e1236b710115eb59f166a950f45710a15d2ef;hp=c981a3c5e41c9b59edaa8237294295427d2f8301;hpb=d3c1f093de953d47c55c11692f27aa2220c840b4;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index c981a3c..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); @@ -69,7 +70,7 @@ uint_t v3_get_addr_width(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); @@ -101,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; @@ -120,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) { @@ -143,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; @@ -183,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"); @@ -196,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; @@ -211,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; @@ -228,6 +253,4 @@ void v3_print_GPRs(struct guest_info * info) { } } - - #endif