013-mm-backport-get_user_pages.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. --- a/backport-include/linux/mm.h
  2. +++ b/backport-include/linux/mm.h
  3. @@ -39,8 +39,20 @@ static inline
  4. long backport_get_user_pages_locked(unsigned long start, unsigned long nr_pages,
  5. int write, int force, struct page **pages, int *locked)
  6. {
  7. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,168))
  8. return get_user_pages_locked(current, current->mm, start, nr_pages,
  9. write, force, pages, locked);
  10. +#else
  11. + int flags = 0;
  12. +
  13. + if (write)
  14. + flags |= FOLL_WRITE;
  15. + if (force)
  16. + flags |= FOLL_FORCE;
  17. +
  18. + return get_user_pages_locked(current, current->mm, start, nr_pages,
  19. + flags, pages, locked);
  20. +#endif
  21. }
  22. #define get_user_pages_locked LINUX_BACKPORT(get_user_pages_locked)
  23. @@ -48,8 +60,20 @@ static inline
  24. long backport_get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
  25. int write, int force, struct page **pages)
  26. {
  27. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,168))
  28. return get_user_pages_unlocked(current, current->mm, start, nr_pages,
  29. write, force, pages);
  30. +#else
  31. + int flags = 0;
  32. +
  33. + if (write)
  34. + flags |= FOLL_WRITE;
  35. + if (force)
  36. + flags |= FOLL_FORCE;
  37. +
  38. + return get_user_pages_unlocked(current, current->mm, start, nr_pages,
  39. + pages, flags);
  40. +#endif
  41. }
  42. #define get_user_pages_unlocked LINUX_BACKPORT(get_user_pages_unlocked)
  43. #endif
  44. @@ -60,8 +84,20 @@ long backport_get_user_pages(unsigned lo
  45. int write, int force, struct page **pages,
  46. struct vm_area_struct **vmas)
  47. {
  48. +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,4,168))
  49. return get_user_pages(current, current->mm, start, nr_pages,
  50. write, force, pages, vmas);
  51. +#else
  52. + int flags = 0;
  53. +
  54. + if (write)
  55. + flags |= FOLL_WRITE;
  56. + if (force)
  57. + flags |= FOLL_FORCE;
  58. +
  59. + return get_user_pages(current, current->mm, start, nr_pages,
  60. + flags, pages, vmas);
  61. +#endif
  62. }
  63. #define get_user_pages LINUX_BACKPORT(get_user_pages)
  64. #endif