ia64/xen-unstable

changeset 15935:4bc37263e69f

vmx: Print VMCS state in a more helpful format.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Sep 19 15:18:23 2007 +0100 (2007-09-19)
parents ec3b23d8d544
children b21ba95c686b
files xen/arch/x86/hvm/vmx/vmcs.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Wed Sep 19 14:25:44 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Wed Sep 19 15:18:23 2007 +0100
     1.3 @@ -648,56 +648,132 @@ void vmx_do_resume(struct vcpu *v)
     1.4      reset_stack_and_jump(vmx_asm_do_vmentry);
     1.5  }
     1.6  
     1.7 -/* Dump a section of VMCS */
     1.8 -static void print_section(char *header, uint32_t start, 
     1.9 -                          uint32_t end, int incr)
    1.10 +static void vmx_dump_sel(char *name, enum x86_segment seg)
    1.11  {
    1.12 -    uint32_t addr, j;
    1.13 -    unsigned long val;
    1.14 -    int code, rc;
    1.15 -    char *fmt[4] = {"0x%04lx ", "0x%016lx ", "0x%08lx ", "0x%016lx "};
    1.16 -    char *err[4] = {"------ ", "------------------ ", 
    1.17 -                    "---------- ", "------------------ "};
    1.18 -
    1.19 -    /* Find width of the field (encoded in bits 14:13 of address) */
    1.20 -    code = (start>>13)&3;
    1.21 +    struct segment_register sreg;
    1.22 +    hvm_get_segment_register(current, seg, &sreg);
    1.23 +    printk("%s: sel=0x%04x, attr=0x%04x, limit=0x%08x, base=0x%016llx\n", 
    1.24 +           name, sreg.sel, sreg.attr.bytes, sreg.limit,
    1.25 +           (unsigned long long)sreg.base);
    1.26 +}
    1.27  
    1.28 -    if (header)
    1.29 -        printk("\t %s", header);
    1.30 -
    1.31 -    for (addr=start, j=0; addr<=end; addr+=incr, j++) {
    1.32 -
    1.33 -        if (!(j&3))
    1.34 -            printk("\n\t\t0x%08x: ", addr);
    1.35 -
    1.36 -        val = __vmread_safe(addr, &rc);
    1.37 -        if (rc == 0)
    1.38 -            printk(fmt[code], val);
    1.39 -        else
    1.40 -            printk("%s", err[code]);
    1.41 -    }
    1.42 -
    1.43 -    printk("\n");
    1.44 +static unsigned long vmr(unsigned long field)
    1.45 +{
    1.46 +    int rc;
    1.47 +    unsigned long val;
    1.48 +    val = __vmread_safe(field, &rc);
    1.49 +    return rc ? 0 : val;
    1.50  }
    1.51  
    1.52 -/* Dump current VMCS */
    1.53  void vmcs_dump_vcpu(void)
    1.54  {
    1.55 -    print_section("16-bit Guest-State Fields", 0x800, 0x80e, 2);
    1.56 -    print_section("16-bit Host-State Fields", 0xc00, 0xc0c, 2);
    1.57 -    print_section("64-bit Control Fields", 0x2000, 0x2013, 1);
    1.58 -    print_section("64-bit Guest-State Fields", 0x2800, 0x2803, 1);
    1.59 -    print_section("32-bit Control Fields", 0x4000, 0x401c, 2);
    1.60 -    print_section("32-bit RO Data Fields", 0x4400, 0x440e, 2);
    1.61 -    print_section("32-bit Guest-State Fields", 0x4800, 0x482a, 2);
    1.62 -    print_section("32-bit Host-State Fields", 0x4c00, 0x4c00, 2);
    1.63 -    print_section("Natural 64-bit Control Fields", 0x6000, 0x600e, 2);
    1.64 -    print_section("64-bit RO Data Fields", 0x6400, 0x640A, 2);
    1.65 -    print_section("Natural 64-bit Guest-State Fields", 0x6800, 0x6826, 2);
    1.66 -    print_section("Natural 64-bit Host-State Fields", 0x6c00, 0x6c16, 2);
    1.67 +    unsigned long long x;
    1.68 +
    1.69 +    printk("*** Guest State ***\n");
    1.70 +    printk("CR0: actual=0x%016llx, shadow=0x%016llx, gh_mask=%016llx\n",
    1.71 +           (unsigned long long)vmr(GUEST_CR0),
    1.72 +           (unsigned long long)vmr(CR0_READ_SHADOW), 
    1.73 +           (unsigned long long)vmr(CR0_GUEST_HOST_MASK));
    1.74 +    printk("CR4: actual=0x%016llx, shadow=0x%016llx, gh_mask=%016llx\n",
    1.75 +           (unsigned long long)vmr(GUEST_CR4),
    1.76 +           (unsigned long long)vmr(CR4_READ_SHADOW), 
    1.77 +           (unsigned long long)vmr(CR4_GUEST_HOST_MASK));
    1.78 +    printk("CR3: actual=0x%016llx, target_count=%d\n",
    1.79 +           (unsigned long long)vmr(GUEST_CR3),
    1.80 +           (int)vmr(CR3_TARGET_COUNT));
    1.81 +    printk("     target0=%016llx, target1=%016llx\n",
    1.82 +           (unsigned long long)vmr(CR3_TARGET_VALUE0),
    1.83 +           (unsigned long long)vmr(CR3_TARGET_VALUE1));
    1.84 +    printk("     target2=%016llx, target3=%016llx\n",
    1.85 +           (unsigned long long)vmr(CR3_TARGET_VALUE2),
    1.86 +           (unsigned long long)vmr(CR3_TARGET_VALUE3));
    1.87 +    printk("RSP = 0x%016llx  RIP = 0x%016llx\n", 
    1.88 +           (unsigned long long)vmr(GUEST_RSP),
    1.89 +           (unsigned long long)vmr(GUEST_RIP));
    1.90 +    printk("RFLAGS=0x%016llx  DR7 = 0x%016llx\n", 
    1.91 +           (unsigned long long)vmr(GUEST_DR7),
    1.92 +           (unsigned long long)vmr(GUEST_RFLAGS));
    1.93 +    printk("Sysenter RSP=%016llx CS:RIP=%04x:%016llx\n",
    1.94 +           (unsigned long long)vmr(GUEST_SYSENTER_ESP),
    1.95 +           (int)vmr(GUEST_SYSENTER_CS),
    1.96 +           (unsigned long long)vmr(GUEST_SYSENTER_EIP));
    1.97 +    vmx_dump_sel("CS", x86_seg_cs);
    1.98 +    vmx_dump_sel("DS", x86_seg_ds);
    1.99 +    vmx_dump_sel("SS", x86_seg_ss);
   1.100 +    vmx_dump_sel("ES", x86_seg_es);
   1.101 +    vmx_dump_sel("FS", x86_seg_fs);
   1.102 +    vmx_dump_sel("GS", x86_seg_gs);
   1.103 +    vmx_dump_sel("GDTR", x86_seg_gdtr);
   1.104 +    vmx_dump_sel("LDTR", x86_seg_ldtr);
   1.105 +    vmx_dump_sel("IDTR", x86_seg_idtr);
   1.106 +    vmx_dump_sel("TR", x86_seg_tr);
   1.107 +    x  = (unsigned long long)vmr(TSC_OFFSET_HIGH) << 32;
   1.108 +    x |= (uint32_t)vmr(TSC_OFFSET);
   1.109 +    printk("TSC Offset = %016llx\n", x);
   1.110 +    x  = (unsigned long long)vmr(GUEST_IA32_DEBUGCTL) << 32;
   1.111 +    x |= (uint32_t)vmr(GUEST_IA32_DEBUGCTL);
   1.112 +    printk("DebugCtl=%016llx DebugExceptions=%016llx\n", x,
   1.113 +           (unsigned long long)vmr(GUEST_PENDING_DBG_EXCEPTIONS));
   1.114 +    printk("Interruptibility=%04x ActivityState=%04x\n",
   1.115 +           (int)vmr(GUEST_INTERRUPTIBILITY_INFO),
   1.116 +           (int)vmr(GUEST_ACTIVITY_STATE));
   1.117 +
   1.118 +    printk("*** Host State ***\n");
   1.119 +    printk("RSP = 0x%016llx  RIP = 0x%016llx\n", 
   1.120 +           (unsigned long long)vmr(HOST_RSP),
   1.121 +           (unsigned long long)vmr(HOST_RIP));
   1.122 +    printk("CS=%04x DS=%04x ES=%04x FS=%04x GS=%04x SS=%04x TR=%04x\n",
   1.123 +           (uint16_t)vmr(HOST_CS_SELECTOR),
   1.124 +           (uint16_t)vmr(HOST_DS_SELECTOR),
   1.125 +           (uint16_t)vmr(HOST_ES_SELECTOR),
   1.126 +           (uint16_t)vmr(HOST_FS_SELECTOR),
   1.127 +           (uint16_t)vmr(HOST_GS_SELECTOR),
   1.128 +           (uint16_t)vmr(HOST_SS_SELECTOR),
   1.129 +           (uint16_t)vmr(HOST_TR_SELECTOR));
   1.130 +    printk("FSBase=%016llx GSBase=%016llx TRBase=%016llx\n",
   1.131 +           (unsigned long long)vmr(HOST_FS_BASE),
   1.132 +           (unsigned long long)vmr(HOST_GS_BASE),
   1.133 +           (unsigned long long)vmr(HOST_TR_BASE));
   1.134 +    printk("GDTBase=%016llx IDTBase=%016llx\n",
   1.135 +           (unsigned long long)vmr(HOST_GDTR_BASE),
   1.136 +           (unsigned long long)vmr(HOST_IDTR_BASE));
   1.137 +    printk("CR0=%016llx CR3=%016llx CR4=%016llx\n",
   1.138 +           (unsigned long long)vmr(HOST_CR0),
   1.139 +           (unsigned long long)vmr(HOST_CR3),
   1.140 +           (unsigned long long)vmr(HOST_CR4));
   1.141 +    printk("Sysenter RSP=%016llx CS:RIP=%04x:%016llx\n",
   1.142 +           (unsigned long long)vmr(HOST_IA32_SYSENTER_ESP),
   1.143 +           (int)vmr(HOST_IA32_SYSENTER_CS),
   1.144 +           (unsigned long long)vmr(HOST_IA32_SYSENTER_EIP));
   1.145 +
   1.146 +    printk("*** Control State ***\n");
   1.147 +    printk("PinBased=%08x CPUBased=%08x SecondaryExec=%08x\n",
   1.148 +           (uint32_t)vmr(PIN_BASED_VM_EXEC_CONTROL),
   1.149 +           (uint32_t)vmr(CPU_BASED_VM_EXEC_CONTROL),
   1.150 +           (uint32_t)vmr(SECONDARY_VM_EXEC_CONTROL));
   1.151 +    printk("EntryControls=%08x ExitControls=%08x\n",
   1.152 +           (uint32_t)vmr(VM_ENTRY_CONTROLS),
   1.153 +           (uint32_t)vmr(VM_EXIT_CONTROLS));
   1.154 +    printk("ExceptionBitmap=%08x\n",
   1.155 +           (uint32_t)vmr(EXCEPTION_BITMAP));
   1.156 +    printk("VMEntry: intr_info=%08x errcode=%08x ilen=%08x\n",
   1.157 +           (uint32_t)vmr(VM_ENTRY_INTR_INFO),
   1.158 +           (uint32_t)vmr(VM_ENTRY_EXCEPTION_ERROR_CODE),
   1.159 +           (uint32_t)vmr(VM_ENTRY_INSTRUCTION_LEN));
   1.160 +    printk("VMExit: intr_info=%08x errcode=%08x ilen=%08x\n",
   1.161 +           (uint32_t)vmr(VM_EXIT_INTR_INFO),
   1.162 +           (uint32_t)vmr(VM_EXIT_INTR_ERROR_CODE),
   1.163 +           (uint32_t)vmr(VM_ENTRY_INSTRUCTION_LEN));
   1.164 +    printk("        reason=%08x qualification=%08x\n",
   1.165 +           (uint32_t)vmr(VM_EXIT_REASON),
   1.166 +           (uint32_t)vmr(EXIT_QUALIFICATION));
   1.167 +    printk("IDTVectoring: info=%08x errcode=%08x\n",
   1.168 +           (uint32_t)vmr(IDT_VECTORING_INFO),
   1.169 +           (uint32_t)vmr(IDT_VECTORING_ERROR_CODE));
   1.170 +    printk("TPR Threshold = 0x%02x\n",
   1.171 +           (uint32_t)vmr(TPR_THRESHOLD));
   1.172  }
   1.173  
   1.174 -
   1.175  static void vmcs_dump(unsigned char ch)
   1.176  {
   1.177      struct domain *d;