Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Resource control extensions to host OS interface
[palacios.releases.git] / palacios / src / palacios / vmcb.c
1 /* 
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.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
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.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #include <palacios/vmcb.h>
21 #include <palacios/vmm.h>
22 #include <palacios/vmm_util.h>
23
24
25
26 void v3_set_vmcb_segment(struct vmcb_selector * vmcb_seg, struct v3_segment * seg) {
27     vmcb_seg->selector = seg->selector;
28     vmcb_seg->limit = seg->limit;
29     vmcb_seg->base = seg->base;
30     vmcb_seg->attrib.fields.type = seg->type;
31     vmcb_seg->attrib.fields.S = seg->system;
32     vmcb_seg->attrib.fields.dpl = seg->dpl;
33     vmcb_seg->attrib.fields.P = seg->present;
34     vmcb_seg->attrib.fields.avl = seg->avail;
35     vmcb_seg->attrib.fields.L = seg->long_mode;
36     vmcb_seg->attrib.fields.db = seg->db;
37     vmcb_seg->attrib.fields.G = seg->granularity;
38 }
39
40
41 void v3_get_vmcb_segment(struct vmcb_selector * vmcb_seg, struct v3_segment * seg) {
42     seg->selector = vmcb_seg->selector;
43     seg->limit = vmcb_seg->limit;
44     seg->base = vmcb_seg->base;
45     seg->type = vmcb_seg->attrib.fields.type;
46     seg->system = vmcb_seg->attrib.fields.S;
47     seg->dpl = vmcb_seg->attrib.fields.dpl;
48     seg->present = vmcb_seg->attrib.fields.P;
49     seg->avail = vmcb_seg->attrib.fields.avl;
50     seg->long_mode = vmcb_seg->attrib.fields.L;
51     seg->db = vmcb_seg->attrib.fields.db;
52     seg->granularity = vmcb_seg->attrib.fields.G;
53 }
54
55
56 void v3_set_vmcb_segments(vmcb_t * vmcb, struct v3_segments * segs) {
57     vmcb_saved_state_t * guest_area = GET_VMCB_SAVE_STATE_AREA(vmcb);
58
59     v3_set_vmcb_segment(&(guest_area->cs), &(segs->cs));
60     v3_set_vmcb_segment(&(guest_area->ds), &(segs->ds));
61     v3_set_vmcb_segment(&(guest_area->es), &(segs->es));
62     v3_set_vmcb_segment(&(guest_area->fs), &(segs->fs));
63     v3_set_vmcb_segment(&(guest_area->gs), &(segs->gs));
64     v3_set_vmcb_segment(&(guest_area->ss), &(segs->ss));
65     v3_set_vmcb_segment(&(guest_area->ldtr), &(segs->ldtr));
66     v3_set_vmcb_segment(&(guest_area->gdtr), &(segs->gdtr));
67     v3_set_vmcb_segment(&(guest_area->idtr), &(segs->idtr));
68     v3_set_vmcb_segment(&(guest_area->tr), &(segs->tr));
69 }
70
71
72 void v3_get_vmcb_segments(vmcb_t * vmcb, struct v3_segments * segs) {
73     vmcb_saved_state_t * guest_area = GET_VMCB_SAVE_STATE_AREA(vmcb);
74
75     v3_get_vmcb_segment(&(guest_area->cs), &(segs->cs));
76     v3_get_vmcb_segment(&(guest_area->ds), &(segs->ds));
77     v3_get_vmcb_segment(&(guest_area->es), &(segs->es));
78     v3_get_vmcb_segment(&(guest_area->fs), &(segs->fs));
79     v3_get_vmcb_segment(&(guest_area->gs), &(segs->gs));
80     v3_get_vmcb_segment(&(guest_area->ss), &(segs->ss));
81     v3_get_vmcb_segment(&(guest_area->ldtr), &(segs->ldtr));
82     v3_get_vmcb_segment(&(guest_area->gdtr), &(segs->gdtr));
83     v3_get_vmcb_segment(&(guest_area->idtr), &(segs->idtr));
84     v3_get_vmcb_segment(&(guest_area->tr), &(segs->tr));
85 }
86
87
88 void PrintDebugVMCB(vmcb_t * vmcb) {
89         int i;
90     reg_ex_t tmp_reg;
91
92     vmcb_ctrl_t * ctrl_area = GET_VMCB_CTRL_AREA(vmcb);
93     vmcb_saved_state_t * guest_area = GET_VMCB_SAVE_STATE_AREA(vmcb);
94
95     PrintDebug(VM_NONE, VCORE_NONE, "VMCB (0x%p)\n", (void *)vmcb);
96
97     PrintDebug(VM_NONE, VCORE_NONE, "--Control Area--\n");
98     PrintDebug(VM_NONE, VCORE_NONE, "CR Reads: 0x%x\n", *(ushort_t*)&(ctrl_area->cr_reads));
99     PrintDebug(VM_NONE, VCORE_NONE, "CR Writes: 0x%x\n", *(ushort_t*)&(ctrl_area->cr_writes));
100     PrintDebug(VM_NONE, VCORE_NONE, "DR Reads: 0x%x\n", *(ushort_t*)&(ctrl_area->dr_reads));
101     PrintDebug(VM_NONE, VCORE_NONE, "DR Writes: 0x%x\n", *(ushort_t*)&(ctrl_area->dr_writes));
102   
103     PrintDebug(VM_NONE, VCORE_NONE, "Exception Bitmap: 0x%x (at 0x%p)\n", *(uint_t*)&(ctrl_area->exceptions), (void *)&(ctrl_area->exceptions));
104     PrintDebug(VM_NONE, VCORE_NONE, "   Divide-by-Zero: %d\n", ctrl_area->exceptions.de);
105     PrintDebug(VM_NONE, VCORE_NONE, "   Debug: %d\n", ctrl_area->exceptions.db);
106     PrintDebug(VM_NONE, VCORE_NONE, "   Non-maskable interrupts: %d\n", ctrl_area->exceptions.nmi);
107     PrintDebug(VM_NONE, VCORE_NONE, "   Breakpoint: %d\n", ctrl_area->exceptions.bp);
108     PrintDebug(VM_NONE, VCORE_NONE, "   Overflow: %d\n", ctrl_area->exceptions.of);
109     PrintDebug(VM_NONE, VCORE_NONE, "   Bound-Range: %d\n", ctrl_area->exceptions.br);
110     PrintDebug(VM_NONE, VCORE_NONE, "   Invalid Opcode: %d\n", ctrl_area->exceptions.ud);
111     PrintDebug(VM_NONE, VCORE_NONE, "   Device not available: %d\n", ctrl_area->exceptions.nm);
112     PrintDebug(VM_NONE, VCORE_NONE, "   Double Fault: %d\n", ctrl_area->exceptions.df);
113     PrintDebug(VM_NONE, VCORE_NONE, "   Invalid TSS: %d\n", ctrl_area->exceptions.ts);
114     PrintDebug(VM_NONE, VCORE_NONE, "   Segment not present: %d\n", ctrl_area->exceptions.np);
115     PrintDebug(VM_NONE, VCORE_NONE, "   Stack: %d\n", ctrl_area->exceptions.ss);
116     PrintDebug(VM_NONE, VCORE_NONE, "   GPF: %d\n", ctrl_area->exceptions.gp);
117     PrintDebug(VM_NONE, VCORE_NONE, "   Page Fault: %d\n", ctrl_area->exceptions.pf);
118     PrintDebug(VM_NONE, VCORE_NONE, "   Floating Point: %d\n", ctrl_area->exceptions.mf);
119     PrintDebug(VM_NONE, VCORE_NONE, "   Alignment Check: %d\n", ctrl_area->exceptions.ac);
120     PrintDebug(VM_NONE, VCORE_NONE, "   Machine Check: %d\n", ctrl_area->exceptions.mc);
121     PrintDebug(VM_NONE, VCORE_NONE, "   SIMD floating point: %d\n", ctrl_area->exceptions.xf);
122     PrintDebug(VM_NONE, VCORE_NONE, "   Security: %d\n", ctrl_area->exceptions.sx);
123
124     PrintDebug(VM_NONE, VCORE_NONE, "Instructions bitmap: 0x%.8x (at 0x%p)\n", *(uint_t*)&(ctrl_area->instrs), &(ctrl_area->instrs));
125     PrintDebug(VM_NONE, VCORE_NONE, "   INTR: %d\n", ctrl_area->instrs.INTR);
126     PrintDebug(VM_NONE, VCORE_NONE, "   NMI: %d\n", ctrl_area->instrs.NMI);
127     PrintDebug(VM_NONE, VCORE_NONE, "   SMI: %d\n", ctrl_area->instrs.SMI);
128     PrintDebug(VM_NONE, VCORE_NONE, "   INIT: %d\n", ctrl_area->instrs.INIT);
129     PrintDebug(VM_NONE, VCORE_NONE, "   VINTR: %d\n", ctrl_area->instrs.VINTR);
130     PrintDebug(VM_NONE, VCORE_NONE, "   CR0: %d\n", ctrl_area->instrs.CR0);
131     PrintDebug(VM_NONE, VCORE_NONE, "   RD_IDTR: %d\n", ctrl_area->instrs.RD_IDTR);
132     PrintDebug(VM_NONE, VCORE_NONE, "   RD_GDTR: %d\n", ctrl_area->instrs.RD_GDTR);
133     PrintDebug(VM_NONE, VCORE_NONE, "   RD_LDTR: %d\n", ctrl_area->instrs.RD_LDTR);
134     PrintDebug(VM_NONE, VCORE_NONE, "   RD_TR: %d\n", ctrl_area->instrs.RD_TR);
135     PrintDebug(VM_NONE, VCORE_NONE, "   WR_IDTR: %d\n", ctrl_area->instrs.WR_IDTR);
136     PrintDebug(VM_NONE, VCORE_NONE, "   WR_GDTR: %d\n", ctrl_area->instrs.WR_GDTR);
137     PrintDebug(VM_NONE, VCORE_NONE, "   WR_LDTR: %d\n", ctrl_area->instrs.WR_LDTR);
138     PrintDebug(VM_NONE, VCORE_NONE, "   WR_TR: %d\n", ctrl_area->instrs.WR_TR);
139     PrintDebug(VM_NONE, VCORE_NONE, "   RDTSC: %d\n", ctrl_area->instrs.RDTSC);
140     PrintDebug(VM_NONE, VCORE_NONE, "   RDPMC: %d\n", ctrl_area->instrs.RDPMC);
141     PrintDebug(VM_NONE, VCORE_NONE, "   PUSHF: %d\n", ctrl_area->instrs.PUSHF);
142     PrintDebug(VM_NONE, VCORE_NONE, "   POPF: %d\n", ctrl_area->instrs.POPF);
143     PrintDebug(VM_NONE, VCORE_NONE, "   CPUID: %d\n", ctrl_area->instrs.CPUID);
144     PrintDebug(VM_NONE, VCORE_NONE, "   RSM: %d\n", ctrl_area->instrs.RSM);
145     PrintDebug(VM_NONE, VCORE_NONE, "   IRET: %d\n", ctrl_area->instrs.IRET);
146     PrintDebug(VM_NONE, VCORE_NONE, "   INTn: %d\n", ctrl_area->instrs.INTn);
147     PrintDebug(VM_NONE, VCORE_NONE, "   INVD: %d\n", ctrl_area->instrs.INVD);
148     PrintDebug(VM_NONE, VCORE_NONE, "   PAUSE: %d\n", ctrl_area->instrs.PAUSE);
149     PrintDebug(VM_NONE, VCORE_NONE, "   HLT: %d\n", ctrl_area->instrs.HLT);
150     PrintDebug(VM_NONE, VCORE_NONE, "   INVLPG: %d\n", ctrl_area->instrs.INVLPG);
151     PrintDebug(VM_NONE, VCORE_NONE, "   INVLPGA: %d\n", ctrl_area->instrs.INVLPGA);
152     PrintDebug(VM_NONE, VCORE_NONE, "   IOIO_PROT: %d\n", ctrl_area->instrs.IOIO_PROT);
153     PrintDebug(VM_NONE, VCORE_NONE, "   MSR_PROT: %d\n", ctrl_area->instrs.MSR_PROT);
154     PrintDebug(VM_NONE, VCORE_NONE, "   task_switch: %d\n", ctrl_area->instrs.task_switch);
155     PrintDebug(VM_NONE, VCORE_NONE, "   FERR_FREEZE: %d\n", ctrl_area->instrs.FERR_FREEZE);
156     PrintDebug(VM_NONE, VCORE_NONE, "   shutdown_evts: %d\n", ctrl_area->instrs.shutdown_evts);
157
158     PrintDebug(VM_NONE, VCORE_NONE, "SVM Instruction Bitmap: %x (at 0x%p)\n", *(uint_t*)&(ctrl_area->svm_instrs), &(ctrl_area->svm_instrs));
159     PrintDebug(VM_NONE, VCORE_NONE, "   VMRUN: %d\n", ctrl_area->svm_instrs.VMRUN);
160     PrintDebug(VM_NONE, VCORE_NONE, "   VMMCALL: %d\n", ctrl_area->svm_instrs.VMMCALL);
161     PrintDebug(VM_NONE, VCORE_NONE, "   VMLOAD: %d\n", ctrl_area->svm_instrs.VMLOAD);
162     PrintDebug(VM_NONE, VCORE_NONE, "   VMSAVE: %d\n", ctrl_area->svm_instrs.VMSAVE);
163     PrintDebug(VM_NONE, VCORE_NONE, "   STGI: %d\n", ctrl_area->svm_instrs.STGI);
164     PrintDebug(VM_NONE, VCORE_NONE, "   CLGI: %d\n", ctrl_area->svm_instrs.CLGI);
165     PrintDebug(VM_NONE, VCORE_NONE, "   SKINIT: %d\n", ctrl_area->svm_instrs.SKINIT);
166     PrintDebug(VM_NONE, VCORE_NONE, "   RDTSCP: %d\n", ctrl_area->svm_instrs.RDTSCP);
167     PrintDebug(VM_NONE, VCORE_NONE, "   ICEBP: %d\n", ctrl_area->svm_instrs.ICEBP);
168     PrintDebug(VM_NONE, VCORE_NONE, "   WBINVD: %d\n", ctrl_area->svm_instrs.WBINVD);
169     PrintDebug(VM_NONE, VCORE_NONE, "   MONITOR: %d\n", ctrl_area->svm_instrs.MONITOR);
170     PrintDebug(VM_NONE, VCORE_NONE, "   MWAIT_always: %d\n", ctrl_area->svm_instrs.MWAIT_always);
171     PrintDebug(VM_NONE, VCORE_NONE, "   MWAIT_if_armed: %d\n", ctrl_area->svm_instrs.MWAIT_if_armed);
172     PrintDebug(VM_NONE, VCORE_NONE, "   XSETBV: %d\n", ctrl_area->svm_instrs.XSETBV);
173     PrintDebug(VM_NONE, VCORE_NONE, "   Pause Filter Threshold: 0x%x\n", ctrl_area->pause_filter_threshold);
174     PrintDebug(VM_NONE, VCORE_NONE, "   Pause Filter Count: 0x%x\n", ctrl_area->pause_filter_count);
175
176
177     tmp_reg.r_reg = ctrl_area->IOPM_BASE_PA;
178     PrintDebug(VM_NONE, VCORE_NONE, "IOPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high);
179     tmp_reg.r_reg = ctrl_area->MSRPM_BASE_PA;
180     PrintDebug(VM_NONE, VCORE_NONE, "MSRPM_BASE_PA: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high);
181     tmp_reg.r_reg = ctrl_area->TSC_OFFSET;
182     PrintDebug(VM_NONE, VCORE_NONE, "TSC_OFFSET: lo: 0x%x, hi: 0x%x\n", tmp_reg.e_reg.low, tmp_reg.e_reg.high);
183
184     PrintDebug(VM_NONE, VCORE_NONE, "guest_ASID: 0x%x\n", ctrl_area->guest_ASID);
185     PrintDebug(VM_NONE, VCORE_NONE, "TLB_CONTROL: 0x%x\n", ctrl_area->TLB_CONTROL);
186
187     PrintDebug(VM_NONE, VCORE_NONE, "Guest Control Bitmap: 0x%x (at %p)\n", *(uint_t*)&(ctrl_area->guest_ctrl), &(ctrl_area->guest_ctrl));
188     PrintDebug(VM_NONE, VCORE_NONE, "   V_TPR: 0x%x\n", ctrl_area->guest_ctrl.V_TPR);
189     PrintDebug(VM_NONE, VCORE_NONE, "   V_IRQ: %d\n", ctrl_area->guest_ctrl.V_IRQ);
190     PrintDebug(VM_NONE, VCORE_NONE, "   V_INTR_PRIO: 0x%x\n", ctrl_area->guest_ctrl.V_INTR_PRIO);
191     PrintDebug(VM_NONE, VCORE_NONE, "   V_IGN_TPR: %d\n", ctrl_area->guest_ctrl.V_IGN_TPR);
192     PrintDebug(VM_NONE, VCORE_NONE, "   V_INTR_MASKING: %d\n", ctrl_area->guest_ctrl.V_INTR_MASKING);
193     PrintDebug(VM_NONE, VCORE_NONE, "   V_INTR_VECTOR: 0x%x\n", ctrl_area->guest_ctrl.V_INTR_VECTOR);
194
195     PrintDebug(VM_NONE, VCORE_NONE, "Interrupt_shadow: %d\n", ctrl_area->interrupt_shadow);
196
197
198     tmp_reg.r_reg = ctrl_area->exit_code;
199     PrintDebug(VM_NONE, VCORE_NONE, "exit_code: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
200     tmp_reg.r_reg = ctrl_area->exit_info1;
201     PrintDebug(VM_NONE, VCORE_NONE, "exit_info1: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
202     tmp_reg.r_reg = ctrl_area->exit_info2;
203     PrintDebug(VM_NONE, VCORE_NONE, "exit_info2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
204
205
206     PrintDebug(VM_NONE, VCORE_NONE, "Exit Int Info: (at %p)\n", &(ctrl_area->exit_int_info));
207     PrintDebug(VM_NONE, VCORE_NONE, "   Vector: 0x%x\n", ctrl_area->exit_int_info.vector);
208     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x) (ev=0x%x) (valid=0x%x)\n", ctrl_area->exit_int_info.type, 
209                ctrl_area->exit_int_info.ev, ctrl_area->exit_int_info.valid);
210     PrintDebug(VM_NONE, VCORE_NONE, "   Error Code: 0x%x\n", ctrl_area->exit_int_info.error_code);
211
212
213     PrintDebug(VM_NONE, VCORE_NONE, "NP_ENABLE: %d\n",ctrl_area->NP_ENABLE);
214
215     PrintDebug(VM_NONE, VCORE_NONE, "AVIC_APIC_BAR: 0x%llx\n", (uint64_t) ctrl_area->AVIC_APIC_BAR);
216
217     PrintDebug(VM_NONE, VCORE_NONE, "Event Injection: (at %p)\n", &(ctrl_area->EVENTINJ));
218     PrintDebug(VM_NONE, VCORE_NONE, "   Vector: 0x%x\n", ctrl_area->EVENTINJ.vector);
219     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x) (ev=0x%x) (valid=0x%x)\n", ctrl_area->EVENTINJ.type, 
220                ctrl_area->EVENTINJ.ev, ctrl_area->EVENTINJ.valid);
221     PrintDebug(VM_NONE, VCORE_NONE, "   Error Code: 0x%x\n", ctrl_area->EVENTINJ.error_code);
222
223
224     tmp_reg.r_reg = ctrl_area->N_CR3;
225     PrintDebug(VM_NONE, VCORE_NONE, "N_CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
226
227     PrintDebug(VM_NONE, VCORE_NONE, "LBR_VIRTUALIZATION_ENABLE: %d\n", ctrl_area->LBR_VIRTUALIZATION_ENABLE);
228
229     PrintDebug(VM_NONE, VCORE_NONE, "VMCB CLEAN BITS: 0x%x\n", ctrl_area->clean_bits);
230
231     PrintDebug(VM_NONE, VCORE_NONE, "NRIP: 0x%llx\n", ctrl_area->nrip);
232     
233     PrintDebug(VM_NONE, VCORE_NONE, "Instruction (at %p)\n", &ctrl_area->num_ifetch_bytes);
234
235     PrintDebug(VM_NONE, VCORE_NONE, "   num_ifetch_bytes=0x%x\n",ctrl_area->num_ifetch_bytes);
236     PrintDebug(VM_NONE,VCORE_NONE, "   bytes=0x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
237                ctrl_area->ifetch_bytes[0],
238                ctrl_area->ifetch_bytes[1],
239                ctrl_area->ifetch_bytes[2],
240                ctrl_area->ifetch_bytes[3],
241                ctrl_area->ifetch_bytes[4],
242                ctrl_area->ifetch_bytes[5],
243                ctrl_area->ifetch_bytes[6],
244                ctrl_area->ifetch_bytes[7],
245                ctrl_area->ifetch_bytes[8],
246                ctrl_area->ifetch_bytes[9],
247                ctrl_area->ifetch_bytes[10],
248                ctrl_area->ifetch_bytes[11],
249                ctrl_area->ifetch_bytes[12],
250                ctrl_area->ifetch_bytes[13],
251                ctrl_area->ifetch_bytes[14]);
252
253     PrintDebug(VM_NONE, VCORE_NONE, "AVIC_APIC_backing_page: 0x%llx\n", (uint64_t) ctrl_area->AVIC_APIC_backing_page);
254     PrintDebug(VM_NONE, VCORE_NONE, "AVIC_logical_table: 0x%llx\n",  (uint64_t)ctrl_area->AVIC_logical_table);
255     PrintDebug(VM_NONE, VCORE_NONE, "AVIC_PHYSICAL_MAX_INDEX: 0x%x\n", ctrl_area->AVIC_PHYSICAL_MAX_INDEX);
256     PrintDebug(VM_NONE, VCORE_NONE, "AVIC_PHYSICAL_TABLE_PTR: 0x%llx\n",  (uint64_t)ctrl_area->AVIC_PHYSICAL_TABLE_PTR);
257
258
259         for (i=0;i<40;i++) { 
260                 if (ctrl_area->rsvd1[i]) {
261                         PrintDebug(VM_NONE, VCORE_NONE, "control rsvd1[%d] has value 0x%x\n", i, ctrl_area->rsvd1[i]);
262                 }
263         }
264
265         for (i=0;i<4;i++) { 
266                 if (ctrl_area->rsvd2[i]) {
267                         PrintDebug(VM_NONE, VCORE_NONE, "control rsvd2[%d] has value 0x%x\n", i, ctrl_area->rsvd2[i]);
268                 }
269         }
270
271         if (ctrl_area->rsvd3) {
272                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd3 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd3);
273         }
274
275         if (ctrl_area->rsvd4) {
276                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd4 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd4);
277         }
278
279         if (ctrl_area->rsvd5) {
280                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd5 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd5);
281         }
282
283         for (i=0;i<8;i++) { 
284                 if (ctrl_area->rsvd6[i]) {
285                         PrintDebug(VM_NONE, VCORE_NONE, "control rsvd6[%d] has value 0x%x\n", i, ctrl_area->rsvd6[i]);
286                 }
287         }
288
289
290         if (ctrl_area->rsvd7) {
291                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd7 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd7);
292         }
293
294         if (ctrl_area->rsvd8) {
295                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd8 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd8);
296         }
297
298         if (ctrl_area->rsvd9) {
299                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd9 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd9);
300         }
301
302         if (ctrl_area->rsvd10) {
303                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd10 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd10);
304         }
305
306         if (ctrl_area->rsvd11) {
307                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd11 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd11);
308         }
309
310         if (ctrl_area->rsvd12) {
311                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd12 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd12);
312         }
313
314         if (ctrl_area->rsvd13) {
315                 PrintDebug(VM_NONE, VCORE_NONE, "control rsvd13 has value 0x%llx\n", (uint64_t) ctrl_area->rsvd13);
316         }
317
318
319         for (i=0;i<VMCB_CTRL_AREA_SIZE-0x100;i++) { 
320                 if (ctrl_area->rsvd_tail[i]) {
321                         PrintDebug(VM_NONE, VCORE_NONE, "control reserved tail %d has value 0x%x\n", i, ctrl_area->rsvd_tail[i]);
322                 }
323         }
324
325
326     PrintDebug(VM_NONE, VCORE_NONE, "\n--Guest Saved State--\n");
327
328     PrintDebug(VM_NONE, VCORE_NONE, "es Selector (at %p): \n", &(guest_area->es));
329     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->es.selector); 
330     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
331                guest_area->es.attrib.fields.type, guest_area->es.attrib.fields.S, 
332                guest_area->es.attrib.fields.dpl, guest_area->es.attrib.fields.P,
333                guest_area->es.attrib.fields.avl, guest_area->es.attrib.fields.L,
334                guest_area->es.attrib.fields.db, guest_area->es.attrib.fields.G);
335     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->es.limit);
336     tmp_reg.r_reg = guest_area->es.base;
337     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
338
339
340     PrintDebug(VM_NONE, VCORE_NONE, "cs Selector (at %p): \n", &(guest_area->cs));
341     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->cs.selector); 
342     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
343                guest_area->cs.attrib.fields.type, guest_area->cs.attrib.fields.S, 
344                guest_area->cs.attrib.fields.dpl, guest_area->cs.attrib.fields.P,
345                guest_area->cs.attrib.fields.avl, guest_area->cs.attrib.fields.L,
346                guest_area->cs.attrib.fields.db, guest_area->cs.attrib.fields.G);
347     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->cs.limit);
348     tmp_reg.r_reg = guest_area->cs.base;
349     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
350
351
352     PrintDebug(VM_NONE, VCORE_NONE, "ss Selector (at %p): \n", &(guest_area->ss));
353     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->ss.selector); 
354     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
355                guest_area->ss.attrib.fields.type, guest_area->ss.attrib.fields.S, 
356                guest_area->ss.attrib.fields.dpl, guest_area->ss.attrib.fields.P,
357                guest_area->ss.attrib.fields.avl, guest_area->ss.attrib.fields.L,
358                guest_area->ss.attrib.fields.db, guest_area->ss.attrib.fields.G);
359     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->ss.limit);
360     tmp_reg.r_reg = guest_area->ss.base;
361     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
362
363
364     PrintDebug(VM_NONE, VCORE_NONE, "ds Selector (at %p): \n", &(guest_area->ds));
365     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->ds.selector); 
366     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
367                guest_area->ds.attrib.fields.type, guest_area->ds.attrib.fields.S, 
368                guest_area->ds.attrib.fields.dpl, guest_area->ds.attrib.fields.P,
369                guest_area->ds.attrib.fields.avl, guest_area->ds.attrib.fields.L,
370                guest_area->ds.attrib.fields.db, guest_area->ds.attrib.fields.G);
371     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->ds.limit);
372     tmp_reg.r_reg = guest_area->ds.base;
373     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
374
375
376     PrintDebug(VM_NONE, VCORE_NONE, "fs Selector (at %p): \n", &(guest_area->fs));
377     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->fs.selector); 
378     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
379                guest_area->fs.attrib.fields.type, guest_area->fs.attrib.fields.S, 
380                guest_area->fs.attrib.fields.dpl, guest_area->fs.attrib.fields.P,
381                guest_area->fs.attrib.fields.avl, guest_area->fs.attrib.fields.L,
382                guest_area->fs.attrib.fields.db, guest_area->fs.attrib.fields.G);
383     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->fs.limit);
384     tmp_reg.r_reg = guest_area->fs.base;
385     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
386
387
388     PrintDebug(VM_NONE, VCORE_NONE, "gs Selector (at %p): \n", &(guest_area->gs));
389     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->gs.selector); 
390     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
391                guest_area->gs.attrib.fields.type, guest_area->gs.attrib.fields.S, 
392                guest_area->gs.attrib.fields.dpl, guest_area->gs.attrib.fields.P,
393                guest_area->gs.attrib.fields.avl, guest_area->gs.attrib.fields.L,
394                guest_area->gs.attrib.fields.db, guest_area->gs.attrib.fields.G);
395     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->gs.limit);
396     tmp_reg.r_reg = guest_area->gs.base;
397     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
398
399
400     PrintDebug(VM_NONE, VCORE_NONE, "gdtr Selector (at %p): \n", &(guest_area->gdtr));
401     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->gdtr.selector); 
402     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
403                guest_area->gdtr.attrib.fields.type, guest_area->gdtr.attrib.fields.S, 
404                guest_area->gdtr.attrib.fields.dpl, guest_area->gdtr.attrib.fields.P,
405                guest_area->gdtr.attrib.fields.avl, guest_area->gdtr.attrib.fields.L,
406                guest_area->gdtr.attrib.fields.db, guest_area->gdtr.attrib.fields.G);
407     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->gdtr.limit);
408     tmp_reg.r_reg = guest_area->gdtr.base;
409     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
410
411
412     PrintDebug(VM_NONE, VCORE_NONE, "ldtr Selector (at %p): \n", &(guest_area->ldtr));
413     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->ldtr.selector); 
414     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
415                guest_area->ldtr.attrib.fields.type, guest_area->ldtr.attrib.fields.S, 
416                guest_area->ldtr.attrib.fields.dpl, guest_area->ldtr.attrib.fields.P,
417                guest_area->ldtr.attrib.fields.avl, guest_area->ldtr.attrib.fields.L,
418                guest_area->ldtr.attrib.fields.db, guest_area->ldtr.attrib.fields.G);
419     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->ldtr.limit);
420     tmp_reg.r_reg = guest_area->ldtr.base;
421     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%.8x, lo: 0x%.8x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
422
423
424     PrintDebug(VM_NONE, VCORE_NONE, "idtr Selector (at %p): \n", &(guest_area->idtr));
425     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->idtr.selector); 
426     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
427                guest_area->idtr.attrib.fields.type, guest_area->idtr.attrib.fields.S, 
428                guest_area->idtr.attrib.fields.dpl, guest_area->idtr.attrib.fields.P,
429                guest_area->idtr.attrib.fields.avl, guest_area->idtr.attrib.fields.L,
430                guest_area->idtr.attrib.fields.db, guest_area->idtr.attrib.fields.G);
431     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->idtr.limit);
432     tmp_reg.r_reg = guest_area->idtr.base;
433     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
434
435
436     PrintDebug(VM_NONE, VCORE_NONE, "tr Selector (at %p): \n", &(guest_area->tr));
437     PrintDebug(VM_NONE, VCORE_NONE, "   Selector: 0x%x\n", guest_area->tr.selector); 
438     PrintDebug(VM_NONE, VCORE_NONE, "   (type=0x%x), (S=%d), (dpl=%d), (P=%d), (avl=%d), (L=%d), (db=%d), (G=%d)\n", 
439                guest_area->tr.attrib.fields.type, guest_area->tr.attrib.fields.S, 
440                guest_area->tr.attrib.fields.dpl, guest_area->tr.attrib.fields.P,
441                guest_area->tr.attrib.fields.avl, guest_area->tr.attrib.fields.L,
442                guest_area->tr.attrib.fields.db, guest_area->tr.attrib.fields.G);
443     PrintDebug(VM_NONE, VCORE_NONE, "   limit: 0x%x\n", guest_area->tr.limit);
444     tmp_reg.r_reg = guest_area->tr.base;
445     PrintDebug(VM_NONE, VCORE_NONE, "   Base: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
446
447
448     PrintDebug(VM_NONE, VCORE_NONE, "cpl: %d\n", guest_area->cpl);
449
450   
451     tmp_reg.r_reg = guest_area->efer;
452     PrintDebug(VM_NONE, VCORE_NONE, "EFER: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
453
454     tmp_reg.r_reg = guest_area->cr4;
455     PrintDebug(VM_NONE, VCORE_NONE, "CR4: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
456     tmp_reg.r_reg = guest_area->cr3;
457     PrintDebug(VM_NONE, VCORE_NONE, "CR3: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
458     tmp_reg.r_reg = guest_area->cr0;
459     PrintDebug(VM_NONE, VCORE_NONE, "CR0: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
460     tmp_reg.r_reg = guest_area->dr7;
461     PrintDebug(VM_NONE, VCORE_NONE, "DR7: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
462     tmp_reg.r_reg = guest_area->dr6;
463     PrintDebug(VM_NONE, VCORE_NONE, "DR6: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
464     tmp_reg.r_reg = guest_area->rflags;
465     PrintDebug(VM_NONE, VCORE_NONE, "RFLAGS: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
466     tmp_reg.r_reg = guest_area->rip;
467     PrintDebug(VM_NONE, VCORE_NONE, "RIP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
468
469
470     tmp_reg.r_reg = guest_area->rsp;
471     PrintDebug(VM_NONE, VCORE_NONE, "RSP: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
472
473   
474     tmp_reg.r_reg = guest_area->rax;
475     PrintDebug(VM_NONE, VCORE_NONE, "RAX: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
476     tmp_reg.r_reg = guest_area->star;
477     PrintDebug(VM_NONE, VCORE_NONE, "STAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
478     tmp_reg.r_reg = guest_area->lstar;
479     PrintDebug(VM_NONE, VCORE_NONE, "LSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
480     tmp_reg.r_reg = guest_area->cstar;
481     PrintDebug(VM_NONE, VCORE_NONE, "CSTAR: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
482     tmp_reg.r_reg = guest_area->sfmask;
483     PrintDebug(VM_NONE, VCORE_NONE, "SFMASK: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
484     tmp_reg.r_reg = guest_area->KernelGsBase;
485     PrintDebug(VM_NONE, VCORE_NONE, "KernelGsBase: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
486     tmp_reg.r_reg = guest_area->sysenter_cs;
487     PrintDebug(VM_NONE, VCORE_NONE, "sysenter_cs: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
488     tmp_reg.r_reg = guest_area->sysenter_esp;
489     PrintDebug(VM_NONE, VCORE_NONE, "sysenter_esp: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
490     tmp_reg.r_reg = guest_area->sysenter_eip;
491     PrintDebug(VM_NONE, VCORE_NONE, "sysenter_eip: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
492     tmp_reg.r_reg = guest_area->cr2;
493     PrintDebug(VM_NONE, VCORE_NONE, "CR2: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
494
495     tmp_reg.r_reg = guest_area->g_pat;
496     PrintDebug(VM_NONE, VCORE_NONE, "g_pat: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
497     tmp_reg.r_reg = guest_area->dbgctl;
498     PrintDebug(VM_NONE, VCORE_NONE, "dbgctl: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
499     tmp_reg.r_reg = guest_area->br_from;
500     PrintDebug(VM_NONE, VCORE_NONE, "br_from: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
501     tmp_reg.r_reg = guest_area->br_to;
502     PrintDebug(VM_NONE, VCORE_NONE, "br_to: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
503     tmp_reg.r_reg = guest_area->lastexcpfrom;
504     PrintDebug(VM_NONE, VCORE_NONE, "lastexcpfrom: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
505     tmp_reg.r_reg = guest_area->lastexcpto;
506     PrintDebug(VM_NONE, VCORE_NONE, "lastexcpto: hi: 0x%x, lo: 0x%x\n", tmp_reg.e_reg.high, tmp_reg.e_reg.low);
507
508         for (i=0;i<43;i++) { 
509                 if (guest_area->rsvd1[i]) {
510                         PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd1[%d] has value 0x%x\n", i, guest_area->rsvd1[i]);
511                 }
512         }
513
514         if (guest_area->rsvd2) {
515                 PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd2 has value 0x%llx\n", (uint64_t) guest_area->rsvd2);
516         }
517
518         for (i=0;i<112;i++) { 
519                 if (guest_area->rsvd3[i]) {
520                         PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd3[%d] has value 0x%x\n", i, guest_area->rsvd3[i]);
521                 }
522         }
523
524         for (i=0;i<88;i++) { 
525                 if (guest_area->rsvd4[i]) {
526                         PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd4[%d] has value 0x%x\n", i, guest_area->rsvd4[i]);
527                 }
528         }
529
530         for (i=0;i<24;i++) { 
531                 if (guest_area->rsvd5[i]) {
532                         PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd5[%d] has value 0x%x\n", i, guest_area->rsvd5[i]);
533                 }
534         }
535
536         for (i=0;i<32;i++) { 
537                 if (guest_area->rsvd6[i]) {
538                         PrintDebug(VM_NONE, VCORE_NONE, "guest rsvd6[%d] has value 0x%x\n", i, guest_area->rsvd6[i]);
539                 }
540         }
541
542
543         for (i=VMCB_END_OFFSET; i<VMCB_TOTAL_SIZE; i++) {
544                 if (((uint8_t*)vmcb)[i]) {
545                         PrintDebug(VM_NONE, VCORE_NONE, "VMCB reserved offset %d has value 0x%x\n", i,((uint8_t*)vmcb)[i]);
546                 }
547         }
548
549 }