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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
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.
15 * Author: Steven Jaconette <stevenjaconette2007@u.northwestern.edu>
17 * This is free software. You are permitted to use,
18 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #ifndef __VMM_DIRECT_PAGING_H__
22 #define __VMM_DIRECT_PAGING_H__
26 #include <palacios/vmm_mem.h>
27 #include <palacios/vmm_paging.h>
28 #include <palacios/vmm_list.h>
29 #include <palacios/vmm_lock.h>
32 /**********************************
33 PASSTHROUGH PAGING - CORE FUNC
34 **********************************/
37 struct v3_passthrough_impl_state {
38 // currently there is only a single implementation
39 // that internally includes SVM and VMX support
40 // The externally visible state is just the callbacks
41 v3_rw_lock_t event_callback_lock;
42 struct list_head event_callback_list;
46 int v3_init_passthrough_paging(struct v3_vm_info *vm);
47 int v3_init_passthrough_paging_core(struct guest_info *core);
48 int v3_deinit_passthrough_paging(struct v3_vm_info *vm);
49 int v3_deinit_passthrough_paging_core(struct guest_info *core);
51 int v3_init_passthrough_pts(struct guest_info * guest_info);
52 int v3_free_passthrough_pts(struct guest_info * core);
54 int v3_reset_passthrough_pts(struct guest_info * guest_info);
56 // actual_start/end may be null if you don't want this info
57 // If non-null, these return the actual affected GPA range
58 int v3_handle_passthrough_pagefault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code,
59 addr_t *actual_start, addr_t *actual_end);
61 int v3_activate_passthrough_pt(struct guest_info * info);
63 int v3_invalidate_passthrough_addr(struct guest_info * info, addr_t inv_addr,
64 addr_t *actual_start, addr_t *actual_end);
66 // The range invalidated is minimally [start, end]
67 int v3_invalidate_passthrough_addr_range(struct guest_info * info,
68 addr_t inv_addr_start, addr_t inv_addr_end,
69 addr_t *actual_start, addr_t *actual_end);
71 /**********************************
72 PASSTHROUGH PAGING - EVENTS
73 **********************************/
75 struct v3_passthrough_pg_event {
76 enum {PASSTHROUGH_PAGEFAULT,PASSTHROUGH_INVALIDATE_RANGE,PASSTHROUGH_ACTIVATE} event_type;
77 enum {PASSTHROUGH_PREIMPL, PASSTHROUGH_POSTIMPL} event_order;
79 pf_error_t error_code; // for pf
80 addr_t gpa_start; // for invalidation of range or page fault
81 addr_t gpa_end; // for invalidation of range or page fault (range is [start,end] )
82 // PREIMPL: start/end is the requested range
83 // POSTIMPL: start/end is the actual range invalidated
88 int v3_register_passthrough_paging_event_callback(struct v3_vm_info *vm,
89 int (*callback)(struct guest_info *core,
90 struct v3_passthrough_pg_event *,
94 int v3_unregister_passthrough_paging_event_callback(struct v3_vm_info *vm,
95 int (*callback)(struct guest_info *core,
96 struct v3_passthrough_pg_event *,
102 /*****************************
103 NESTED PAGING - CORE FUNC
104 *****************************/
107 struct v3_nested_impl_state {
108 // currently there is only a single implementation
109 // that internally includes SVM and VMX support
110 // The externally visible state is just the callbacks
111 v3_rw_lock_t event_callback_lock;
112 struct list_head event_callback_list;
115 int v3_init_nested_paging(struct v3_vm_info *vm);
116 int v3_init_nested_paging_core(struct guest_info *core, void *hwinfo);
117 int v3_deinit_nested_paging(struct v3_vm_info *vm);
118 int v3_deinit_nested_paging_core(struct guest_info *core);
121 // actual_start/end may be null if you don't want this info
122 // If non-null, these return the actual affected GPA range
123 int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, void *pfinfo,
124 addr_t *actual_start, addr_t *actual_end);
126 int v3_invalidate_nested_addr(struct guest_info * info, addr_t inv_addr,
127 addr_t *actual_start, addr_t *actual_end);
129 // The range invalidated is minimally [start, end]
130 int v3_invalidate_nested_addr_range(struct guest_info * info,
131 addr_t inv_addr_start, addr_t inv_addr_end,
132 addr_t *actual_start, addr_t *actual_end);
136 /*****************************
137 NESTED PAGING - EVENTS
138 *****************************/
140 struct v3_nested_pg_event {
141 enum {NESTED_PAGEFAULT,NESTED_INVALIDATE_RANGE} event_type;
142 enum {NESTED_PREIMPL, NESTED_POSTIMPL} event_order;
143 addr_t gpa; // for pf
144 pf_error_t error_code; // for pf
145 addr_t gpa_start; // for invalidation of range or page fault
146 addr_t gpa_end; // for invalidation of range or page fault (range is [start,end] )
147 // PREIMPL: start/end is the requested range
148 // POSTIMPL: start/end is the actual range invalidated
153 int v3_register_nested_paging_event_callback(struct v3_vm_info *vm,
154 int (*callback)(struct guest_info *core,
155 struct v3_nested_pg_event *,
159 int v3_unregister_nested_paging_event_callback(struct v3_vm_info *vm,
160 int (*callback)(struct guest_info *core,
161 struct v3_nested_pg_event *,
166 #endif // ! __V3VEE__