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.


added profiling support
[palacios.git] / palacios / src / palacios / vmm_paging_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 #ifdef USE_VMM_PAGING_DEBUG
21
22 /* 
23  * 
24  *  This is an implementation file that gets included only in vmm_paging.c
25  * 
26  */
27
28
29 static void PrintPDE32(addr_t virtual_address, pde32_t * pde)
30 {
31   PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
32              (void *)virtual_address,
33              (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER),
34              pde->present,
35              pde->writable,
36              pde->user_page, 
37              pde->write_through,
38              pde->cache_disable,
39              pde->accessed,
40              pde->reserved,
41              pde->large_page,
42              pde->global_page,
43              pde->vmm_info);
44 }
45
46   
47 static void PrintPTE32(addr_t virtual_address, pte32_t * pte)
48 {
49   PrintDebug("PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n",
50              (void *)virtual_address,
51              (void*)(addr_t)(pte->page_base_addr << PAGE_POWER),
52              pte->present,
53              pte->writable,
54              pte->user_page,
55              pte->write_through,
56              pte->cache_disable,
57              pte->accessed,
58              pte->dirty,
59              pte->pte_attr,
60              pte->global_page,
61              pte->vmm_info);
62 }
63
64
65
66
67
68
69
70
71 static void PrintPDPE32PAE(addr_t virtual_address, pdpe32pae_t * pdpe)
72 {
73   PrintDebug("PDPE %p -> %p : present=%x, wt=%x, cd=%x, accessed=%x, kernelInfo=%x\n",
74              (void *)virtual_address,
75              (void *)(addr_t) (pdpe->pd_base_addr << PAGE_POWER),
76              pdpe->present,
77              pdpe->write_through,
78              pdpe->cache_disable,
79              pdpe->accessed,
80              pdpe->vmm_info);
81 }
82
83 static void PrintPDE32PAE(addr_t virtual_address, pde32pae_t * pde)
84 {
85   PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
86              (void *)virtual_address,
87              (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER),
88              pde->present,
89              pde->writable,
90              pde->user_page, 
91              pde->write_through,
92              pde->cache_disable,
93              pde->accessed,
94              pde->large_page,
95              pde->global_page,
96              pde->vmm_info);
97 }
98
99   
100 static void PrintPTE32PAE(addr_t virtual_address, pte32pae_t * pte)
101 {
102   PrintDebug("PTE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n",
103              (void *)virtual_address,
104              (void*)(addr_t)(pte->page_base_addr << PAGE_POWER),
105              pte->present,
106              pte->writable,
107              pte->user_page,
108              pte->write_through,
109              pte->cache_disable,
110              pte->accessed,
111              pte->dirty,
112              pte->pte_attr,
113              pte->global_page,
114              pte->vmm_info);
115 }
116
117
118
119
120
121
122
123
124 static void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml)
125 {
126   PrintDebug("PML4e64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, kernelInfo=%x\n",
127              (void *)virtual_address,
128              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pml->pdp_base_addr)),
129              pml->present,
130              pml->writable,
131              pml->user_page, 
132              pml->write_through,
133              pml->cache_disable,
134              pml->accessed,
135              pml->reserved,
136              pml->vmm_info);
137 }
138
139 static void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe)
140 {
141   PrintDebug("PDPE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage/zero=%x, kernelInfo=%x\n",
142              (void *)virtual_address,
143              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pdpe->pd_base_addr)),
144              pdpe->present,
145              pdpe->writable,
146              pdpe->user_page, 
147              pdpe->write_through,
148              pdpe->cache_disable,
149              pdpe->accessed,
150              pdpe->avail,
151              pdpe->large_page,
152              pdpe->zero,
153              pdpe->vmm_info);
154 }
155
156
157
158 static void PrintPDE64(addr_t virtual_address, pde64_t * pde)
159 {
160   PrintDebug("PDE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
161              (void *)virtual_address,
162              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pde->pt_base_addr)),
163              pde->present,
164              pde->writable,
165              pde->user_page, 
166              pde->write_through,
167              pde->cache_disable,
168              pde->accessed,
169              pde->avail,
170              pde->large_page,
171              pde->global_page,
172              pde->vmm_info);
173 }
174
175   
176 static void PrintPTE64(addr_t virtual_address, pte64_t * pte)
177 {
178   PrintDebug("PTE64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, dirty=%x, pteAttribute=%x, globalPage=%x, vmm_info=%x\n",
179              (void *)virtual_address,
180              (void*)(addr_t)(BASE_TO_PAGE_ADDR(pte->page_base_addr)),
181              pte->present,
182              pte->writable,
183              pte->user_page,
184              pte->write_through,
185              pte->cache_disable,
186              pte->accessed,
187              pte->dirty,
188              pte->pte_attr,
189              pte->global_page,
190              pte->vmm_info);
191 }
192
193   
194
195
196
197
198
199
200
201
202
203
204
205
206 static int print_page_tree_cb(page_type_t type, addr_t vaddr, addr_t page_ptr, addr_t page_pa, void * private_data) {
207
208   switch (type) {
209
210     /* 64 Bit */
211
212   case PAGE_PML464:
213     {
214       pml4e64_t * pml = (pml4e64_t *)page_ptr;
215       PrintPML4e64(vaddr, &(pml[PML4E64_INDEX(vaddr)]));
216       break;
217     }
218   case PAGE_PDP64:
219     {
220       pdpe64_t * pdp = (pdpe64_t *)page_ptr;
221       PrintPDPE64(vaddr, &(pdp[PDPE64_INDEX(vaddr)]));
222       break;
223     }
224   case PAGE_PD64:
225     {
226       pde64_t * pd = (pde64_t *)page_ptr;
227       PrintPDE64(vaddr, &(pd[PDE64_INDEX(vaddr)]));
228       break;
229     }
230   case PAGE_PT64:
231     {
232       pte64_t * pt = (pte64_t *)page_ptr;
233       PrintPTE64(vaddr, &(pt[PTE64_INDEX(vaddr)]));
234       break;
235     }
236
237     /* 32 BIT PAE */
238     
239   case PAGE_PDP32PAE:
240     {
241       pdpe32pae_t * pdp = (pdpe32pae_t *)page_ptr;
242       PrintPDPE32PAE(vaddr, &(pdp[PDPE32PAE_INDEX(vaddr)]));
243       break;
244     }
245   case PAGE_PD32PAE:
246     {
247       pde32pae_t * pd = (pde32pae_t *)page_ptr;
248       PrintPDE32PAE(vaddr, &(pd[PDE32PAE_INDEX(vaddr)]));
249       break;
250     }
251   case PAGE_PT32PAE:
252     {
253       pte32pae_t * pt = (pte32pae_t *)page_ptr;
254       PrintPTE32PAE(vaddr, &(pt[PTE32PAE_INDEX(vaddr)]));
255       break;
256     }
257
258     /* 32 Bit */
259
260   case PAGE_PD32:
261     {
262       pde32_t * pd = (pde32_t *)page_ptr;
263       PrintPDE32(vaddr, &(pd[PDE32_INDEX(vaddr)]));
264       break;
265     }
266   case PAGE_PT32:
267     {
268       pte32_t * pt = (pte32_t *)page_ptr;
269       PrintPTE32(vaddr, &(pt[PTE32_INDEX(vaddr)]));
270       break;
271     }
272   default:
273     PrintDebug("%s %p->%p \n", v3_page_type_to_str(type), (void *)vaddr, (void *)page_pa);
274     break;
275   }
276
277   return 0;
278 }
279
280
281
282 void PrintPTEntry(page_type_t type, addr_t vaddr, void * entry) {
283   print_page_tree_cb(type, vaddr, PAGE_ADDR_4KB((addr_t)entry), 0, NULL);
284 }
285
286
287 void PrintHostPageTables(v3_vm_cpu_mode_t cpu_mode, addr_t cr3) {
288   switch (cpu_mode) {
289   case PROTECTED:
290     v3_walk_host_pt_32(cr3, print_page_tree_cb, NULL);
291   case PROTECTED_PAE:
292     v3_walk_host_pt_32pae(cr3, print_page_tree_cb, NULL);
293   case LONG:
294   case LONG_32_COMPAT:
295   case LONG_16_COMPAT:
296     v3_walk_host_pt_64(cr3, print_page_tree_cb, NULL);
297     break;
298   default:
299     PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(cpu_mode));
300     break;
301   }
302 }
303
304
305 void PrintGuestPageTables(struct guest_info * info, addr_t cr3) {
306   switch (info->cpu_mode) {
307   case PROTECTED:
308     v3_walk_guest_pt_32(info, cr3, print_page_tree_cb, NULL);
309   case PROTECTED_PAE:
310     v3_walk_guest_pt_32pae(info, cr3, print_page_tree_cb, NULL);
311   case LONG:
312   case LONG_32_COMPAT:
313   case LONG_16_COMPAT:
314     v3_walk_guest_pt_64(info, cr3, print_page_tree_cb, NULL);
315     break;
316   default:
317     PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode));
318     break;
319   }
320 }
321
322 void PrintHostPageTree(v3_vm_cpu_mode_t cpu_mode, addr_t virtual_addr, addr_t cr3) {
323   switch (cpu_mode) {
324   case PROTECTED:
325     v3_drill_host_pt_32(cr3, virtual_addr, print_page_tree_cb, NULL);
326   case PROTECTED_PAE:
327     v3_drill_host_pt_32pae(cr3, virtual_addr, print_page_tree_cb, NULL);
328   case LONG:
329   case LONG_32_COMPAT:
330   case LONG_16_COMPAT:
331     v3_drill_host_pt_64(cr3, virtual_addr, print_page_tree_cb, NULL);
332     break;
333   default:
334     PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(cpu_mode));
335     break;
336   }
337 }
338
339 void PrintGuestPageTree(struct guest_info * info, addr_t virtual_addr, addr_t cr3) {
340   switch (info->cpu_mode) {
341   case PROTECTED:
342     v3_drill_guest_pt_32(info, cr3, virtual_addr, print_page_tree_cb, NULL);
343   case PROTECTED_PAE:
344     v3_drill_guest_pt_32pae(info, cr3, virtual_addr, print_page_tree_cb, NULL);
345   case LONG:
346   case LONG_32_COMPAT:
347   case LONG_16_COMPAT:
348     v3_drill_guest_pt_64(info, cr3, virtual_addr, print_page_tree_cb, NULL);
349     break;
350   default:
351     PrintError("Unsupported CPU MODE %s\n", v3_cpu_mode_to_str(info->cpu_mode));
352     break;
353   }
354 }
355
356
357 #endif