#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?
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);
}
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;
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;
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");
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;
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");
return -EFAULT;
}
- if (v3_host_dev_read_guest_mem(dev->guestdev,
- dev,
+ if (v3_host_dev_read_guest_mem(dev,
+ dev->guestdev,
op.gpa,
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;
}
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);
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;
}
- if (v3_host_dev_write_guest_mem(dev->guestdev,
- dev,
+ if (v3_host_dev_write_guest_mem(dev,
+ dev->guestdev,
op.gpa,
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;
}
DEEP_DEBUG_PRINT("palacios: hostdev: irq guest\n");
- return v3_host_dev_raise_irq(dev->guestdev, dev, op.irq);
+ return v3_host_dev_raise_irq(dev, dev->guestdev, op.irq);
}
break;
}
-
-
-
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,
};
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;
}
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);
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;
}
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);
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");
}
+static int host_dev_guest_deinit(struct v3_guest * guest, void * vm_data) {
+
+ palacios_free(vm_data);
+ return 0;
+}
+
.init = host_dev_init,
.deinit = NULL,
.guest_init = host_dev_guest_init,
- .guest_deinit = NULL
+ .guest_deinit = host_dev_guest_deinit
};