@@ -1096,6 +1096,11 @@ static __always_inline int validate_range(struct mm_struct *mm,
1096
1096
return 0 ;
1097
1097
}
1098
1098
1099
+ static inline bool vma_can_userfault (struct vm_area_struct * vma )
1100
+ {
1101
+ return vma_is_anonymous (vma ) || is_vm_hugetlb_page (vma );
1102
+ }
1103
+
1099
1104
static int userfaultfd_register (struct userfaultfd_ctx * ctx ,
1100
1105
unsigned long arg )
1101
1106
{
@@ -1185,7 +1190,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
1185
1190
1186
1191
/* check not compatible vmas */
1187
1192
ret = - EINVAL ;
1188
- if (!vma_is_anonymous ( cur ) && ! is_vm_hugetlb_page (cur ))
1193
+ if (!vma_can_userfault (cur ))
1189
1194
goto out_unlock ;
1190
1195
/*
1191
1196
* If this vma contains ending address, and huge pages
@@ -1229,7 +1234,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
1229
1234
do {
1230
1235
cond_resched ();
1231
1236
1232
- BUG_ON (!vma_is_anonymous ( vma ) && ! is_vm_hugetlb_page (vma ));
1237
+ BUG_ON (!vma_can_userfault (vma ));
1233
1238
BUG_ON (vma -> vm_userfaultfd_ctx .ctx &&
1234
1239
vma -> vm_userfaultfd_ctx .ctx != ctx );
1235
1240
@@ -1367,7 +1372,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
1367
1372
* provides for more strict behavior to notice
1368
1373
* unregistration errors.
1369
1374
*/
1370
- if (!vma_is_anonymous ( cur ) && ! is_vm_hugetlb_page (cur ))
1375
+ if (!vma_can_userfault (cur ))
1371
1376
goto out_unlock ;
1372
1377
1373
1378
found = true;
@@ -1381,7 +1386,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx,
1381
1386
do {
1382
1387
cond_resched ();
1383
1388
1384
- BUG_ON (!vma_is_anonymous ( vma ) && ! is_vm_hugetlb_page (vma ));
1389
+ BUG_ON (!vma_can_userfault (vma ));
1385
1390
1386
1391
/*
1387
1392
* Nothing to do: this vma is already registered into this
0 commit comments