X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmx_handler.c;h=1da5abd8054f9a8b5271c8a8f5b8079f690ba567;hb=ed8feff1d5dd6bf028cd5ba0960ec125505d7597;hp=af76455dcddec729a5169a5370eab7a938897abd;hpb=cfcceed5890430afedcc544bd7dbb69e29dfd65a;p=palacios.git diff --git a/palacios/src/palacios/vmx_handler.c b/palacios/src/palacios/vmx_handler.c index af76455..1da5abd 100644 --- a/palacios/src/palacios/vmx_handler.c +++ b/palacios/src/palacios/vmx_handler.c @@ -23,6 +23,8 @@ #include #include #include +#include + #include #include #include @@ -65,10 +67,10 @@ static int inline handle_cr_access(struct guest_info * info, ulong_t exit_qual) // PrintDebug("Control register: %d\n", cr_qual->access_type); switch(cr_qual->cr_id) { case 0: - PrintDebug("Handling CR0 Access\n"); + //PrintDebug("Handling CR0 Access\n"); return v3_vmx_handle_cr0_access(info); case 3: - PrintDebug("Handling CR3 Access\n"); + //PrintDebug("Handling CR3 Access\n"); return v3_vmx_handle_cr3_access(info); default: PrintError("Unhandled CR access: %d\n", cr_qual->cr_id); @@ -178,19 +180,13 @@ int v3_handle_vmx_exit(struct v3_gprs * gprs, struct guest_info * info, struct v } break; - case VMEXIT_CPUID: { - int instr_len; - uint32_t target = info->vm_regs.rax; - - v3_cpuid(target, (addr_t *)&(info->vm_regs.rax), (addr_t *)&(info->vm_regs.rbx), - (addr_t *)&(info->vm_regs.rcx), (addr_t *)&(info->vm_regs.rdx)); - - check_vmcs_read(VMCS_EXIT_INSTR_LEN, &instr_len); - - info->rip += instr_len; + case VMEXIT_CPUID: + if (v3_handle_cpuid(info) == -1) { + PrintError("Error Handling CPUID instruction\n"); + return -1; + } break; - } case VMEXIT_RDMSR: if (v3_handle_msr_read(info) == -1) { PrintError("Error handling MSR Read\n"); @@ -205,6 +201,19 @@ int v3_handle_vmx_exit(struct v3_gprs * gprs, struct guest_info * info, struct v } break; + case VMEXIT_VMCALL: + /* + * Hypercall + */ + + // VMCALL is a 3 byte op + // We do this early because some hypercalls can change the rip... + info->rip += 3; + + if (v3_handle_hypercall(info) == -1) { + return -1; + } + break; case VMEXIT_IO_INSTR: { struct vmx_exit_io_qual * io_qual = (struct vmx_exit_io_qual *)&exit_qual; @@ -297,12 +306,16 @@ int v3_handle_vmx_exit(struct v3_gprs * gprs, struct guest_info * info, struct v check_vmcs_write(VMCS_ENTRY_EXCP_ERR, info->excp_state.excp_error_code); int_info.error_code = 1; +#ifdef CONFIG_DEBUG_INTERRUPTS PrintDebug("Injecting exception %d with error code %x\n", int_info.vector, info->excp_state.excp_error_code); +#endif } int_info.valid = 1; +#ifdef CONFIG_DEBUG_INTERRUPTS PrintDebug("Injecting exception %d (EIP=%p)\n", int_info.vector, (void *)info->rip); +#endif check_vmcs_write(VMCS_ENTRY_INT_INFO, int_info.value); v3_injecting_excp(info, int_info.vector);