drm/rockchip: vop2: Fix the windows switch between different layers
[drm/drm-misc.git] / arch / x86 / kernel / crash_dump_32.c
blob5f4ae5476e193014686d5835be35fc467af11583
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Memory preserving reboot related code.
5 * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
6 * Copyright (C) IBM Corporation, 2004. All rights reserved
7 */
9 #include <linux/slab.h>
10 #include <linux/errno.h>
11 #include <linux/highmem.h>
12 #include <linux/crash_dump.h>
13 #include <linux/uio.h>
15 static inline bool is_crashed_pfn_valid(unsigned long pfn)
17 #ifndef CONFIG_X86_PAE
19 * non-PAE kdump kernel executed from a PAE one will crop high pte
20 * bits and poke unwanted space counting again from address 0, we
21 * don't want that. pte must fit into unsigned long. In fact the
22 * test checks high 12 bits for being zero (pfn will be shifted left
23 * by PAGE_SHIFT).
25 return pte_pfn(pfn_pte(pfn, __pgprot(0))) == pfn;
26 #else
27 return true;
28 #endif
31 ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, size_t csize,
32 unsigned long offset)
34 void *vaddr;
36 if (!csize)
37 return 0;
39 if (!is_crashed_pfn_valid(pfn))
40 return -EFAULT;
42 vaddr = kmap_local_pfn(pfn);
43 csize = copy_to_iter(vaddr + offset, csize, iter);
44 kunmap_local(vaddr);
46 return csize;