From: Peter Dinda Date: Mon, 23 Mar 2015 21:09:33 +0000 (-0500) Subject: Add HVM configuration capability, init/deinit, etc X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=1c5bf75232c70f01570ddc8b075f9455b7c6ba34 Add HVM configuration capability, init/deinit, etc --- diff --git a/palacios/include/palacios/vm_guest.h b/palacios/include/palacios/vm_guest.h index a4fca43..3029c3c 100644 --- a/palacios/include/palacios/vm_guest.h +++ b/palacios/include/palacios/vm_guest.h @@ -69,6 +69,10 @@ struct v3_sym_core_state; #include #endif +#ifdef V3_CONFIG_HVM +#include +#endif + #include @@ -154,6 +158,12 @@ struct guest_info { #ifdef V3_CONFIG_MEM_TRACK struct v3_core_mem_track memtrack_state; #endif + +#ifdef V3_CONFIG_HVM + struct v3_core_hvm hvm_state; +#endif + + /* struct v3_core_dev_mgr core_dev_mgr; */ void * decoder_state; @@ -189,6 +199,9 @@ struct v3_vm_info { v3_vm_class_t vm_class; struct v3_fw_cfg_state fw_cfg_state; + // This is always the total RAM (addresses 0...mem_size) + // in the VM. + // With an HVM, this is partitioned as per hvm_state addr_t mem_size; /* In bytes for now */ uint32_t mem_align; struct v3_mem_map mem_map; @@ -251,11 +264,17 @@ struct v3_vm_info { struct v3_vm_mem_track memtrack_state; #endif +#ifdef V3_CONFIG_HVM + struct v3_vm_hvm hvm_state; +#endif + uint64_t yield_cycle_period; void * host_priv_data; + // This is always the total number of vcores in the VM + // With an HVM, these are partitioned as per hvm_state int num_cores; int avail_cores; // Available logical cores diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index 569fa0b..acbb11e 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -37,6 +37,7 @@ #include #endif + v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { struct cr0_32 * cr0; struct efer_64 * efer; @@ -376,6 +377,10 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_deinit_telemetry(vm); #endif +#ifdef V3_CONFIG_HVM + v3_deinit_hvm_vm(vm); +#endif + v3_deinit_events(vm); #ifdef V3_CONFIG_MEM_TRACK @@ -483,6 +488,10 @@ int v3_free_core(struct guest_info * core) { v3_deinit_core_telemetry(core); #endif +#ifdef V3_CONFIG_HVM + v3_deinit_hvm_core(core); +#endif + switch (v3_mach_type) { #ifdef V3_CONFIG_SVM case V3_SVM_CPU: diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index b291ada..6690e97 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -154,6 +154,10 @@ void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus, char *op // Parse host-os defined options into an easily-accessed format. v3_parse_options(options); +#ifdef V3_CONFIG_HVM + v3_init_hvm(); +#endif + // Memory manager initialization v3_init_mem(); @@ -255,6 +259,10 @@ void Shutdown_V3() { v3_deinit_mem(); +#ifdef V3_CONFIG_HVM + v3_deinit_hvm(); +#endif + v3_deinit_options(); @@ -869,6 +877,7 @@ int v3_get_state_vm(struct v3_vm_info *vm, case VM_INVALID: base->state = V3_VM_INVALID; break; case VM_RUNNING: base->state = V3_VM_RUNNING; break; case VM_STOPPED: base->state = V3_VM_STOPPED; break; + case VM_RESETTING: base->state = V3_VM_RESETTING; break; case VM_PAUSED: base->state = V3_VM_PAUSED; break; case VM_ERROR: base->state = V3_VM_ERROR; break; case VM_SIMULATING: base->state = V3_VM_SIMULATING; break; @@ -909,7 +918,7 @@ int v3_get_state_vm(struct v3_vm_info *vm, core->num_vcores=numcores; - for (i=0;imem_map.num_base_regions;i++) { + for (i=0;iregion[i].host_paddr = (void*)(vm->mem_map.base_regions[i].host_addr); mem->region[i].size = v3_mem_block_size; #ifdef V3_CONFIG_SWAPPING diff --git a/palacios/src/palacios/vmm_config.c b/palacios/src/palacios/vmm_config.c index 781754a..374c1a5 100644 --- a/palacios/src/palacios/vmm_config.c +++ b/palacios/src/palacios/vmm_config.c @@ -37,6 +37,10 @@ #include #endif +#ifdef V3_CONFIG_HVM +#include +#endif + #include #include @@ -351,6 +355,14 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) { } #endif +#ifdef V3_CONFIG_HVM + if (v3_init_hvm_vm(vm,vm_cfg)) { + PrintError(vm,VCORE_NONE,"Cannot initialize HVM for VM\n"); + return -1; + } +#endif + + if (v3_init_vm(vm) == -1) { PrintError(VM_NONE, VCORE_NONE, "Failed to initialize VM\n"); return -1; @@ -425,6 +437,13 @@ static int pre_config_core(struct guest_info * info, v3_cfg_tree_t * core_cfg) { return -1; } +#ifdef V3_CONFIG_HVM + if (v3_init_hvm_core(info)) { + PrintError(info->vm_info, info, "Error Initializing HVM Core\n"); + return -1; + } +#endif + if (info->vm_info->vm_class == V3_PC_VM) { if (pre_config_pc_core(info, core_cfg) == -1) { PrintError(info->vm_info, info, "PC Post configuration failure\n");