x86/unwinder: Handle stack overflows more gracefully
[linux/fpc-iii.git] / arch / mips / generic / kexec.c
blob1ca409f58929670c58a8e23f47aa9843f53a03bf
1 /*
2 * Copyright (C) 2016 Imagination Technologies
3 * Author: Marcin Nowakowski <marcin.nowakowski@mips.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
11 #include <linux/kexec.h>
12 #include <linux/libfdt.h>
13 #include <linux/uaccess.h>
15 static int generic_kexec_prepare(struct kimage *image)
17 int i;
19 for (i = 0; i < image->nr_segments; i++) {
20 struct fdt_header fdt;
22 if (image->segment[i].memsz <= sizeof(fdt))
23 continue;
25 if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
26 continue;
28 if (fdt_check_header(&fdt))
29 continue;
31 kexec_args[0] = -2;
32 kexec_args[1] = (unsigned long)
33 phys_to_virt((unsigned long)image->segment[i].mem);
34 break;
36 return 0;
39 static int __init register_generic_kexec(void)
41 _machine_kexec_prepare = generic_kexec_prepare;
42 return 0;
44 arch_initcall(register_generic_kexec);