Skip to content

Commit

Permalink
KVM: Allow kernel to select size of mmap() buffer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Avi Kivity committed May 3, 2007
1 parent 1961d27 commit 07c45a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
;
}
Expand Down
4 changes: 4 additions & 0 deletions include/linux/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07c45a3

Please sign in to comment.