aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/lapic.c
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2008-09-08 14:23:48 -0400
committerAvi Kivity <avi@qumranet.com>2008-10-15 04:15:26 -0400
commitd76901750ab9f71091d33ef3d2b5909d8a9a4ad4 (patch)
treee4a7ac912c70a05e4c8ee4e7294d9add48383fc2 /arch/x86/kvm/lapic.c
parenta6a3034cb979b1fa3948d8e1e91b2387fc66b89b (diff)
KVM: x86: do not execute halted vcpus
Offline or uninitialized vcpu's can be executed if requested to perform userspace work. Follow Avi's suggestion to handle halted vcpu's in the main loop, simplifying kvm_emulate_halt(). Introduce a new vcpu->requests bit to indicate events that promote state from halted to running. Also standardize vcpu wake sites. Signed-off-by: Marcelo Tosatti <mtosatti <at> redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'arch/x86/kvm/lapic.c')
-rw-r--r--arch/x86/kvm/lapic.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index be94f93a73f6..fd00f698692f 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -339,13 +339,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
339 } else 339 } else
340 apic_clear_vector(vector, apic->regs + APIC_TMR); 340 apic_clear_vector(vector, apic->regs + APIC_TMR);
341 341
342 if (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE) 342 kvm_vcpu_kick(vcpu);
343 kvm_vcpu_kick(vcpu);
344 else if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED) {
345 vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
346 if (waitqueue_active(&vcpu->wq))
347 wake_up_interruptible(&vcpu->wq);
348 }
349 343
350 result = (orig_irr == 0); 344 result = (orig_irr == 0);
351 break; 345 break;
@@ -384,8 +378,7 @@ static int __apic_accept_irq(struct kvm_lapic *apic, int delivery_mode,
384 if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) { 378 if (vcpu->arch.mp_state == KVM_MP_STATE_INIT_RECEIVED) {
385 vcpu->arch.sipi_vector = vector; 379 vcpu->arch.sipi_vector = vector;
386 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED; 380 vcpu->arch.mp_state = KVM_MP_STATE_SIPI_RECEIVED;
387 if (waitqueue_active(&vcpu->wq)) 381 kvm_vcpu_kick(vcpu);
388 wake_up_interruptible(&vcpu->wq);
389 } 382 }
390 break; 383 break;
391 384
@@ -950,10 +943,9 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
950 943
951 if(!atomic_inc_and_test(&apic->timer.pending)) 944 if(!atomic_inc_and_test(&apic->timer.pending))
952 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests); 945 set_bit(KVM_REQ_PENDING_TIMER, &apic->vcpu->requests);
953 if (waitqueue_active(q)) { 946 if (waitqueue_active(q))
954 apic->vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE;
955 wake_up_interruptible(q); 947 wake_up_interruptible(q);
956 } 948
957 if (apic_lvtt_period(apic)) { 949 if (apic_lvtt_period(apic)) {
958 result = 1; 950 result = 1;
959 apic->timer.dev.expires = ktime_add_ns( 951 apic->timer.dev.expires = ktime_add_ns(