crash_dump.c 605 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * This code comes from arch/arm64/kernel/crash_dump.c
  4. * Created by: AKASHI Takahiro <[email protected]>
  5. * Copyright (C) 2017 Linaro Limited
  6. */
  7. #include <linux/crash_dump.h>
  8. #include <linux/io.h>
  9. #include <linux/uio.h>
  10. ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn,
  11. size_t csize, unsigned long offset)
  12. {
  13. void *vaddr;
  14. if (!csize)
  15. return 0;
  16. vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);
  17. if (!vaddr)
  18. return -ENOMEM;
  19. csize = copy_to_iter(vaddr + offset, csize, iter);
  20. memunmap(vaddr);
  21. return csize;
  22. }