The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Frederik Deweerdt <frederik.deweerdt@xprog.eu>
To: Glauber Costa <glommer@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, avi@redhat.com
Subject: Re: [PATCH] v3: allow userspace to adjust kvmclock offset
Date: Tue, 13 Oct 2009 21:11:37 +0000	[thread overview]
Message-ID: <20091013211137.GB31282@gambetta> (raw)
In-Reply-To: <1255467305-14748-1-git-send-email-glommer@redhat.com>

On Tue, Oct 13, 2009 at 04:55:05PM -0400, Glauber Costa wrote:
> +	case KVM_SET_CLOCK: {
> +		struct timespec now;
> +		struct kvm_clock_data user_ns;
> +		u64 now_ns;
> +		long delta;
		^^^^
Should'nt that read s64? I guess such a large value won't happen in
practice, but the 32bits case would truncate the value differently in
the substraction below.

Regards,
Frederik
> +
> +		r =  -EFAULT;
> +		if (copy_from_user(&user_ns, argp, sizeof(user_ns)))
> +			goto out;
> +
> +		r = 0;
> +		ktime_get_ts(&now);
> +		now_ns = timespec_to_ns(&now);
> +		delta = user_ns.clock - now_ns;
> +		kvm->arch.kvmclock_offset = delta;
> +		break;	
> +	}
> +	case KVM_GET_CLOCK: {
> +		struct timespec now;
> +		struct kvm_clock_data user_ns;
> +		u64 now_ns;
> +
> +		ktime_get_ts(&now);
> +		now_ns = timespec_to_ns(&now);
> +		user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
> +
> +		if (copy_to_user(argp, &user_ns, sizeof(user_ns)))
> +			r =  -EFAULT;
> +
> +		break;	
> +	}
> +
>  	default:
>  		;
>  	}
> diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> index f8f8900..ad0ecbc 100644
> --- a/include/linux/kvm.h
> +++ b/include/linux/kvm.h
> @@ -497,6 +497,11 @@ struct kvm_irqfd {
>  	__u8  pad[20];
>  };
>  
> +struct kvm_clock_data {
> +	__u64 clock;
> +	__u64 pad[2];
> +};
> +
>  /*
>   * ioctls for VM fds
>   */
> @@ -546,6 +551,8 @@ struct kvm_irqfd {
>  #define KVM_CREATE_PIT2		   _IOW(KVMIO, 0x77, struct kvm_pit_config)
>  #define KVM_SET_BOOT_CPU_ID        _IO(KVMIO, 0x78)
>  #define KVM_IOEVENTFD             _IOW(KVMIO, 0x79, struct kvm_ioeventfd)
> +#define KVM_SET_CLOCK		  _IOW(KVMIO, 0x7a, struct kvm_clock_data)
> +#define KVM_GET_CLOCK		  _IOW(KVMIO, 0x7b, struct kvm_clock_data)
>  
>  /*
>   * ioctls for vcpu fds
> -- 
> 1.6.2.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      reply	other threads:[~2009-10-13 21:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-13 20:55 [PATCH] v3: allow userspace to adjust kvmclock offset Glauber Costa
2009-10-13 21:11 ` Frederik Deweerdt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091013211137.GB31282@gambetta \
    --to=frederik.deweerdt@xprog.eu \
    --cc=avi@redhat.com \
    --cc=glommer@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox