]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: Fix kvm_vcpu_block() task state race
authorMarcelo Tosatti <mtosatti@redhat.com>
Thu, 8 May 2008 22:47:01 +0000 (19:47 -0300)
committerAvi Kivity <avi@qumranet.com>
Sun, 18 May 2008 11:37:12 +0000 (14:37 +0300)
commit139febd51a5692e029b9489e9df42da5f1ca6d77
treed0a63882f0592a4ce23a98478fb9c935213b2e16
parent7ea6911061ea76065c16ea1b541ffe192827eb09
KVM: Fix kvm_vcpu_block() task state race

There's still a race in kvm_vcpu_block(), if a wake_up_interruptible()
call happens before the task state is set to TASK_INTERRUPTIBLE:

CPU0                            CPU1

kvm_vcpu_block

add_wait_queue

kvm_cpu_has_interrupt = 0
                                set interrupt
                                if (waitqueue_active())
                                        wake_up_interruptible()

kvm_cpu_has_pending_timer
kvm_arch_vcpu_runnable
signal_pending

set_current_state(TASK_INTERRUPTIBLE)
schedule()

Can be fixed by using prepare_to_wait() which sets the task state before
testing for the wait condition.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
virt/kvm/kvm_main.c