X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=5d01aa93eb564190d022ece93eb319c912806474;hb=1fa090b14d99831af81c9d62aa47243ac1f0b9a5;hp=4dddf6efebf867afef84397e258be5dcf39d1c1f;hpb=14fa18cc54571eaa7aaa0f7d55677bdb4dad81a6;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index 4dddf6e..5d01aa9 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -364,24 +364,26 @@ void v3_print_GPRs(struct guest_info * info) { #include #include static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_data) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(v3_get_cpu_id()); - + v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + int cpu_valid = 0; + v3_print_guest_state(core); - // init SVM/VMX #ifdef CONFIG_SVM if ((cpu_type == V3_SVM_CPU) || (cpu_type == V3_SVM_REV3_CPU)) { + cpu_valid = 1; PrintDebugVMCB((vmcb_t *)(core->vmm_data)); } #endif #ifdef CONFIG_VMX - else if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { + if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { + cpu_valid = 1; v3_print_vmcs(); } #endif - else { - PrintError("Invalid CPU Type\n"); + if (!cpu_valid) { + PrintError("Invalid CPU Type 0x%x\n", cpu_type); return -1; } @@ -404,8 +406,8 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat int v3_init_vm(struct v3_vm_info * vm) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(v3_get_cpu_id()); - + v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + int cpu_valid = 0; if (v3_get_foreground_vm() == NULL) { v3_set_foreground_vm(vm); @@ -449,31 +451,30 @@ int v3_init_vm(struct v3_vm_info * vm) { if ((cpu_type == V3_SVM_CPU) || (cpu_type == V3_SVM_REV3_CPU)) { v3_init_svm_io_map(vm); v3_init_svm_msr_map(vm); - } + cpu_valid = 1; + } #endif #ifdef CONFIG_VMX - else if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { + if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { v3_init_vmx_io_map(vm); v3_init_vmx_msr_map(vm); + cpu_valid = 1; } #endif - else { - PrintError("Invalid CPU Type\n"); + if (!cpu_valid) { + PrintError("Invalid CPU Type 0x%x\n", cpu_type); return -1; } - - v3_register_hypercall(vm, GUEST_INFO_HCALL, info_hcall, NULL); - V3_Print("GUEST_INFO_HCALL=%x\n", GUEST_INFO_HCALL); return 0; } int v3_init_core(struct guest_info * core) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(v3_get_cpu_id()); + v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); struct v3_vm_info * vm = core->vm_info; /* @@ -499,25 +500,30 @@ int v3_init_core(struct guest_info * core) { #endif // init SVM/VMX + + + switch (cpu_type) { #ifdef CONFIG_SVM - if ((cpu_type == V3_SVM_CPU) || (cpu_type == V3_SVM_REV3_CPU)) { - if (v3_init_svm_vmcb(core, vm->vm_class) == -1) { - PrintError("Error in SVM initialization\n"); - return -1; - } - } + case V3_SVM_CPU: + case V3_SVM_REV3_CPU: + if (v3_init_svm_vmcb(core, vm->vm_class) == -1) { + PrintError("Error in SVM initialization\n"); + return -1; + } + break; #endif #ifdef CONFIG_VMX - else if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { - if (v3_init_vmx_vmcs(core, vm->vm_class) == -1) { - PrintError("Error in VMX initialization\n"); - return -1; - } - } + case V3_VMX_CPU: + case V3_VMX_EPT_CPU: + if (v3_init_vmx_vmcs(core, vm->vm_class) == -1) { + PrintError("Error in VMX initialization\n"); + return -1; + } + break; #endif - else { - PrintError("Invalid CPU Type\n"); - return -1; + default: + PrintError("Invalid CPU Type 0x%x\n", cpu_type); + return -1; } return 0;