From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWS0T-0001Wc-Ur for qemu-devel@nongnu.org; Wed, 16 Oct 2013 10:23:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWS0L-0003m6-0S for qemu-devel@nongnu.org; Wed, 16 Oct 2013 10:23:25 -0400 Received: from e06smtp10.uk.ibm.com ([195.75.94.106]:50725) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWS0K-0003lt-Mr for qemu-devel@nongnu.org; Wed, 16 Oct 2013 10:23:16 -0400 Received: from /spool/local by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Oct 2013 15:23:14 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 42B5B17D8059 for ; Wed, 16 Oct 2013 15:23:38 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9GEN0R643253952 for ; Wed, 16 Oct 2013 14:23:00 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9GENC4c002960 for ; Wed, 16 Oct 2013 08:23:13 -0600 Message-ID: <525EA150.3060107@de.ibm.com> Date: Wed, 16 Oct 2013 16:23:12 +0200 From: Christian Borntraeger MIME-Version: 1.0 References: <525E8DC3.70409@borntraeger.net> <525E8F53.3090603@redhat.com> In-Reply-To: <525E8F53.3090603@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] RFC: KVM _CREATE_DEVICE considered harmful? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "qemu-devel@nongnu.org" , Jens Freimann , Alexander Graf , Gleb Natapov , KVM list dropping valgrind devel since its subscribers only... On 16/10/13 15:06, Paolo Bonzini wrote: > Il 16/10/2013 14:59, Christian Borntraeger ha scritto: >> >> Now, newer KVMs have the ability to create subdevices of a KVM guest (e.g. an in kernel >> kvm interrupt controller) with the following ioctl: >> >> #define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device) >> >> qemu can then work on these devices with the ioctls >> >> /* ioctls for fds returned by KVM_CREATE_DEVICE */ >> #define KVM_SET_DEVICE_ATTR _IOW(KVMIO, 0xe1, struct kvm_device_attr) >> #define KVM_GET_DEVICE_ATTR _IOW(KVMIO, 0xe2, struct kvm_device_attr) >> #define KVM_HAS_DEVICE_ATTR _IOW(KVMIO, 0xe3, struct kvm_device_attr) >> >> struct kvm_device_attr { >> __u32 flags; /* no flags currently defined */ >> __u32 group; /* device-defined */ >> __u64 attr; /* group-defined */ >> __u64 addr; /* userspace address of attr data */ >> }; > > Would it work to simply add an "__u64 size;" field to kvm_device_attr, > that is filled on exit by KVM_GET/HAS_DEVICE_ADDR, and filled on entry > to KVM_SET_DEVICE_ADDR? That would work, but it would change the ioctl number of KVM_*_DEVICE_ADDR, due to the changed size of struct kvm_device_attr. We would then need compat handlers in the kernel. If we could encode it in the existing interface the impact would be smaller. e.g. #define ATTR_ATTR_MASK 0xffffffffULL #define ATTR_LEN_MASK 0xffffffff00000000ULL switch (attr->attr) { ---> switch (attr->attr & ATTR_ATTR_MASK) { Then we could keep the device model abstraction. Just thinking here..better proposals are welcome Christian