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>
31 /**********************************
32 PASSTHROUGH PAGING - CORE FUNC
33 **********************************/
36 struct v3_passthrough_impl_state {
37 // currently there is only a single implementation
38 // that internally includes SVM and VMX support
39 // The externally visible state is just the callbacks
40 v3_rw_lock_t event_callback_lock;
41 struct list_head event_callback_list;
45 int v3_init_passthrough_paging(struct v3_vm_info *vm);
46 int v3_init_passthrough_paging_core(struct guest_info *core);
47 int v3_deinit_passthrough_paging(struct v3_vm_info *vm);
48 int v3_deinit_passthrough_paging_core(struct guest_info *core);
50 int v3_init_passthrough_pts(struct guest_info * guest_info);
51 int v3_free_passthrough_pts(struct guest_info * core);
53 int v3_reset_passthrough_pts(struct guest_info * guest_info);
55 // actual_start/end may be null if you don't want this info
56 // If non-null, these return the actual affected GPA range
57 int v3_handle_passthrough_pagefault(struct guest_info * info, addr_t fault_addr, pf_error_t error_code,
58 addr_t *actual_start, addr_t *actual_end);
60 int v3_activate_passthrough_pt(struct guest_info * info);
62 int v3_invalidate_passthrough_addr(struct guest_info * info, addr_t inv_addr,
63 addr_t *actual_start, addr_t *actual_end);
65 // The range invalidated is minimally [start, end]
66 int v3_invalidate_passthrough_addr_range(struct guest_info * info,
67 addr_t inv_addr_start, addr_t inv_addr_end,
68 addr_t *actual_start, addr_t *actual_end);
70 /**********************************
71 PASSTHROUGH PAGING - EVENTS
72 **********************************/
74 struct v3_passthrough_pg_event {
75 enum {PASSTHROUGH_PAGEFAULT,PASSTHROUGH_INVALIDATE_RANGE,PASSTHROUGH_ACTIVATE} event_type;
76 enum {PASSTHROUGH_PREIMPL, PASSTHROUGH_POSTIMPL} event_order;
78 pf_error_t error_code; // for pf
79 addr_t gpa_start; // for invalidation of range or page fault
80 addr_t gpa_end; // for invalidation of range or page fault (range is [start,end] )
81 // PREIMPL: start/end is the requested range
82 // POSTIMPL: start/end is the actual range invalidated
87 int v3_register_passthrough_paging_event_callback(struct v3_vm_info *vm,
88 int (*callback)(struct guest_info *core,
89 struct v3_passthrough_pg_event *,
93 int v3_unregister_passthrough_paging_event_callback(struct v3_vm_info *vm,
94 int (*callback)(struct guest_info *core,
95 struct v3_passthrough_pg_event *,
101 /*****************************
102 NESTED PAGING - CORE FUNC
103 *****************************/
106 struct v3_nested_impl_state {
107 // currently there is only a single implementation
108 // that internally includes SVM and VMX support
109 // The externally visible state is just the callbacks
110 v3_rw_lock_t event_callback_lock;
111 struct list_head event_callback_list;
114 int v3_init_nested_paging(struct v3_vm_info *vm);
115 int v3_init_nested_paging_core(struct guest_info *core, void *hwinfo);
116 int v3_deinit_nested_paging(struct v3_vm_info *vm);
117 int v3_deinit_nested_paging_core(struct guest_info *core);
120 // actual_start/end may be null if you don't want this info
121 // If non-null, these return the actual affected GPA range
122 int v3_handle_nested_pagefault(struct guest_info * info, addr_t fault_addr, void *pfinfo,
123 addr_t *actual_start, addr_t *actual_end);
125 int v3_invalidate_nested_addr(struct guest_info * info, addr_t inv_addr,
126 addr_t *actual_start, addr_t *actual_end);
128 // The range invalidated is minimally [start, end]
129 int v3_invalidate_nested_addr_range(struct guest_info * info,
130 addr_t inv_addr_start, addr_t inv_addr_end,
131 addr_t *actual_start, addr_t *actual_end);
135 /*****************************
136 NESTED PAGING - EVENTS
137 *****************************/
139 struct v3_nested_pg_event {
140 enum {NESTED_PAGEFAULT,NESTED_INVALIDATE_RANGE} event_type;
141 enum {NESTED_PREIMPL, NESTED_POSTIMPL} event_order;
142 addr_t gpa; // for pf
143 pf_error_t error_code; // for pf
144 addr_t gpa_start; // for invalidation of range or page fault
145 addr_t gpa_end; // for invalidation of range or page fault (range is [start,end] )
146 // PREIMPL: start/end is the requested range
147 // POSTIMPL: start/end is the actual range invalidated
152 int v3_register_nested_paging_event_callback(struct v3_vm_info *vm,
153 int (*callback)(struct guest_info *core,
154 struct v3_nested_pg_event *,
158 int v3_unregister_nested_paging_event_callback(struct v3_vm_info *vm,
159 int (*callback)(struct guest_info *core,
160 struct v3_nested_pg_event *,
165 #endif // ! __V3VEE__