crash_dump.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /*
  2. * S390 kdump implementation
  3. *
  4. * Copyright IBM Corp. 2011
  5. * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
  6. */
  7. #include <linux/crash_dump.h>
  8. #include <asm/lowcore.h>
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/gfp.h>
  12. #include <linux/slab.h>
  13. #include <linux/bootmem.h>
  14. #include <linux/elf.h>
  15. #include <asm/asm-offsets.h>
  16. #include <linux/memblock.h>
  17. #include <asm/os_info.h>
  18. #include <asm/elf.h>
  19. #include <asm/ipl.h>
  20. #include <asm/sclp.h>
  21. #define PTR_ADD(x, y) (((char *) (x)) + ((unsigned long) (y)))
  22. #define PTR_SUB(x, y) (((char *) (x)) - ((unsigned long) (y)))
  23. #define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y))))
  24. static struct memblock_region oldmem_region;
  25. static struct memblock_type oldmem_type = {
  26. .cnt = 1,
  27. .max = 1,
  28. .total_size = 0,
  29. .regions = &oldmem_region,
  30. };
  31. struct save_area {
  32. struct list_head list;
  33. u64 psw[2];
  34. u64 ctrs[16];
  35. u64 gprs[16];
  36. u32 acrs[16];
  37. u64 fprs[16];
  38. u32 fpc;
  39. u32 prefix;
  40. u64 todpreg;
  41. u64 timer;
  42. u64 todcmp;
  43. u64 vxrs_low[16];
  44. __vector128 vxrs_high[16];
  45. };
  46. static LIST_HEAD(dump_save_areas);
  47. /*
  48. * Allocate a save area
  49. */
  50. struct save_area * __init save_area_alloc(bool is_boot_cpu)
  51. {
  52. struct save_area *sa;
  53. sa = (void *) memblock_alloc(sizeof(*sa), 8);
  54. if (is_boot_cpu)
  55. list_add(&sa->list, &dump_save_areas);
  56. else
  57. list_add_tail(&sa->list, &dump_save_areas);
  58. return sa;
  59. }
  60. /*
  61. * Return the address of the save area for the boot CPU
  62. */
  63. struct save_area * __init save_area_boot_cpu(void)
  64. {
  65. if (list_empty(&dump_save_areas))
  66. return NULL;
  67. return list_first_entry(&dump_save_areas, struct save_area, list);
  68. }
  69. /*
  70. * Copy CPU registers into the save area
  71. */
  72. void __init save_area_add_regs(struct save_area *sa, void *regs)
  73. {
  74. struct lowcore *lc;
  75. lc = (struct lowcore *)(regs - __LC_FPREGS_SAVE_AREA);
  76. memcpy(&sa->psw, &lc->psw_save_area, sizeof(sa->psw));
  77. memcpy(&sa->ctrs, &lc->cregs_save_area, sizeof(sa->ctrs));
  78. memcpy(&sa->gprs, &lc->gpregs_save_area, sizeof(sa->gprs));
  79. memcpy(&sa->acrs, &lc->access_regs_save_area, sizeof(sa->acrs));
  80. memcpy(&sa->fprs, &lc->floating_pt_save_area, sizeof(sa->fprs));
  81. memcpy(&sa->fpc, &lc->fpt_creg_save_area, sizeof(sa->fpc));
  82. memcpy(&sa->prefix, &lc->prefixreg_save_area, sizeof(sa->prefix));
  83. memcpy(&sa->todpreg, &lc->tod_progreg_save_area, sizeof(sa->todpreg));
  84. memcpy(&sa->timer, &lc->cpu_timer_save_area, sizeof(sa->timer));
  85. memcpy(&sa->todcmp, &lc->clock_comp_save_area, sizeof(sa->todcmp));
  86. }
  87. /*
  88. * Copy vector registers into the save area
  89. */
  90. void __init save_area_add_vxrs(struct save_area *sa, __vector128 *vxrs)
  91. {
  92. int i;
  93. /* Copy lower halves of vector registers 0-15 */
  94. for (i = 0; i < 16; i++)
  95. memcpy(&sa->vxrs_low[i], &vxrs[i].u[2], 8);
  96. /* Copy vector registers 16-31 */
  97. memcpy(sa->vxrs_high, vxrs + 16, 16 * sizeof(__vector128));
  98. }
  99. /*
  100. * Return physical address for virtual address
  101. */
  102. static inline void *load_real_addr(void *addr)
  103. {
  104. unsigned long real_addr;
  105. asm volatile(
  106. " lra %0,0(%1)\n"
  107. " jz 0f\n"
  108. " la %0,0\n"
  109. "0:"
  110. : "=a" (real_addr) : "a" (addr) : "cc");
  111. return (void *)real_addr;
  112. }
  113. /*
  114. * Copy memory of the old, dumped system to a kernel space virtual address
  115. */
  116. int copy_oldmem_kernel(void *dst, void *src, size_t count)
  117. {
  118. unsigned long from, len;
  119. void *ra;
  120. int rc;
  121. while (count) {
  122. from = __pa(src);
  123. if (!OLDMEM_BASE && from < sclp.hsa_size) {
  124. /* Copy from zfcpdump HSA area */
  125. len = min(count, sclp.hsa_size - from);
  126. rc = memcpy_hsa_kernel(dst, from, len);
  127. if (rc)
  128. return rc;
  129. } else {
  130. /* Check for swapped kdump oldmem areas */
  131. if (OLDMEM_BASE && from - OLDMEM_BASE < OLDMEM_SIZE) {
  132. from -= OLDMEM_BASE;
  133. len = min(count, OLDMEM_SIZE - from);
  134. } else if (OLDMEM_BASE && from < OLDMEM_SIZE) {
  135. len = min(count, OLDMEM_SIZE - from);
  136. from += OLDMEM_BASE;
  137. } else {
  138. len = count;
  139. }
  140. if (is_vmalloc_or_module_addr(dst)) {
  141. ra = load_real_addr(dst);
  142. len = min(PAGE_SIZE - offset_in_page(ra), len);
  143. } else {
  144. ra = dst;
  145. }
  146. if (memcpy_real(ra, (void *) from, len))
  147. return -EFAULT;
  148. }
  149. dst += len;
  150. src += len;
  151. count -= len;
  152. }
  153. return 0;
  154. }
  155. /*
  156. * Copy memory of the old, dumped system to a user space virtual address
  157. */
  158. static int copy_oldmem_user(void __user *dst, void *src, size_t count)
  159. {
  160. unsigned long from, len;
  161. int rc;
  162. while (count) {
  163. from = __pa(src);
  164. if (!OLDMEM_BASE && from < sclp.hsa_size) {
  165. /* Copy from zfcpdump HSA area */
  166. len = min(count, sclp.hsa_size - from);
  167. rc = memcpy_hsa_user(dst, from, len);
  168. if (rc)
  169. return rc;
  170. } else {
  171. /* Check for swapped kdump oldmem areas */
  172. if (OLDMEM_BASE && from - OLDMEM_BASE < OLDMEM_SIZE) {
  173. from -= OLDMEM_BASE;
  174. len = min(count, OLDMEM_SIZE - from);
  175. } else if (OLDMEM_BASE && from < OLDMEM_SIZE) {
  176. len = min(count, OLDMEM_SIZE - from);
  177. from += OLDMEM_BASE;
  178. } else {
  179. len = count;
  180. }
  181. rc = copy_to_user_real(dst, (void *) from, count);
  182. if (rc)
  183. return rc;
  184. }
  185. dst += len;
  186. src += len;
  187. count -= len;
  188. }
  189. return 0;
  190. }
  191. /*
  192. * Copy one page from "oldmem"
  193. */
  194. ssize_t copy_oldmem_page(unsigned long pfn, char *buf, size_t csize,
  195. unsigned long offset, int userbuf)
  196. {
  197. void *src;
  198. int rc;
  199. if (!csize)
  200. return 0;
  201. src = (void *) (pfn << PAGE_SHIFT) + offset;
  202. if (userbuf)
  203. rc = copy_oldmem_user((void __force __user *) buf, src, csize);
  204. else
  205. rc = copy_oldmem_kernel((void *) buf, src, csize);
  206. return rc;
  207. }
  208. /*
  209. * Remap "oldmem" for kdump
  210. *
  211. * For the kdump reserved memory this functions performs a swap operation:
  212. * [0 - OLDMEM_SIZE] is mapped to [OLDMEM_BASE - OLDMEM_BASE + OLDMEM_SIZE]
  213. */
  214. static int remap_oldmem_pfn_range_kdump(struct vm_area_struct *vma,
  215. unsigned long from, unsigned long pfn,
  216. unsigned long size, pgprot_t prot)
  217. {
  218. unsigned long size_old;
  219. int rc;
  220. if (pfn < OLDMEM_SIZE >> PAGE_SHIFT) {
  221. size_old = min(size, OLDMEM_SIZE - (pfn << PAGE_SHIFT));
  222. rc = remap_pfn_range(vma, from,
  223. pfn + (OLDMEM_BASE >> PAGE_SHIFT),
  224. size_old, prot);
  225. if (rc || size == size_old)
  226. return rc;
  227. size -= size_old;
  228. from += size_old;
  229. pfn += size_old >> PAGE_SHIFT;
  230. }
  231. return remap_pfn_range(vma, from, pfn, size, prot);
  232. }
  233. /*
  234. * Remap "oldmem" for zfcpdump
  235. *
  236. * We only map available memory above HSA size. Memory below HSA size
  237. * is read on demand using the copy_oldmem_page() function.
  238. */
  239. static int remap_oldmem_pfn_range_zfcpdump(struct vm_area_struct *vma,
  240. unsigned long from,
  241. unsigned long pfn,
  242. unsigned long size, pgprot_t prot)
  243. {
  244. unsigned long hsa_end = sclp.hsa_size;
  245. unsigned long size_hsa;
  246. if (pfn < hsa_end >> PAGE_SHIFT) {
  247. size_hsa = min(size, hsa_end - (pfn << PAGE_SHIFT));
  248. if (size == size_hsa)
  249. return 0;
  250. size -= size_hsa;
  251. from += size_hsa;
  252. pfn += size_hsa >> PAGE_SHIFT;
  253. }
  254. return remap_pfn_range(vma, from, pfn, size, prot);
  255. }
  256. /*
  257. * Remap "oldmem" for kdump or zfcpdump
  258. */
  259. int remap_oldmem_pfn_range(struct vm_area_struct *vma, unsigned long from,
  260. unsigned long pfn, unsigned long size, pgprot_t prot)
  261. {
  262. if (OLDMEM_BASE)
  263. return remap_oldmem_pfn_range_kdump(vma, from, pfn, size, prot);
  264. else
  265. return remap_oldmem_pfn_range_zfcpdump(vma, from, pfn, size,
  266. prot);
  267. }
  268. /*
  269. * Alloc memory and panic in case of ENOMEM
  270. */
  271. static void *kzalloc_panic(int len)
  272. {
  273. void *rc;
  274. rc = kzalloc(len, GFP_KERNEL);
  275. if (!rc)
  276. panic("s390 kdump kzalloc (%d) failed", len);
  277. return rc;
  278. }
  279. /*
  280. * Initialize ELF note
  281. */
  282. static void *nt_init_name(void *buf, Elf64_Word type, void *desc, int d_len,
  283. const char *name)
  284. {
  285. Elf64_Nhdr *note;
  286. u64 len;
  287. note = (Elf64_Nhdr *)buf;
  288. note->n_namesz = strlen(name) + 1;
  289. note->n_descsz = d_len;
  290. note->n_type = type;
  291. len = sizeof(Elf64_Nhdr);
  292. memcpy(buf + len, name, note->n_namesz);
  293. len = roundup(len + note->n_namesz, 4);
  294. memcpy(buf + len, desc, note->n_descsz);
  295. len = roundup(len + note->n_descsz, 4);
  296. return PTR_ADD(buf, len);
  297. }
  298. static inline void *nt_init(void *buf, Elf64_Word type, void *desc, int d_len)
  299. {
  300. return nt_init_name(buf, type, desc, d_len, KEXEC_CORE_NOTE_NAME);
  301. }
  302. /*
  303. * Fill ELF notes for one CPU with save area registers
  304. */
  305. static void *fill_cpu_elf_notes(void *ptr, int cpu, struct save_area *sa)
  306. {
  307. struct elf_prstatus nt_prstatus;
  308. elf_fpregset_t nt_fpregset;
  309. /* Prepare prstatus note */
  310. memset(&nt_prstatus, 0, sizeof(nt_prstatus));
  311. memcpy(&nt_prstatus.pr_reg.gprs, sa->gprs, sizeof(sa->gprs));
  312. memcpy(&nt_prstatus.pr_reg.psw, sa->psw, sizeof(sa->psw));
  313. memcpy(&nt_prstatus.pr_reg.acrs, sa->acrs, sizeof(sa->acrs));
  314. nt_prstatus.pr_pid = cpu;
  315. /* Prepare fpregset (floating point) note */
  316. memset(&nt_fpregset, 0, sizeof(nt_fpregset));
  317. memcpy(&nt_fpregset.fpc, &sa->fpc, sizeof(sa->fpc));
  318. memcpy(&nt_fpregset.fprs, &sa->fprs, sizeof(sa->fprs));
  319. /* Create ELF notes for the CPU */
  320. ptr = nt_init(ptr, NT_PRSTATUS, &nt_prstatus, sizeof(nt_prstatus));
  321. ptr = nt_init(ptr, NT_PRFPREG, &nt_fpregset, sizeof(nt_fpregset));
  322. ptr = nt_init(ptr, NT_S390_TIMER, &sa->timer, sizeof(sa->timer));
  323. ptr = nt_init(ptr, NT_S390_TODCMP, &sa->todcmp, sizeof(sa->todcmp));
  324. ptr = nt_init(ptr, NT_S390_TODPREG, &sa->todpreg, sizeof(sa->todpreg));
  325. ptr = nt_init(ptr, NT_S390_CTRS, &sa->ctrs, sizeof(sa->ctrs));
  326. ptr = nt_init(ptr, NT_S390_PREFIX, &sa->prefix, sizeof(sa->prefix));
  327. if (MACHINE_HAS_VX) {
  328. ptr = nt_init(ptr, NT_S390_VXRS_HIGH,
  329. &sa->vxrs_high, sizeof(sa->vxrs_high));
  330. ptr = nt_init(ptr, NT_S390_VXRS_LOW,
  331. &sa->vxrs_low, sizeof(sa->vxrs_low));
  332. }
  333. return ptr;
  334. }
  335. /*
  336. * Initialize prpsinfo note (new kernel)
  337. */
  338. static void *nt_prpsinfo(void *ptr)
  339. {
  340. struct elf_prpsinfo prpsinfo;
  341. memset(&prpsinfo, 0, sizeof(prpsinfo));
  342. prpsinfo.pr_sname = 'R';
  343. strcpy(prpsinfo.pr_fname, "vmlinux");
  344. return nt_init(ptr, NT_PRPSINFO, &prpsinfo, sizeof(prpsinfo));
  345. }
  346. /*
  347. * Get vmcoreinfo using lowcore->vmcore_info (new kernel)
  348. */
  349. static void *get_vmcoreinfo_old(unsigned long *size)
  350. {
  351. char nt_name[11], *vmcoreinfo;
  352. Elf64_Nhdr note;
  353. void *addr;
  354. if (copy_oldmem_kernel(&addr, &S390_lowcore.vmcore_info, sizeof(addr)))
  355. return NULL;
  356. memset(nt_name, 0, sizeof(nt_name));
  357. if (copy_oldmem_kernel(&note, addr, sizeof(note)))
  358. return NULL;
  359. if (copy_oldmem_kernel(nt_name, addr + sizeof(note),
  360. sizeof(nt_name) - 1))
  361. return NULL;
  362. if (strcmp(nt_name, "VMCOREINFO") != 0)
  363. return NULL;
  364. vmcoreinfo = kzalloc_panic(note.n_descsz);
  365. if (copy_oldmem_kernel(vmcoreinfo, addr + 24, note.n_descsz))
  366. return NULL;
  367. *size = note.n_descsz;
  368. return vmcoreinfo;
  369. }
  370. /*
  371. * Initialize vmcoreinfo note (new kernel)
  372. */
  373. static void *nt_vmcoreinfo(void *ptr)
  374. {
  375. unsigned long size;
  376. void *vmcoreinfo;
  377. vmcoreinfo = os_info_old_entry(OS_INFO_VMCOREINFO, &size);
  378. if (!vmcoreinfo)
  379. vmcoreinfo = get_vmcoreinfo_old(&size);
  380. if (!vmcoreinfo)
  381. return ptr;
  382. return nt_init_name(ptr, 0, vmcoreinfo, size, "VMCOREINFO");
  383. }
  384. /*
  385. * Initialize ELF header (new kernel)
  386. */
  387. static void *ehdr_init(Elf64_Ehdr *ehdr, int mem_chunk_cnt)
  388. {
  389. memset(ehdr, 0, sizeof(*ehdr));
  390. memcpy(ehdr->e_ident, ELFMAG, SELFMAG);
  391. ehdr->e_ident[EI_CLASS] = ELFCLASS64;
  392. ehdr->e_ident[EI_DATA] = ELFDATA2MSB;
  393. ehdr->e_ident[EI_VERSION] = EV_CURRENT;
  394. memset(ehdr->e_ident + EI_PAD, 0, EI_NIDENT - EI_PAD);
  395. ehdr->e_type = ET_CORE;
  396. ehdr->e_machine = EM_S390;
  397. ehdr->e_version = EV_CURRENT;
  398. ehdr->e_phoff = sizeof(Elf64_Ehdr);
  399. ehdr->e_ehsize = sizeof(Elf64_Ehdr);
  400. ehdr->e_phentsize = sizeof(Elf64_Phdr);
  401. ehdr->e_phnum = mem_chunk_cnt + 1;
  402. return ehdr + 1;
  403. }
  404. /*
  405. * Return CPU count for ELF header (new kernel)
  406. */
  407. static int get_cpu_cnt(void)
  408. {
  409. struct save_area *sa;
  410. int cpus = 0;
  411. list_for_each_entry(sa, &dump_save_areas, list)
  412. if (sa->prefix != 0)
  413. cpus++;
  414. return cpus;
  415. }
  416. /*
  417. * Return memory chunk count for ELF header (new kernel)
  418. */
  419. static int get_mem_chunk_cnt(void)
  420. {
  421. int cnt = 0;
  422. u64 idx;
  423. for_each_mem_range(idx, &memblock.physmem, &oldmem_type, NUMA_NO_NODE,
  424. MEMBLOCK_NONE, NULL, NULL, NULL)
  425. cnt++;
  426. return cnt;
  427. }
  428. /*
  429. * Initialize ELF loads (new kernel)
  430. */
  431. static void loads_init(Elf64_Phdr *phdr, u64 loads_offset)
  432. {
  433. phys_addr_t start, end;
  434. u64 idx;
  435. for_each_mem_range(idx, &memblock.physmem, &oldmem_type, NUMA_NO_NODE,
  436. MEMBLOCK_NONE, &start, &end, NULL) {
  437. phdr->p_filesz = end - start;
  438. phdr->p_type = PT_LOAD;
  439. phdr->p_offset = start;
  440. phdr->p_vaddr = start;
  441. phdr->p_paddr = start;
  442. phdr->p_memsz = end - start;
  443. phdr->p_flags = PF_R | PF_W | PF_X;
  444. phdr->p_align = PAGE_SIZE;
  445. phdr++;
  446. }
  447. }
  448. /*
  449. * Initialize notes (new kernel)
  450. */
  451. static void *notes_init(Elf64_Phdr *phdr, void *ptr, u64 notes_offset)
  452. {
  453. struct save_area *sa;
  454. void *ptr_start = ptr;
  455. int cpu;
  456. ptr = nt_prpsinfo(ptr);
  457. cpu = 1;
  458. list_for_each_entry(sa, &dump_save_areas, list)
  459. if (sa->prefix != 0)
  460. ptr = fill_cpu_elf_notes(ptr, cpu++, sa);
  461. ptr = nt_vmcoreinfo(ptr);
  462. memset(phdr, 0, sizeof(*phdr));
  463. phdr->p_type = PT_NOTE;
  464. phdr->p_offset = notes_offset;
  465. phdr->p_filesz = (unsigned long) PTR_SUB(ptr, ptr_start);
  466. phdr->p_memsz = phdr->p_filesz;
  467. return ptr;
  468. }
  469. /*
  470. * Create ELF core header (new kernel)
  471. */
  472. int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)
  473. {
  474. Elf64_Phdr *phdr_notes, *phdr_loads;
  475. int mem_chunk_cnt;
  476. void *ptr, *hdr;
  477. u32 alloc_size;
  478. u64 hdr_off;
  479. /* If we are not in kdump or zfcpdump mode return */
  480. if (!OLDMEM_BASE && ipl_info.type != IPL_TYPE_FCP_DUMP)
  481. return 0;
  482. /* If we cannot get HSA size for zfcpdump return error */
  483. if (ipl_info.type == IPL_TYPE_FCP_DUMP && !sclp.hsa_size)
  484. return -ENODEV;
  485. /* For kdump, exclude previous crashkernel memory */
  486. if (OLDMEM_BASE) {
  487. oldmem_region.base = OLDMEM_BASE;
  488. oldmem_region.size = OLDMEM_SIZE;
  489. oldmem_type.total_size = OLDMEM_SIZE;
  490. }
  491. mem_chunk_cnt = get_mem_chunk_cnt();
  492. alloc_size = 0x1000 + get_cpu_cnt() * 0x4a0 +
  493. mem_chunk_cnt * sizeof(Elf64_Phdr);
  494. hdr = kzalloc_panic(alloc_size);
  495. /* Init elf header */
  496. ptr = ehdr_init(hdr, mem_chunk_cnt);
  497. /* Init program headers */
  498. phdr_notes = ptr;
  499. ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr));
  500. phdr_loads = ptr;
  501. ptr = PTR_ADD(ptr, sizeof(Elf64_Phdr) * mem_chunk_cnt);
  502. /* Init notes */
  503. hdr_off = PTR_DIFF(ptr, hdr);
  504. ptr = notes_init(phdr_notes, ptr, ((unsigned long) hdr) + hdr_off);
  505. /* Init loads */
  506. hdr_off = PTR_DIFF(ptr, hdr);
  507. loads_init(phdr_loads, hdr_off);
  508. *addr = (unsigned long long) hdr;
  509. *size = (unsigned long long) hdr_off;
  510. BUG_ON(elfcorehdr_size > alloc_size);
  511. return 0;
  512. }
  513. /*
  514. * Free ELF core header (new kernel)
  515. */
  516. void elfcorehdr_free(unsigned long long addr)
  517. {
  518. kfree((void *)(unsigned long)addr);
  519. }
  520. /*
  521. * Read from ELF header
  522. */
  523. ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
  524. {
  525. void *src = (void *)(unsigned long)*ppos;
  526. memcpy(buf, src, count);
  527. *ppos += count;
  528. return count;
  529. }
  530. /*
  531. * Read from ELF notes data
  532. */
  533. ssize_t elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)
  534. {
  535. void *src = (void *)(unsigned long)*ppos;
  536. memcpy(buf, src, count);
  537. *ppos += count;
  538. return count;
  539. }