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.


821d7b369159ca09024fdf7a88f28077f5ad94d7
[palacios.git] / palacios / src / palacios / vmm_direct_paging.c
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, Steven Jaconette <stevenjaconette2007@u.northwestern.edu> 
11  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
12  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
13  * All rights reserved.
14  *
15  * Author: Steven Jaconette <stevenjaconette2007@u.northwestern.edu>
16  *
17  * This is free software.  You are permitted to use,
18  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19  */
20
21 #include <palacios/vmm_direct_paging.h>
22 #include <palacios/vmm_paging.h>
23 #include <palacios/vmm.h>
24 #include <palacios/vm_guest_mem.h>
25 #include <palacios/vm_guest.h>
26
27 static addr_t create_generic_pt_page() {
28     void * page = 0;
29     page = V3_VAddr(V3_AllocPages(1));
30     memset(page, 0, PAGE_SIZE);
31
32     return (addr_t)page;
33 }
34
35 // Inline handler functions for each cpu mode
36 #include "vmm_direct_paging_32.h"
37 #include "vmm_direct_paging_32pae.h"
38 #include "vmm_direct_paging_64.h"
39
40
41 addr_t v3_create_direct_passthrough_pts(struct guest_info * info) {
42     return create_generic_pt_page();
43 }
44
45 int v3_handle_passthrough_pagefault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
46     v3_vm_cpu_mode_t mode = v3_get_cpu_mode(info);
47
48     switch(mode) {
49         case REAL:
50         case PROTECTED:
51             return handle_passthrough_pagefault_32(info, fault_addr, error_code);
52
53         case PROTECTED_PAE:
54         case LONG:
55         case LONG_32_COMPAT:
56             // Long mode will only use 32PAE page tables...
57             return handle_passthrough_pagefault_32pae(info, fault_addr, error_code);
58
59         default:
60             PrintError("Unknown CPU Mode\n");
61             break;
62     }
63     return -1;
64 }
65
66
67
68 int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code) {
69     // THIS IS VERY BAD
70     v3_vm_cpu_mode_t mode = LONG;
71
72     switch(mode) {
73         case REAL:
74         case PROTECTED:
75             return handle_passthrough_pagefault_32(info, fault_addr, error_code);
76
77         case PROTECTED_PAE:
78             return handle_passthrough_pagefault_32pae(info, fault_addr, error_code);
79
80         case LONG:
81         case LONG_32_COMPAT:
82             return handle_passthrough_pagefault_64(info, fault_addr, error_code);           
83         
84         default:
85             PrintError("Unknown CPU Mode\n");
86             break;
87     }
88     return -1;
89 }
90