X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-host-dev.c;h=ca5de91f7ff1092500a0ac39ad6200c9dcccf70c;hb=a19f42cc45ff4c4a07bf917a78a2a422319a78bb;hp=23d05e74de3d1c912854789878763f8dbf37f948;hpb=c13d012baf51f5fbb8359c89820c90723429a173;p=palacios.git diff --git a/linux_module/iface-host-dev.c b/linux_module/iface-host-dev.c index 23d05e7..ca5de91 100644 --- a/linux_module/iface-host-dev.c +++ b/linux_module/iface-host-dev.c @@ -127,21 +127,18 @@ struct palacios_host_dev { #define SHALLOW_DEBUG 0 #if DEEP_DEBUG -#define DEEP_DEBUG_PRINT(fmt, args...) printk((fmt), ##args) +#define DEEP_DEBUG_PRINT(fmt, args...) DEBUG((fmt), ##args) #else #define DEEP_DEBUG_PRINT(fmt, args...) #endif #if SHALLOW_DEBUG -#define SHALLOW_DEBUG_PRINT(fmt, args...) printk((fmt), ##args) +#define SHALLOW_DEBUG_PRINT(fmt, args...) INFO((fmt), ##args) #else #define SHALLOW_DEBUG_PRINT(fmt, args...) #endif -#define ERROR(fmt, args...) printk((fmt), ##args) -#define INFO(fmt, args...) printk((fmt), ##args) - struct palacios_host_device_user { spinlock_t lock; int connected; // is the user space connected to this? @@ -171,14 +168,14 @@ struct palacios_host_device_user { static void palacios_host_dev_user_free(struct palacios_host_device_user *dev) { if (dev->req) { - kfree(dev->req); + palacios_free(dev->req); dev->req=0; } if (dev->resp) { - kfree(dev->resp); + palacios_free(dev->resp); dev->resp=0; } - kfree(dev); + palacios_free(dev); } @@ -216,8 +213,8 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons if ((*r)==0) { // allocate it DEEP_DEBUG_PRINT("palacios: hostdev: attempt alloc\n"); - *r = kmalloc(sizeof(struct palacios_host_dev_host_request_response)+data_size,GFP_KERNEL); - DEEP_DEBUG_PRINT("palacios: hostdev: kmalloc done\n"); + *r = palacios_alloc(sizeof(struct palacios_host_dev_host_request_response)+data_size); + DEEP_DEBUG_PRINT("palacios: hostdev: palacios_alloc done\n"); if ((*r)==0) { ERROR("palacios: hostdev: failed to allocate\n"); return -1; @@ -238,10 +235,10 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons struct palacios_host_dev_host_request_response *new; if (!copy) { - kfree(*r); + palacios_free(*r); *r=0; } - new = kmalloc(sizeof(struct palacios_host_dev_host_request_response)+data_size,GFP_KERNEL); + new = palacios_alloc(sizeof(struct palacios_host_dev_host_request_response)+data_size); if (!new) { ERROR("palacios: hostdev: failed to reallocate\n"); return -1; @@ -250,7 +247,7 @@ static int palacios_resize_reqresp(struct palacios_host_dev_host_request_respons if (copy) { memcpy(new->data,(*r)->data,(*r)->data_len-sizeof(struct palacios_host_dev_host_request_response)); new->data_len=(*r)->data_len; - kfree(*r); + palacios_free(*r); } *r=new; DEEP_DEBUG_PRINT("palacios: hostdev: reallocated\n"); @@ -342,8 +339,7 @@ static int host_dev_release(struct inode * i, struct file * filp) return 0; } - -static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, unsigned long arg) +static long host_dev_ioctl(struct file * fp, unsigned int val, unsigned long arg) { void __user *argp = (void __user *)arg; @@ -371,7 +367,7 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u switch (op.type) { case PALACIOS_HOST_DEV_USER_REQUEST_READ_GUEST: { - void *temp = kmalloc(op.len,GFP_KERNEL); + void *temp = palacios_alloc(op.len); DEEP_DEBUG_PRINT("palacios: hostdev: read guest\n"); @@ -386,17 +382,17 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u temp, op.len) != op.len) { ERROR("palacios: unable to read enough from guest for host device \"%s\"\n",dev->url); - kfree(temp); + palacios_free(temp); return -EFAULT; } if (copy_to_user(op.data,temp,op.len)) { ERROR("palacios: unable to copy to user for host device \"%s\"\n",dev->url); - kfree(temp); + palacios_free(temp); return -EFAULT; } - kfree(temp); + palacios_free(temp); return op.len; } @@ -408,7 +404,7 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u DEEP_DEBUG_PRINT("palacios: hostdev: write guest\n"); - temp = kmalloc(op.len,GFP_KERNEL); + temp = palacios_alloc(op.len); if (!temp) { ERROR("palacios: unable to allocate enough for write guest request for host device \"%s\"\n",dev->url); @@ -417,7 +413,7 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u if (copy_from_user(temp,op.data,op.len)) { ERROR("palacios: unable to copy from user for host device \"%s\"\n",dev->url); - kfree(temp); + palacios_free(temp); return -EFAULT; } @@ -427,11 +423,11 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u temp, op.len) != op.len) { ERROR("palacios: unable to write enough to guest for host device \"%s\"\n",dev->url); - kfree(temp); + palacios_free(temp); return -EFAULT; } - kfree(temp); + palacios_free(temp); return op.len; } @@ -596,13 +592,11 @@ static int host_dev_ioctl(struct inode *ip, struct file *fp, unsigned int val, u } - - - static struct file_operations host_dev_fops = { .poll = host_dev_poll, .release = host_dev_release, - .ioctl = host_dev_ioctl, + .compat_ioctl = host_dev_ioctl, + .unlocked_ioctl = host_dev_ioctl, }; @@ -619,7 +613,7 @@ static int host_dev_connect(struct v3_guest * guest, unsigned int cmd, unsigned if (copy_from_user(url, argp, MAX_URL)) { - printk("copy from user error getting url for host device connect...\n"); + ERROR("copy from user error getting url for host device connect...\n"); return -EFAULT; } @@ -656,11 +650,11 @@ static int host_dev_connect(struct v3_guest * guest, unsigned int cmd, unsigned dev->connected=1; dev->waiting=0; if (dev->req) { - kfree(dev->req); + palacios_free(dev->req); dev->req=0; } if (dev->resp) { - kfree(dev->resp); + palacios_free(dev->resp); dev->resp=0; } INFO("palacios: connected fd for device \"%s\"\n",url); @@ -753,7 +747,7 @@ static v3_host_dev_t palacios_host_dev_open_deferred(char *url, host_dev = get_vm_ext_data(guest, "HOST_DEVICE_INTERFACE"); if (host_dev == NULL) { - printk("Error locating vm host data for HOST_DEVICE_INTERFACE\n"); + ERROR("Error locating vm host data for HOST_DEVICE_INTERFACE\n"); return 0; } @@ -778,7 +772,7 @@ static v3_host_dev_t palacios_host_dev_open_deferred(char *url, INFO("palacios: creating host device \"%s\"\n",url); - dev = kmalloc(sizeof(struct palacios_host_device_user),GFP_KERNEL); + dev = palacios_alloc(sizeof(struct palacios_host_device_user)); if (!dev) { ERROR("palacios: cannot allocate for host device \"%s\"\n",url); @@ -1327,7 +1321,7 @@ static int host_dev_init( void ) { static int host_dev_guest_init(struct v3_guest * guest, void ** vm_data ) { - struct palacios_host_dev * host_dev = kmalloc(sizeof(struct palacios_host_dev), GFP_KERNEL); + struct palacios_host_dev * host_dev = palacios_alloc(sizeof(struct palacios_host_dev)); if (!host_dev) { ERROR("palacios: failed to do guest_init for host device\n"); @@ -1347,6 +1341,12 @@ static int host_dev_guest_init(struct v3_guest * guest, void ** vm_data ) { } +static int host_dev_guest_deinit(struct v3_guest * guest, void * vm_data) { + + palacios_free(vm_data); + return 0; +} + @@ -1355,7 +1355,7 @@ static struct linux_ext host_dev_ext = { .init = host_dev_init, .deinit = NULL, .guest_init = host_dev_guest_init, - .guest_deinit = NULL + .guest_deinit = host_dev_guest_deinit };