Carsten Otte wrote: > Zhang, Xiantao wrote: >> +static struct kvm_vcpu *lid_to_vcpu(struct kvm *kvm, unsigned long >> id, + unsigned long eid) +{ >> + ia64_lid_t lid; >> + int i; >> + >> + for (i = 0; i < KVM_MAX_VCPUS; i++) { >> + if (kvm->vcpus[i]) { >> + lid.val = VCPU_LID(kvm->vcpus[i]); >> + if (lid.id == id && lid.eid == eid) >> + return kvm->vcpus[i]; >> + } >> + } >> + >> + return NULL; >> +} >> + >> +static int handle_ipi(struct kvm_vcpu *vcpu, struct kvm_run >> *kvm_run) +{ + struct exit_ctl_data *p = kvm_get_exit_data(vcpu); >> + struct kvm_vcpu *target_vcpu; >> + struct kvm_pt_regs *regs; >> + ia64_ipi_a addr = p->u.ipi_data.addr; >> + ia64_ipi_d data = p->u.ipi_data.data; >> + >> + target_vcpu = lid_to_vcpu(vcpu->kvm, addr.id, addr.eid); + if >> (!target_vcpu) + return handle_vm_error(vcpu, kvm_run); >> + >> + if (!target_vcpu->arch.launched) { >> + regs = vcpu_regs(target_vcpu); >> + >> + regs->cr_iip = vcpu->kvm->arch.rdv_sal_data.boot_ip; >> + regs->r1 = vcpu->kvm->arch.rdv_sal_data.boot_gp; + >> + target_vcpu->arch.mp_state = VCPU_MP_STATE_RUNNABLE; >> + if (waitqueue_active(&target_vcpu->wq)) >> + wake_up_interruptible(&target_vcpu->wq); >> + } else { >> + vcpu_deliver_ipi(target_vcpu, data.dm, data.vector); + if >> (target_vcpu != vcpu) + kvm_vcpu_kick(target_vcpu); >> + } >> + >> + return 1; >> +} > *Shrug*. This looks highly racy to me. You do access various values in > target_vcpu without any lock! I know that taking the target vcpu's > lock does'nt work because that one is held all the time during > KVM_VCPU_RUN. My solution to that was struct local_interrupt, which > has its own lock, and has the waitqueue plus everything I need to send > a sigp [that's our flavor of ipi]. ex Hi, Carsten Why do you think it is racy? In this function, target_vcpu->arch.launched should be set to 1 for the first run, and keep its value all the time. Except the first IPI to wake up the vcpu, all IPIs received by target vcpu should go into "else" condition. So you mean the race condition exist in "else" code ? Xiantao -- To unsubscribe from this list: send the line "unsubscribe linux-ia64" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html
![]() |