// SPDX-License-Identifier: GPL-2.01/*2* Memory preserving reboot related code.3*4* Created by: Hariprasad Nellitheertha ([email protected])5* Copyright (C) IBM Corporation, 2004. All rights reserved6*/78#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>1314static inline bool is_crashed_pfn_valid(unsigned long pfn)15{16#ifndef CONFIG_X86_PAE17/*18* non-PAE kdump kernel executed from a PAE one will crop high pte19* bits and poke unwanted space counting again from address 0, we20* don't want that. pte must fit into unsigned long. In fact the21* test checks high 12 bits for being zero (pfn will be shifted left22* by PAGE_SHIFT).23*/24return pte_pfn(pfn_pte(pfn, __pgprot(0))) == pfn;25#else26return true;27#endif28}2930ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, size_t csize,31unsigned long offset)32{33void *vaddr;3435if (!csize)36return 0;3738if (!is_crashed_pfn_valid(pfn))39return -EFAULT;4041vaddr = kmap_local_pfn(pfn);42csize = copy_to_iter(vaddr + offset, csize, iter);43kunmap_local(vaddr);4445return csize;46}474849