X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm.c;h=dbb1b8d0620579510ad36a0e67f682ab7775512d;hb=3e937e5468169b8183a22a90f6d07ff370abde0c;hp=0a281ab684c698a6988e87f37d0b7a925f6de44b;hpb=6b9abb54ebafd8266f1711b803ccb027675a465f;p=palacios.git diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 0a281ab..dbb1b8d 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -44,7 +44,6 @@ #include #endif - v3_cpu_arch_t v3_cpu_types[V3_CONFIG_MAX_CPUS]; v3_cpu_arch_t v3_mach_type = V3_INVALID_CPU; @@ -151,6 +150,10 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *op v3_cpu_types[i] = V3_INVALID_CPU; } +#ifdef V3_CONFIG_CACHEPART + v3_init_cachepart(); +#endif + // Parse host-os defined options into an easily-accessed format. v3_parse_options(options); @@ -162,6 +165,7 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *op v3_init_hvm(); #endif + // Memory manager initialization v3_init_mem(); @@ -273,6 +277,9 @@ void Shutdown_V3() { v3_deinit_options(); +#ifdef V3_CONFIG_CACHEPART + v3_deinit_cachepart(); +#endif } @@ -332,7 +339,9 @@ struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name, unsi } memset(vm->name, 0, 128); - strncpy(vm->name, name, 127); + strncpy(vm->name, name, 128); + vm->name[127] = 0; + if(v3_cpu_mapper_register_vm(vm) == -1) { @@ -359,12 +368,17 @@ struct v3_vm_info * v3_create_vm(void * cfg, void * priv_data, char * name, unsi PrintDebug(vm, VCORE_NONE, "Creating virtual core %u on logical core %u\n", vcore_id, core->pcpu_id); - sprintf(core->exec_name, "%s-%u", vm->name, vcore_id); + sprintf(core->exec_name, "%s-%d", vm->name, vcore_id); PrintDebug(vm, VCORE_NONE, "run: core=%u, func=0x%p, arg=0x%p, name=%s\n", core->pcpu_id, start_core, core, core->exec_name); - core->core_thread = V3_CREATE_THREAD_ON_CPU(core->pcpu_id, start_core, core, core->exec_name); + + // Resource controls for cores can be independent, but + // currently are not, hence this copy. + core->resource_control = vm->resource_control; + + core->core_thread = V3_CREATE_THREAD_ON_CPU(core->pcpu_id, start_core, core, core->exec_name, &core->resource_control); if (core->core_thread == NULL) { PrintError(vm, VCORE_NONE, "Thread creation failed\n"); @@ -537,8 +551,12 @@ int v3_reset_vm_extended(struct v3_vm_info *vm, v3_vm_reset_type t, void *data) #endif break; case V3_VM_RESET_CORE_RANGE: - start = ((uint32_t*)data)[0]; - end = ((uint32_t*)data)[1]; + if (data) { + start = ((uint32_t*)data)[0]; + end = ((uint32_t*)data)[1]; + } else { + return -1; + } break; default: PrintError(vm,VCORE_NONE,"Unsupported reset type %d for this VM\n",t); @@ -723,7 +741,8 @@ int v3_move_vm_mem(struct v3_vm_info * vm, void *gpa, int target_cpu) { new_hpa = V3_AllocPagesExtended(num_pages, PAGE_SIZE_4KB, new_node, - 0, 0); // no constraints given new shadow pager impl + vm->resource_control.pg_filter_func, + vm->resource_control.pg_filter_state); if (!new_hpa) { PrintError(vm, VCORE_NONE, "Cannot allocate memory for new base region...\n"); @@ -731,6 +750,8 @@ int v3_move_vm_mem(struct v3_vm_info * vm, void *gpa, int target_cpu) { } // Note, assumes virtual contiguity in the host OS... + // A null deref here can only happen if the host does not provide the + // physical_to_virtual functions or if they do not work memcpy(V3_VAddr((void*)new_hpa), V3_VAddr((void*)(reg->host_addr)), num_pages*PAGE_SIZE); old_hpa = (void*)(reg->host_addr); @@ -1207,18 +1228,6 @@ v3_cpu_mode_t v3_get_host_cpu_mode() { #endif -void v3_print_cond(const char * fmt, ...) { - if (v3_dbg_enable == 1) { - char buf[2048]; - va_list ap; - - va_start(ap, fmt); - vsnprintf(buf, 2048, fmt, ap); - va_end(ap); - - V3_Print(VM_NONE, VCORE_NONE,"%s", buf); - } -}