diff options
author | Avi Kivity <avi@qumranet.com> | 2007-11-25 06:41:11 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:18 -0500 |
commit | 298101da2f507c13eaf179ee4507a7c0fe3e7b06 (patch) | |
tree | 2c0808964e5bc04812f0379b945fb187aaf901eb /drivers/kvm/svm.c | |
parent | 4bf8ed8dd2781a5e7603a83f8ee1d4f5aa04ebc4 (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/svm.c')
-rw-r--r-- | drivers/kvm/svm.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index c75c6b65b651..87072c647f28 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c | |||
@@ -188,6 +188,25 @@ static void svm_set_efer(struct kvm_vcpu *vcpu, u64 efer) | |||
188 | vcpu->shadow_efer = efer; | 188 | vcpu->shadow_efer = efer; |
189 | } | 189 | } |
190 | 190 | ||
191 | static void svm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr, | ||
192 | bool has_error_code, u32 error_code) | ||
193 | { | ||
194 | struct vcpu_svm *svm = to_svm(vcpu); | ||
195 | |||
196 | svm->vmcb->control.event_inj = nr | ||
197 | | SVM_EVTINJ_VALID | ||
198 | | (has_error_code ? SVM_EVTINJ_VALID_ERR : 0) | ||
199 | | SVM_EVTINJ_TYPE_EXEPT; | ||
200 | svm->vmcb->control.event_inj_err = error_code; | ||
201 | } | ||
202 | |||
203 | static bool svm_exception_injected(struct kvm_vcpu *vcpu) | ||
204 | { | ||
205 | struct vcpu_svm *svm = to_svm(vcpu); | ||
206 | |||
207 | return !(svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_VALID); | ||
208 | } | ||
209 | |||
191 | static void svm_inject_gp(struct kvm_vcpu *vcpu, unsigned error_code) | 210 | static void svm_inject_gp(struct kvm_vcpu *vcpu, unsigned error_code) |
192 | { | 211 | { |
193 | struct vcpu_svm *svm = to_svm(vcpu); | 212 | struct vcpu_svm *svm = to_svm(vcpu); |
@@ -1712,6 +1731,8 @@ static struct kvm_x86_ops svm_x86_ops = { | |||
1712 | .patch_hypercall = svm_patch_hypercall, | 1731 | .patch_hypercall = svm_patch_hypercall, |
1713 | .get_irq = svm_get_irq, | 1732 | .get_irq = svm_get_irq, |
1714 | .set_irq = svm_set_irq, | 1733 | .set_irq = svm_set_irq, |
1734 | .queue_exception = svm_queue_exception, | ||
1735 | .exception_injected = svm_exception_injected, | ||
1715 | .inject_pending_irq = svm_intr_assist, | 1736 | .inject_pending_irq = svm_intr_assist, |
1716 | .inject_pending_vectors = do_interrupt_requests, | 1737 | .inject_pending_vectors = do_interrupt_requests, |
1717 | 1738 | ||