Advertisement
emin_int11

son 33 gun

May 28th, 2015
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. task_struct
  2. | ---pmd /-pte->page
  3. | / /
  4. mm_struct ----> pgd----pmd---pte->page
  5. / | \ \
  6. / | \ ---pmd
  7. / | \
  8. / | \
  9. vm_area_struct-->vm_area_struct-->vm_area_struct
  10. | |
  11. | |
  12. struct file struct file
  13. / | \
  14. / | \
  15. / | \
  16. page-->page-->page
  17.  
  18.  
  19. The kernal maintains additional information on each memory address that is mapped by a process. Each process is assigned a struct mm_struct pointed to by the task_struct.
  20. struct mm_struct {
  21. struct vm_area_struct * mmap;
  22. rb_root_t mm_rb;
  23. struct vm_area_struct * mmap_cache;
  24. pgd_t * pgd;
  25. atomic_t mm_users;
  26. atomic_t mm_count;
  27. int map_count;
  28. struct rw_semaphore mmap_sem;
  29. spinlock_t page_table_lock;
  30. struct list_head mmlist;
  31. unsigned long start_code, end_code, start_data, end_data;
  32. unsigned long start_brk, brk, start_stack;
  33. unsigned long arg_start, arg_end, env_start, env_end;
  34. unsigned long rss, total_vm, locked_vm;
  35. unsigned long def_flags;
  36. unsigned long cpu_vm_mask;
  37. unsigned long swap_address;
  38.  
  39. unsigned dumpable:1;
  40.  
  41. mm_context_t context;
  42. };
  43.  
  44.  
  45. The vm_area_structs refer to a block of memory in the address space that is been used.
  46.  
  47. Text Code and initialised data from the executable itself. Starts at 0x08040000
  48. Heap Uninitialised data and the heap starting after text
  49. Stack The stack. Grows down from __PAGE_OFFSET (default 0xC00000000)
  50.  
  51. struct vm_area_struct {
  52. struct mm_struct * vm_mm;
  53. unsigned long vm_start;
  54. unsigned long vm_end;
  55.  
  56. /* linked list of VM areas per task, sorted by address */
  57. struct vm_area_struct *vm_next;
  58.  
  59. pgprot_t vm_page_prot;
  60. unsigned long vm_flags;
  61.  
  62. rb_node_t vm_rb;
  63. struct vm_area_struct *vm_next_share;
  64. struct vm_area_struct **vm_pprev_share;
  65.  
  66. struct vm_operations_struct * vm_ops;
  67.  
  68. /* Information about our backing store: */
  69. unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
  70. units, *not* PAGE_CACHE_SIZE */
  71. struct file * vm_file; /* File we map to (can be NULL). */
  72. unsigned long vm_raend; /* XXX: put full readahead info here. */
  73. void * vm_private_data; /* was vm_pte (shared mem) */
  74. };
  75.  
  76. 110 * vm_flags in vm_area_struct, see mm_types.h.
  77. 111 */
  78. 112 #define VM_NONE 0x00000000
  79. 113
  80. 114 #define VM_READ 0x00000001 /* currently active flags */
  81. 115 #define VM_WRITE 0x00000002
  82. 116 #define VM_EXEC 0x00000004
  83. 117 #define VM_SHARED 0x00000008
  84.  
  85.  
  86. snippet address space
  87.  
  88. 08048000-0804e000 r-xp 00000000 03:01 64652 /sbin/init text
  89. 0804e000-0804f000 rw-p 00006000 03:01 64652 /sbin/init data
  90. 0804f000-08053000 rwxp 00000000 00:00 0 zero-mapped BSS
  91. 40000000-40015000 r-xp 00000000 03:01 96278 /lib/ld-2.3.2.so text
  92. 40015000-40016000 rw-p 00014000 03:01 96278 /lib/ld-2.3.2.so data
  93. 40016000-40017000 rw-p 00000000 00:00 0 BSS for ld.so
  94. 42000000-4212e000 r-xp 00000000 03:01 80290 /lib/tls/libc-2.3.2.so text
  95. 4212e000-42131000 rw-p 0012e000 03:01 80290 /lib/tls/libc-2.3.2.so data
  96. 42131000-42133000 rw-p 00000000 00:00 0 BSS for libc
  97. bffff000-c0000000 rwxp 00000000 00:00 0 Stack segment
  98. ffffe000-fffff000 ---p 00000000 00:00 0 vsyscall page
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement