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.


Resource control extensions to host OS interface
[palacios.git] / palacios / include / palacios / vm_guest.h
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, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #ifndef __VM_GUEST_H__
21 #define __VM_GUEST_H__
22
23 #ifdef __V3VEE__
24
25 #include <palacios/vmm_types.h>
26 #include <palacios/vmm_mem.h>
27 #include <palacios/vmm_mem_hook.h>
28 #include <palacios/vmm_io.h>
29 #include <palacios/vmm_shadow_paging.h>
30 #include <palacios/vmm_direct_paging.h>
31 #include <palacios/vmm_intr.h>
32 #include <palacios/vmm_excp.h>
33 #include <palacios/vmm_dev_mgr.h>
34 #include <palacios/vmm_time.h>
35 #include <palacios/vmm_host_events.h>
36 #include <palacios/vmm_msr.h>
37 #include <palacios/vmm_hypercall.h>
38 #include <palacios/vmm_cpuid.h>
39 #include <palacios/vmm_regs.h>
40 #include <palacios/vmm_extensions.h>
41 #include <palacios/vmm_barrier.h>
42 #include <palacios/vmm_subset.h>
43 #include <palacios/vmm_timeout.h>
44 #include <palacios/vmm_exits.h>
45 #include <palacios/vmm_events.h>
46 #include <palacios/vmm_scheduler.h>
47 #include <palacios/vmm_fw_cfg.h>
48 #include <palacios/vmm_fp.h>
49 #include <palacios/vmm_perftune.h>
50
51
52 #ifdef V3_CONFIG_TELEMETRY
53 #include <palacios/vmm_telemetry.h>
54 #endif
55
56 #ifdef V3_CONFIG_PMU_TELEMETRY
57 #include <palacios/vmm_pmu_telemetry.h>
58 #endif
59
60 #ifdef V3_CONFIG_PWRSTAT_TELEMETRY
61 #include <palacios/vmm_pwrstat_telemetry.h>
62 #endif
63
64 #ifdef V3_CONFIG_SYMBIOTIC
65 #include <palacios/vmm_symbiotic.h>
66 struct v3_sym_core_state;
67 #endif
68
69 #ifdef V3_CONFIG_MEM_TRACK
70 #include <palacios/vmm_mem_track.h>
71 #endif
72
73 #ifdef V3_CONFIG_MULTIBOOT
74 #include <palacios/vmm_multiboot.h>
75 #endif
76
77 #ifdef V3_CONFIG_HVM
78 #include <palacios/vmm_hvm.h>
79 #endif
80
81 #ifdef V3_CONFIG_CACHEPART
82 #include <palacios/vmm_cachepart.h>
83 #endif
84
85 #include <palacios/vmm_config.h>
86
87 struct v3_intr_state;
88
89
90
91
92 /* per-core state */
93 struct guest_info {
94     char exec_name[256];
95     
96     uint64_t rip;
97
98     uint_t cpl;
99
100     struct vm_core_time time_state;
101     struct v3_core_timeouts timeouts;
102     void * sched_priv_data;
103
104     // Resource constraints/etc for the thread running this core
105     v3_resource_control_t  resource_control;
106
107     v3_paging_mode_t shdw_pg_mode;
108     // arch-independent state of shadow pager
109     struct v3_shdw_pg_state shdw_pg_state;
110     // arch-indepedent state of the passthrough pager
111     addr_t direct_map_pt;
112     // arch-independent state of the nested pager (currently none)
113     // struct v3_nested_pg_state nested_pg_state;
114     // per-core state of the swapper (currently none)
115     //#ifdef V3_CONFIG_SWAPPING
116     //   struct v3_swap_impl_state swap_impl;
117     //#endif
118     
119
120     union {
121         uint32_t flags;
122         struct {
123             uint8_t use_large_pages        : 1;    /* Enable virtual page tables to use large pages */
124             uint8_t use_giant_pages        : 1;    /* Enable virtual page tables to use giant (1GB) pages */
125             uint32_t rsvd                  : 30;
126         } __attribute__((packed));
127     } __attribute__((packed));
128
129
130     /* This structure is how we get interrupts for the guest */
131     struct v3_intr_core_state intr_core_state;
132
133     /* This structure is how we get exceptions for the guest */
134     struct v3_excp_state excp_state;
135
136
137     v3_cpu_mode_t cpu_mode;
138     v3_mem_mode_t mem_mode;
139
140
141     struct v3_gprs vm_regs;
142     struct v3_ctrl_regs ctrl_regs;
143     struct v3_dbg_regs dbg_regs;
144     struct v3_segments segments;
145     struct v3_msrs     msrs;
146
147     struct v3_fp_state fp_state;
148
149     // the arch-dependent state (SVM or VMX)
150     void * vmm_data;
151
152     uint64_t yield_start_cycle;
153     
154     uint64_t num_exits;
155
156 #ifdef V3_CONFIG_TELEMETRY
157     struct v3_core_telemetry core_telem;
158 #endif
159
160 #ifdef V3_CONFIG_PMU_TELEMETRY
161     struct v3_core_pmu_telemetry pmu_telem;
162 #endif
163
164 #ifdef V3_CONFIG_PWRSTAT_TELEMETRY
165     struct v3_core_pwrstat_telemetry pwrstat_telem;
166 #endif
167
168 #ifdef V3_CONFIG_MEM_TRACK
169     struct v3_core_mem_track memtrack_state;
170 #endif
171
172 #ifdef V3_CONFIG_HVM
173     struct v3_core_hvm  hvm_state;
174 #endif
175
176
177     /* struct v3_core_dev_mgr core_dev_mgr; */
178
179     void * decoder_state;
180
181 #ifdef V3_CONFIG_SYMBIOTIC
182     /* Symbiotic state */
183     struct v3_sym_core_state sym_core_state;
184 #endif
185
186     /* Per-core config tree data. */
187     v3_cfg_tree_t * core_cfg_data;
188
189     struct v3_vm_info * vm_info;
190
191     v3_core_operating_mode_t core_run_state;
192
193     void * core_thread; /* thread struct for virtual core */
194
195     /* the logical cpu on which this core runs */
196     uint32_t pcpu_id;
197     
198     /* The virtual core # of this cpu (what the guest sees this core as) */
199     uint32_t vcpu_id;
200
201 };
202
203
204
205 /* shared state across cores */
206 struct v3_vm_info {
207     char name[128];
208
209     v3_vm_class_t vm_class;
210
211     // Resource control for whole VM - determined early and used
212     // when building the VM, then cloned to each core
213     v3_resource_control_t resource_control;
214
215     struct v3_fw_cfg_state fw_cfg_state;
216
217     // This is always the total RAM (addresses 0...mem_size)
218     // in the VM.  
219     // With an HVM, this is partitioned as per hvm_state
220     addr_t mem_size; /* In bytes for now */
221     uint32_t mem_align;
222     struct v3_mem_map mem_map;
223
224     struct v3_mem_hooks mem_hooks;
225
226     // arch-indepentent state of shadow pager
227     struct v3_shdw_impl_state shdw_impl;
228     // arch-independent state of passthrough pager (currently none)
229     struct v3_passthrough_impl_state passthrough_impl;
230     // arch-independent state of the nested pager
231     struct v3_nested_impl_state nested_impl;
232 #ifdef V3_CONFIG_SWAPPING
233     // swapping state, if enabled
234     struct v3_swap_impl_state swap_state;
235 #endif
236
237     void * sched_priv_data;
238
239     struct v3_io_map io_map;
240     struct v3_msr_map msr_map;
241     struct v3_cpuid_map cpuid_map;
242     struct v3_exit_map exit_map;
243     struct v3_event_map event_map;
244
245     v3_hypercall_map_t hcall_map;
246
247
248     struct v3_intr_routers intr_routers;
249
250     /* device_map */
251     struct vmm_dev_mgr  dev_mgr;
252
253     struct v3_time time_state;
254
255     struct v3_host_events host_event_hooks;
256
257     struct v3_config * cfg_data;
258
259     v3_vm_operating_mode_t run_state;
260
261     struct v3_barrier barrier;
262
263
264     struct v3_extensions extensions;
265
266     struct v3_perf_options perf_options;
267
268 #ifdef V3_CONFIG_SYMBIOTIC
269     /* Symbiotic state */
270     struct v3_sym_vm_state sym_vm_state;
271 #endif
272
273 #ifdef V3_CONFIG_TELEMETRY
274     uint_t enable_telemetry;
275     struct v3_telemetry_state telemetry;
276 #endif
277
278 #ifdef V3_CONFIG_MEM_TRACK
279     struct v3_vm_mem_track memtrack_state;
280 #endif
281
282 #ifdef V3_CONFIG_MULTIBOOT
283     struct v3_vm_multiboot  mb_state;
284 #endif
285
286 #ifdef V3_CONFIG_HVM
287     struct v3_vm_hvm  hvm_state;
288 #endif
289
290     // used to implement reset of regular VM and ROS
291     v3_counting_barrier_t  reset_barrier;
292
293 #ifdef V3_CONFIG_CACHEPART
294     v3_cachepart_t  cachepart_state;
295 #endif
296
297
298     uint64_t yield_cycle_period;  
299
300
301     void * host_priv_data;
302
303     // This is always the total number of vcores in the VM 
304     // With an HVM, these are partitioned as per hvm_state
305     int num_cores;
306
307     int avail_cores; // Available logical cores
308
309     // JRL: This MUST be the last entry...
310     struct guest_info cores[0];
311 };
312
313 int v3_init_vm(struct v3_vm_info * vm);
314 int v3_init_core(struct guest_info * core);
315
316 int v3_free_vm_internal(struct v3_vm_info * vm);
317 int v3_free_core(struct guest_info * core);
318
319
320 uint_t v3_get_addr_width(struct guest_info * info);
321 v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info);
322 v3_mem_mode_t v3_get_vm_mem_mode(struct guest_info * info);
323
324
325 const uchar_t * v3_cpu_mode_to_str(v3_cpu_mode_t mode);
326 const uchar_t * v3_mem_mode_to_str(v3_mem_mode_t mode);
327
328
329
330 #endif /* ! __V3VEE__ */
331
332
333
334 #endif