Il 03/09/2013 05:03, Marcelo Tosatti ha scritto: > > Here is the code I was thinking of: > > > > spin_lock(&ka->pvclock_gtod_sync_lock); > > make_all_cpus_request(kvm, KVM_REQ_CLOCK_UPDATE); > > > > /* > > * No guest entries from this point: VCPUs will be spinning > > * on pvclock_gtod_sync_lock in kvm_guest_time_update. > > */ > > pvclock_update_vm_gtod_copy(kvm); > > > > /* > > * Let kvm_guest_time_update continue: entering the guest > > * is now allowed too. > > */ > > spin_unlock(&ka->pvclock_gtod_sync_lock); > > > > KVM_REQ_CLOCK_UPDATE is used to cancel guest entry and execute > > kvm_guest_time_update. But kvm_guest_time_update will spin on > > pvclock_gtod_sync_lock until pvclock_update_vm_gtod_copy exits and > > kvm_gen_update_masterclock releases the spinlock. > > Not safe because there are places which set KVM_REQ_CLOCK_UPDATE without > kicking target vcpu out of guest mode. Unless you use a modified > make_all_cpus_request. make_all_cpus_request does force an exit, even if the bit is already set in vcpus->requests. But maybe here is where I'm missing something. > The point of REQ_MCLOCK_INPROGRESS request is to guarantee that the > following is not possible: > > - 2 vcpus in guest mode with per-vcpu kvmclock areas with > different {system_timestamp, tsc_offset} values. Understood. > To achieve that: > > - Kick all vcpus out of guest mode (via a request bit that can't be > cleared). > - Update the {system_timestamp, tsc_offset} values. > - Clear the request bit. After make_all_cpus_request, all VCPUs will be out of guest mode, and the request bit will not be cleared until pvclock_gtod_sync_lock is released. Paolo -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html