]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: Allow kernel to select size of mmap() buffer
authorAvi Kivity <avi@qumranet.com>
Wed, 7 Mar 2007 11:05:38 +0000 (13:05 +0200)
committerAvi Kivity <avi@qumranet.com>
Thu, 3 May 2007 07:52:24 +0000 (10:52 +0300)
This allows us to store offsets in the kernel/user kvm_run area, and be
sure that userspace has them mapped.  As offsets can be outside the
kvm_run struct, userspace has no way of knowing how much to mmap.

Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/kvm_main.c
include/linux/kvm.h

index df85f5f65489d311a6ca245d7b262776f8564ad8..cba0b87c34e4050fa9889ec0fd4ac2b2b5d857cd 100644 (file)
@@ -2436,7 +2436,7 @@ static long kvm_dev_ioctl(struct file *filp,
                          unsigned int ioctl, unsigned long arg)
 {
        void __user *argp = (void __user *)arg;
-       int r = -EINVAL;
+       long r = -EINVAL;
 
        switch (ioctl) {
        case KVM_GET_API_VERSION:
@@ -2478,6 +2478,12 @@ static long kvm_dev_ioctl(struct file *filp,
                 */
                r = 0;
                break;
+       case KVM_GET_VCPU_MMAP_SIZE:
+               r = -EINVAL;
+               if (arg)
+                       goto out;
+               r = PAGE_SIZE;
+               break;
        default:
                ;
        }
index c0d10cd8088ea3a4c0c1b0dc8a2a27c9d6d9cd1c..dad90816cad860efeb385fe2d989723949fab66a 100644 (file)
@@ -253,6 +253,10 @@ struct kvm_signal_mask {
  * return is 1 (yes) or 0 (no, sorry).
  */
 #define KVM_CHECK_EXTENSION       _IO(KVMIO,   0x03)
+/*
+ * Get size for mmap(vcpu_fd)
+ */
+#define KVM_GET_VCPU_MMAP_SIZE    _IO(KVMIO,   0x04) /* in bytes */
 
 /*
  * ioctls for VM fds