diff options
author | Mike Larkin <mlarkin@cvs.openbsd.org> | 2018-04-26 14:34:43 +0000 |
---|---|---|
committer | Mike Larkin <mlarkin@cvs.openbsd.org> | 2018-04-26 14:34:43 +0000 |
commit | 606055f78dd47fff19cd9036562184ae358b8b48 (patch) | |
tree | 9c2b471949d64218d7f10f635997d18bd51449b9 /sys/arch/amd64 | |
parent | 4839e413b63ca5a577fcfb4007cb5318851fba64 (diff) |
vmm(4): Rearrange some interrupt window exiting code
Simplify some code and reduce the number of places we are handling VINTR
exits.
ok brynet
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/vmm.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 455a10a6dcc..cacf5df42c6 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.193 2018/04/26 11:37:25 mlarkin Exp $ */ +/* $OpenBSD: vmm.c,v 1.194 2018/04/26 14:34:42 mlarkin Exp $ */ /* * Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org> * @@ -4461,6 +4461,15 @@ svm_handle_exit(struct vcpu *vcpu) break; } + /* + * Guest is now ready for interrupts, so disable interrupt + * window exiting. + */ + vmcb->v_irq = 0; + vmcb->v_intr_vector = 0; + vmcb->v_intercept1 &= ~SVM_INTERCEPT_VINTR; + svm_set_dirty(vcpu, SVM_CLEANBITS_TPR | SVM_CLEANBITS_I); + update_rip = 0; break; case SVM_VMEXIT_INTR: @@ -6089,29 +6098,16 @@ vcpu_run_svm(struct vcpu *vcpu, struct vm_run_params *vrp) /* Handle vmd(8) injected interrupts */ /* Is there an interrupt pending injection? */ - if (irq != 0xFFFF) { - if (vcpu->vc_irqready) { - vmcb->v_eventinj = (irq & 0xFF) | (1<<31); - } else { - vmcb->v_irq = 1; - vmcb->v_intr_misc = SVM_INTR_MISC_V_IGN_TPR; - vmcb->v_intr_vector = 0; - vmcb->v_intercept1 |= SVM_INTERCEPT_VINTR; - svm_set_dirty(vcpu, SVM_CLEANBITS_TPR | - SVM_CLEANBITS_I); - } - + if (irq != 0xFFFF && vcpu->vc_irqready) { + DPRINTF("%s: inject irq %d\n", __func__, irq & 0xFF); + vmcb->v_eventinj = (irq & 0xFF) | (1<<31); irq = 0xFFFF; - } else if (!vcpu->vc_intr) { - /* Disable interrupt window */ - vmcb->v_irq = 0; - vmcb->v_intr_vector = 0; - vmcb->v_intercept1 &= ~SVM_INTERCEPT_VINTR; - svm_set_dirty(vcpu, SVM_CLEANBITS_TPR | SVM_CLEANBITS_I); - } + } /* Inject event if present */ if (vcpu->vc_event != 0) { + DPRINTF("%s: inject event %d\n", __func__, + vcpu->vc_event); /* Set the "Send error code" flag for certain vectors */ switch (vcpu->vc_event & 0xFF) { case VMM_EX_DF: |