X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm.c;h=d60e55a04dfbd80dc8bd9984acc9ded7945d5ec0;hb=ead9425b90a4adf9e7dc9b97086796b9323d6d42;hp=ebcdfb85579d76be006d987dad7432d2d9cf62ec;hpb=94f67717b6461df514dc225ed84f03b44c44061b;p=palacios.git diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index ebcdfb8..d60e55a 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -33,10 +33,6 @@ #include #endif -#ifdef V3_CONFIG_VNET -#include -#endif - v3_cpu_arch_t v3_cpu_types[V3_CONFIG_MAX_CPUS]; struct v3_os_hooks * os_hooks = NULL; @@ -44,6 +40,7 @@ int v3_dbg_enable = 0; + static void init_cpu(void * arg) { uint32_t cpu_id = (uint32_t)(addr_t)arg; @@ -123,10 +120,6 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { #endif -#ifdef V3_CONFIG_VNET - v3_init_vnet(); -#endif - #ifdef V3_CONFIG_MULTITHREAD_OS if ((hooks) && (hooks->call_on_cpu)) { @@ -157,10 +150,6 @@ void Shutdown_V3() { #endif -#ifdef V3_CONFIG_VNET - v3_deinit_vnet(); -#endif - #ifdef V3_CONFIG_MULTITHREAD_OS if ((os_hooks) && (os_hooks->call_on_cpu)) { for (i = 0; i < V3_CONFIG_MAX_CPUS; i++) { @@ -204,13 +193,15 @@ struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name) { } + + static int start_core(void * p) { struct guest_info * core = (struct guest_info *)p; - PrintDebug("virtual core %u: in start_core (RIP=%p)\n", - core->cpu_id, (void *)(addr_t)core->rip); + PrintDebug("virtual core %u (on logical core %u): in start_core (RIP=%p)\n", + core->vcpu_id, core->pcpu_id, (void *)(addr_t)core->rip); switch (v3_cpu_types[0]) { #ifdef V3_CONFIG_SVM @@ -292,7 +283,6 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { i--; // We reset the logical core idx. Not strictly necessary I guess... } else { - /* This assumes that the core 0 thread has been mapped to physical core 0 */ if (i == V3_Get_CPU()) { // We skip the local CPU because it is reserved for vcore 0 continue; @@ -327,6 +317,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { core_idx, start_core, core, core->exec_name); // TODO: actually manage these threads instead of just launching them + core->pcpu_id = core_idx; core_thread = V3_CREATE_THREAD_ON_CPU(core_idx, start_core, core, core->exec_name); if (core_thread == NULL) { @@ -341,6 +332,8 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { sprintf(vm->cores[0].exec_name, "%s", vm->name); + vm->cores[0].pcpu_id = V3_Get_CPU(); + if (start_core(&(vm->cores[0])) != 0) { PrintError("Error starting VM core 0\n"); v3_stop_vm(vm); @@ -353,6 +346,33 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { } +int v3_reset_vm_core(struct guest_info * core, addr_t rip) { + + switch (v3_cpu_types[core->pcpu_id]) { +#ifdef V3_CONFIG_SVM + case V3_SVM_CPU: + case V3_SVM_REV3_CPU: + PrintDebug("Resetting SVM Guest CPU %d\n", core->vcpu_id); + return v3_reset_svm_vm_core(core, rip); +#endif +#ifdef V3_CONFIG_VMX + case V3_VMX_CPU: + case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: + PrintDebug("Resetting VMX Guest CPU %d\n", core->vcpu_id); + return v3_reset_vmx_vm_core(core, rip); +#endif + case V3_INVALID_CPU: + default: + PrintError("CPU has no virtualization Extensions\n"); + break; + } + + return -1; +} + + + int v3_stop_vm(struct v3_vm_info * vm) {