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.


Direct paging changes
[palacios.git] / palacios / src / palacios / vmm_direct_paging_32.h
1 #ifndef __VMM_DIRECT_PAGING_32_H__
2 #define __VMM_DIRECT_PAGING_32_H__
3
4 #include <palacios/vmm_mem.h>
5 #include <palacios/vmm_paging.h>
6 #include <palacios/vmm.h>
7 #include <palacios/vm_guest_mem.h>
8 #include <palacios/vm_guest.h>
9
10 static pde32_t * create_pde32() {
11   void * pde = 0;
12   pde = V3_VAddr(V3_AllocPages(1));
13   memset(pde, 0, PAGE_SIZE);
14
15   return (pde32_t *) pde;
16 }
17
18
19 static pte32_t * create_pte32() {
20   void * pte = 0;
21   pte = V3_VAddr(V3_AllocPages(1));
22   memset(pte, 0, PAGE_SIZE);
23
24   return (pte32_t *) pte;
25 }
26
27
28 static inline pde32_t * v3_create_direct_passthrough_pts_32(struct guest_info * info) {
29   return create_pde32();
30 }
31
32
33 static inline int v3_handle_shadow_pagefault_physical_mode_32(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
34   // Check to see if pde and pte exist (create them if not)
35   pde32_t * pde = CR3_TO_PDE32_VA(info->ctrl_regs.cr3);
36   int pde_index = PDE32_INDEX(fault_addr);
37   int pte_index = PTE32_INDEX(fault_addr);
38   if(pde[pde_index].present != 1) {
39     PrintError("Creating new page table for PTE index: %d\n", pde_index);
40     pte32_t * pte = create_pte32();
41     addr_t host_addr;
42     if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1;
43       pte[pte_index].present = 1;
44       pte[pte_index].writable = 1;
45       pte[pte_index].user_page = 1;
46       pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
47
48       pde[pde_index].present = 1;
49       pde[pde_index].writable = 1;
50       pde[pde_index].user_page = 1;
51       pde[pde_index].pt_base_addr = PAGE_BASE_ADDR((addr_t)V3_PAddr(pte));
52       PrintError("Fault Addr: 0x%p\nHost Addr: 0x%p\n", (void*)fault_addr, (void*)host_addr);
53     }
54     else {
55       pte32_t * pte = (void*)BASE_TO_PAGE_ADDR(pde[pde_index].pt_base_addr);
56       if(pte[pte_index].present != 1) {
57         addr_t host_addr;
58         if(guest_pa_to_host_pa(info, fault_addr, &host_addr) == -1) return -1;
59         pte[pte_index].present = 1;
60         pte[pte_index].writable = 1;
61         pte[pte_index].user_page = 1;
62         pte[pte_index].page_base_addr = PAGE_BASE_ADDR(host_addr);
63       }
64     }
65     return 0;
66 }
67
68
69 #endif