Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51d59c6b authored by Marcelo Tosatti's avatar Marcelo Tosatti
Browse files

KVM: x86: fix pvclock guest stopped flag reporting



kvm_guest_time_update unconditionally clears hv_clock.flags field,
so the notification never reaches the guest.

Fix it by allowing PVCLOCK_GUEST_STOPPED to passthrough.

Reviewed-by: default avatarEric B Munson <emunson@mgebm.net>
Reviewed-by: default avatarAmit Shah <amit.shah@redhat.com>
Signed-off-by: default avatarMarcelo Tosatti <mtosatti@redhat.com>
parent 64eb0620
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -420,6 +420,8 @@ struct kvm_vcpu_arch {
	unsigned int hw_tsc_khz;
	unsigned int hw_tsc_khz;
	unsigned int time_offset;
	unsigned int time_offset;
	struct page *time_page;
	struct page *time_page;
	/* set guest stopped flag in pvclock flags field */
	bool pvclock_set_guest_stopped_request;


	struct {
	struct {
		u64 msr_val;
		u64 msr_val;
+10 −3
Original line number Original line Diff line number Diff line
@@ -1134,6 +1134,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
	unsigned long this_tsc_khz;
	unsigned long this_tsc_khz;
	s64 kernel_ns, max_kernel_ns;
	s64 kernel_ns, max_kernel_ns;
	u64 tsc_timestamp;
	u64 tsc_timestamp;
	u8 pvclock_flags;


	/* Keep irq disabled to prevent changes to the clock */
	/* Keep irq disabled to prevent changes to the clock */
	local_irq_save(flags);
	local_irq_save(flags);
@@ -1215,7 +1216,14 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
	vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;
	vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset;
	vcpu->last_kernel_ns = kernel_ns;
	vcpu->last_kernel_ns = kernel_ns;
	vcpu->last_guest_tsc = tsc_timestamp;
	vcpu->last_guest_tsc = tsc_timestamp;
	vcpu->hv_clock.flags = 0;

	pvclock_flags = 0;
	if (vcpu->pvclock_set_guest_stopped_request) {
		pvclock_flags |= PVCLOCK_GUEST_STOPPED;
		vcpu->pvclock_set_guest_stopped_request = false;
	}

	vcpu->hv_clock.flags = pvclock_flags;


	/*
	/*
	 * The interface expects us to write an even number signaling that the
	 * The interface expects us to write an even number signaling that the
@@ -2624,10 +2632,9 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
 */
 */
static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
{
{
	struct pvclock_vcpu_time_info *src = &vcpu->arch.hv_clock;
	if (!vcpu->arch.time_page)
	if (!vcpu->arch.time_page)
		return -EINVAL;
		return -EINVAL;
	src->flags |= PVCLOCK_GUEST_STOPPED;
	vcpu->arch.pvclock_set_guest_stopped_request = true;
	kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
	kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
	return 0;
	return 0;
}
}