From: Avi Kivity <avi@qumranet.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: kvm-devel@lists.sourceforge.net, akpm@osdl.org,
linux-kernel@vger.kernel.org, uril@qumranet.com
Subject: Re: [kvm-devel] [PATCH 3/3] KVM: Expose MSRs to userspace
Date: Thu, 16 Nov 2006 21:17:18 +0200 [thread overview]
Message-ID: <455CB93E.4090309@qumranet.com> (raw)
In-Reply-To: <200611162008.48931.arnd@arndb.de>
Arnd Bergmann wrote:
> On Thursday 16 November 2006 19:04, Avi Kivity wrote:
>
>> +struct kvm_msr_entry {
>> + __u32 index;
>> + __u32 reserved;
>> + __u64 data;
>> +};
>> +
>> +/* for KVM_GET_MSRS and KVM_SET_MSRS */
>> +struct kvm_msrs {
>> + __u32 vcpu;
>> + __u32 nmsrs; /* number of msrs in entries */
>> +
>> + union {
>> + struct kvm_msr_entry __user *entries;
>> + __u64 padding;
>> + };
>> +};
>>
>
> ioctl interfaces with pointers in them are generally a bad idea,
> though you handle most of the points against them fine here
> (endianess doesn't matter, padding is correct).
>
> Still, it might be better not to set a bad example. Is accessing
> the MSRs actually performance critical? If not, you could
> define the ioctl to take only a single entry argument.
>
>
But then you can't dynamically determine which MSRs are available.
And no, reading/setting MSRs isn't performance critical for the current
use cases.
> A possible alternative could also be to have a variable length
> argument like below, but that creates other problems:
>
> +struct kvm_msrs {
> + __u32 vcpu;
> + __u32 nmsrs; /* number of msrs in entries */
> + struct kvm_msr_entry entries[0]; /* followed by actual msrs */
> +};
>
> This would mean that you can't tell the transfer size from the
> ioctl number, but you can't do that in your code either, because
> you do two separate transfers.
>
>
Heh. That was the original implementation by Uri. I felt that was
wrong because _IOW() encodes the size in the ioctl number, bit the
actual size is different.
> Arnd <><
>
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
next prev parent reply other threads:[~2006-11-16 19:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-16 17:59 [PATCH 0/3] KVM: Save/resume support Avi Kivity
[not found] ` <455CA70C.9060307-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-16 18:02 ` [PATCH 1/3] KVM: Expose interrupt bitmap Avi Kivity
2006-11-16 18:03 ` [PATCH 2/3] KVM: Add time stamp counter msr and accessors Avi Kivity
2006-11-16 18:04 ` [PATCH 3/3] KVM: Expose MSRs to userspace Avi Kivity
2006-11-16 19:08 ` Arnd Bergmann
2006-11-16 19:17 ` Avi Kivity [this message]
[not found] ` <455CB93E.4090309-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-17 8:06 ` Christoph Hellwig
2006-11-17 1:02 ` Andrew Morton
[not found] ` <20061116170214.b7785bd0.akpm-3NddpPZAyC0@public.gmane.org>
2006-11-17 7:20 ` Avi Kivity
[not found] ` <455D62D1.6040203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-17 8:15 ` Andrew Morton
[not found] ` <20061117001510.58f01b3c.akpm-3NddpPZAyC0@public.gmane.org>
2006-11-17 8:17 ` Avi Kivity
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=455CB93E.4090309@qumranet.com \
--to=avi@qumranet.com \
--cc=akpm@osdl.org \
--cc=arnd@arndb.de \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=uril@qumranet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox