X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_config.c;h=25d8b23f011d37a13cfb06993e8218b6b7feeb9b;hb=fdb16aa5e99a19a91264ae84beaf77d3036548d5;hp=50e3b1c0b6283e88253aa49f2fe95e44e63aee28;hpb=c0e8207d10b6b077c3fac4fb013ba7485f3a6391;p=palacios.git diff --git a/palacios/src/palacios/vmm_config.c b/palacios/src/palacios/vmm_config.c index 50e3b1c..25d8b23 100644 --- a/palacios/src/palacios/vmm_config.c +++ b/palacios/src/palacios/vmm_config.c @@ -38,7 +38,6 @@ #include -#include #include "vmm_config_class.h" @@ -58,6 +57,7 @@ struct file_idx_table { static int setup_memory_map(struct v3_vm_info * vm, v3_cfg_tree_t * cfg); +static int setup_extensions(struct v3_vm_info * vm, v3_cfg_tree_t * cfg); static int setup_devices(struct v3_vm_info * vm, v3_cfg_tree_t * cfg); @@ -237,6 +237,7 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { vm->mem_size = (addr_t)atoi(memory_str) * 1024 * 1024; vm->mem_align = get_alignment(align_str); + PrintDebug("Alignment for %lu bytes of memory computed as 0x%x\n", vm->mem_size, vm->mem_align); if (strcasecmp(vm_class, "PC") == 0) { @@ -291,7 +292,8 @@ static int determine_paging_mode(struct guest_info * info, v3_cfg_tree_t * core_ if (pg_mode) { if ((strcasecmp(pg_mode, "nested") == 0)) { - if (v3_cpu_types[info->cpu_id] == V3_SVM_REV3_CPU) { + // we assume symmetric cores, so if core 0 has nested paging they all do + if (v3_cpu_types[0] == V3_SVM_REV3_CPU) { info->shdw_pg_mode = NESTED_PAGING; } else { PrintError("Nested paging not supported on this hardware. Defaulting to shadow paging\n"); @@ -337,9 +339,9 @@ static int determine_paging_mode(struct guest_info * info, v3_cfg_tree_t * core_ } static int pre_config_core(struct guest_info * info, v3_cfg_tree_t * core_cfg) { - - if (determine_paging_mode(info, core_cfg)) + if (determine_paging_mode(info, core_cfg) != 0) { return -1; + } v3_init_core(info); @@ -367,9 +369,18 @@ static int post_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { PrintError("Setting up guest memory map failed...\n"); return -1; } - - //v3_hook_io_port(info, 1234, &IO_Read, NULL, info); - + + /* + * Initialize configured extensions + */ + if (setup_extensions(vm, cfg) == -1) { + PrintError("Failed to setup extensions\n"); + return -1; + } + + /* + * Initialize configured devices + */ if (setup_devices(vm, cfg) == -1) { PrintError("Failed to setup devices\n"); return -1; @@ -399,6 +410,11 @@ static int post_config_core(struct guest_info * info, v3_cfg_tree_t * cfg) { info->core_run_state = CORE_STOPPED; + if (v3_init_core_extensions(info) == -1) { + PrintError("Error intializing extension core states\n"); + return -1; + } + if (info->vm_info->vm_class == V3_PC_VM) { if (post_config_pc_core(info, cfg) == -1) { PrintError("PC Post configuration failure\n"); @@ -457,7 +473,6 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { } num_cores = atoi(v3_cfg_val(cores_cfg, "count")); - if (num_cores == 0) { PrintError("No cores specified in configuration\n"); return NULL; @@ -483,7 +498,6 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { return NULL; } - V3_Print("Per core configuration\n"); per_core_cfg = v3_cfg_subtree(cores_cfg, "core"); @@ -500,6 +514,7 @@ struct v3_vm_info * v3_config_guest(void * cfg_blob, void * priv_data) { return NULL; } + per_core_cfg = v3_cfg_next_branch(per_core_cfg); } @@ -542,6 +557,7 @@ int v3_free_config(struct v3_vm_info * vm) { + static int setup_memory_map(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { v3_cfg_tree_t * mem_region = v3_cfg_subtree(v3_cfg_subtree(cfg, "memmap"), "region"); @@ -564,6 +580,24 @@ static int setup_memory_map(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { } +static int setup_extensions(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { + v3_cfg_tree_t * extension = v3_cfg_subtree(v3_cfg_subtree(cfg, "extensions"), "extension"); + + while (extension) { + char * ext_name = v3_cfg_val(extension, "name"); + + V3_Print("Configuring extension %s\n", ext_name); + + if (v3_add_extension(vm, ext_name, extension) == -1) { + PrintError("Error adding extension %s\n", ext_name); + return -1; + } + + extension = v3_cfg_next_branch(extension); + } + + return 0; +} static int setup_devices(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { @@ -590,4 +624,3 @@ static int setup_devices(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { -