File: kexec.c

package info (click to toggle)
linux 4.19.37-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 962,264 kB
  • sloc: ansic: 16,757,120; asm: 271,404; makefile: 38,285; sh: 33,529; perl: 27,681; python: 21,031; cpp: 5,063; yacc: 4,648; lex: 2,585; awk: 1,385; ruby: 25; sed: 5
file content (44 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
 * Copyright (C) 2016 Imagination Technologies
 * Author: Marcin Nowakowski <marcin.nowakowski@mips.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 */

#include <linux/kexec.h>
#include <linux/libfdt.h>
#include <linux/uaccess.h>

static int generic_kexec_prepare(struct kimage *image)
{
	int i;

	for (i = 0; i < image->nr_segments; i++) {
		struct fdt_header fdt;

		if (image->segment[i].memsz <= sizeof(fdt))
			continue;

		if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
			continue;

		if (fdt_check_header(&fdt))
			continue;

		kexec_args[0] = -2;
		kexec_args[1] = (unsigned long)
			phys_to_virt((unsigned long)image->segment[i].mem);
		break;
	}
	return 0;
}

static int __init register_generic_kexec(void)
{
	_machine_kexec_prepare = generic_kexec_prepare;
	return 0;
}
arch_initcall(register_generic_kexec);