Re: [PATCH] use guest value of version field in kvmclock

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 2, 2011 at 10:51 AM, Glauber Costa <glommer@xxxxxxxxxx> wrote:
> Avi noticed that we have to use guest's value for the version field,
> instead of keeping track of it ourselves. If we don't do that,
> the following situation can arise:
>
> Âvcpu->arch.hv_clock.version is initialized to zero.
> ÂGuest reads version (result: 2)
> ÂGuest starts reading data
> ÂLive migration; vcpu->arch.hv_clock.version is zeroed
> ÂSteal time update; vcpu->arch.hv_clock.version += 2; write to guest
> ÂGuest continues reading data
> ÂGuest reads version (result: 2)
Please ignore it. I did test this patch but appearently used the wrong
module, and it tricked me
this version is obviously wrong.

>
> Signed-off-by: Glauber Costa <glommer@xxxxxxxxxx>
> CC: Avi Kivity <avi@xxxxxxxxxx>
> ---
> Âarch/x86/kvm/x86.c | Â Â9 ++++++---
> Â1 files changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index c39ab4a..7fdc84a 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -1151,15 +1151,18 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
> Â Â Â Âvcpu->last_guest_tsc = tsc_timestamp;
> Â Â Â Âvcpu->hv_clock.flags = 0;
>
> + Â Â Â shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);
> +
> Â Â Â Â/*
> Â Â Â Â * The interface expects us to write an even number signaling that the
> Â Â Â Â * update is finished. Since the guest won't see the intermediate
> - Â Â Â Â* state, we just increase by 2 at the end.
> + Â Â Â Â* state, we just increase by 2 at the end. We use the guest's value as
> + Â Â Â Â* a basis to make it migration-safe.
> Â Â Â Â */
> + Â Â Â memcpy(&vcpu->hv_clock, shared_kaddr + vcpu->time_offset,
> + Â Â Â Â Â Â Âsizeof(vcpu->hv_clock));
> Â Â Â Âvcpu->hv_clock.version += 2;
>
> - Â Â Â shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0);
> -
> Â Â Â Âmemcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
> Â Â Â Â Â Â Â sizeof(vcpu->hv_clock));
>
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>



-- 
Sent from my Atari.
--
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


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux