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.


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