aboutsummaryrefslogtreecommitdiffstats
path: root/loopback_driver.c
diff options
context:
space:
mode:
authorMichele Paolino <m.paolino@virtualopensystems.com>2024-07-12 13:13:30 +0000
committerMichele Paolino <m.paolino@virtualopensystems.com>2024-07-25 13:38:07 +0000
commit78268b295615143255c9968087897226e9c16053 (patch)
tree2c82ff186c3efc2e7eaf76d7278ce363e7d46445 /loopback_driver.c
parentc434ed98e4269ac17456242c42a4a67bb05e24dd (diff)
virtio-loopback-driver fixes
Updates kernel version checks to successfully compile both on aws and AGL Ref Hardware v2: improve accuracy of the linux kernel versions Bug-AGL: SPEC-4834 Change-Id: Ibc75e3b1b8c1085afbcb02bd4976080b7dbc59cb Signed-off-by: Michele Paolino <m.paolino@virtualopensystems.com>
Diffstat (limited to 'loopback_driver.c')
-rw-r--r--loopback_driver.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/loopback_driver.c b/loopback_driver.c
index 5bb1181..989b865 100644
--- a/loopback_driver.c
+++ b/loopback_driver.c
@@ -30,6 +30,8 @@
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/device.h>
+#include <linux/version.h>
+#include <linux/slab.h>
/* Virtio-loopback includes */
#include <linux/dma-mapping.h>
@@ -429,6 +431,10 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned int in
goto error_new_virtqueue;
}
+
+#if LINUX_VERSION_CODE > KERNEL_VERSION(6,0,0)
+ vq->num_max = num;
+#endif
/* Activate the queue */
write_adapter(virtqueue_get_vring_size(vq), VIRTIO_MMIO_QUEUE_NUM, 4);
if (vm_dev->version == 1) {
@@ -735,7 +741,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);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,3,0)
vma->vm_flags |= VM_PFNMAP;
#else
vm_flags_set(vma, VM_PFNMAP);
@@ -921,7 +927,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,220)
+ efd_file = fcheck_files(userspace_task->files, efd_data.efd[0]);
+#else
efd_file = files_lookup_fd_rcu(userspace_task->files, efd_data.efd[0]);
+#endif
+
rcu_read_unlock();
efd_ctx = eventfd_ctx_fileget(efd_file);
@@ -1074,7 +1086,7 @@ static int __init loopback_init(void)
err = alloc_chrdev_region(&dev, 0, MAX_DEV, "loopback");
dev_major = MAJOR(dev);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6,4,0)
loopback_class = class_create(THIS_MODULE, "loopback");
#else
loopback_class = class_create("loopback");