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.


c87e829df0b6e5d5319ae97391f3bfb48b0cf51e
[palacios.git] / palacios / src / palacios / vmm_paging_debug.h
1
2 #ifdef USE_VMM_PAGING_DEBUG
3
4 /* 
5  * 
6  *  This is an implementation file that gets included only in vmm_paging.c
7  * 
8  */
9
10
11 void PrintPDE32(addr_t virtual_address, pde32_t * pde)
12 {
13   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",
14              (void *)virtual_address,
15              (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER),
16              pde->present,
17              pde->writable,
18              pde->user_page, 
19              pde->write_through,
20              pde->cache_disable,
21              pde->accessed,
22              pde->reserved,
23              pde->large_page,
24              pde->global_page,
25              pde->vmm_info);
26 }
27
28   
29 void PrintPTE32(addr_t virtual_address, pte32_t * pte)
30 {
31   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",
32              (void *)virtual_address,
33              (void*)(addr_t)(pte->page_base_addr << PAGE_POWER),
34              pte->present,
35              pte->writable,
36              pte->user_page,
37              pte->write_through,
38              pte->cache_disable,
39              pte->accessed,
40              pte->dirty,
41              pte->pte_attr,
42              pte->global_page,
43              pte->vmm_info);
44 }
45
46
47
48
49
50
51
52
53
54
55 void PrintPD32(pde32_t * pde)
56 {
57   int i;
58
59   PrintDebug("Page Directory at %p:\n", pde);
60   for (i = 0; (i < MAX_PDE32_ENTRIES); i++) { 
61     if ( pde[i].present) {
62       PrintPDE32((addr_t)(PAGE_SIZE * MAX_PTE32_ENTRIES * i), &(pde[i]));
63     }
64   }
65 }
66
67 void PrintPT32(addr_t starting_address, pte32_t * pte) 
68 {
69   int i;
70
71   PrintDebug("Page Table at %p:\n", pte);
72   for (i = 0; (i < MAX_PTE32_ENTRIES) ; i++) { 
73     if (pte[i].present) {
74       PrintPTE32(starting_address + (PAGE_SIZE * i), &(pte[i]));
75     }
76   }
77 }
78
79
80
81
82
83
84
85 void PrintDebugPageTables(pde32_t * pde)
86 {
87   int i;
88   
89   PrintDebug("Dumping the pages starting with the pde page at %p\n", pde);
90
91   for (i = 0; (i < MAX_PDE32_ENTRIES); i++) { 
92     if (pde[i].present) {
93       PrintPDE32((addr_t)(PAGE_SIZE * MAX_PTE32_ENTRIES * i), &(pde[i]));
94       PrintPT32((addr_t)(PAGE_SIZE * MAX_PTE32_ENTRIES * i), (pte32_t *)V3_VAddr((void *)(addr_t)(pde[i].pt_base_addr << PAGE_POWER)));
95     }
96   }
97 }
98     
99
100
101
102
103
104
105
106 void PrintPDPE32PAE(addr_t virtual_address, pdpe32pae_t * pdpe)
107 {
108   PrintDebug("PDPE %p -> %p : present=%x, wt=%x, cd=%x, accessed=%x, kernelInfo=%x\n",
109              (void *)virtual_address,
110              (void *)(addr_t) (pdpe->pd_base_addr << PAGE_POWER),
111              pdpe->present,
112              pdpe->write_through,
113              pdpe->cache_disable,
114              pdpe->accessed,
115              pdpe->vmm_info);
116 }
117
118 void PrintPDE32PAE(addr_t virtual_address, pde32pae_t * pde)
119 {
120   PrintDebug("PDE %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, largePages=%x, globalPage=%x, kernelInfo=%x\n",
121              (void *)virtual_address,
122              (void *)(addr_t) (pde->pt_base_addr << PAGE_POWER),
123              pde->present,
124              pde->writable,
125              pde->user_page, 
126              pde->write_through,
127              pde->cache_disable,
128              pde->accessed,
129              pde->large_page,
130              pde->global_page,
131              pde->vmm_info);
132 }
133
134   
135 void PrintPTE32PAE(addr_t virtual_address, pte32pae_t * pte)
136 {
137   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",
138              (void *)virtual_address,
139              (void*)(addr_t)(pte->page_base_addr << PAGE_POWER),
140              pte->present,
141              pte->writable,
142              pte->user_page,
143              pte->write_through,
144              pte->cache_disable,
145              pte->accessed,
146              pte->dirty,
147              pte->pte_attr,
148              pte->global_page,
149              pte->vmm_info);
150 }
151
152
153
154
155
156
157 void PrintDebugPageTables32PAE(pdpe32pae_t * pdpe)
158 {
159   int i, j, k;
160   pde32pae_t * pde;
161   pte32pae_t * pte;
162   addr_t virtual_addr = 0;
163
164   PrintDebug("Dumping the pages starting with the pde page at %p\n", pdpe);
165
166   for (i = 0; (i < MAX_PDPE32PAE_ENTRIES); i++) { 
167
168     if (pdpe[i].present) {
169       pde = (pde32pae_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pdpe[i].pd_base_addr));
170
171       PrintPDPE32PAE(virtual_addr, &(pdpe[i]));
172
173       for (j = 0; j < MAX_PDE32PAE_ENTRIES; j++) {
174
175         if (pde[j].present) {
176           pte = (pte32pae_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pde[j].pt_base_addr));
177
178           PrintPDE32PAE(virtual_addr, &(pde[j]));
179
180           for (k = 0; k < MAX_PTE32PAE_ENTRIES; k++) {
181             if (pte[k].present) {
182               PrintPTE32PAE(virtual_addr, &(pte[k]));
183             }
184
185             virtual_addr += PAGE_SIZE;
186           }
187         } else {
188           virtual_addr += PAGE_SIZE * MAX_PTE32PAE_ENTRIES;
189         }
190       }
191     } else {
192       virtual_addr += PAGE_SIZE * MAX_PDE32PAE_ENTRIES * MAX_PTE32PAE_ENTRIES;
193     }
194   }
195 }
196     
197
198
199 void PrintPML4e64(addr_t virtual_address, pml4e64_t * pml)
200 {
201   PrintDebug("PML4e64 %p -> %p : present=%x, writable=%x, user=%x, wt=%x, cd=%x, accessed=%x, reserved=%x, kernelInfo=%x\n",
202              (void *)virtual_address,
203              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pml->pdp_base_addr)),
204              pml->present,
205              pml->writable,
206              pml->user_page, 
207              pml->write_through,
208              pml->cache_disable,
209              pml->accessed,
210              pml->reserved,
211              pml->vmm_info);
212 }
213
214 void PrintPDPE64(addr_t virtual_address, pdpe64_t * pdpe)
215 {
216   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",
217              (void *)virtual_address,
218              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pdpe->pd_base_addr)),
219              pdpe->present,
220              pdpe->writable,
221              pdpe->user_page, 
222              pdpe->write_through,
223              pdpe->cache_disable,
224              pdpe->accessed,
225              pdpe->avail,
226              pdpe->large_page,
227              pdpe->zero,
228              pdpe->vmm_info);
229 }
230
231
232
233 void PrintPDE64(addr_t virtual_address, pde64_t * pde)
234 {
235   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",
236              (void *)virtual_address,
237              (void *)(addr_t) (BASE_TO_PAGE_ADDR(pde->pt_base_addr)),
238              pde->present,
239              pde->writable,
240              pde->user_page, 
241              pde->write_through,
242              pde->cache_disable,
243              pde->accessed,
244              pde->avail,
245              pde->large_page,
246              pde->global_page,
247              pde->vmm_info);
248 }
249
250   
251 void PrintPTE64(addr_t virtual_address, pte64_t * pte)
252 {
253   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",
254              (void *)virtual_address,
255              (void*)(addr_t)(BASE_TO_PAGE_ADDR(pte->page_base_addr)),
256              pte->present,
257              pte->writable,
258              pte->user_page,
259              pte->write_through,
260              pte->cache_disable,
261              pte->accessed,
262              pte->dirty,
263              pte->pte_attr,
264              pte->global_page,
265              pte->vmm_info);
266 }
267
268   
269
270
271
272 void PrintPageTree_64(addr_t virtual_addr, pml4e64_t * pml) {
273   uint_t pml4_index = PML4E64_INDEX(virtual_addr);
274   uint_t pdpe_index = PDPE64_INDEX(virtual_addr);
275   uint_t pde_index = PDE64_INDEX(virtual_addr);
276   uint_t pte_index = PTE64_INDEX(virtual_addr);
277
278   PrintPML4e64(virtual_addr, &(pml[pml4_index]));
279   if (pml[pml4_index].present) {
280     pdpe64_t * pdpe = (pdpe64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pml[pml4_index].pdp_base_addr));
281     PrintPDPE64(virtual_addr, &(pdpe[pdpe_index]));
282
283     if (pdpe[pdpe_index].present) {
284       pde64_t * pde = (pde64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pdpe[pdpe_index].pd_base_addr));
285       PrintPDE64(virtual_addr, &(pde[pde_index]));
286       
287       if (pde[pde_index].present) {
288         pte64_t * pte = (pte64_t *)V3_VAddr((void *)(addr_t)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr));
289         PrintPTE64(virtual_addr, &(pte[pte_index]));
290       }
291
292     }
293
294   }
295
296 }
297
298
299
300
301 void PrintPageTree(v3_vm_cpu_mode_t cpu_mode, addr_t virtual_addr, addr_t cr3) {
302   switch (cpu_mode) {
303   case LONG:
304   case LONG_32_COMPAT:
305   case LONG_16_COMPAT:
306     PrintPageTree_64(virtual_addr, CR3_TO_PML4E64_VA(cr3));
307     break;
308   default:
309     PrintError("Unsupported CPU MODE %d\n", cpu_mode);
310     break;
311   }
312 }
313
314
315 #endif