kcore.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. /*
  2. * fs/proc/kcore.c kernel ELF core dumper
  3. *
  4. * Modelled on fs/exec.c:aout_core_dump()
  5. * Jeremy Fitzhardinge <jeremy@sw.oz.au>
  6. * ELF version written by David Howells <David.Howells@nexor.co.uk>
  7. * Modified and incorporated into 2.3.x by Tigran Aivazian <tigran@veritas.com>
  8. * Support to dump vmalloc'd areas (ELF only), Tigran Aivazian <tigran@veritas.com>
  9. * Safe accesses to vmalloc/direct-mapped discontiguous areas, Kanoj Sarcar <kanoj@sgi.com>
  10. */
  11. #include <linux/mm.h>
  12. #include <linux/proc_fs.h>
  13. #include <linux/kcore.h>
  14. #include <linux/user.h>
  15. #include <linux/capability.h>
  16. #include <linux/elf.h>
  17. #include <linux/elfcore.h>
  18. #include <linux/notifier.h>
  19. #include <linux/vmalloc.h>
  20. #include <linux/highmem.h>
  21. #include <linux/printk.h>
  22. #include <linux/bootmem.h>
  23. #include <linux/init.h>
  24. #include <linux/slab.h>
  25. #include <linux/uaccess.h>
  26. #include <asm/io.h>
  27. #include <linux/list.h>
  28. #include <linux/ioport.h>
  29. #include <linux/memory.h>
  30. #include <linux/sched/task.h>
  31. #include <asm/sections.h>
  32. #include "internal.h"
  33. #define CORE_STR "CORE"
  34. #ifndef ELF_CORE_EFLAGS
  35. #define ELF_CORE_EFLAGS 0
  36. #endif
  37. static struct proc_dir_entry *proc_root_kcore;
  38. #ifndef kc_vaddr_to_offset
  39. #define kc_vaddr_to_offset(v) ((v) - PAGE_OFFSET)
  40. #endif
  41. #ifndef kc_offset_to_vaddr
  42. #define kc_offset_to_vaddr(o) ((o) + PAGE_OFFSET)
  43. #endif
  44. /* An ELF note in memory */
  45. struct memelfnote
  46. {
  47. const char *name;
  48. int type;
  49. unsigned int datasz;
  50. void *data;
  51. };
  52. static LIST_HEAD(kclist_head);
  53. static DEFINE_RWLOCK(kclist_lock);
  54. static int kcore_need_update = 1;
  55. void
  56. kclist_add(struct kcore_list *new, void *addr, size_t size, int type)
  57. {
  58. new->addr = (unsigned long)addr;
  59. new->size = size;
  60. new->type = type;
  61. write_lock(&kclist_lock);
  62. list_add_tail(&new->list, &kclist_head);
  63. write_unlock(&kclist_lock);
  64. }
  65. static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
  66. {
  67. size_t try, size;
  68. struct kcore_list *m;
  69. *nphdr = 1; /* PT_NOTE */
  70. size = 0;
  71. list_for_each_entry(m, &kclist_head, list) {
  72. try = kc_vaddr_to_offset((size_t)m->addr + m->size);
  73. if (try > size)
  74. size = try;
  75. *nphdr = *nphdr + 1;
  76. }
  77. *elf_buflen = sizeof(struct elfhdr) +
  78. (*nphdr + 2)*sizeof(struct elf_phdr) +
  79. 3 * ((sizeof(struct elf_note)) +
  80. roundup(sizeof(CORE_STR), 4)) +
  81. roundup(sizeof(struct elf_prstatus), 4) +
  82. roundup(sizeof(struct elf_prpsinfo), 4) +
  83. roundup(arch_task_struct_size, 4);
  84. *elf_buflen = PAGE_ALIGN(*elf_buflen);
  85. return size + *elf_buflen;
  86. }
  87. static void free_kclist_ents(struct list_head *head)
  88. {
  89. struct kcore_list *tmp, *pos;
  90. list_for_each_entry_safe(pos, tmp, head, list) {
  91. list_del(&pos->list);
  92. kfree(pos);
  93. }
  94. }
  95. /*
  96. * Replace all KCORE_RAM/KCORE_VMEMMAP information with passed list.
  97. */
  98. static void __kcore_update_ram(struct list_head *list)
  99. {
  100. int nphdr;
  101. size_t size;
  102. struct kcore_list *tmp, *pos;
  103. LIST_HEAD(garbage);
  104. write_lock(&kclist_lock);
  105. if (kcore_need_update) {
  106. list_for_each_entry_safe(pos, tmp, &kclist_head, list) {
  107. if (pos->type == KCORE_RAM
  108. || pos->type == KCORE_VMEMMAP)
  109. list_move(&pos->list, &garbage);
  110. }
  111. list_splice_tail(list, &kclist_head);
  112. } else
  113. list_splice(list, &garbage);
  114. kcore_need_update = 0;
  115. proc_root_kcore->size = get_kcore_size(&nphdr, &size);
  116. write_unlock(&kclist_lock);
  117. free_kclist_ents(&garbage);
  118. }
  119. #ifdef CONFIG_HIGHMEM
  120. /*
  121. * If no highmem, we can assume [0...max_low_pfn) continuous range of memory
  122. * because memory hole is not as big as !HIGHMEM case.
  123. * (HIGHMEM is special because part of memory is _invisible_ from the kernel.)
  124. */
  125. static int kcore_update_ram(void)
  126. {
  127. LIST_HEAD(head);
  128. struct kcore_list *ent;
  129. int ret = 0;
  130. ent = kmalloc(sizeof(*ent), GFP_KERNEL);
  131. if (!ent)
  132. return -ENOMEM;
  133. ent->addr = (unsigned long)__va(0);
  134. ent->size = max_low_pfn << PAGE_SHIFT;
  135. ent->type = KCORE_RAM;
  136. list_add(&ent->list, &head);
  137. __kcore_update_ram(&head);
  138. return ret;
  139. }
  140. #else /* !CONFIG_HIGHMEM */
  141. #ifdef CONFIG_SPARSEMEM_VMEMMAP
  142. /* calculate vmemmap's address from given system ram pfn and register it */
  143. static int
  144. get_sparsemem_vmemmap_info(struct kcore_list *ent, struct list_head *head)
  145. {
  146. unsigned long pfn = __pa(ent->addr) >> PAGE_SHIFT;
  147. unsigned long nr_pages = ent->size >> PAGE_SHIFT;
  148. unsigned long start, end;
  149. struct kcore_list *vmm, *tmp;
  150. start = ((unsigned long)pfn_to_page(pfn)) & PAGE_MASK;
  151. end = ((unsigned long)pfn_to_page(pfn + nr_pages)) - 1;
  152. end = PAGE_ALIGN(end);
  153. /* overlap check (because we have to align page */
  154. list_for_each_entry(tmp, head, list) {
  155. if (tmp->type != KCORE_VMEMMAP)
  156. continue;
  157. if (start < tmp->addr + tmp->size)
  158. if (end > tmp->addr)
  159. end = tmp->addr;
  160. }
  161. if (start < end) {
  162. vmm = kmalloc(sizeof(*vmm), GFP_KERNEL);
  163. if (!vmm)
  164. return 0;
  165. vmm->addr = start;
  166. vmm->size = end - start;
  167. vmm->type = KCORE_VMEMMAP;
  168. list_add_tail(&vmm->list, head);
  169. }
  170. return 1;
  171. }
  172. #else
  173. static int
  174. get_sparsemem_vmemmap_info(struct kcore_list *ent, struct list_head *head)
  175. {
  176. return 1;
  177. }
  178. #endif
  179. static int
  180. kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
  181. {
  182. struct list_head *head = (struct list_head *)arg;
  183. struct kcore_list *ent;
  184. ent = kmalloc(sizeof(*ent), GFP_KERNEL);
  185. if (!ent)
  186. return -ENOMEM;
  187. ent->addr = (unsigned long)__va((pfn << PAGE_SHIFT));
  188. ent->size = nr_pages << PAGE_SHIFT;
  189. /* Sanity check: Can happen in 32bit arch...maybe */
  190. if (ent->addr < (unsigned long) __va(0))
  191. goto free_out;
  192. /* cut not-mapped area. ....from ppc-32 code. */
  193. if (ULONG_MAX - ent->addr < ent->size)
  194. ent->size = ULONG_MAX - ent->addr;
  195. /* cut when vmalloc() area is higher than direct-map area */
  196. if (VMALLOC_START > (unsigned long)__va(0)) {
  197. if (ent->addr > VMALLOC_START)
  198. goto free_out;
  199. if (VMALLOC_START - ent->addr < ent->size)
  200. ent->size = VMALLOC_START - ent->addr;
  201. }
  202. ent->type = KCORE_RAM;
  203. list_add_tail(&ent->list, head);
  204. if (!get_sparsemem_vmemmap_info(ent, head)) {
  205. list_del(&ent->list);
  206. goto free_out;
  207. }
  208. return 0;
  209. free_out:
  210. kfree(ent);
  211. return 1;
  212. }
  213. static int kcore_update_ram(void)
  214. {
  215. int nid, ret;
  216. unsigned long end_pfn;
  217. LIST_HEAD(head);
  218. /* Not inialized....update now */
  219. /* find out "max pfn" */
  220. end_pfn = 0;
  221. for_each_node_state(nid, N_MEMORY) {
  222. unsigned long node_end;
  223. node_end = node_end_pfn(nid);
  224. if (end_pfn < node_end)
  225. end_pfn = node_end;
  226. }
  227. /* scan 0 to max_pfn */
  228. ret = walk_system_ram_range(0, end_pfn, &head, kclist_add_private);
  229. if (ret) {
  230. free_kclist_ents(&head);
  231. return -ENOMEM;
  232. }
  233. __kcore_update_ram(&head);
  234. return ret;
  235. }
  236. #endif /* CONFIG_HIGHMEM */
  237. /*****************************************************************************/
  238. /*
  239. * determine size of ELF note
  240. */
  241. static int notesize(struct memelfnote *en)
  242. {
  243. int sz;
  244. sz = sizeof(struct elf_note);
  245. sz += roundup((strlen(en->name) + 1), 4);
  246. sz += roundup(en->datasz, 4);
  247. return sz;
  248. } /* end notesize() */
  249. /*****************************************************************************/
  250. /*
  251. * store a note in the header buffer
  252. */
  253. static char *storenote(struct memelfnote *men, char *bufp)
  254. {
  255. struct elf_note en;
  256. #define DUMP_WRITE(addr,nr) do { memcpy(bufp,addr,nr); bufp += nr; } while(0)
  257. en.n_namesz = strlen(men->name) + 1;
  258. en.n_descsz = men->datasz;
  259. en.n_type = men->type;
  260. DUMP_WRITE(&en, sizeof(en));
  261. DUMP_WRITE(men->name, en.n_namesz);
  262. /* XXX - cast from long long to long to avoid need for libgcc.a */
  263. bufp = (char*) roundup((unsigned long)bufp,4);
  264. DUMP_WRITE(men->data, men->datasz);
  265. bufp = (char*) roundup((unsigned long)bufp,4);
  266. #undef DUMP_WRITE
  267. return bufp;
  268. } /* end storenote() */
  269. /*
  270. * store an ELF coredump header in the supplied buffer
  271. * nphdr is the number of elf_phdr to insert
  272. */
  273. static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
  274. {
  275. struct elf_prstatus prstatus; /* NT_PRSTATUS */
  276. struct elf_prpsinfo prpsinfo; /* NT_PRPSINFO */
  277. struct elf_phdr *nhdr, *phdr;
  278. struct elfhdr *elf;
  279. struct memelfnote notes[3];
  280. off_t offset = 0;
  281. struct kcore_list *m;
  282. /* setup ELF header */
  283. elf = (struct elfhdr *) bufp;
  284. bufp += sizeof(struct elfhdr);
  285. offset += sizeof(struct elfhdr);
  286. memcpy(elf->e_ident, ELFMAG, SELFMAG);
  287. elf->e_ident[EI_CLASS] = ELF_CLASS;
  288. elf->e_ident[EI_DATA] = ELF_DATA;
  289. elf->e_ident[EI_VERSION]= EV_CURRENT;
  290. elf->e_ident[EI_OSABI] = ELF_OSABI;
  291. memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
  292. elf->e_type = ET_CORE;
  293. elf->e_machine = ELF_ARCH;
  294. elf->e_version = EV_CURRENT;
  295. elf->e_entry = 0;
  296. elf->e_phoff = sizeof(struct elfhdr);
  297. elf->e_shoff = 0;
  298. elf->e_flags = ELF_CORE_EFLAGS;
  299. elf->e_ehsize = sizeof(struct elfhdr);
  300. elf->e_phentsize= sizeof(struct elf_phdr);
  301. elf->e_phnum = nphdr;
  302. elf->e_shentsize= 0;
  303. elf->e_shnum = 0;
  304. elf->e_shstrndx = 0;
  305. /* setup ELF PT_NOTE program header */
  306. nhdr = (struct elf_phdr *) bufp;
  307. bufp += sizeof(struct elf_phdr);
  308. offset += sizeof(struct elf_phdr);
  309. nhdr->p_type = PT_NOTE;
  310. nhdr->p_offset = 0;
  311. nhdr->p_vaddr = 0;
  312. nhdr->p_paddr = 0;
  313. nhdr->p_filesz = 0;
  314. nhdr->p_memsz = 0;
  315. nhdr->p_flags = 0;
  316. nhdr->p_align = 0;
  317. /* setup ELF PT_LOAD program header for every area */
  318. list_for_each_entry(m, &kclist_head, list) {
  319. phdr = (struct elf_phdr *) bufp;
  320. bufp += sizeof(struct elf_phdr);
  321. offset += sizeof(struct elf_phdr);
  322. phdr->p_type = PT_LOAD;
  323. phdr->p_flags = PF_R|PF_W|PF_X;
  324. phdr->p_offset = kc_vaddr_to_offset(m->addr) + dataoff;
  325. phdr->p_vaddr = (size_t)m->addr;
  326. if (m->type == KCORE_RAM || m->type == KCORE_TEXT)
  327. phdr->p_paddr = __pa(m->addr);
  328. else
  329. phdr->p_paddr = (elf_addr_t)-1;
  330. phdr->p_filesz = phdr->p_memsz = m->size;
  331. phdr->p_align = PAGE_SIZE;
  332. }
  333. /*
  334. * Set up the notes in similar form to SVR4 core dumps made
  335. * with info from their /proc.
  336. */
  337. nhdr->p_offset = offset;
  338. /* set up the process status */
  339. notes[0].name = CORE_STR;
  340. notes[0].type = NT_PRSTATUS;
  341. notes[0].datasz = sizeof(struct elf_prstatus);
  342. notes[0].data = &prstatus;
  343. memset(&prstatus, 0, sizeof(struct elf_prstatus));
  344. nhdr->p_filesz = notesize(&notes[0]);
  345. bufp = storenote(&notes[0], bufp);
  346. /* set up the process info */
  347. notes[1].name = CORE_STR;
  348. notes[1].type = NT_PRPSINFO;
  349. notes[1].datasz = sizeof(struct elf_prpsinfo);
  350. notes[1].data = &prpsinfo;
  351. memset(&prpsinfo, 0, sizeof(struct elf_prpsinfo));
  352. prpsinfo.pr_state = 0;
  353. prpsinfo.pr_sname = 'R';
  354. prpsinfo.pr_zomb = 0;
  355. strcpy(prpsinfo.pr_fname, "vmlinux");
  356. strlcpy(prpsinfo.pr_psargs, saved_command_line, sizeof(prpsinfo.pr_psargs));
  357. nhdr->p_filesz += notesize(&notes[1]);
  358. bufp = storenote(&notes[1], bufp);
  359. /* set up the task structure */
  360. notes[2].name = CORE_STR;
  361. notes[2].type = NT_TASKSTRUCT;
  362. notes[2].datasz = arch_task_struct_size;
  363. notes[2].data = current;
  364. nhdr->p_filesz += notesize(&notes[2]);
  365. bufp = storenote(&notes[2], bufp);
  366. } /* end elf_kcore_store_hdr() */
  367. /*****************************************************************************/
  368. /*
  369. * read from the ELF header and then kernel memory
  370. */
  371. static ssize_t
  372. read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
  373. {
  374. char *buf = file->private_data;
  375. ssize_t acc = 0;
  376. size_t size, tsz;
  377. size_t elf_buflen;
  378. int nphdr;
  379. unsigned long start;
  380. read_lock(&kclist_lock);
  381. size = get_kcore_size(&nphdr, &elf_buflen);
  382. if (buflen == 0 || *fpos >= size) {
  383. read_unlock(&kclist_lock);
  384. return 0;
  385. }
  386. /* trim buflen to not go beyond EOF */
  387. if (buflen > size - *fpos)
  388. buflen = size - *fpos;
  389. /* construct an ELF core header if we'll need some of it */
  390. if (*fpos < elf_buflen) {
  391. char * elf_buf;
  392. tsz = elf_buflen - *fpos;
  393. if (buflen < tsz)
  394. tsz = buflen;
  395. elf_buf = kzalloc(elf_buflen, GFP_ATOMIC);
  396. if (!elf_buf) {
  397. read_unlock(&kclist_lock);
  398. return -ENOMEM;
  399. }
  400. elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen);
  401. read_unlock(&kclist_lock);
  402. if (copy_to_user(buffer, elf_buf + *fpos, tsz)) {
  403. kfree(elf_buf);
  404. return -EFAULT;
  405. }
  406. kfree(elf_buf);
  407. buflen -= tsz;
  408. *fpos += tsz;
  409. buffer += tsz;
  410. acc += tsz;
  411. /* leave now if filled buffer already */
  412. if (buflen == 0)
  413. return acc;
  414. } else
  415. read_unlock(&kclist_lock);
  416. /*
  417. * Check to see if our file offset matches with any of
  418. * the addresses in the elf_phdr on our list.
  419. */
  420. start = kc_offset_to_vaddr(*fpos - elf_buflen);
  421. if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
  422. tsz = buflen;
  423. while (buflen) {
  424. struct kcore_list *m;
  425. read_lock(&kclist_lock);
  426. list_for_each_entry(m, &kclist_head, list) {
  427. if (start >= m->addr && start < (m->addr+m->size))
  428. break;
  429. }
  430. read_unlock(&kclist_lock);
  431. if (&m->list == &kclist_head) {
  432. if (clear_user(buffer, tsz))
  433. return -EFAULT;
  434. } else if (m->type == KCORE_VMALLOC) {
  435. vread(buf, (char *)start, tsz);
  436. /* we have to zero-fill user buffer even if no read */
  437. if (copy_to_user(buffer, buf, tsz))
  438. return -EFAULT;
  439. } else {
  440. if (kern_addr_valid(start)) {
  441. unsigned long n;
  442. /*
  443. * Using bounce buffer to bypass the
  444. * hardened user copy kernel text checks.
  445. */
  446. memcpy(buf, (char *) start, tsz);
  447. n = copy_to_user(buffer, buf, tsz);
  448. /*
  449. * We cannot distinguish between fault on source
  450. * and fault on destination. When this happens
  451. * we clear too and hope it will trigger the
  452. * EFAULT again.
  453. */
  454. if (n) {
  455. if (clear_user(buffer + tsz - n,
  456. n))
  457. return -EFAULT;
  458. }
  459. } else {
  460. if (clear_user(buffer, tsz))
  461. return -EFAULT;
  462. }
  463. }
  464. buflen -= tsz;
  465. *fpos += tsz;
  466. buffer += tsz;
  467. acc += tsz;
  468. start += tsz;
  469. tsz = (buflen > PAGE_SIZE ? PAGE_SIZE : buflen);
  470. }
  471. return acc;
  472. }
  473. static int open_kcore(struct inode *inode, struct file *filp)
  474. {
  475. if (!capable(CAP_SYS_RAWIO))
  476. return -EPERM;
  477. filp->private_data = kmalloc(PAGE_SIZE, GFP_KERNEL);
  478. if (!filp->private_data)
  479. return -ENOMEM;
  480. if (kcore_need_update)
  481. kcore_update_ram();
  482. if (i_size_read(inode) != proc_root_kcore->size) {
  483. inode_lock(inode);
  484. i_size_write(inode, proc_root_kcore->size);
  485. inode_unlock(inode);
  486. }
  487. return 0;
  488. }
  489. static int release_kcore(struct inode *inode, struct file *file)
  490. {
  491. kfree(file->private_data);
  492. return 0;
  493. }
  494. static const struct file_operations proc_kcore_operations = {
  495. .read = read_kcore,
  496. .open = open_kcore,
  497. .release = release_kcore,
  498. .llseek = default_llseek,
  499. };
  500. /* just remember that we have to update kcore */
  501. static int __meminit kcore_callback(struct notifier_block *self,
  502. unsigned long action, void *arg)
  503. {
  504. switch (action) {
  505. case MEM_ONLINE:
  506. case MEM_OFFLINE:
  507. write_lock(&kclist_lock);
  508. kcore_need_update = 1;
  509. write_unlock(&kclist_lock);
  510. }
  511. return NOTIFY_OK;
  512. }
  513. static struct notifier_block kcore_callback_nb __meminitdata = {
  514. .notifier_call = kcore_callback,
  515. .priority = 0,
  516. };
  517. static struct kcore_list kcore_vmalloc;
  518. #ifdef CONFIG_ARCH_PROC_KCORE_TEXT
  519. static struct kcore_list kcore_text;
  520. /*
  521. * If defined, special segment is used for mapping kernel text instead of
  522. * direct-map area. We need to create special TEXT section.
  523. */
  524. static void __init proc_kcore_text_init(void)
  525. {
  526. kclist_add(&kcore_text, _text, _end - _text, KCORE_TEXT);
  527. }
  528. #else
  529. static void __init proc_kcore_text_init(void)
  530. {
  531. }
  532. #endif
  533. #if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
  534. /*
  535. * MODULES_VADDR has no intersection with VMALLOC_ADDR.
  536. */
  537. struct kcore_list kcore_modules;
  538. static void __init add_modules_range(void)
  539. {
  540. if (MODULES_VADDR != VMALLOC_START && MODULES_END != VMALLOC_END) {
  541. kclist_add(&kcore_modules, (void *)MODULES_VADDR,
  542. MODULES_END - MODULES_VADDR, KCORE_VMALLOC);
  543. }
  544. }
  545. #else
  546. static void __init add_modules_range(void)
  547. {
  548. }
  549. #endif
  550. static int __init proc_kcore_init(void)
  551. {
  552. proc_root_kcore = proc_create("kcore", S_IRUSR, NULL,
  553. &proc_kcore_operations);
  554. if (!proc_root_kcore) {
  555. pr_err("couldn't create /proc/kcore\n");
  556. return 0; /* Always returns 0. */
  557. }
  558. /* Store text area if it's special */
  559. proc_kcore_text_init();
  560. /* Store vmalloc area */
  561. kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
  562. VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
  563. add_modules_range();
  564. /* Store direct-map area from physical memory map */
  565. kcore_update_ram();
  566. register_hotmemory_notifier(&kcore_callback_nb);
  567. return 0;
  568. }
  569. fs_initcall(proc_kcore_init);