Skip to content

Commit

Permalink
feat: vm_flags compatibility across all kernels.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerzyjamroz committed Nov 1, 2024
1 parent f971541 commit 01abe4a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mrmShared/linux/CONFIG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Version definition for driver
# 20240124 Release
DRV_VERSION := 3
DRV_VERSION := 4
DRV_GROUP := mrf

# Package control vars
Expand Down
3 changes: 1 addition & 2 deletions mrmShared/linux/dkms-rpm/CONFIG
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

RPM_RELEASE := 1
# NOTE: Not necessary DIST ?= el7
RPM_RELEASE := 2
ARCH := noarch
12 changes: 7 additions & 5 deletions mrmShared/linux/uio_mrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/mm.h>

#define DRV_NAME "mrf-pci"

Expand Down Expand Up @@ -96,6 +97,9 @@ void __iomem *pci_ioremap_bar(struct pci_dev* pdev,int bar)
#define VM_RESERVED 0
#endif

// Make it compatible with kernels without support of the wrapper
void vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags) __attribute__((weak));

/** Linux 3.12 adds a size test when mapping UIO_MEM_PHYS ranges
* to fix an clear security issue. 7314e613d5ff9f0934f7a0f74ed7973b903315d1
*
Expand Down Expand Up @@ -123,11 +127,9 @@ int mrf_mmap_physical(struct uio_info *info, struct vm_area_struct *vma)
return -EINVAL;
}

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0))
vm_flags_set(vma, VM_IO | VM_RESERVED);
#else
vma->vm_flags |= VM_IO | VM_RESERVED;
#endif
if (vm_flags_set) vm_flags_set(vma, VM_IO | VM_RESERVED);
else vma->vm_flags |= VM_IO | VM_RESERVED;

vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);

return remap_pfn_range(vma,
Expand Down

0 comments on commit 01abe4a

Please sign in to comment.