X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=614c6a548138537814186890f42cbef762f76393;hb=f4ba2c6bbcd720a0cd5f9ca9ca0b691656011fa7;hp=ef025faa838467c9a2f6628959bd77df06924422;hpb=0c51b09942d51a3b355728526333ad3f3895131d;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index ef025fa..614c6a5 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -44,17 +44,45 @@ v3_vm_cpu_mode_t v3_get_cpu_mode(struct guest_info * info) { if (cr0->pe == 0) { return REAL; - } else if ((cr4->pae == 0) && (efer->lma == 0)) { + } else if ((cr4->pae == 0) && (efer->lme == 0)) { return PROTECTED; - } else if (efer->lma == 0) { + } else if (efer->lme == 0) { return PROTECTED_PAE; - } else if ((efer->lma == 1) && (cs->long_mode == 1)) { + } else if ((efer->lme == 1) && (cs->long_mode == 1)) { return LONG; } else { + // What about LONG_16_COMPAT??? return LONG_32_COMPAT; } } + +static const uchar_t REAL_STR[] = "Real"; +static const uchar_t PROTECTED_STR[] = "Protected"; +static const uchar_t PROTECTED_PAE_STR[] = "Protected+PAE"; +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) { + switch (mode) { + case REAL: + return REAL_STR; + case PROTECTED: + return PROTECTED_STR; + case PROTECTED_PAE: + return PROTECTED_PAE_STR; + case LONG: + return LONG_STR; + case LONG_32_COMPAT: + return LONG_32_COMPAT_STR; + case LONG_16_COMPAT: + return LONG_16_COMPAT_STR; + default: + return NULL; + } +} + v3_vm_mem_mode_t v3_get_mem_mode(struct guest_info * info) { struct cr0_32 * cr0; @@ -68,8 +96,6 @@ v3_vm_mem_mode_t v3_get_mem_mode(struct guest_info * info) { return -1; } - - if (cr0->pg == 0) { return PHYSICAL_MEM; } else { @@ -77,6 +103,20 @@ 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) { + switch (mode) { + case PHYSICAL_MEM: + return PHYS_MEM_STR; + case VIRTUAL_MEM: + return VIRT_MEM_STR; + default: + return NULL; + } +} + void v3_print_segments(struct guest_info * info) { struct v3_segments * segs = &(info->segments); @@ -91,7 +131,7 @@ void v3_print_segments(struct guest_info * info) { for (i = 0; seg_names[i] != NULL; i++) { PrintDebug("\t%s: Sel=%x, base=%p, limit=%x\n", seg_names[i], seg_ptr[i].selector, - (void *)seg_ptr[i].base, seg_ptr[i].limit); + (void *)(addr_t)seg_ptr[i].base, seg_ptr[i].limit); } @@ -110,10 +150,10 @@ void v3_print_ctrl_regs(struct guest_info * info) { PrintDebug("32 bit Ctrl Regs:\n"); for (i = 0; reg_names[i] != NULL; i++) { - PrintDebug("\t%s=0x%p\n", reg_names[i], (void *)reg_ptr[i]); + PrintDebug("\t%s=0x%p\n", reg_names[i], (void *)(addr_t)reg_ptr[i]); } - PrintDebug("\tEFER=0x%p\n", (void*)(guest_state->efer)); + PrintDebug("\tEFER=0x%p\n", (void*)(addr_t)(guest_state->efer)); } @@ -129,6 +169,6 @@ void v3_print_GPRs(struct guest_info * info) { PrintDebug("32 bit GPRs:\n"); for (i = 0; reg_names[i] != NULL; i++) { - PrintDebug("\t%s=0x%p\n", reg_names[i], (void *)reg_ptr[i]); + PrintDebug("\t%s=0x%p\n", reg_names[i], (void *)(addr_t)reg_ptr[i]); } }