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.


More debugging output (APIC, LDT, etc)
[palacios.git] / palacios / include / palacios / vmm_debug.h
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
21 #ifndef __VMM_DEBUG_H__
22 #define __VMM_DEBUG_H__
23
24
25 #ifdef __V3VEE__
26
27 #include <palacios/vmm.h>
28 #include <palacios/vmm_regs.h>
29
30 #define NUM_IDT_ENTRIES 256
31 #define NUM_GDT_ENTRIES 16
32 #define NUM_LDT_ENTRIES 16
33
34 struct segment_selector {
35     uint8_t  rpl        :  2;
36     uint8_t  ti         :  1;
37     uint16_t index      : 13;
38 }__attribute__((packed));
39
40 struct int_trap_gate_long {
41     uint16_t offset_lo  : 16;
42     uint16_t selector   : 16;
43     uint8_t  ist        :  3;
44     uint8_t  ign        :  5;
45     uint8_t  type       :  4;
46     uint8_t  s          :  1;
47     uint8_t  dpl        :  2;
48     uint8_t  p          :  1;
49     uint16_t offset_mid : 16;
50     uint32_t offset_hi  : 32;
51     uint32_t ign2       : 32;
52 }__attribute__((packed));
53
54 struct call_gate_long {
55     uint16_t offset_lo  : 16;
56     uint16_t selector   : 16;
57     uint8_t  ign        :  8;
58     uint8_t  type       :  4;
59     uint8_t  s          :  1;
60     uint8_t  dpl        :  2;
61     uint8_t  p          :  1;
62     uint16_t offset_mid : 16;
63     uint32_t offset_hi  : 32;
64     uint8_t  ign2       :  8;
65     uint8_t  count      :  5;
66     uint32_t ign3       : 19;
67 }__attribute__((packed));
68
69 struct system_desc_long {
70     uint16_t limit_lo   : 16;
71     uint16_t base_lo    : 16;
72     uint8_t  base_mid1  :  8;
73     uint8_t  type       :  4;
74     uint8_t  s          :  1;
75     uint8_t  dpl        :  2;
76     uint8_t  p          :  1;
77     uint8_t  limit_hi   :  4;
78     uint8_t  avl        :  1;
79     uint8_t  ign        :  2;
80     uint8_t  g          :  1;
81     uint8_t  base_mid2  :  8;
82     uint32_t base_hi    : 32;
83     uint8_t  ign2       :  8;
84     uint8_t  lgcy_type  :  5;
85     uint32_t ign3       : 19;
86 }__attribute__((packed));
87
88 struct data_desc_long {
89     uint16_t limit_lo   : 16;
90     uint16_t base_lo    : 16;
91     uint8_t  base_mid   :  8;
92     uint8_t  a          :  1;
93     uint8_t  w          :  1;
94     uint8_t  e          :  1;
95     uint8_t  zero       :  1;
96     uint8_t  one        :  1;
97     uint8_t  dpl        :  2;
98     uint8_t  p          :  1;
99     uint8_t  limit_hi   :  4;
100     uint8_t  avl        :  1;
101     uint8_t  ign        :  1;
102     uint8_t  db         :  1;
103     uint8_t  g          :  1;
104     uint8_t  base_hi    :  8;
105 }__attribute__((packed));
106
107 struct code_desc_long {
108     uint16_t limit_lo   : 16;
109     uint16_t base_lo    : 16;
110     uint8_t  base_mid   :  8;
111     uint8_t  a          :  1;
112     uint8_t  r          :  1;
113     uint8_t  c          :  1;
114     uint8_t  one1       :  1;
115     uint8_t  one2       :  1;
116     uint8_t  dpl        :  2;
117     uint8_t  p          :  1;
118     uint8_t  limit_hi   :  4;
119     uint8_t  avl        :  1;
120     uint8_t  l          :  1;
121     uint8_t  d          :  1;
122     uint8_t  g          :  1;
123     uint8_t  base_hi    :  8;
124 }__attribute__((packed));
125
126 struct int_trap_gate_lgcy {
127     uint16_t offset_lo  : 16;
128     uint16_t selector   : 16;
129     uint8_t  ign        :  8;
130     uint8_t  type       :  4;
131     uint8_t  s          :  1;
132     uint8_t  dpl        :  2;
133     uint8_t  p          :  1;
134     uint16_t offset_hi  : 16;
135 }__attribute__((packed));
136
137 struct call_gate_lgcy {
138     uint16_t offset_lo  : 16;
139     uint16_t selector   : 16;
140     uint8_t  count      :  4;
141     uint8_t  ign        :  4;
142     uint8_t  type       :  4;
143     uint8_t  s          :  1;
144     uint8_t  dpl        :  2;
145     uint8_t  p          :  1;
146     uint16_t offset_hi  : 16;
147 }__attribute__((packed));
148
149 struct trap_gate_lgcy {
150     uint16_t ign        : 16;
151     uint16_t selector   : 16;
152     uint8_t  ign2       :  8;
153     uint8_t  type       :  4;
154     uint8_t  s          :  1;
155     uint8_t  dpl        :  2;
156     uint8_t  p          :  1;
157     uint16_t ign3       : 16;
158 }__attribute__((packed));
159
160 struct system_desc_lgcy {
161     uint16_t limit_lo   : 16;
162     uint16_t base_lo    : 16;
163     uint8_t  base_mid   :  8;
164     uint8_t  type       :  4;
165     uint8_t  s          :  1;
166     uint8_t  dpl        :  2;
167     uint8_t  p          :  1;
168     uint8_t  limit_hi   :  4;
169     uint8_t  avl        :  1;
170     uint8_t  ign        :  2;
171     uint8_t  g          :  1;
172     uint8_t  base_hi    :  8;
173 }__attribute__((packed));
174
175 struct data_desc_lgcy {
176     uint16_t limit_lo   : 16;
177     uint16_t base_lo    : 16;
178     uint8_t  base_mid   :  8;
179     uint8_t  type       :  4;
180     uint8_t  s          :  1;
181     uint8_t  dpl        :  2;
182     uint8_t  p          :  1;
183     uint8_t  limit_hi   :  4;
184     uint8_t  avl        :  1;
185     uint8_t  ign        :  1;
186     uint8_t  db         :  1;
187     uint8_t  g          :  1;
188     uint8_t  base_hi    :  8;
189 }__attribute__((packed));
190
191 struct code_desc_lgcy {
192     uint16_t limit_lo   : 16;
193     uint16_t base_lo    : 16;
194     uint8_t  base_mid   :  8;
195     uint8_t  type       :  4;
196     uint8_t  s          :  1;
197     uint8_t  dpl        :  2;
198     uint8_t  p          :  1;
199     uint8_t  limit_hi   :  4;
200     uint8_t  avl        :  1;
201     uint8_t  ign        :  1;
202     uint8_t  d          :  1;
203     uint8_t  g          :  1;
204     uint8_t  base_hi    :  8;
205 }__attribute__((packed));
206         
207
208 struct selector_error_code {
209     uint8_t  ext        :  1;
210     uint8_t  idt        :  1;
211     uint8_t  ti         :  1;
212     uint16_t index      : 13;
213     uint16_t ign        : 16;
214 }__attribute__((packed));
215
216 struct tss_long {
217     uint32_t res1;
218     uint64_t rsp0;
219     uint64_t rsp1;
220     uint64_t rsp2;
221     uint64_t res2;
222     uint64_t ist1;
223     uint64_t ist2;
224     uint64_t ist3;
225     uint64_t ist4;
226     uint64_t ist5;
227     uint64_t ist6;
228     uint64_t ist7;
229     uint64_t res3;
230     uint32_t res4;
231     uint32_t iomap_base;
232     // Followed by up to 8 KB of io permission bitmap
233 } __attribute__((packed));
234
235
236 int v3_init_vm_debugging(struct v3_vm_info * vm);
237
238 void v3_print_guest_state(struct guest_info * core);
239 void v3_print_arch_state(struct guest_info * core);
240
241 void v3_print_segments(struct v3_segments * segs);
242 void v3_print_ctrl_regs(struct guest_info * core);
243 void v3_print_GPRs(struct guest_info * core);
244
245 void v3_print_backtrace(struct guest_info * core);
246 void v3_print_stack(struct guest_info * core);
247 void v3_print_guest_state_all(struct v3_vm_info * vm);
248
249 void v3_print_idt(struct guest_info * core, addr_t idtr_base);
250 void v3_print_gdt(struct guest_info * core, addr_t gdtr_base);
251 void v3_print_ldt(struct guest_info * core, addr_t ldtr_base);
252 void v3_print_tss(struct guest_info * core, addr_t ldtr_base);
253 void v3_print_gp_error(struct guest_info * core, addr_t exit_info1);
254
255 #endif // !__V3VEE__
256
257 #endif