From: Avi Kivity <avi@redhat.com>
To: Joerg Roedel <joerg.roedel@amd.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Zachary Amsden <zamsden@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz
Date: Thu, 24 Mar 2011 12:14:36 +0200 [thread overview]
Message-ID: <4D8B198C.9020502@redhat.com> (raw)
In-Reply-To: <1300952424-32014-7-git-send-email-joerg.roedel@amd.com>
On 03/24/2011 09:40 AM, Joerg Roedel wrote:
> This patch implements two new vm-ioctls to get and set the
> virtual_tsc_khz if the machine supports tsc-scaling. Setting
> the tsc-frequency is only possible before userspace creates
> any vcpu.
>
>
> +4.54 KVM_SET_TSC_KHZ
> +
> +Capability: KVM_CAP_TSC_CONTROL
> +Architectures: x86
> +Type: vm ioctl
> +Parameters: __u32 (in)
> +Returns: 0 on success, -1 on error
> +
> +Specifies the tsc frequency for the virtual machine. This IOCTL must be
> +used before any vcpu is created. The unit of the frequency is KHz.
Should it not be a vcpu ioctl?
KVM_CAP_TSC_CONTROL depends on both kvm and the underlying cpu. I guess
it's okay.
Need to return an error if the frequency cannot be accommodated. In
theory we need to provide the range of supported frequencies, but we can
live without it (and it will be very difficult to provide if we take
accuracy into account).
> +
> +4.55 KVM_GET_TSC_KHZ
> +
> +Capability: KVM_CAP_GET_TSC_KHZ
> +Architectures: x86
> +Type: vm ioctl
> +Parameters: __u32 (out)
> +Returns: 0 on success, -1 on error
> +
> +Returns the tsc frequency of the guest. The unit of the return value is
> +KHz. If the host has unstable tsc this ioctl return an error.
Which error?
(it's important since this is an expected error, unlike most others)
> @@ -3580,6 +3591,52 @@ long kvm_arch_vm_ioctl(struct file *filp,
> r = 0;
> break;
> }
> + case KVM_SET_TSC_KHZ: {
> + u32 user_tsc_khz;
> +
> + if (!kvm_has_tsc_control)
> + break;
> +
> + r = -EFAULT;
> + if (copy_from_user(&user_tsc_khz, argp, sizeof(__u32)))
> + goto out;
Can just use the input value (arg) instead of copy_from_user().
> +
> + r = -EINVAL;
> + if (user_tsc_khz< kvm_min_guest_tsc_khz ||
> + user_tsc_khz> kvm_max_guest_tsc_khz)
<= and >= are probably safer.
> + goto out;
> +
> + mutex_lock(&kvm->lock);
> + /*
> + * We force the tsc frequency to be set before any
> + * vcpu is created
> + */
> + if (atomic_read(&kvm->online_vcpus)> 0) {
> + mutex_unlock(&kvm->lock);
> + goto out;
> + }
> +
> + kvm_arch_set_tsc_khz(kvm, user_tsc_khz);
> +
> + mutex_unlock(&kvm->lock);
Making these vcpu ioctls will remove the locking.
> +
> + r = 0;
> + goto out;
> + }
> + case KVM_GET_TSC_KHZ: {
> + u32 vtsc_khz = kvm->arch.virtual_tsc_khz;
> +
> + r = -EIO;
> + if (check_tsc_unstable())
> + goto out;
> +
> + r = -EFAULT;
> + if (copy_to_user(argp,&vtsc_khz, sizeof(__u32)))
> + goto out;
And an ordinary return here.
> +
> + r = 0;
> + goto out;
> + }
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2011-03-24 10:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-24 7:40 [PATCH 0/6][RESEND] TSC scaling support for KVM v2 Joerg Roedel
2011-03-24 7:40 ` [PATCH 1/6] KVM: SVM: Implement infrastructure for TSC_RATE_MSR Joerg Roedel
2011-03-24 9:51 ` Avi Kivity
2011-03-24 9:58 ` Joerg Roedel
2011-03-24 7:40 ` [PATCH 2/6] KVM: X86: Let kvm-clock report the right tsc frequency Joerg Roedel
2011-03-24 9:58 ` Avi Kivity
2011-03-24 7:40 ` [PATCH 3/6] KVM: X86: Make tsc_delta calculation a function of guest tsc Joerg Roedel
2011-03-24 7:40 ` [PATCH 4/6] KVM: SVM: Propagate requested TSC frequency on vcpu init Joerg Roedel
2011-03-24 10:04 ` Avi Kivity
2011-03-24 10:21 ` Joerg Roedel
2011-03-24 10:30 ` Avi Kivity
2011-03-24 7:40 ` [PATCH 5/6] KVM: X86: Delegate tsc-offset calculation to architecture code Joerg Roedel
2011-03-24 7:40 ` [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz Joerg Roedel
2011-03-24 10:14 ` Avi Kivity [this message]
2011-03-24 10:41 ` Joerg Roedel
2011-03-24 10:44 ` Avi Kivity
2011-03-24 10:47 ` Joerg Roedel
-- strict thread matches above, loose matches on Subject: below --
2011-03-25 8:44 [PATCH 0/6] TSC scaling support for KVM v3 Joerg Roedel
2011-03-25 8:44 ` [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz Joerg Roedel
2011-03-15 9:36 [PATCH 0/6] TSC scaling support for KVM v2 Joerg Roedel
2011-03-15 9:36 ` [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz Joerg Roedel
2011-02-09 17:29 [PATCH 0/6] KVM support for TSC scaling Joerg Roedel
2011-02-09 17:29 ` [PATCH 6/6] KVM: X86: Implement userspace interface to set virtual_tsc_khz Joerg Roedel
2011-02-13 15:12 ` Avi Kivity
2011-02-21 17:17 ` Roedel, Joerg
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=4D8B198C.9020502@redhat.com \
--to=avi@redhat.com \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=zamsden@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.