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.


8fda86e703dc051be77907f2c5cc7fd09d6ae238
[palacios.git] / palacios / src / palacios / vmm_symbiotic.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, 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
21 #include <palacios/vmm_symbiotic.h>
22 #include <palacios/vm_guest.h>
23
24
25 #define SYM_CPUID_NUM 0x90000000
26
27 static int cpuid_fn(struct guest_info * core, uint32_t cpuid, 
28                     uint32_t * eax, uint32_t * ebx,
29                     uint32_t * ecx, uint32_t * edx,
30                     void * private_data) {
31     extern v3_cpu_arch_t v3_cpu_types[];
32
33     *eax = *(uint32_t *)"V3V";
34
35     if ((v3_cpu_types[0] == V3_SVM_CPU) || 
36         (v3_cpu_types[0] == V3_SVM_REV3_CPU)) {
37         *ebx = *(uint32_t *)"SVM";
38     } else if ((v3_cpu_types[0] == V3_VMX_CPU) || 
39                (v3_cpu_types[0] == V3_VMX_EPT_CPU)) {
40         *ebx = *(uint32_t *)"VMX";
41     }
42
43
44     return 0;
45 }
46
47
48 int v3_init_symbiotic_vm(struct v3_vm_info * vm) {
49     struct v3_sym_vm_state * vm_state = &(vm->sym_vm_state);
50     memset(vm_state, 0, sizeof(struct v3_sym_vm_state));
51
52     v3_hook_cpuid(vm, SYM_CPUID_NUM, cpuid_fn, NULL);
53
54     if (v3_init_symspy_vm(vm, &(vm_state->symspy_state)) == -1) {
55         PrintError("Error initializing global SymSpy state\n");
56         return -1;
57     }
58
59 #ifdef V3_CONFIG_SYMCALL
60     if (v3_init_symcall_vm(vm) == -1) {
61         PrintError("Error intializing global SymCall state\n");
62         return -1;
63     }
64 #endif
65
66 #ifdef V3_CONFIG_SYMMOD
67     if (v3_init_symmod_vm(vm, vm->cfg_data->cfg) == -1) {
68         PrintError("Error initializing global SymMod state\n");
69         return -1;
70     }
71 #endif
72
73
74     return 0;
75 }
76
77
78 int v3_deinit_symbiotic_vm(struct v3_vm_info * vm) {
79
80 #ifdef V3_CONFIG_SYMMOD
81     if (v3_deinit_symmod_vm(vm) == -1) {
82         PrintError("Error deinitializing global SymMod state\n");
83         return -1;
84     }
85 #endif
86
87     v3_unhook_cpuid(vm, SYM_CPUID_NUM);
88
89     
90     return 0;
91 }
92
93
94
95 int v3_init_symbiotic_core(struct guest_info * core) {
96     struct v3_sym_core_state * core_state = &(core->sym_core_state);
97     memset(core_state, 0, sizeof(struct v3_sym_core_state));
98     
99
100     if (v3_init_symspy_core(core, &(core_state->symspy_state)) == -1) {
101         PrintError("Error intializing local SymSpy state\n");
102         return -1;
103     }
104
105     return 0;
106 }
107
108
109 int v3_deinit_symbiotic_core(struct guest_info * core) {
110
111     return 0;
112 }