Re: kvm/ia64: Fix halt emulation logic.

Marcelo Tosatti
2008-11-03T02:36:38Z

Hi Xiantao,

On Wed, Oct 15, 2008 at 09:47:24PM +0800, Zhang, Xiantao wrote:
> + expires = div64_u64(itc_diff, cyc_per_usec);
> + kt = ktime_set(0, 1000 * expires);
> +
> + down_read(&vcpu->kvm->slots_lock);
> + vcpu->arch.ht_active = 1;
> + hrtimer_start(p_ht, kt, HRTIMER_MODE_ABS);
>
> - if (irqchip_in_kernel(vcpu->kvm)) {
> vcpu->arch.mp_state = KVM_MP_STATE_HALTED;
> kvm_vcpu_block(vcpu);
> hrtimer_cancel(p_ht);
> vcpu->arch.ht_active = 0;
>
> + if (test_and_clear_bit(KVM_REQ_UNHALT, &vcpu->requests))
> + if (vcpu->arch.mp_state == KVM_MP_STATE_HALTED)
> + vcpu->arch.mp_state =
> + KVM_MP_STATE_RUNNABLE;
> + up_read(&vcpu->kvm->slots_lock);

You should release slots_lock when blocking via kvm_vcpu_block().
Otherwise paths that grab it for write will depend on these vcpus to
unhalt.

BTW, none of the data structures in this section of code should be
protected by slots_lock?