2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <palacios/vmcs.h>
21 #include <palacios/vmx_lowlevel.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vmx.h>
24 #include <palacios/vm_guest_mem.h>
25 #include <palacios/vmm_ctrl_regs.h>
26 #include <palacios/vmm_lowlevel.h>
32 static int inline check_vmcs_write(vmcs_field_t field, addr_t val) {
34 ret = vmcs_write(field, val);
36 if (ret != VMX_SUCCESS) {
37 PrintError("VMWRITE error on %s!: %d\n", v3_vmcs_field_to_str(field), ret);
44 static int inline check_vmcs_read(vmcs_field_t field, void * val) {
46 ret = vmcs_read(field, val);
48 if (ret != VMX_SUCCESS) {
49 PrintError("VMREAD error on %s!: %d\n", v3_vmcs_field_to_str(field), ret);
61 typedef enum { ES = 0,
70 IDTR = 18} vmcs_seg_offsets_t;
72 typedef enum {BASE = VMCS_GUEST_ES_BASE,
73 LIMIT = VMCS_GUEST_ES_LIMIT,
74 ACCESS = VMCS_GUEST_ES_ACCESS,
75 SELECTOR = VMCS_GUEST_ES_SELECTOR } vmcs_seg_bases_t;
79 static int v3_read_vmcs_segment(struct v3_segment * seg, vmcs_seg_offsets_t seg_type) {
80 vmcs_field_t selector = VMCS_GUEST_ES_SELECTOR + seg_type;
81 vmcs_field_t base = VMCS_GUEST_ES_BASE + seg_type;
82 vmcs_field_t limit = VMCS_GUEST_ES_LIMIT + seg_type;
83 vmcs_field_t access = VMCS_GUEST_ES_ACCESS + seg_type;
84 struct vmcs_segment vmcs_seg;
86 memset(&vmcs_seg, 0, sizeof(struct vmcs_segment));
88 check_vmcs_read(limit, &(vmcs_seg.limit));
89 check_vmcs_read(base, &(vmcs_seg.base));
91 if ((seg_type != GDTR) && (seg_type != IDTR)) {
92 check_vmcs_read(selector, &(vmcs_seg.selector));
93 check_vmcs_read(access, &(vmcs_seg.access.val));
96 v3_vmxseg_to_seg(&vmcs_seg, seg);
101 static int v3_write_vmcs_segment(struct v3_segment * seg, vmcs_seg_offsets_t seg_type) {
102 vmcs_field_t selector = VMCS_GUEST_ES_SELECTOR + seg_type;
103 vmcs_field_t base = VMCS_GUEST_ES_BASE + seg_type;
104 vmcs_field_t limit = VMCS_GUEST_ES_LIMIT + seg_type;
105 vmcs_field_t access = VMCS_GUEST_ES_ACCESS + seg_type;
106 struct vmcs_segment vmcs_seg;
108 v3_seg_to_vmxseg(seg, &vmcs_seg);
110 check_vmcs_write(limit, vmcs_seg.limit);
111 check_vmcs_write(base, vmcs_seg.base);
113 if ((seg_type != GDTR) && (seg_type != IDTR)) {
114 check_vmcs_write(access, vmcs_seg.access.val);
115 check_vmcs_write(selector, vmcs_seg.selector);
121 int v3_read_vmcs_segments(struct v3_segments * segs) {
122 v3_read_vmcs_segment(&(segs->cs), CS);
123 v3_read_vmcs_segment(&(segs->ds), DS);
124 v3_read_vmcs_segment(&(segs->es), ES);
125 v3_read_vmcs_segment(&(segs->fs), FS);
126 v3_read_vmcs_segment(&(segs->gs), GS);
127 v3_read_vmcs_segment(&(segs->ss), SS);
128 v3_read_vmcs_segment(&(segs->ldtr), LDTR);
129 v3_read_vmcs_segment(&(segs->gdtr), GDTR);
130 v3_read_vmcs_segment(&(segs->idtr), IDTR);
131 v3_read_vmcs_segment(&(segs->tr), TR);
136 int v3_write_vmcs_segments(struct v3_segments * segs) {
137 v3_write_vmcs_segment(&(segs->cs), CS);
138 v3_write_vmcs_segment(&(segs->ds), DS);
139 v3_write_vmcs_segment(&(segs->es), ES);
140 v3_write_vmcs_segment(&(segs->fs), FS);
141 v3_write_vmcs_segment(&(segs->gs), GS);
142 v3_write_vmcs_segment(&(segs->ss), SS);
143 v3_write_vmcs_segment(&(segs->ldtr), LDTR);
144 v3_write_vmcs_segment(&(segs->gdtr), GDTR);
145 v3_write_vmcs_segment(&(segs->idtr), IDTR);
146 v3_write_vmcs_segment(&(segs->tr), TR);
152 void v3_vmxseg_to_seg(struct vmcs_segment * vmcs_seg, struct v3_segment * seg) {
153 memset(seg, 0, sizeof(struct v3_segment));
155 seg->selector = vmcs_seg->selector;
156 seg->limit = vmcs_seg->limit;
157 seg->base = vmcs_seg->base;
159 seg->type = vmcs_seg->access.type;
160 seg->system = vmcs_seg->access.desc_type;
161 seg->dpl = vmcs_seg->access.dpl;
162 seg->present = vmcs_seg->access.present;
163 seg->avail = vmcs_seg->access.avail;
164 seg->long_mode = vmcs_seg->access.long_mode;
165 seg->db = vmcs_seg->access.db;
166 seg->granularity = vmcs_seg->access.granularity;
167 seg->unusable = vmcs_seg->access.unusable;
171 void v3_seg_to_vmxseg(struct v3_segment * seg, struct vmcs_segment * vmcs_seg) {
172 memset(vmcs_seg, 0, sizeof(struct vmcs_segment));
174 vmcs_seg->selector = seg->selector;
175 vmcs_seg->limit = seg->limit;
176 vmcs_seg->base = seg->base;
178 vmcs_seg->access.type = seg->type;
179 vmcs_seg->access.desc_type = seg->system;
180 vmcs_seg->access.dpl = seg->dpl;
181 vmcs_seg->access.present = seg->present;
182 vmcs_seg->access.avail = seg->avail;
183 vmcs_seg->access.long_mode = seg->long_mode;
184 vmcs_seg->access.db = seg->db;
185 vmcs_seg->access.granularity = seg->granularity;
186 vmcs_seg->access.unusable = seg->unusable;
192 int v3_update_vmcs_ctrl_fields(struct guest_info * info) {
194 struct vmx_data * arch_data = (struct vmx_data *)(info->vmm_data);
196 vmx_ret |= check_vmcs_write(VMCS_PIN_CTRLS, arch_data->pin_ctrls.value);
197 vmx_ret |= check_vmcs_write(VMCS_PROC_CTRLS, arch_data->pri_proc_ctrls.value);
199 if (arch_data->pri_proc_ctrls.sec_ctrls) {
200 vmx_ret |= check_vmcs_write(VMCS_SEC_PROC_CTRLS, arch_data->sec_proc_ctrls.value);
203 vmx_ret |= check_vmcs_write(VMCS_EXIT_CTRLS, arch_data->exit_ctrls.value);
204 vmx_ret |= check_vmcs_write(VMCS_ENTRY_CTRLS, arch_data->entry_ctrls.value);
205 vmx_ret |= check_vmcs_write(VMCS_EXCP_BITMAP, arch_data->excp_bmap.value);
207 if (info->shdw_pg_mode == NESTED_PAGING) {
208 vmx_ret |= check_vmcs_write(VMCS_EPT_PTR, info->direct_map_pt);
219 int v3_vmx_save_vmcs(struct guest_info * info) {
220 struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data);
223 check_vmcs_read(VMCS_GUEST_RIP, &(info->rip));
224 check_vmcs_read(VMCS_GUEST_RSP, &(info->vm_regs.rsp));
226 check_vmcs_read(VMCS_GUEST_CR0, &(info->ctrl_regs.cr0));
227 check_vmcs_read(VMCS_CR0_READ_SHDW, &(info->shdw_pg_state.guest_cr0));
228 check_vmcs_read(VMCS_GUEST_CR3, &(info->ctrl_regs.cr3));
229 check_vmcs_read(VMCS_GUEST_CR4, &(info->ctrl_regs.cr4));
230 check_vmcs_read(VMCS_CR4_READ_SHDW, &(vmx_info->guest_cr4));
231 check_vmcs_read(VMCS_GUEST_DR7, &(info->dbg_regs.dr7));
233 check_vmcs_read(VMCS_GUEST_RFLAGS, &(info->ctrl_regs.rflags));
236 check_vmcs_read(VMCS_GUEST_EFER, &(info->ctrl_regs.efer));
237 check_vmcs_read(VMCS_ENTRY_CTRLS, &(vmx_info->entry_ctrls.value));
240 error = v3_read_vmcs_segments(&(info->segments));
246 int v3_vmx_restore_vmcs(struct guest_info * info) {
247 struct vmx_data * vmx_info = (struct vmx_data *)(info->vmm_data);
250 check_vmcs_write(VMCS_GUEST_RIP, info->rip);
251 check_vmcs_write(VMCS_GUEST_RSP, info->vm_regs.rsp);
253 check_vmcs_write(VMCS_GUEST_CR0, info->ctrl_regs.cr0);
254 check_vmcs_write(VMCS_CR0_READ_SHDW, info->shdw_pg_state.guest_cr0);
255 check_vmcs_write(VMCS_GUEST_CR3, info->ctrl_regs.cr3);
256 check_vmcs_write(VMCS_GUEST_CR4, info->ctrl_regs.cr4);
257 check_vmcs_write(VMCS_CR4_READ_SHDW, vmx_info->guest_cr4);
258 check_vmcs_write(VMCS_GUEST_DR7, info->dbg_regs.dr7);
260 check_vmcs_write(VMCS_GUEST_RFLAGS, info->ctrl_regs.rflags);
263 check_vmcs_write(VMCS_GUEST_EFER, info->ctrl_regs.efer);
264 check_vmcs_write(VMCS_ENTRY_CTRLS, vmx_info->entry_ctrls.value);
267 error = v3_write_vmcs_segments(&(info->segments));
275 int v3_update_vmcs_host_state(struct guest_info * info) {
278 struct v3_msr tmp_msr;
283 } __attribute__((packed)) tmp_seg;
286 __asm__ __volatile__ ( "movq %%cr0, %0; "
291 __asm__ __volatile__ ( "movl %%cr0, %0; "
296 vmx_ret |= check_vmcs_write(VMCS_HOST_CR0, tmp);
300 __asm__ __volatile__ ( "movq %%cr3, %0; "
305 __asm__ __volatile__ ( "movl %%cr3, %0; "
310 vmx_ret |= check_vmcs_write(VMCS_HOST_CR3, tmp);
314 __asm__ __volatile__ ( "movq %%cr4, %0; "
319 __asm__ __volatile__ ( "movl %%cr4, %0; "
324 vmx_ret |= check_vmcs_write(VMCS_HOST_CR4, tmp);
327 __asm__ __volatile__(
333 gdtr_base = tmp_seg.base;
334 vmx_ret |= check_vmcs_write(VMCS_HOST_GDTR_BASE, tmp_seg.base);
336 __asm__ __volatile__(
342 vmx_ret |= check_vmcs_write(VMCS_HOST_IDTR_BASE, tmp_seg.base);
344 __asm__ __volatile__(
350 vmx_ret |= check_vmcs_write(VMCS_HOST_TR_SELECTOR, tmp_seg.selector);
352 /* The GDTR *index* is bits 3-15 of the selector. */
354 struct tss_descriptor * desc = NULL;
355 desc = (struct tss_descriptor *)(gdtr_base + (8 * (tmp_seg.selector >> 3)));
357 tmp_seg.base = ((desc->base1) |
358 (desc->base2 << 16) |
359 (desc->base3 << 24) |
361 ((uint64_t)desc->base4 << 32)
367 vmx_ret |= check_vmcs_write(VMCS_HOST_TR_BASE, tmp_seg.base);
372 __asm__ __volatile__ ( "movq %%cs, %0; "
377 __asm__ __volatile__ ( "movl %%cs, %0; "
382 vmx_ret |= check_vmcs_write(VMCS_HOST_CS_SELECTOR, tmp);
385 __asm__ __volatile__ ( "movq %%ss, %0; "
390 __asm__ __volatile__ ( "movl %%ss, %0; "
395 vmx_ret |= check_vmcs_write(VMCS_HOST_SS_SELECTOR, tmp);
398 __asm__ __volatile__ ( "movq %%ds, %0; "
403 __asm__ __volatile__ ( "movl %%ds, %0; "
408 vmx_ret |= check_vmcs_write(VMCS_HOST_DS_SELECTOR, tmp);
411 __asm__ __volatile__ ( "movq %%es, %0; "
416 __asm__ __volatile__ ( "movl %%es, %0; "
421 vmx_ret |= check_vmcs_write(VMCS_HOST_ES_SELECTOR, tmp);
424 __asm__ __volatile__ ( "movq %%fs, %0; "
429 __asm__ __volatile__ ( "movl %%fs, %0; "
434 vmx_ret |= check_vmcs_write(VMCS_HOST_FS_SELECTOR, tmp);
437 __asm__ __volatile__ ( "movq %%gs, %0; "
442 __asm__ __volatile__ ( "movl %%gs, %0; "
447 vmx_ret |= check_vmcs_write(VMCS_HOST_GS_SELECTOR, tmp);
450 #define SYSENTER_CS_MSR 0x00000174
451 #define SYSENTER_ESP_MSR 0x00000175
452 #define SYSENTER_EIP_MSR 0x00000176
453 #define FS_BASE_MSR 0xc0000100
454 #define GS_BASE_MSR 0xc0000101
455 #define EFER_MSR 0xc0000080
459 v3_get_msr(SYSENTER_CS_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
460 vmx_ret |= check_vmcs_write(VMCS_HOST_SYSENTER_CS, tmp_msr.lo);
463 v3_get_msr(SYSENTER_ESP_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
464 vmx_ret |= check_vmcs_write(VMCS_HOST_SYSENTER_ESP, tmp_msr.value);
467 v3_get_msr(SYSENTER_EIP_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
468 vmx_ret |= check_vmcs_write(VMCS_HOST_SYSENTER_EIP, tmp_msr.value);
472 v3_get_msr(FS_BASE_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
473 vmx_ret |= check_vmcs_write(VMCS_HOST_FS_BASE, tmp_msr.value);
476 v3_get_msr(GS_BASE_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
477 vmx_ret |= check_vmcs_write(VMCS_HOST_GS_BASE, tmp_msr.value);
481 v3_get_msr(EFER_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
482 vmx_ret |= check_vmcs_write(VMCS_HOST_EFER, tmp_msr.value);
484 // PERF GLOBAL CONTROL
488 v3_get_msr(IA32_PAT_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
489 vmx_ret |= check_vmcs_write(VMCS_HOST_PAT, tmp_msr.value);
492 // save STAR, LSTAR, FMASK, KERNEL_GS_BASE MSRs in MSR load/store area
494 struct vmx_data * vmx_state = (struct vmx_data *)info->vmm_data;
495 struct vmcs_msr_save_area * msr_entries = vmx_state->msr_area;
498 v3_get_msr(IA32_STAR_MSR, &(msr_entries->host_star.hi), &(msr_entries->host_star.lo));
499 v3_get_msr(IA32_LSTAR_MSR, &(msr_entries->host_lstar.hi), &(msr_entries->host_lstar.lo));
500 v3_get_msr(IA32_FMASK_MSR, &(msr_entries->host_fmask.hi), &(msr_entries->host_fmask.lo));
501 v3_get_msr(IA32_KERN_GS_BASE_MSR, &(msr_entries->host_kern_gs.hi), &(msr_entries->host_kern_gs.lo));
516 static inline void print_vmcs_field(vmcs_field_t vmcs_index) {
517 int len = v3_vmcs_get_field_len(vmcs_index);
520 if (vmcs_read(vmcs_index, &val) != VMX_SUCCESS) {
521 PrintError("VMCS_READ error for %s\n", v3_vmcs_field_to_str(vmcs_index));
526 PrintDebug("\t%s: 0x%.4x\n", v3_vmcs_field_to_str(vmcs_index), (uint16_t)val);
527 } else if (len == 4) {
528 PrintDebug("\t%s: 0x%.8x\n", v3_vmcs_field_to_str(vmcs_index), (uint32_t)val);
529 } else if (len == 8) {
530 PrintDebug("\t%s: 0x%p\n", v3_vmcs_field_to_str(vmcs_index), (void *)(addr_t)val);
535 static void print_vmcs_segments() {
536 struct v3_segments segs;
538 v3_read_vmcs_segments(&segs);
539 v3_print_segments(&segs);
542 PrintDebug(" ==> CS\n");
543 print_vmcs_field(VMCS_GUEST_CS_SELECTOR);
544 print_vmcs_field(VMCS_GUEST_CS_BASE);
545 print_vmcs_field(VMCS_GUEST_CS_LIMIT);
546 print_vmcs_field(VMCS_GUEST_CS_ACCESS);
548 PrintDebug(" ==> SS\n");
549 print_vmcs_field(VMCS_GUEST_SS_SELECTOR);
550 print_vmcs_field(VMCS_GUEST_SS_BASE);
551 print_vmcs_field(VMCS_GUEST_SS_LIMIT);
552 print_vmcs_field(VMCS_GUEST_SS_ACCESS);
554 PrintDebug(" ==> DS\n");
555 print_vmcs_field(VMCS_GUEST_DS_SELECTOR);
556 print_vmcs_field(VMCS_GUEST_DS_BASE);
557 print_vmcs_field(VMCS_GUEST_DS_LIMIT);
558 print_vmcs_field(VMCS_GUEST_DS_ACCESS);
560 PrintDebug(" ==> ES\n");
561 print_vmcs_field(VMCS_GUEST_ES_SELECTOR);
562 print_vmcs_field(VMCS_GUEST_ES_BASE);
563 print_vmcs_field(VMCS_GUEST_ES_LIMIT);
564 print_vmcs_field(VMCS_GUEST_ES_ACCESS);
566 PrintDebug(" ==> FS\n");
567 print_vmcs_field(VMCS_GUEST_FS_SELECTOR);
568 print_vmcs_field(VMCS_GUEST_FS_BASE);
569 print_vmcs_field(VMCS_GUEST_FS_LIMIT);
570 print_vmcs_field(VMCS_GUEST_FS_ACCESS);
572 PrintDebug(" ==> GS\n");
573 print_vmcs_field(VMCS_GUEST_GS_SELECTOR);
574 print_vmcs_field(VMCS_GUEST_GS_BASE);
575 print_vmcs_field(VMCS_GUEST_GS_LIMIT);
576 print_vmcs_field(VMCS_GUEST_GS_ACCESS);
578 PrintDebug(" ==> LDTR\n");
579 print_vmcs_field(VMCS_GUEST_LDTR_SELECTOR);
580 print_vmcs_field(VMCS_GUEST_LDTR_BASE);
581 print_vmcs_field(VMCS_GUEST_LDTR_LIMIT);
582 print_vmcs_field(VMCS_GUEST_LDTR_ACCESS);
584 PrintDebug(" ==> TR\n");
585 print_vmcs_field(VMCS_GUEST_TR_SELECTOR);
586 print_vmcs_field(VMCS_GUEST_TR_BASE);
587 print_vmcs_field(VMCS_GUEST_TR_LIMIT);
588 print_vmcs_field(VMCS_GUEST_TR_ACCESS);
590 PrintDebug(" ==> GDTR\n");
591 print_vmcs_field(VMCS_GUEST_GDTR_BASE);
592 print_vmcs_field(VMCS_GUEST_GDTR_LIMIT);
594 PrintDebug(" ==> IDTR\n");
595 print_vmcs_field(VMCS_GUEST_IDTR_BASE);
596 print_vmcs_field(VMCS_GUEST_IDTR_LIMIT);
604 static void print_guest_state()
606 PrintDebug("VMCS_GUEST_STATE\n");
607 print_vmcs_field(VMCS_GUEST_RIP);
608 print_vmcs_field(VMCS_GUEST_RSP);
609 print_vmcs_field(VMCS_GUEST_RFLAGS);
610 print_vmcs_field(VMCS_GUEST_CR0);
611 print_vmcs_field(VMCS_GUEST_CR3);
612 print_vmcs_field(VMCS_GUEST_CR4);
613 print_vmcs_field(VMCS_GUEST_DR7);
616 print_vmcs_field(VMCS_GUEST_EFER);
618 print_vmcs_field(VMCS_GUEST_EFER_HIGH);
624 print_vmcs_segments();
628 print_vmcs_field(VMCS_GUEST_DBG_CTL);
630 print_vmcs_field(VMCS_GUEST_DBG_CTL_HIGH);
632 print_vmcs_field(VMCS_GUEST_SYSENTER_CS);
633 print_vmcs_field(VMCS_GUEST_SYSENTER_ESP);
634 print_vmcs_field(VMCS_GUEST_SYSENTER_EIP);
638 print_vmcs_field(VMCS_GUEST_PAT);
640 print_vmcs_field(VMCS_GUEST_PAT_HIGH);
643 //if load IA32_PERF_GLOBAL_CTRL
644 print_vmcs_field(VMCS_GUEST_PERF_GLOBAL_CTRL);
646 print_vmcs_field(VMCS_GUEST_PERF_GLOBAL_CTRL_HIGH);
649 print_vmcs_field(VMCS_GUEST_SMBASE);
654 PrintDebug("GUEST_NON_REGISTER_STATE\n");
656 print_vmcs_field(VMCS_GUEST_ACTIVITY_STATE);
657 print_vmcs_field(VMCS_GUEST_INT_STATE);
658 print_vmcs_field(VMCS_GUEST_PENDING_DBG_EXCP);
660 // if VMX preempt timer
661 print_vmcs_field(VMCS_PREEMPT_TIMER);
665 static void print_host_state()
667 PrintDebug("VMCS_HOST_STATE\n");
669 print_vmcs_field(VMCS_HOST_RIP);
670 print_vmcs_field(VMCS_HOST_RSP);
671 print_vmcs_field(VMCS_HOST_CR0);
672 print_vmcs_field(VMCS_HOST_CR3);
673 print_vmcs_field(VMCS_HOST_CR4);
678 print_vmcs_field(VMCS_HOST_EFER);
680 print_vmcs_field(VMCS_HOST_EFER_HIGH);
685 print_vmcs_field(VMCS_HOST_CS_SELECTOR);
686 print_vmcs_field(VMCS_HOST_SS_SELECTOR);
687 print_vmcs_field(VMCS_HOST_DS_SELECTOR);
688 print_vmcs_field(VMCS_HOST_ES_SELECTOR);
689 print_vmcs_field(VMCS_HOST_FS_SELECTOR);
690 print_vmcs_field(VMCS_HOST_GS_SELECTOR);
691 print_vmcs_field(VMCS_HOST_TR_SELECTOR);
694 print_vmcs_field(VMCS_HOST_FS_BASE);
695 print_vmcs_field(VMCS_HOST_GS_BASE);
696 print_vmcs_field(VMCS_HOST_TR_BASE);
697 print_vmcs_field(VMCS_HOST_GDTR_BASE);
698 print_vmcs_field(VMCS_HOST_IDTR_BASE);
701 print_vmcs_field(VMCS_HOST_SYSENTER_CS);
702 print_vmcs_field(VMCS_HOST_SYSENTER_ESP);
703 print_vmcs_field(VMCS_HOST_SYSENTER_EIP);
707 print_vmcs_field(VMCS_HOST_PAT);
709 print_vmcs_field(VMCS_HOST_PAT_HIGH);
712 // if load IA32_PERF_GLOBAL_CTRL
713 print_vmcs_field(VMCS_HOST_PERF_GLOBAL_CTRL);
715 print_vmcs_field(VMCS_HOST_PERF_GLOBAL_CTRL_HIGH);
720 static void print_exec_ctrls() {
721 PrintDebug("VMCS_EXEC_CTRL_FIELDS\n");
722 print_vmcs_field(VMCS_PIN_CTRLS);
723 print_vmcs_field(VMCS_PROC_CTRLS);
725 // if activate secondary controls
726 print_vmcs_field(VMCS_SEC_PROC_CTRLS);
728 print_vmcs_field(VMCS_EXCP_BITMAP);
729 print_vmcs_field(VMCS_PG_FAULT_ERR_MASK);
730 print_vmcs_field(VMCS_PG_FAULT_ERR_MATCH);
732 print_vmcs_field(VMCS_IO_BITMAP_A_ADDR);
734 print_vmcs_field(VMCS_IO_BITMAP_A_ADDR_HIGH);
737 print_vmcs_field(VMCS_IO_BITMAP_B_ADDR);
739 print_vmcs_field(VMCS_IO_BITMAP_B_ADDR_HIGH);
742 print_vmcs_field(VMCS_TSC_OFFSET);
744 print_vmcs_field(VMCS_TSC_OFFSET_HIGH);
749 print_vmcs_field(VMCS_CR0_MASK);
750 print_vmcs_field(VMCS_CR0_READ_SHDW);
751 print_vmcs_field(VMCS_CR4_MASK);
752 print_vmcs_field(VMCS_CR4_READ_SHDW);
754 print_vmcs_field(VMCS_CR3_TGT_CNT);
755 print_vmcs_field(VMCS_CR3_TGT_VAL_0);
756 print_vmcs_field(VMCS_CR3_TGT_VAL_1);
757 print_vmcs_field(VMCS_CR3_TGT_VAL_2);
758 print_vmcs_field(VMCS_CR3_TGT_VAL_3);
760 // Check max number of CR3 targets... may continue...
765 // if virtualize apic accesses
766 print_vmcs_field(VMCS_APIC_ACCESS_ADDR);
768 print_vmcs_field(VMCS_APIC_ACCESS_ADDR_HIGH);
772 print_vmcs_field(VMCS_VAPIC_ADDR);
774 print_vmcs_field(VMCS_VAPIC_ADDR_HIGH);
778 print_vmcs_field(VMCS_TPR_THRESHOLD);
781 // if use MSR bitmaps
782 print_vmcs_field(VMCS_MSR_BITMAP);
784 print_vmcs_field(VMCS_MSR_BITMAP_HIGH);
787 print_vmcs_field(VMCS_EXEC_PTR);
789 print_vmcs_field(VMCS_EXEC_PTR_HIGH);
795 static void print_ept_state() {
796 V3_Print("VMCS EPT INFO\n");
799 print_vmcs_field(VMCS_VPID);
801 print_vmcs_field(VMCS_EPT_PTR);
803 print_vmcs_field(VMCS_EPT_PTR_HIGH);
806 print_vmcs_field(VMCS_GUEST_PHYS_ADDR);
808 print_vmcs_field(VMCS_GUEST_PHYS_ADDR_HIGH);
813 print_vmcs_field(VMCS_GUEST_PDPTE0);
815 print_vmcs_field(VMCS_GUEST_PDPTE0_HIGH);
818 print_vmcs_field(VMCS_GUEST_PDPTE1);
820 print_vmcs_field(VMCS_GUEST_PDPTE1_HIGH);
823 print_vmcs_field(VMCS_GUEST_PDPTE2);
825 print_vmcs_field(VMCS_GUEST_PDPTE2_HIGH);
828 print_vmcs_field(VMCS_GUEST_PDPTE3);
830 print_vmcs_field(VMCS_GUEST_PDPTE3_HIGH);
838 static void print_exit_ctrls() {
839 PrintDebug("VMCS_EXIT_CTRLS\n");
841 print_vmcs_field(VMCS_EXIT_CTRLS);
844 print_vmcs_field(VMCS_EXIT_MSR_STORE_CNT);
845 print_vmcs_field(VMCS_EXIT_MSR_STORE_ADDR);
847 print_vmcs_field(VMCS_EXIT_MSR_STORE_ADDR_HIGH);
850 print_vmcs_field(VMCS_EXIT_MSR_LOAD_CNT);
851 print_vmcs_field(VMCS_EXIT_MSR_LOAD_ADDR);
853 print_vmcs_field(VMCS_EXIT_MSR_LOAD_ADDR_HIGH);
857 // if pause loop exiting
858 print_vmcs_field(VMCS_PLE_GAP);
859 print_vmcs_field(VMCS_PLE_WINDOW);
864 static void print_entry_ctrls() {
865 PrintDebug("VMCS_ENTRY_CTRLS\n");
867 print_vmcs_field(VMCS_ENTRY_CTRLS);
869 print_vmcs_field(VMCS_ENTRY_MSR_LOAD_CNT);
870 print_vmcs_field(VMCS_ENTRY_MSR_LOAD_ADDR);
872 print_vmcs_field(VMCS_ENTRY_MSR_LOAD_ADDR_HIGH);
875 print_vmcs_field(VMCS_ENTRY_INT_INFO);
876 print_vmcs_field(VMCS_ENTRY_EXCP_ERR);
877 print_vmcs_field(VMCS_ENTRY_INSTR_LEN);
883 static void print_exit_info() {
884 PrintDebug("VMCS_EXIT_INFO\n");
886 print_vmcs_field(VMCS_EXIT_REASON);
887 print_vmcs_field(VMCS_EXIT_QUAL);
889 print_vmcs_field(VMCS_EXIT_INT_INFO);
890 print_vmcs_field(VMCS_EXIT_INT_ERR);
892 print_vmcs_field(VMCS_IDT_VECTOR_INFO);
893 print_vmcs_field(VMCS_IDT_VECTOR_ERR);
895 print_vmcs_field(VMCS_EXIT_INSTR_LEN);
897 print_vmcs_field(VMCS_GUEST_LINEAR_ADDR);
898 print_vmcs_field(VMCS_EXIT_INSTR_INFO);
900 print_vmcs_field(VMCS_IO_RCX);
901 print_vmcs_field(VMCS_IO_RSI);
902 print_vmcs_field(VMCS_IO_RDI);
903 print_vmcs_field(VMCS_IO_RIP);
906 print_vmcs_field(VMCS_INSTR_ERR);
909 void v3_print_vmcs() {
911 print_vmcs_field(VMCS_LINK_PTR);
913 print_vmcs_field(VMCS_LINK_PTR_HIGH);
930 * Returns the field length in bytes
931 * It doesn't get much uglier than this... Thanks Intel
933 int v3_vmcs_get_field_len(vmcs_field_t field) {
934 struct vmcs_field_encoding * enc = (struct vmcs_field_encoding *)&field;
936 switch (enc->width) {
940 if (enc->access_type == 1) {
943 return sizeof(addr_t);
949 return sizeof(addr_t);
951 PrintError("Invalid VMCS field: 0x%x\n", field);
966 static const char VMCS_VPID_STR[] = "VPID";
967 static const char VMCS_GUEST_ES_SELECTOR_STR[] = "GUEST_ES_SELECTOR";
968 static const char VMCS_GUEST_CS_SELECTOR_STR[] = "GUEST_CS_SELECTOR";
969 static const char VMCS_GUEST_SS_SELECTOR_STR[] = "GUEST_SS_SELECTOR";
970 static const char VMCS_GUEST_DS_SELECTOR_STR[] = "GUEST_DS_SELECTOR";
971 static const char VMCS_GUEST_FS_SELECTOR_STR[] = "GUEST_FS_SELECTOR";
972 static const char VMCS_GUEST_GS_SELECTOR_STR[] = "GUEST_GS_SELECTOR";
973 static const char VMCS_GUEST_LDTR_SELECTOR_STR[] = "GUEST_LDTR_SELECTOR";
974 static const char VMCS_GUEST_TR_SELECTOR_STR[] = "GUEST_TR_SELECTOR";
975 static const char VMCS_HOST_ES_SELECTOR_STR[] = "HOST_ES_SELECTOR";
976 static const char VMCS_HOST_CS_SELECTOR_STR[] = "HOST_CS_SELECTOR";
977 static const char VMCS_HOST_SS_SELECTOR_STR[] = "HOST_SS_SELECTOR";
978 static const char VMCS_HOST_DS_SELECTOR_STR[] = "HOST_DS_SELECTOR";
979 static const char VMCS_HOST_FS_SELECTOR_STR[] = "HOST_FS_SELECTOR";
980 static const char VMCS_HOST_GS_SELECTOR_STR[] = "HOST_GS_SELECTOR";
981 static const char VMCS_HOST_TR_SELECTOR_STR[] = "HOST_TR_SELECTOR";
982 static const char VMCS_IO_BITMAP_A_ADDR_STR[] = "IO_BITMAP_A_ADDR";
983 static const char VMCS_IO_BITMAP_A_ADDR_HIGH_STR[] = "IO_BITMAP_A_ADDR_HIGH";
984 static const char VMCS_IO_BITMAP_B_ADDR_STR[] = "IO_BITMAP_B_ADDR";
985 static const char VMCS_IO_BITMAP_B_ADDR_HIGH_STR[] = "IO_BITMAP_B_ADDR_HIGH";
986 static const char VMCS_MSR_BITMAP_STR[] = "MSR_BITMAPS";
987 static const char VMCS_MSR_BITMAP_HIGH_STR[] = "MSR_BITMAPS_HIGH";
988 static const char VMCS_EXIT_MSR_STORE_ADDR_STR[] = "EXIT_MSR_STORE_ADDR";
989 static const char VMCS_EXIT_MSR_STORE_ADDR_HIGH_STR[] = "EXIT_MSR_STORE_ADDR_HIGH";
990 static const char VMCS_EXIT_MSR_LOAD_ADDR_STR[] = "EXIT_MSR_LOAD_ADDR";
991 static const char VMCS_EXIT_MSR_LOAD_ADDR_HIGH_STR[] = "EXIT_MSR_LOAD_ADDR_HIGH";
992 static const char VMCS_ENTRY_MSR_LOAD_ADDR_STR[] = "ENTRY_MSR_LOAD_ADDR";
993 static const char VMCS_ENTRY_MSR_LOAD_ADDR_HIGH_STR[] = "ENTRY_MSR_LOAD_ADDR_HIGH";
994 static const char VMCS_EXEC_PTR_STR[] = "VMCS_EXEC_PTR";
995 static const char VMCS_EXEC_PTR_HIGH_STR[] = "VMCS_EXEC_PTR_HIGH";
996 static const char VMCS_TSC_OFFSET_STR[] = "TSC_OFFSET";
997 static const char VMCS_TSC_OFFSET_HIGH_STR[] = "TSC_OFFSET_HIGH";
998 static const char VMCS_VAPIC_ADDR_STR[] = "VAPIC_PAGE_ADDR";
999 static const char VMCS_VAPIC_ADDR_HIGH_STR[] = "VAPIC_PAGE_ADDR_HIGH";
1000 static const char VMCS_APIC_ACCESS_ADDR_STR[] = "APIC_ACCESS_ADDR";
1001 static const char VMCS_APIC_ACCESS_ADDR_HIGH_STR[] = "APIC_ACCESS_ADDR_HIGH";
1002 static const char VMCS_EPT_PTR_STR[] = "VMCS_EPT_PTR";
1003 static const char VMCS_EPT_PTR_HIGH_STR[] = "VMCS_EPT_PTR_HIGH";
1004 static const char VMCS_GUEST_PHYS_ADDR_STR[] = "VMCS_GUEST_PHYS_ADDR";
1005 static const char VMCS_GUEST_PHYS_ADDR_HIGH_STR[] = "VMCS_GUEST_PHYS_ADDR_HIGH";
1006 static const char VMCS_LINK_PTR_STR[] = "VMCS_LINK_PTR";
1007 static const char VMCS_LINK_PTR_HIGH_STR[] = "VMCS_LINK_PTR_HIGH";
1008 static const char VMCS_GUEST_DBG_CTL_STR[] = "GUEST_DEBUG_CTL";
1009 static const char VMCS_GUEST_DBG_CTL_HIGH_STR[] = "GUEST_DEBUG_CTL_HIGH";
1010 static const char VMCS_GUEST_PAT_STR[] = "GUEST_PAT";
1011 static const char VMCS_GUEST_PAT_HIGH_STR[] = "GUEST_PAT_HIGH";
1012 static const char VMCS_GUEST_EFER_STR[] = "GUEST_EFER";
1013 static const char VMCS_GUEST_EFER_HIGH_STR[] = "GUEST_EFER_HIGH";
1014 static const char VMCS_GUEST_PERF_GLOBAL_CTRL_STR[] = "GUEST_PERF_GLOBAL_CTRL";
1015 static const char VMCS_GUEST_PERF_GLOBAL_CTRL_HIGH_STR[] = "GUEST_PERF_GLOBAL_CTRL_HIGH";
1016 static const char VMCS_GUEST_PDPTE0_STR[] = "GUEST_PDPTE0";
1017 static const char VMCS_GUEST_PDPTE0_HIGH_STR[] = "GUEST_PDPTE0_HIGH";
1018 static const char VMCS_GUEST_PDPTE1_STR[] = "GUEST_PDPTE1";
1019 static const char VMCS_GUEST_PDPTE1_HIGH_STR[] = "GUEST_PDPTE1_HIGH";
1020 static const char VMCS_GUEST_PDPTE2_STR[] = "GUEST_PDPTE2";
1021 static const char VMCS_GUEST_PDPTE2_HIGH_STR[] = "GUEST_PDPTE2_HIGH";
1022 static const char VMCS_GUEST_PDPTE3_STR[] = "GUEST_PDPTE3";
1023 static const char VMCS_GUEST_PDPTE3_HIGH_STR[] = "GUEST_PDPTE3_HIGH";
1024 static const char VMCS_HOST_PAT_STR[] = "HOST_PAT";
1025 static const char VMCS_HOST_PAT_HIGH_STR[] = "HOST_PAT_HIGH";
1026 static const char VMCS_HOST_EFER_STR[] = "VMCS_HOST_EFER";
1027 static const char VMCS_HOST_EFER_HIGH_STR[] = "VMCS_HOST_EFER_HIGH";
1028 static const char VMCS_HOST_PERF_GLOBAL_CTRL_STR[] = "HOST_PERF_GLOBAL_CTRL";
1029 static const char VMCS_HOST_PERF_GLOBAL_CTRL_HIGH_STR[] = "HOST_PERF_GLOBAL_CTRL_HIGH";
1030 static const char VMCS_PIN_CTRLS_STR[] = "PIN_VM_EXEC_CTRLS";
1031 static const char VMCS_PROC_CTRLS_STR[] = "PROC_VM_EXEC_CTRLS";
1032 static const char VMCS_EXCP_BITMAP_STR[] = "EXCEPTION_BITMAP";
1033 static const char VMCS_PG_FAULT_ERR_MASK_STR[] = "PAGE_FAULT_ERROR_MASK";
1034 static const char VMCS_PG_FAULT_ERR_MATCH_STR[] = "PAGE_FAULT_ERROR_MATCH";
1035 static const char VMCS_CR3_TGT_CNT_STR[] = "CR3_TARGET_COUNT";
1036 static const char VMCS_EXIT_CTRLS_STR[] = "VM_EXIT_CTRLS";
1037 static const char VMCS_EXIT_MSR_STORE_CNT_STR[] = "VM_EXIT_MSR_STORE_COUNT";
1038 static const char VMCS_EXIT_MSR_LOAD_CNT_STR[] = "VM_EXIT_MSR_LOAD_COUNT";
1039 static const char VMCS_ENTRY_CTRLS_STR[] = "VM_ENTRY_CTRLS";
1040 static const char VMCS_ENTRY_MSR_LOAD_CNT_STR[] = "VM_ENTRY_MSR_LOAD_COUNT";
1041 static const char VMCS_ENTRY_INT_INFO_STR[] = "VM_ENTRY_INT_INFO_FIELD";
1042 static const char VMCS_ENTRY_EXCP_ERR_STR[] = "VM_ENTRY_EXCEPTION_ERROR";
1043 static const char VMCS_ENTRY_INSTR_LEN_STR[] = "VM_ENTRY_INSTR_LENGTH";
1044 static const char VMCS_TPR_THRESHOLD_STR[] = "TPR_THRESHOLD";
1045 static const char VMCS_SEC_PROC_CTRLS_STR[] = "VMCS_SEC_PROC_CTRLS";
1046 static const char VMCS_PLE_GAP_STR[] = "PLE_GAP";
1047 static const char VMCS_PLE_WINDOW_STR[] = "PLE_WINDOW";
1048 static const char VMCS_INSTR_ERR_STR[] = "VM_INSTR_ERROR";
1049 static const char VMCS_EXIT_REASON_STR[] = "EXIT_REASON";
1050 static const char VMCS_EXIT_INT_INFO_STR[] = "VM_EXIT_INT_INFO";
1051 static const char VMCS_EXIT_INT_ERR_STR[] = "VM_EXIT_INT_ERROR";
1052 static const char VMCS_IDT_VECTOR_INFO_STR[] = "IDT_VECTOR_INFO";
1053 static const char VMCS_IDT_VECTOR_ERR_STR[] = "IDT_VECTOR_ERROR";
1054 static const char VMCS_EXIT_INSTR_LEN_STR[] = "VM_EXIT_INSTR_LENGTH";
1055 static const char VMCS_EXIT_INSTR_INFO_STR[] = "VMX_INSTR_INFO";
1056 static const char VMCS_GUEST_ES_LIMIT_STR[] = "GUEST_ES_LIMIT";
1057 static const char VMCS_GUEST_CS_LIMIT_STR[] = "GUEST_CS_LIMIT";
1058 static const char VMCS_GUEST_SS_LIMIT_STR[] = "GUEST_SS_LIMIT";
1059 static const char VMCS_GUEST_DS_LIMIT_STR[] = "GUEST_DS_LIMIT";
1060 static const char VMCS_GUEST_FS_LIMIT_STR[] = "GUEST_FS_LIMIT";
1061 static const char VMCS_GUEST_GS_LIMIT_STR[] = "GUEST_GS_LIMIT";
1062 static const char VMCS_GUEST_LDTR_LIMIT_STR[] = "GUEST_LDTR_LIMIT";
1063 static const char VMCS_GUEST_TR_LIMIT_STR[] = "GUEST_TR_LIMIT";
1064 static const char VMCS_GUEST_GDTR_LIMIT_STR[] = "GUEST_GDTR_LIMIT";
1065 static const char VMCS_GUEST_IDTR_LIMIT_STR[] = "GUEST_IDTR_LIMIT";
1066 static const char VMCS_GUEST_ES_ACCESS_STR[] = "GUEST_ES_ACCESS";
1067 static const char VMCS_GUEST_CS_ACCESS_STR[] = "GUEST_CS_ACCESS";
1068 static const char VMCS_GUEST_SS_ACCESS_STR[] = "GUEST_SS_ACCESS";
1069 static const char VMCS_GUEST_DS_ACCESS_STR[] = "GUEST_DS_ACCESS";
1070 static const char VMCS_GUEST_FS_ACCESS_STR[] = "GUEST_FS_ACCESS";
1071 static const char VMCS_GUEST_GS_ACCESS_STR[] = "GUEST_GS_ACCESS";
1072 static const char VMCS_GUEST_LDTR_ACCESS_STR[] = "GUEST_LDTR_ACCESS";
1073 static const char VMCS_GUEST_TR_ACCESS_STR[] = "GUEST_TR_ACCESS";
1074 static const char VMCS_GUEST_INT_STATE_STR[] = "GUEST_INT_STATE";
1075 static const char VMCS_GUEST_ACTIVITY_STATE_STR[] = "GUEST_ACTIVITY_STATE";
1076 static const char VMCS_GUEST_SMBASE_STR[] = "GUEST_SMBASE";
1077 static const char VMCS_GUEST_SYSENTER_CS_STR[] = "GUEST_SYSENTER_CS";
1078 static const char VMCS_PREEMPT_TIMER_STR[] = "PREEMPT_TIMER";
1079 static const char VMCS_HOST_SYSENTER_CS_STR[] = "HOST_SYSENTER_CS";
1080 static const char VMCS_CR0_MASK_STR[] = "CR0_GUEST_HOST_MASK";
1081 static const char VMCS_CR4_MASK_STR[] = "CR4_GUEST_HOST_MASK";
1082 static const char VMCS_CR0_READ_SHDW_STR[] = "CR0_READ_SHADOW";
1083 static const char VMCS_CR4_READ_SHDW_STR[] = "CR4_READ_SHADOW";
1084 static const char VMCS_CR3_TGT_VAL_0_STR[] = "CR3_TARGET_VALUE_0";
1085 static const char VMCS_CR3_TGT_VAL_1_STR[] = "CR3_TARGET_VALUE_1";
1086 static const char VMCS_CR3_TGT_VAL_2_STR[] = "CR3_TARGET_VALUE_2";
1087 static const char VMCS_CR3_TGT_VAL_3_STR[] = "CR3_TARGET_VALUE_3";
1088 static const char VMCS_EXIT_QUAL_STR[] = "EXIT_QUALIFICATION";
1089 static const char VMCS_IO_RCX_STR[] = "IO_RCX";
1090 static const char VMCS_IO_RSI_STR[] = "IO_RSI";
1091 static const char VMCS_IO_RDI_STR[] = "IO_RDI";
1092 static const char VMCS_IO_RIP_STR[] = "IO_RIP";
1093 static const char VMCS_GUEST_LINEAR_ADDR_STR[] = "GUEST_LINEAR_ADDR";
1094 static const char VMCS_GUEST_CR0_STR[] = "GUEST_CR0";
1095 static const char VMCS_GUEST_CR3_STR[] = "GUEST_CR3";
1096 static const char VMCS_GUEST_CR4_STR[] = "GUEST_CR4";
1097 static const char VMCS_GUEST_ES_BASE_STR[] = "GUEST_ES_BASE";
1098 static const char VMCS_GUEST_CS_BASE_STR[] = "GUEST_CS_BASE";
1099 static const char VMCS_GUEST_SS_BASE_STR[] = "GUEST_SS_BASE";
1100 static const char VMCS_GUEST_DS_BASE_STR[] = "GUEST_DS_BASE";
1101 static const char VMCS_GUEST_FS_BASE_STR[] = "GUEST_FS_BASE";
1102 static const char VMCS_GUEST_GS_BASE_STR[] = "GUEST_GS_BASE";
1103 static const char VMCS_GUEST_LDTR_BASE_STR[] = "GUEST_LDTR_BASE";
1104 static const char VMCS_GUEST_TR_BASE_STR[] = "GUEST_TR_BASE";
1105 static const char VMCS_GUEST_GDTR_BASE_STR[] = "GUEST_GDTR_BASE";
1106 static const char VMCS_GUEST_IDTR_BASE_STR[] = "GUEST_IDTR_BASE";
1107 static const char VMCS_GUEST_DR7_STR[] = "GUEST_DR7";
1108 static const char VMCS_GUEST_RSP_STR[] = "GUEST_RSP";
1109 static const char VMCS_GUEST_RIP_STR[] = "GUEST_RIP";
1110 static const char VMCS_GUEST_RFLAGS_STR[] = "GUEST_RFLAGS";
1111 static const char VMCS_GUEST_PENDING_DBG_EXCP_STR[] = "GUEST_PENDING_DEBUG_EXCS";
1112 static const char VMCS_GUEST_SYSENTER_ESP_STR[] = "GUEST_SYSENTER_ESP";
1113 static const char VMCS_GUEST_SYSENTER_EIP_STR[] = "GUEST_SYSENTER_EIP";
1114 static const char VMCS_HOST_CR0_STR[] = "HOST_CR0";
1115 static const char VMCS_HOST_CR3_STR[] = "HOST_CR3";
1116 static const char VMCS_HOST_CR4_STR[] = "HOST_CR4";
1117 static const char VMCS_HOST_FS_BASE_STR[] = "HOST_FS_BASE";
1118 static const char VMCS_HOST_GS_BASE_STR[] = "HOST_GS_BASE";
1119 static const char VMCS_HOST_TR_BASE_STR[] = "HOST_TR_BASE";
1120 static const char VMCS_HOST_GDTR_BASE_STR[] = "HOST_GDTR_BASE";
1121 static const char VMCS_HOST_IDTR_BASE_STR[] = "HOST_IDTR_BASE";
1122 static const char VMCS_HOST_SYSENTER_ESP_STR[] = "HOST_SYSENTER_ESP";
1123 static const char VMCS_HOST_SYSENTER_EIP_STR[] = "HOST_SYSENTER_EIP";
1124 static const char VMCS_HOST_RSP_STR[] = "HOST_RSP";
1125 static const char VMCS_HOST_RIP_STR[] = "HOST_RIP";
1129 const char * v3_vmcs_field_to_str(vmcs_field_t field) {
1132 return VMCS_VPID_STR;
1133 case VMCS_GUEST_ES_SELECTOR:
1134 return VMCS_GUEST_ES_SELECTOR_STR;
1135 case VMCS_GUEST_CS_SELECTOR:
1136 return VMCS_GUEST_CS_SELECTOR_STR;
1137 case VMCS_GUEST_SS_SELECTOR:
1138 return VMCS_GUEST_SS_SELECTOR_STR;
1139 case VMCS_GUEST_DS_SELECTOR:
1140 return VMCS_GUEST_DS_SELECTOR_STR;
1141 case VMCS_GUEST_FS_SELECTOR:
1142 return VMCS_GUEST_FS_SELECTOR_STR;
1143 case VMCS_GUEST_GS_SELECTOR:
1144 return VMCS_GUEST_GS_SELECTOR_STR;
1145 case VMCS_GUEST_LDTR_SELECTOR:
1146 return VMCS_GUEST_LDTR_SELECTOR_STR;
1147 case VMCS_GUEST_TR_SELECTOR:
1148 return VMCS_GUEST_TR_SELECTOR_STR;
1149 case VMCS_HOST_ES_SELECTOR:
1150 return VMCS_HOST_ES_SELECTOR_STR;
1151 case VMCS_HOST_CS_SELECTOR:
1152 return VMCS_HOST_CS_SELECTOR_STR;
1153 case VMCS_HOST_SS_SELECTOR:
1154 return VMCS_HOST_SS_SELECTOR_STR;
1155 case VMCS_HOST_DS_SELECTOR:
1156 return VMCS_HOST_DS_SELECTOR_STR;
1157 case VMCS_HOST_FS_SELECTOR:
1158 return VMCS_HOST_FS_SELECTOR_STR;
1159 case VMCS_HOST_GS_SELECTOR:
1160 return VMCS_HOST_GS_SELECTOR_STR;
1161 case VMCS_HOST_TR_SELECTOR:
1162 return VMCS_HOST_TR_SELECTOR_STR;
1163 case VMCS_IO_BITMAP_A_ADDR:
1164 return VMCS_IO_BITMAP_A_ADDR_STR;
1165 case VMCS_IO_BITMAP_A_ADDR_HIGH:
1166 return VMCS_IO_BITMAP_A_ADDR_HIGH_STR;
1167 case VMCS_IO_BITMAP_B_ADDR:
1168 return VMCS_IO_BITMAP_B_ADDR_STR;
1169 case VMCS_IO_BITMAP_B_ADDR_HIGH:
1170 return VMCS_IO_BITMAP_B_ADDR_HIGH_STR;
1171 case VMCS_MSR_BITMAP:
1172 return VMCS_MSR_BITMAP_STR;
1173 case VMCS_MSR_BITMAP_HIGH:
1174 return VMCS_MSR_BITMAP_HIGH_STR;
1175 case VMCS_EXIT_MSR_STORE_ADDR:
1176 return VMCS_EXIT_MSR_STORE_ADDR_STR;
1177 case VMCS_EXIT_MSR_STORE_ADDR_HIGH:
1178 return VMCS_EXIT_MSR_STORE_ADDR_HIGH_STR;
1179 case VMCS_EXIT_MSR_LOAD_ADDR:
1180 return VMCS_EXIT_MSR_LOAD_ADDR_STR;
1181 case VMCS_EXIT_MSR_LOAD_ADDR_HIGH:
1182 return VMCS_EXIT_MSR_LOAD_ADDR_HIGH_STR;
1183 case VMCS_ENTRY_MSR_LOAD_ADDR:
1184 return VMCS_ENTRY_MSR_LOAD_ADDR_STR;
1185 case VMCS_ENTRY_MSR_LOAD_ADDR_HIGH:
1186 return VMCS_ENTRY_MSR_LOAD_ADDR_HIGH_STR;
1188 return VMCS_EXEC_PTR_STR;
1189 case VMCS_EXEC_PTR_HIGH:
1190 return VMCS_EXEC_PTR_HIGH_STR;
1191 case VMCS_TSC_OFFSET:
1192 return VMCS_TSC_OFFSET_STR;
1193 case VMCS_TSC_OFFSET_HIGH:
1194 return VMCS_TSC_OFFSET_HIGH_STR;
1195 case VMCS_VAPIC_ADDR:
1196 return VMCS_VAPIC_ADDR_STR;
1197 case VMCS_VAPIC_ADDR_HIGH:
1198 return VMCS_VAPIC_ADDR_HIGH_STR;
1199 case VMCS_APIC_ACCESS_ADDR:
1200 return VMCS_APIC_ACCESS_ADDR_STR;
1201 case VMCS_APIC_ACCESS_ADDR_HIGH:
1202 return VMCS_APIC_ACCESS_ADDR_HIGH_STR;
1204 return VMCS_EPT_PTR_STR;
1205 case VMCS_EPT_PTR_HIGH:
1206 return VMCS_EPT_PTR_HIGH_STR;
1207 case VMCS_GUEST_PHYS_ADDR:
1208 return VMCS_GUEST_PHYS_ADDR_STR;
1209 case VMCS_GUEST_PHYS_ADDR_HIGH:
1210 return VMCS_GUEST_PHYS_ADDR_HIGH_STR;
1212 return VMCS_LINK_PTR_STR;
1213 case VMCS_LINK_PTR_HIGH:
1214 return VMCS_LINK_PTR_HIGH_STR;
1215 case VMCS_GUEST_DBG_CTL:
1216 return VMCS_GUEST_DBG_CTL_STR;
1217 case VMCS_GUEST_DBG_CTL_HIGH:
1218 return VMCS_GUEST_DBG_CTL_HIGH_STR;
1219 case VMCS_GUEST_PAT:
1220 return VMCS_GUEST_PAT_STR;
1221 case VMCS_GUEST_PAT_HIGH:
1222 return VMCS_GUEST_PAT_HIGH_STR;
1223 case VMCS_GUEST_EFER:
1224 return VMCS_GUEST_EFER_STR;
1225 case VMCS_GUEST_EFER_HIGH:
1226 return VMCS_GUEST_EFER_HIGH_STR;
1227 case VMCS_GUEST_PERF_GLOBAL_CTRL:
1228 return VMCS_GUEST_PERF_GLOBAL_CTRL_STR;
1229 case VMCS_GUEST_PERF_GLOBAL_CTRL_HIGH:
1230 return VMCS_GUEST_PERF_GLOBAL_CTRL_HIGH_STR;
1231 case VMCS_GUEST_PDPTE0:
1232 return VMCS_GUEST_PDPTE0_STR;
1233 case VMCS_GUEST_PDPTE0_HIGH:
1234 return VMCS_GUEST_PDPTE0_HIGH_STR;
1235 case VMCS_GUEST_PDPTE1:
1236 return VMCS_GUEST_PDPTE1_STR;
1237 case VMCS_GUEST_PDPTE1_HIGH:
1238 return VMCS_GUEST_PDPTE1_HIGH_STR;
1239 case VMCS_GUEST_PDPTE2:
1240 return VMCS_GUEST_PDPTE2_STR;
1241 case VMCS_GUEST_PDPTE2_HIGH:
1242 return VMCS_GUEST_PDPTE2_HIGH_STR;
1243 case VMCS_GUEST_PDPTE3:
1244 return VMCS_GUEST_PDPTE3_STR;
1245 case VMCS_GUEST_PDPTE3_HIGH:
1246 return VMCS_GUEST_PDPTE3_HIGH_STR;
1248 return VMCS_HOST_PAT_STR;
1249 case VMCS_HOST_PAT_HIGH:
1250 return VMCS_HOST_PAT_HIGH_STR;
1251 case VMCS_HOST_EFER:
1252 return VMCS_HOST_EFER_STR;
1253 case VMCS_HOST_EFER_HIGH:
1254 return VMCS_HOST_EFER_HIGH_STR;
1255 case VMCS_HOST_PERF_GLOBAL_CTRL:
1256 return VMCS_HOST_PERF_GLOBAL_CTRL_STR;
1257 case VMCS_HOST_PERF_GLOBAL_CTRL_HIGH:
1258 return VMCS_HOST_PERF_GLOBAL_CTRL_HIGH_STR;
1259 case VMCS_PIN_CTRLS:
1260 return VMCS_PIN_CTRLS_STR;
1261 case VMCS_PROC_CTRLS:
1262 return VMCS_PROC_CTRLS_STR;
1263 case VMCS_EXCP_BITMAP:
1264 return VMCS_EXCP_BITMAP_STR;
1265 case VMCS_PG_FAULT_ERR_MASK:
1266 return VMCS_PG_FAULT_ERR_MASK_STR;
1267 case VMCS_PG_FAULT_ERR_MATCH:
1268 return VMCS_PG_FAULT_ERR_MATCH_STR;
1269 case VMCS_CR3_TGT_CNT:
1270 return VMCS_CR3_TGT_CNT_STR;
1271 case VMCS_EXIT_CTRLS:
1272 return VMCS_EXIT_CTRLS_STR;
1273 case VMCS_EXIT_MSR_STORE_CNT:
1274 return VMCS_EXIT_MSR_STORE_CNT_STR;
1275 case VMCS_EXIT_MSR_LOAD_CNT:
1276 return VMCS_EXIT_MSR_LOAD_CNT_STR;
1277 case VMCS_ENTRY_CTRLS:
1278 return VMCS_ENTRY_CTRLS_STR;
1279 case VMCS_ENTRY_MSR_LOAD_CNT:
1280 return VMCS_ENTRY_MSR_LOAD_CNT_STR;
1281 case VMCS_ENTRY_INT_INFO:
1282 return VMCS_ENTRY_INT_INFO_STR;
1283 case VMCS_ENTRY_EXCP_ERR:
1284 return VMCS_ENTRY_EXCP_ERR_STR;
1285 case VMCS_ENTRY_INSTR_LEN:
1286 return VMCS_ENTRY_INSTR_LEN_STR;
1287 case VMCS_TPR_THRESHOLD:
1288 return VMCS_TPR_THRESHOLD_STR;
1289 case VMCS_SEC_PROC_CTRLS:
1290 return VMCS_SEC_PROC_CTRLS_STR;
1292 return VMCS_PLE_GAP_STR;
1293 case VMCS_PLE_WINDOW:
1294 return VMCS_PLE_WINDOW_STR;
1295 case VMCS_INSTR_ERR:
1296 return VMCS_INSTR_ERR_STR;
1297 case VMCS_EXIT_REASON:
1298 return VMCS_EXIT_REASON_STR;
1299 case VMCS_EXIT_INT_INFO:
1300 return VMCS_EXIT_INT_INFO_STR;
1301 case VMCS_EXIT_INT_ERR:
1302 return VMCS_EXIT_INT_ERR_STR;
1303 case VMCS_IDT_VECTOR_INFO:
1304 return VMCS_IDT_VECTOR_INFO_STR;
1305 case VMCS_IDT_VECTOR_ERR:
1306 return VMCS_IDT_VECTOR_ERR_STR;
1307 case VMCS_EXIT_INSTR_LEN:
1308 return VMCS_EXIT_INSTR_LEN_STR;
1309 case VMCS_EXIT_INSTR_INFO:
1310 return VMCS_EXIT_INSTR_INFO_STR;
1311 case VMCS_GUEST_ES_LIMIT:
1312 return VMCS_GUEST_ES_LIMIT_STR;
1313 case VMCS_GUEST_CS_LIMIT:
1314 return VMCS_GUEST_CS_LIMIT_STR;
1315 case VMCS_GUEST_SS_LIMIT:
1316 return VMCS_GUEST_SS_LIMIT_STR;
1317 case VMCS_GUEST_DS_LIMIT:
1318 return VMCS_GUEST_DS_LIMIT_STR;
1319 case VMCS_GUEST_FS_LIMIT:
1320 return VMCS_GUEST_FS_LIMIT_STR;
1321 case VMCS_GUEST_GS_LIMIT:
1322 return VMCS_GUEST_GS_LIMIT_STR;
1323 case VMCS_GUEST_LDTR_LIMIT:
1324 return VMCS_GUEST_LDTR_LIMIT_STR;
1325 case VMCS_GUEST_TR_LIMIT:
1326 return VMCS_GUEST_TR_LIMIT_STR;
1327 case VMCS_GUEST_GDTR_LIMIT:
1328 return VMCS_GUEST_GDTR_LIMIT_STR;
1329 case VMCS_GUEST_IDTR_LIMIT:
1330 return VMCS_GUEST_IDTR_LIMIT_STR;
1331 case VMCS_GUEST_ES_ACCESS:
1332 return VMCS_GUEST_ES_ACCESS_STR;
1333 case VMCS_GUEST_CS_ACCESS:
1334 return VMCS_GUEST_CS_ACCESS_STR;
1335 case VMCS_GUEST_SS_ACCESS:
1336 return VMCS_GUEST_SS_ACCESS_STR;
1337 case VMCS_GUEST_DS_ACCESS:
1338 return VMCS_GUEST_DS_ACCESS_STR;
1339 case VMCS_GUEST_FS_ACCESS:
1340 return VMCS_GUEST_FS_ACCESS_STR;
1341 case VMCS_GUEST_GS_ACCESS:
1342 return VMCS_GUEST_GS_ACCESS_STR;
1343 case VMCS_GUEST_LDTR_ACCESS:
1344 return VMCS_GUEST_LDTR_ACCESS_STR;
1345 case VMCS_GUEST_TR_ACCESS:
1346 return VMCS_GUEST_TR_ACCESS_STR;
1347 case VMCS_GUEST_INT_STATE:
1348 return VMCS_GUEST_INT_STATE_STR;
1349 case VMCS_GUEST_ACTIVITY_STATE:
1350 return VMCS_GUEST_ACTIVITY_STATE_STR;
1351 case VMCS_GUEST_SMBASE:
1352 return VMCS_GUEST_SMBASE_STR;
1353 case VMCS_GUEST_SYSENTER_CS:
1354 return VMCS_GUEST_SYSENTER_CS_STR;
1355 case VMCS_PREEMPT_TIMER:
1356 return VMCS_PREEMPT_TIMER_STR;
1357 case VMCS_HOST_SYSENTER_CS:
1358 return VMCS_HOST_SYSENTER_CS_STR;
1360 return VMCS_CR0_MASK_STR;
1362 return VMCS_CR4_MASK_STR;
1363 case VMCS_CR0_READ_SHDW:
1364 return VMCS_CR0_READ_SHDW_STR;
1365 case VMCS_CR4_READ_SHDW:
1366 return VMCS_CR4_READ_SHDW_STR;
1367 case VMCS_CR3_TGT_VAL_0:
1368 return VMCS_CR3_TGT_VAL_0_STR;
1369 case VMCS_CR3_TGT_VAL_1:
1370 return VMCS_CR3_TGT_VAL_1_STR;
1371 case VMCS_CR3_TGT_VAL_2:
1372 return VMCS_CR3_TGT_VAL_2_STR;
1373 case VMCS_CR3_TGT_VAL_3:
1374 return VMCS_CR3_TGT_VAL_3_STR;
1375 case VMCS_EXIT_QUAL:
1376 return VMCS_EXIT_QUAL_STR;
1378 return VMCS_IO_RCX_STR;
1380 return VMCS_IO_RSI_STR;
1382 return VMCS_IO_RDI_STR;
1384 return VMCS_IO_RIP_STR;
1385 case VMCS_GUEST_LINEAR_ADDR:
1386 return VMCS_GUEST_LINEAR_ADDR_STR;
1387 case VMCS_GUEST_CR0:
1388 return VMCS_GUEST_CR0_STR;
1389 case VMCS_GUEST_CR3:
1390 return VMCS_GUEST_CR3_STR;
1391 case VMCS_GUEST_CR4:
1392 return VMCS_GUEST_CR4_STR;
1393 case VMCS_GUEST_ES_BASE:
1394 return VMCS_GUEST_ES_BASE_STR;
1395 case VMCS_GUEST_CS_BASE:
1396 return VMCS_GUEST_CS_BASE_STR;
1397 case VMCS_GUEST_SS_BASE:
1398 return VMCS_GUEST_SS_BASE_STR;
1399 case VMCS_GUEST_DS_BASE:
1400 return VMCS_GUEST_DS_BASE_STR;
1401 case VMCS_GUEST_FS_BASE:
1402 return VMCS_GUEST_FS_BASE_STR;
1403 case VMCS_GUEST_GS_BASE:
1404 return VMCS_GUEST_GS_BASE_STR;
1405 case VMCS_GUEST_LDTR_BASE:
1406 return VMCS_GUEST_LDTR_BASE_STR;
1407 case VMCS_GUEST_TR_BASE:
1408 return VMCS_GUEST_TR_BASE_STR;
1409 case VMCS_GUEST_GDTR_BASE:
1410 return VMCS_GUEST_GDTR_BASE_STR;
1411 case VMCS_GUEST_IDTR_BASE:
1412 return VMCS_GUEST_IDTR_BASE_STR;
1413 case VMCS_GUEST_DR7:
1414 return VMCS_GUEST_DR7_STR;
1415 case VMCS_GUEST_RSP:
1416 return VMCS_GUEST_RSP_STR;
1417 case VMCS_GUEST_RIP:
1418 return VMCS_GUEST_RIP_STR;
1419 case VMCS_GUEST_RFLAGS:
1420 return VMCS_GUEST_RFLAGS_STR;
1421 case VMCS_GUEST_PENDING_DBG_EXCP:
1422 return VMCS_GUEST_PENDING_DBG_EXCP_STR;
1423 case VMCS_GUEST_SYSENTER_ESP:
1424 return VMCS_GUEST_SYSENTER_ESP_STR;
1425 case VMCS_GUEST_SYSENTER_EIP:
1426 return VMCS_GUEST_SYSENTER_EIP_STR;
1428 return VMCS_HOST_CR0_STR;
1430 return VMCS_HOST_CR3_STR;
1432 return VMCS_HOST_CR4_STR;
1433 case VMCS_HOST_FS_BASE:
1434 return VMCS_HOST_FS_BASE_STR;
1435 case VMCS_HOST_GS_BASE:
1436 return VMCS_HOST_GS_BASE_STR;
1437 case VMCS_HOST_TR_BASE:
1438 return VMCS_HOST_TR_BASE_STR;
1439 case VMCS_HOST_GDTR_BASE:
1440 return VMCS_HOST_GDTR_BASE_STR;
1441 case VMCS_HOST_IDTR_BASE:
1442 return VMCS_HOST_IDTR_BASE_STR;
1443 case VMCS_HOST_SYSENTER_ESP:
1444 return VMCS_HOST_SYSENTER_ESP_STR;
1445 case VMCS_HOST_SYSENTER_EIP:
1446 return VMCS_HOST_SYSENTER_EIP_STR;
1448 return VMCS_HOST_RSP_STR;
1450 return VMCS_HOST_RIP_STR;