Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/x86/kernel/crash_dump_32.c
26424 views
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
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>
14
15
static inline bool is_crashed_pfn_valid(unsigned long pfn)
16
{
17
#ifndef CONFIG_X86_PAE
18
/*
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).
24
*/
25
return pte_pfn(pfn_pte(pfn, __pgprot(0))) == pfn;
26
#else
27
return true;
28
#endif
29
}
30
31
ssize_t copy_oldmem_page(struct iov_iter *iter, unsigned long pfn, size_t csize,
32
unsigned long offset)
33
{
34
void *vaddr;
35
36
if (!csize)
37
return 0;
38
39
if (!is_crashed_pfn_valid(pfn))
40
return -EFAULT;
41
42
vaddr = kmap_local_pfn(pfn);
43
csize = copy_to_iter(vaddr + offset, csize, iter);
44
kunmap_local(vaddr);
45
46
return csize;
47
}
48
49