Skip to content

Commit

Permalink
Merge pull request #64 from alex--m/topic/fix_v6_5
Browse files Browse the repository at this point in the history
Resolve build errors on kernel 6.4 and 6.5
  • Loading branch information
hjelmn authored Sep 11, 2024
2 parents 61c39ef + 0c56201 commit 3bcab55
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
9 changes: 8 additions & 1 deletion kernel/xpmem_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ xpmem_attach(struct file *file, xpmem_apid_t apid, off_t offset, size_t size,
vaddr + size);
xpmem_mmap_write_unlock(current->mm);
for ( ; existing_vma && existing_vma->vm_start < vaddr + size
; existing_vma = existing_vma->vm_next) {
; existing_vma = find_vma(current->mm, existing_vma->vm_end)) {
if (xpmem_is_vm_ops_set(existing_vma)) {
ret = -EINVAL;
goto out_3;
Expand All @@ -527,8 +527,15 @@ xpmem_attach(struct file *file, xpmem_apid_t apid, off_t offset, size_t size,
xpmem_mmap_write_unlock(current->mm);

vma->vm_private_data = att;

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

vma->vm_ops = &xpmem_vm_ops;

att->at_vma = vma;
Expand Down
2 changes: 1 addition & 1 deletion kernel/xpmem_mmu_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ xpmem_invalidate_range(struct mmu_notifier *mn,
return;
}

for ( ; vma && vma->vm_start < end; vma = vma->vm_next) {
for ( ; vma && vma->vm_start < end; vma = find_vma(mm, vma->vm_end)) {
unsigned long vm_start;
unsigned long vm_end;

Expand Down
14 changes: 12 additions & 2 deletions kernel/xpmem_pfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ xpmem_vaddr_to_pte_offset(struct mm_struct *mm, u64 vaddr, u64 *offset)
}
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
pte = pte_offset_kernel(pmd, vaddr);
#else
pte = pte_offset_map(pmd, vaddr);
#endif
if (!pte_present(*pte))
return NULL;

Expand Down Expand Up @@ -216,7 +220,11 @@ xpmem_vaddr_to_pte_size(struct mm_struct *mm, u64 vaddr, u64 *size)
return NULL;
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
pte = pte_offset_kernel(pmd, vaddr);
#else
pte = pte_offset_map(pmd, vaddr);
#endif
if (!pte_present(*pte)) {
*size = PAGE_SIZE;
return NULL;
Expand Down Expand Up @@ -268,10 +276,12 @@ xpmem_pin_page(struct xpmem_thread_group *tg, struct task_struct *src_task,
foll_write = (vma->vm_flags & VM_WRITE) ? FOLL_WRITE : 0;

/* get_user_pages()/get_user_pages_remote() faults and pins the page */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
ret = get_user_pages_remote (src_mm, vaddr, 1, foll_write, &page, NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
ret = get_user_pages_remote (src_mm, vaddr, 1, foll_write, &page, NULL,
NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)
ret = get_user_pages_remote (src_task, src_mm, vaddr, 1, foll_write,
&page, NULL, NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
Expand Down

0 comments on commit 3bcab55

Please sign in to comment.