aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/vmx.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-11-25 06:41:11 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:18 -0500
commit298101da2f507c13eaf179ee4507a7c0fe3e7b06 (patch)
tree2c0808964e5bc04812f0379b945fb187aaf901eb /drivers/kvm/vmx.c
parent4bf8ed8dd2781a5e7603a83f8ee1d4f5aa04ebc4 (diff)
KVM: Generalize exception injection mechanism
Instead of each subarch doing its own thing, add an API for queuing an injection, and manage failed exception injection centerally (i.e., if an inject failed due to a shadow page fault, we need to requeue it). Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/vmx.c')
-rw-r--r--drivers/kvm/vmx.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index fc5e7c8381ce..f382956f176a 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -595,6 +595,24 @@ static void skip_emulated_instruction(struct kvm_vcpu *vcpu)
595 vcpu->interrupt_window_open = 1; 595 vcpu->interrupt_window_open = 1;
596} 596}
597 597
598static void vmx_queue_exception(struct kvm_vcpu *vcpu, unsigned nr,
599 bool has_error_code, u32 error_code)
600{
601 vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
602 nr | INTR_TYPE_EXCEPTION
603 | (has_error_code ? INTR_INFO_DELIEVER_CODE_MASK : 0)
604 | INTR_INFO_VALID_MASK);
605 if (has_error_code)
606 vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
607}
608
609static bool vmx_exception_injected(struct kvm_vcpu *vcpu)
610{
611 struct vcpu_vmx *vmx = to_vmx(vcpu);
612
613 return !(vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK);
614}
615
598static void vmx_inject_gp(struct kvm_vcpu *vcpu, unsigned error_code) 616static void vmx_inject_gp(struct kvm_vcpu *vcpu, unsigned error_code)
599{ 617{
600 printk(KERN_DEBUG "inject_general_protection: rip 0x%lx\n", 618 printk(KERN_DEBUG "inject_general_protection: rip 0x%lx\n",
@@ -2641,6 +2659,8 @@ static struct kvm_x86_ops vmx_x86_ops = {
2641 .patch_hypercall = vmx_patch_hypercall, 2659 .patch_hypercall = vmx_patch_hypercall,
2642 .get_irq = vmx_get_irq, 2660 .get_irq = vmx_get_irq,
2643 .set_irq = vmx_inject_irq, 2661 .set_irq = vmx_inject_irq,
2662 .queue_exception = vmx_queue_exception,
2663 .exception_injected = vmx_exception_injected,
2644 .inject_pending_irq = vmx_intr_assist, 2664 .inject_pending_irq = vmx_intr_assist,
2645 .inject_pending_vectors = do_interrupt_requests, 2665 .inject_pending_vectors = do_interrupt_requests,
2646 2666