Function Report

Linux Kernel (v4.4)

Source File:fs\exec.c Create Date:2016-01-14 14:22:01
Last Modify:2016-01-11 07:01:32 Copyright©Brick
home page Tree
Annotate the kernelChinese

Function Name:shift_arg_pages

Function:static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)

Return Type:static int

Parameter:

Type Parameter NameRemarks
struct vm_area_struct * vma
unsigned long shift

Function description:During bprm_mm_init(), we create a temporary stack at STACK_TOP_MAX. Once the binfmt code determines where the new stack should reside, we shift it to its final location. The process proceeds as follows:

584  *mm = The address space we belong to.
585  old_start = Our start address within vm_mm.
586  old_end = The first byte after our end address within vm_mm.
587  length = old_end - old_start
588  new_start = old_start - shift
589  new_end = old_end - shift
592  Don't use BUG() or BUG_ON() unless there's really no way out; one example might be detecting data structure corruption in the middle of an operation that can't be backed out of
598  If vma != look up the first VMA in which addr resides, NULL if none- should be called with mm->mmap_sem at least held readlocked then Returning -Bad address
604  If We cannot adjust vm_start, vm_end, vm_pgoff fields of a vma that is already present in an i_mmap tree without adjusting the tree then Returning -Out of memory
612  If length != move_page_tables(vma, old_start, vma, new_start, length, false) then Returning -Out of memory
615  lru_add_drain()
616  Called to initialize an(on-stack) mmu_gather structure for page-table tear-down from@mm. The@fullmm argument is used when@mm is without users and we're going to destroy the full address space(exit/execve).
617  If new_end > old_start then
622  This function frees user-level page tables of a process.
623  Else
631  This function frees user-level page tables of a process.
633  Called at the end of the shootdown operation to free up any resources that were required.
638  We cannot adjust vm_start, vm_end, vm_pgoff fields of a vma that is already present in an i_mmap tree without adjusting the tree
640  Returning 0
Caller
Function NameFunction description
setup_arg_pagesFinalizes the stack vm_area_struct. The flags and permissions are updated, the stack is optionally relocated, and some extra space is added.