Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\userfaultfd.c Create Date:2022-07-28 20:20:36
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:userfaultfd_register

Proto:static int userfaultfd_register(struct userfaultfd_ctx *ctx, unsigned long arg)

Type:int

Parameter:

TypeParameterName
struct userfaultfd_ctx *ctx
unsigned longarg
1305  mm = mm with one ore more vmas attached to this userfaultfd_ctx
1309  __user * user_uffdio_register
1315  user_uffdio_register = arg
1317  ret = -EFAULT
1318  If copy_from_user( & uffdio_register, user_uffdio_register, size of uffdio_register - sizeof(__u64)) Then Go to out
1322  ret = -EINVAL
1323  If Not mode Then Go to out
1325  If mode & ~(UFFDIO_REGISTER_MODE_MISSING | UFFDIO_REGISTER_MODE_WP) Then Go to out
1328  vm_flags = 0
1329  If mode & UFFDIO_REGISTER_MODE_MISSING Then vm_flags |= missing pages tracking
1331  If mode & UFFDIO_REGISTER_MODE_WP Then
1332  vm_flags |= wrprotect pages tracking
1337  ret = -EINVAL
1338  Go to out
1341  ret = validate_range(mm, & start, len)
1343  If ret Then Go to out
1346  start = start
1347  end = start + len
1349  ret = -ENOMEM
1350  If Not mmget_not_zero(mm) Then Go to out
1353  lock for writing
1354  If Not This has to be called after a get_task_mm()/mmget_not_zero()* followed by taking the mmap_sem for writing before modifying the* vmas or anything the coredump pretends not to change from under it Then Go to out_unlock
1356  vma = Same as find_vma, but also return a pointer to the previous VMA in *pprev.
1357  If Not vma Then Go to out_unlock
1361  ret = -EINVAL
1362  If Our start address within vm_mm. >= end Then Go to out_unlock
1369  If is_vm_hugetlb_page(vma) Then
1370  vma_hpagesize = Return the size of the pages allocated when backing a VMA. In the majority* cases this will be same size as used by the page table entries.
1372  If start & vma_hpagesize - 1 Then Go to out_unlock
1379  found = false
1380  basic_ioctls = false
1381  When cur && Our start address within vm_mm. < end cycle
1382  cond_resched()
1384  BUG_ON(!!ctx ^ !!(Flags, see mm.h. & (missing pages tracking | wrprotect pages tracking )))
1388  ret = -EINVAL
1389  If Not vma_can_userfault(cur) Then Go to out_unlock
1400  ret = -EPERM
1401  If Value for the false possibility is greater at compile time(!(Flags, see mm.h. & VM_MAYWRITE)) Then Go to out_unlock
1412  ret = -EINVAL
1414  If end & vma_hpagesize - 1 Then Go to out_unlock
1424  ret = -EBUSY
1425  If ctx && ctx != ctx Then Go to out_unlock
1432  If is_vm_hugetlb_page(cur) Then basic_ioctls = true
1435  found = true
1437  BUG_ON(!found)
1439  If Our start address within vm_mm. < start Then prev = vma
1442  ret = 0
1443  Do
1444  cond_resched()
1446  BUG_ON(!vma_can_userfault(vma))
1447  BUG_ON(ctx && ctx != ctx)
1449  WARN_ON(!(Flags, see mm.h. & VM_MAYWRITE))
1455  If ctx == ctx && (Flags, see mm.h. & vm_flags) == vm_flags Then Go to skip
1459  If Our start address within vm_mm. > start Then start = Our start address within vm_mm.
1461  vma_end = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(end, The first byte after our end addresswithin vm_mm. )
1463  new_flags = Flags, see mm.h. & ~(missing pages tracking | wrprotect pages tracking ) | vm_flags
1465  prev = Given a mapping request (addr,end,vm_flags,file,pgoff), figure out* whether that can be merged with its predecessor or its successor
1469  If prev Then
1470  vma = prev
1471  Go to next
1475  If ret Then Break
1480  If ret Then Break
1483  :
1489  Flags, see mm.h. = new_flags
1490  ctx = ctx
1492  :
1493  prev = vma
1494  start = The first byte after our end addresswithin vm_mm.
1495  vma = linked list of VM areas per task, sorted by address
1496  When vma && Our start address within vm_mm. < end cycle
1497  out_unlock :
1498  lease a write lock
1499  Decrement the use count and release all resources for an mm.
1500  If Not ret Then
1506  If Write a simple value into user space(basic_ioctls ? UFFD_API_RANGE_IOCTLS_BASIC : UFFD_API_RANGE_IOCTLS, & * kernel answers which ioctl commands are available for the * range, keep at the end as the last 8 bytes aren't read.) Then ret = -EFAULT
1511  out :
1512  Return ret
Caller
NameDescribe
userfaultfd_ioctl