X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=7736e383436afd5fa42fb69ed5f3213723964b1c;hb=4e43946f01f687361197dc9571b7df02ae20de30;hp=e49e4d405e6b2989a0ae0dbf410e160977807dbf;hpb=ffc83679ff6580fe325f505a91bf568660d663f7;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index e49e4d4..7736e38 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -33,20 +33,28 @@ #include #include +#ifdef V3_CONFIG_MEM_TRACK +#include +#endif +#ifdef V3_CONFIG_CACHEPART +#include +#endif + v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { struct cr0_32 * cr0; struct efer_64 * efer; - struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); struct v3_segment * cs = &(info->segments.cs); - + struct cr4_32 * cr4; if (info->shdw_pg_mode == SHADOW_PAGING) { cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer); + cr4 = (struct cr4_32 *)&(info->shdw_pg_state.guest_cr4); } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); efer = (struct efer_64 *)&(info->ctrl_regs.efer); + cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); } else { PrintError(info->vm_info, info, "Invalid Paging Mode...\n"); V3_ASSERT(info->vm_info, info, 0); @@ -249,6 +257,19 @@ int v3_init_vm(struct v3_vm_info * vm) { return -1; } + if (v3_init_passthrough_paging(vm) == -1) { + PrintError(vm, VCORE_NONE, "VM initialization error in passthrough paging\n"); + return -1; + } + + if (v3_init_nested_paging(vm) == -1) { + PrintError(vm, VCORE_NONE, "VM initialization error in nested paging\n"); + return -1; + } + +#ifdef V3_CONFIG_MEM_TRACK + v3_mem_track_init(vm); +#endif v3_init_time_vm(vm); @@ -300,6 +321,14 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_remove_hypercall(vm, GUEST_INFO_HCALL); +#ifdef V3_CONFIG_HVM + v3_deinit_hvm_vm(vm); +#endif + +#ifdef V3_CONFIG_MULTIBOOT + v3_deinit_multiboot_vm(vm); +#endif + #ifdef V3_CONFIG_SYMBIOTIC v3_deinit_symbiotic_vm(vm); @@ -332,8 +361,15 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_deinit_time_vm(vm); v3_deinit_mem_hooks(vm); + +#ifdef V3_CONFIG_SWAPPING + v3_deinit_swapping_vm(vm); +#endif + v3_delete_mem_map(vm); v3_deinit_shdw_impl(vm); + v3_deinit_passthrough_paging(vm); + v3_deinit_nested_paging(vm); v3_deinit_ext_manager(vm); v3_deinit_intr_routers(vm); @@ -352,10 +388,18 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_deinit_telemetry(vm); #endif + v3_deinit_events(vm); +#ifdef V3_CONFIG_MEM_TRACK + v3_mem_track_deinit(vm); +#endif + v3_fw_cfg_deinit(vm); +#ifdef V3_CONFIG_CACHEPART + v3_deinit_cachepart_vm(vm); +#endif return 0; } @@ -370,12 +414,22 @@ int v3_init_core(struct guest_info * core) { /* * Initialize the subsystem data strutures */ + + +#ifdef V3_CONFIG_CACHEPART + v3_init_cachepart_core(core); +#endif + #ifdef V3_CONFIG_TELEMETRY v3_init_core_telemetry(core); #endif if (core->shdw_pg_mode == SHADOW_PAGING) { + v3_init_passthrough_paging_core(core); v3_init_shdw_pg_state(core); + } else { + //done later due to SVM/VMX differences + //v3_init_nested_paging_core(core); } v3_init_time_core(core); @@ -433,6 +487,14 @@ int v3_free_core(struct guest_info * core) { v3_deinit_symbiotic_core(core); #endif +#ifdef V3_CONFIG_HVM + v3_deinit_hvm_core(core); +#endif + +#ifdef V3_CONFIG_MULTIBOOT + v3_deinit_multiboot_core(core); +#endif + v3_deinit_decoder(core); v3_deinit_intr_controllers(core); @@ -440,6 +502,9 @@ int v3_free_core(struct guest_info * core) { if (core->shdw_pg_mode == SHADOW_PAGING) { v3_deinit_shdw_pg_state(core); + v3_deinit_passthrough_paging_core(core); + } else { + v3_deinit_nested_paging_core(core); } v3_free_passthrough_pts(core); @@ -448,6 +513,8 @@ int v3_free_core(struct guest_info * core) { v3_deinit_core_telemetry(core); #endif + + switch (v3_mach_type) { #ifdef V3_CONFIG_SVM case V3_SVM_CPU: @@ -473,6 +540,10 @@ int v3_free_core(struct guest_info * core) { return -1; } +#ifdef V3_CONFIG_CACHEPART + v3_deinit_cachepart_core(core); +#endif + return 0; }