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, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm_symbiotic.h>
22 #include <palacios/vm_guest.h>
25 #define SYM_CPUID_NUM 0x90000000
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[];
33 *eax = *(uint32_t *)"V3V";
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";
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));
52 v3_hook_cpuid(vm, SYM_CPUID_NUM, cpuid_fn, NULL);
54 if (v3_init_symspy_vm(vm, &(vm_state->symspy_state)) == -1) {
55 PrintError("Error initializing global SymSpy state\n");
60 if (v3_init_symcall_vm(vm) == -1) {
61 PrintError("Error intializing global SymCall state\n");
67 if (v3_init_symmod_vm(vm, vm->cfg_data->cfg) == -1) {
68 PrintError("Error initializing global SymMod state\n");
78 int v3_deinit_symbiotic_vm(struct v3_vm_info * vm) {
81 if (v3_deinit_symmod_vm(vm) == -1) {
82 PrintError("Error deinitializing global SymMod state\n");
87 v3_unhook_cpuid(vm, SYM_CPUID_NUM);
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));
100 if (v3_init_symspy_core(core, &(core_state->symspy_state)) == -1) {
101 PrintError("Error intializing local SymSpy state\n");
109 int v3_deinit_symbiotic_core(struct guest_info * core) {