crash_dump_32.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Memory preserving reboot related code.
  4. *
  5. * Created by: Hariprasad Nellitheertha ([email protected])
  6. * Copyright (C) IBM Corporation, 2004. All rights reserved
  7. */
  8. #include <linux/slab.h>
  9. #include <linux/errno.h>
  10. #include <linux/highmem.h>
  11. #include <linux/crash_dump.h>
  12. #include <linux/uio.h>
  13. static inline bool is_crashed_pfn_valid(unsigned long pfn)
  14. {
  15. #ifndef CONFIG_X86_PAE
  16. /*
  17. * non-PAE kdump kernel executed from a PAE one will crop high pte
  18. * bits and poke unwanted space counting again from address 0, we
  19. * don't want that. pte must fit into unsigned long. In fact the
  20. * test checks high 12 bits for being zero (pfn will be shifted left
  21. * by PAGE_SHIFT).
  22. */
  23. return pte_pfn(pfn_pte(pfn, __pgprot(0))) == pfn;
  24. #else
  25. return true;
  26. #endif
  27. }
  28. ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, size_t csize,
  29. unsigned long offset)
  30. {
  31. void *vaddr;
  32. if (!csize)
  33. return 0;
  34. if (!is_crashed_pfn_valid(pfn))
  35. return -EFAULT;
  36. vaddr = kmap_local_pfn(pfn);
  37. csize = copy_to_iter(vaddr + offset, csize, iter);
  38. kunmap_local(vaddr);
  39. return csize;
  40. }