X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm.c;h=e96bd26467d206f47fbc1926cc923e48f8586924;hb=6cff7c8b0ec58e3b94d9583f709ca9056ae928dd;hp=7e08dd9ce9e30f4cab24d04077eaf4c09886b176;hpb=fe2922a2862b1a4f1fb340ab4649f831ac17719c;p=palacios.git diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 7e08dd9..e96bd26 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -26,19 +26,15 @@ #include #include -#ifdef CONFIG_SVM +#ifdef V3_CONFIG_SVM #include #endif -#ifdef CONFIG_VMX +#ifdef V3_CONFIG_VMX #include #endif -#ifdef CONFIG_VNET -#include -#endif - -v3_cpu_arch_t v3_cpu_types[CONFIG_MAX_CPUS]; +v3_cpu_arch_t v3_cpu_types[V3_CONFIG_MAX_CPUS]; struct v3_os_hooks * os_hooks = NULL; int v3_dbg_enable = 0; @@ -47,14 +43,14 @@ int v3_dbg_enable = 0; static void init_cpu(void * arg) { uint32_t cpu_id = (uint32_t)(addr_t)arg; -#ifdef CONFIG_SVM +#ifdef V3_CONFIG_SVM if (v3_is_svm_capable()) { PrintDebug("Machine is SVM Capable\n"); v3_init_svm_cpu(cpu_id); } else #endif -#ifdef CONFIG_VMX +#ifdef V3_CONFIG_VMX if (v3_is_vmx_capable()) { PrintDebug("Machine is VMX Capable\n"); v3_init_vmx_cpu(cpu_id); @@ -72,17 +68,18 @@ static void deinit_cpu(void * arg) { switch (v3_cpu_types[cpu_id]) { - #ifdef CONFIG_SVM - case V3_VMX_CPU: - case V3_VMX_EPT_CPU: - PrintDebug("Machine is SVM Capable\n"); +#ifdef V3_CONFIG_SVM + case V3_SVM_CPU: + case V3_SVM_REV3_CPU: + PrintDebug("Deinitializing SVM CPU %d\n", cpu_id); v3_deinit_svm_cpu(cpu_id); break; #endif -#ifdef CONFIG_VMX - case V3_SVM_CPU: - case V3_SVM_REV3_CPU: - PrintDebug("Machine is VMX Capable\n"); +#ifdef V3_CONFIG_VMX + case V3_VMX_CPU: + case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: + PrintDebug("Deinitializing VMX CPU %d\n", cpu_id); v3_deinit_vmx_cpu(cpu_id); break; #endif @@ -103,7 +100,7 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { // Set global variables. os_hooks = hooks; - for (i = 0; i < CONFIG_MAX_CPUS; i++) { + for (i = 0; i < V3_CONFIG_MAX_CPUS; i++) { v3_cpu_types[i] = V3_INVALID_CPU; } @@ -117,17 +114,13 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { V3_init_extensions(); -#ifdef CONFIG_SYMMOD +#ifdef V3_CONFIG_SYMMOD V3_init_symmod(); #endif -#ifdef CONFIG_VNET - v3_init_vnet(); -#endif - -#ifdef CONFIG_MULTITHREAD_OS +#ifdef V3_CONFIG_MULTITHREAD_OS if ((hooks) && (hooks->call_on_cpu)) { for (i = 0; i < num_cpus; i++) { @@ -151,18 +144,14 @@ void Shutdown_V3() { V3_deinit_extensions(); -#ifdef CONFIG_SYMMOD +#ifdef V3_CONFIG_SYMMOD V3_deinit_symmod(); #endif -#ifdef CONFIG_VNET - v3_deinit_vnet(); -#endif - -#ifdef CONFIG_MULTITHREAD_OS +#ifdef V3_CONFIG_MULTITHREAD_OS if ((os_hooks) && (os_hooks->call_on_cpu)) { - for (i = 0; i < CONFIG_MAX_CPUS; i++) { + for (i = 0; i < V3_CONFIG_MAX_CPUS; i++) { if (v3_cpu_types[i] != V3_INVALID_CPU) { deinit_cpu((void *)(addr_t)i); } @@ -183,14 +172,13 @@ v3_cpu_arch_t v3_get_cpu_type(int cpu_id) { struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name) { struct v3_vm_info * vm = v3_config_guest(cfg, priv_data); - V3_Print("CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); - - if (vm == NULL) { PrintError("Could not configure guest\n"); return NULL; } + V3_Print("CORE 0 RIP=%p\n", (void *)(addr_t)(vm->cores[0].rip)); + if (name == NULL) { name = "[V3_VM]"; } else if (strlen(name) >= 128) { @@ -213,15 +201,16 @@ static int start_core(void * p) core->cpu_id, (void *)(addr_t)core->rip); switch (v3_cpu_types[0]) { -#ifdef CONFIG_SVM +#ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: return v3_start_svm_guest(core); break; #endif -#if CONFIG_VMX +#if V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: return v3_start_vmx_guest(core); break; #endif @@ -235,7 +224,7 @@ static int start_core(void * p) // For the moment very ugly. Eventually we will shift the cpu_mask to an arbitrary sized type... -#ifdef CONFIG_MULTITHREAD_OS +#ifdef V3_CONFIG_MULTITHREAD_OS #define MAX_CORES 32 #else #define MAX_CORES 1 @@ -271,7 +260,7 @@ int v3_start_vm(struct v3_vm_info * vm, unsigned int cpu_mask) { return -1; } -#ifdef CONFIG_MULTITHREAD_OS +#ifdef V3_CONFIG_MULTITHREAD_OS // spawn off new threads, for other cores for (i = 0, vcore_id = 1; (i < MAX_CORES) && (vcore_id < vm->num_cores); i++) { int major = 0; @@ -290,18 +279,19 @@ 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; + } + core_idx = i; } major = core_idx / 8; minor = core_idx % 8; - /* This assumes that the core 0 thread has been mapped to physical core 0 */ - if (core_idx == V3_Get_CPU()) { - // We skip the local CPU because it is reserved for vcore 0 - continue; - } - if ((core_mask[major] & (0x1 << minor)) == 0) { PrintError("Logical CPU %d not available for virtual core %d; not started\n", @@ -373,8 +363,6 @@ int v3_stop_vm(struct v3_vm_info * vm) { break; } - V3_Print("Yielding\n"); - v3_yield(NULL); } @@ -492,7 +480,7 @@ void v3_print_cond(const char * fmt, ...) { } -#ifdef CONFIG_MULTITHREAD_OS +#ifdef V3_CONFIG_MULTITHREAD_OS void v3_interrupt_cpu(struct v3_vm_info * vm, int logical_cpu, int vector) { extern struct v3_os_hooks * os_hooks; @@ -507,15 +495,16 @@ void v3_interrupt_cpu(struct v3_vm_info * vm, int logical_cpu, int vector) { int v3_vm_enter(struct guest_info * info) { switch (v3_cpu_types[0]) { -#ifdef CONFIG_SVM +#ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: return v3_svm_enter(info); break; #endif -#if CONFIG_VMX +#if V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: return v3_vmx_enter(info); break; #endif