aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2008-11-25 14:17:01 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:02:45 -0400
commitf0b85051d0f0891378a83db22c0786f1d756fbff (patch)
tree116254e323aaebf37bb46d2c17d7e3654814e46b /arch/x86
parent8e0ee43bc2c3e19db56a4adaa9a9b04ce885cd84 (diff)
KVM: SVM: Clean up VINTR setting
The current VINTR intercept setters don't look clean to me. To make the code easier to read and enable the possibilty to trap on a VINTR set, this uses a helper function to set the VINTR intercept. v2 uses two distinct functions for setting and clearing the bit Acked-by: Joerg Roedel <joro@8bytes.org> Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/svm.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index a9e769e4e251..33407d95761f 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -718,6 +718,16 @@ static void svm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags)
718 to_svm(vcpu)->vmcb->save.rflags = rflags; 718 to_svm(vcpu)->vmcb->save.rflags = rflags;
719} 719}
720 720
721static void svm_set_vintr(struct vcpu_svm *svm)
722{
723 svm->vmcb->control.intercept |= 1ULL << INTERCEPT_VINTR;
724}
725
726static void svm_clear_vintr(struct vcpu_svm *svm)
727{
728 svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR);
729}
730
721static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg) 731static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg)
722{ 732{
723 struct vmcb_save_area *save = &to_svm(vcpu)->vmcb->save; 733 struct vmcb_save_area *save = &to_svm(vcpu)->vmcb->save;
@@ -1380,7 +1390,7 @@ static int interrupt_window_interception(struct vcpu_svm *svm,
1380{ 1390{
1381 KVMTRACE_0D(PEND_INTR, &svm->vcpu, handler); 1391 KVMTRACE_0D(PEND_INTR, &svm->vcpu, handler);
1382 1392
1383 svm->vmcb->control.intercept &= ~(1ULL << INTERCEPT_VINTR); 1393 svm_clear_vintr(svm);
1384 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK; 1394 svm->vmcb->control.int_ctl &= ~V_IRQ_MASK;
1385 /* 1395 /*
1386 * If the user space waits to inject interrupts, exit as soon as 1396 * If the user space waits to inject interrupts, exit as soon as
@@ -1593,7 +1603,7 @@ static void svm_intr_assist(struct kvm_vcpu *vcpu)
1593 (vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) || 1603 (vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) ||
1594 (vmcb->control.event_inj & SVM_EVTINJ_VALID)) { 1604 (vmcb->control.event_inj & SVM_EVTINJ_VALID)) {
1595 /* unable to deliver irq, set pending irq */ 1605 /* unable to deliver irq, set pending irq */
1596 vmcb->control.intercept |= (1ULL << INTERCEPT_VINTR); 1606 svm_set_vintr(svm);
1597 svm_inject_irq(svm, 0x0); 1607 svm_inject_irq(svm, 0x0);
1598 goto out; 1608 goto out;
1599 } 1609 }
@@ -1652,9 +1662,9 @@ static void do_interrupt_requests(struct kvm_vcpu *vcpu,
1652 */ 1662 */
1653 if (!svm->vcpu.arch.interrupt_window_open && 1663 if (!svm->vcpu.arch.interrupt_window_open &&
1654 (svm->vcpu.arch.irq_summary || kvm_run->request_interrupt_window)) 1664 (svm->vcpu.arch.irq_summary || kvm_run->request_interrupt_window))
1655 control->intercept |= 1ULL << INTERCEPT_VINTR; 1665 svm_set_vintr(svm);
1656 else 1666 else
1657 control->intercept &= ~(1ULL << INTERCEPT_VINTR); 1667 svm_clear_vintr(svm);
1658} 1668}
1659 1669
1660static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr) 1670static int svm_set_tss_addr(struct kvm *kvm, unsigned int addr)