aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Paolino <m.paolino@virtualopensystems.com>2023-12-08 11:04:25 +0000
committerMichele Paolino <m.paolino@virtualopensystems.com>2023-12-11 06:25:56 +0000
commitf9c1c04c0a3c2a133d969c3aae8490cb25145985 (patch)
tree5da2144d325ed7af1a52d220600e7f67db5c2660
parent0b267633e1648ef0ddc9fce9c22ca6300091cceb (diff)
Fix kernel driver to compile with 5.10 and 5.15
fcheck_files replace with files_lookup_fd_rcu in kernels > 5.11 and code cleaning. This is going to fix part of the virtio-loopback issues found in patchset 29407. Bug-AGL: SPEC-4834 Change-Id: I66ef985df68bcb02222489eb0de7b71c048fbb20 Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
-rw-r--r--loopback_driver.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/loopback_driver.c b/loopback_driver.c
index 950b2cb..609f118 100644
--- a/loopback_driver.c
+++ b/loopback_driver.c
@@ -476,8 +476,6 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int in
goto error_new_virtqueue;
}
- vq->num_max = num;
-
/* Activate the queue */
write_adapter(virtqueue_get_vring_size(vq), VIRTIO_MMIO_QUEUE_NUM, 4);
if (vm_dev->version == 1) {
@@ -949,7 +947,7 @@ int pf_mmap_vm_page(struct file *filp, struct vm_area_struct *vma)
uint64_t size = (unsigned long)(vma->vm_end - vma->vm_start);
uint64_t pfn = ((cur_ram_idx++) * 0x40000);
- vm_flags_set(vma, VM_PFNMAP);
+ vma->vm_flags |= VM_PFNMAP;
add_share_mmap(filp, pfn, vma->vm_start, size);
return 0;
}
@@ -979,7 +977,8 @@ int mmap_communication_shared_space(struct file *filp, struct vm_area_struct *vm
uint64_t com_mmap_pfn = ((uint64_t)virt_to_phys(com_mmap_virt)) >> PAGE_SHIFT;
int ret;
- vm_flags_set(vma, VM_RESERVED);
+ vma->vm_flags |= VM_RESERVED;
+
ret = remap_pfn_range(vma, vma->vm_start, com_mmap_pfn, size, vma->vm_page_prot);
if (ret != 0)
@@ -1166,11 +1165,13 @@ static long loopback_ioctl(struct file *file,
userspace_task = pid_task(find_vpid(efd_data.pid), PIDTYPE_PID);
rcu_read_lock();
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)
- efd_file = files_lookup_fd_rcu(userspace_task->files, efd_data.efd[0]);
+ efd_file = fcheck_files(userspace_task->files, efd_data.efd[0]);
#else
- rcu_read_unlock();
+ efd_file = files_lookup_fd_rcu(userspace_task->files, efd_data.efd[0]);
#endif
+ rcu_read_unlock();
efd_ctx = eventfd_ctx_fileget(efd_file);
if (!efd_ctx)
@@ -1323,7 +1324,7 @@ static int __init loopback_init(void)
err = alloc_chrdev_region(&dev, 0, MAX_DEV, "loopback");
dev_major = MAJOR(dev);
- loopback_class = class_create("loopback");
+ loopback_class = class_create(THIS_MODULE, "loopback");
for (i = 0; i < MAX_DEV; i++) {
cdev_init(&loopback_data[i].cdev, &fops);