Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Add HVM configuration capability, init/deinit, etc
Peter Dinda [Mon, 23 Mar 2015 21:09:33 +0000 (16:09 -0500)]
palacios/include/palacios/vm_guest.h
palacios/src/palacios/vm_guest.c
palacios/src/palacios/vmm.c
palacios/src/palacios/vmm_config.c

index a4fca43..3029c3c 100644 (file)
@@ -69,6 +69,10 @@ struct v3_sym_core_state;
 #include <palacios/vmm_mem_track.h>
 #endif
 
+#ifdef V3_CONFIG_HVM
+#include <palacios/vmm_hvm.h>
+#endif
+
 
 
 #include <palacios/vmm_config.h>
@@ -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
index 569fa0b..acbb11e 100644 (file)
@@ -37,6 +37,7 @@
 #include <palacios/vmm_mem_track.h>
 #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:
index b291ada..6690e97 100644 (file)
@@ -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;i<vm->mem_map.num_base_regions;i++) {
+    for (i=0;i<numregions;i++) {
        mem->region[i].host_paddr =  (void*)(vm->mem_map.base_regions[i].host_addr);
        mem->region[i].size = v3_mem_block_size;
 #ifdef V3_CONFIG_SWAPPING
index 781754a..374c1a5 100644 (file)
 #include <palacios/vmm_swapping.h>
 #endif
 
+#ifdef V3_CONFIG_HVM
+#include <palacios/vmm_hvm.h>
+#endif
+
 #include <palacios/vmm_host_events.h>
 #include <palacios/vmm_perftune.h>
 
@@ -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");