2 * kexec.c - kexec system call
3 * Copyright (C) 2002-2004 Eric Biederman <ebiederm@xmission.com>
5 * This source code is licensed under the GNU General Public License,
6 * Version 2. See the file COPYING for more details.
10 #include <linux/file.h>
11 #include <linux/slab.h>
13 #include <linux/kexec.h>
14 #include <linux/spinlock.h>
15 #include <linux/list.h>
16 #include <linux/highmem.h>
17 #include <linux/syscalls.h>
18 #include <linux/reboot.h>
19 #include <linux/syscalls.h>
20 #include <linux/ioport.h>
21 #include <linux/hardirq.h>
24 #include <asm/uaccess.h>
26 #include <asm/system.h>
27 #include <asm/semaphore.h>
29 /* Location of the reserved area for the crash kernel */
30 struct resource crashk_res = {
31 .name = "Crash kernel",
34 .flags = IORESOURCE_BUSY | IORESOURCE_MEM
37 int kexec_should_crash(struct task_struct *p)
39 if (in_interrupt() || !p->pid || p->pid == 1 || panic_on_oops)
45 * When kexec transitions to the new kernel there is a one-to-one
46 * mapping between physical and virtual addresses. On processors
47 * where you can disable the MMU this is trivial, and easy. For
48 * others it is still a simple predictable page table to setup.
50 * In that environment kexec copies the new kernel to its final
51 * resting place. This means I can only support memory whose
52 * physical address can fit in an unsigned long. In particular
53 * addresses where (pfn << PAGE_SHIFT) > ULONG_MAX cannot be handled.
54 * If the assembly stub has more restrictive requirements
55 * KEXEC_SOURCE_MEMORY_LIMIT and KEXEC_DEST_MEMORY_LIMIT can be
56 * defined more restrictively in <asm/kexec.h>.
58 * The code for the transition from the current kernel to the
59 * the new kernel is placed in the control_code_buffer, whose size
60 * is given by KEXEC_CONTROL_CODE_SIZE. In the best case only a single
61 * page of memory is necessary, but some architectures require more.
62 * Because this memory must be identity mapped in the transition from
63 * virtual to physical addresses it must live in the range
64 * 0 - TASK_SIZE, as only the user space mappings are arbitrarily
67 * The assembly stub in the control code buffer is passed a linked list
68 * of descriptor pages detailing the source pages of the new kernel,
69 * and the destination addresses of those source pages. As this data
70 * structure is not used in the context of the current OS, it must
73 * The code has been made to work with highmem pages and will use a
74 * destination page in its final resting place (if it happens
75 * to allocate it). The end product of this is that most of the
76 * physical address space, and most of RAM can be used.
78 * Future directions include:
79 * - allocating a page table with the control code buffer identity
80 * mapped, to simplify machine_kexec and make kexec_on_panic more
85 * KIMAGE_NO_DEST is an impossible destination address..., for
86 * allocating pages whose destination address we do not care about.
88 #define KIMAGE_NO_DEST (-1UL)
90 static int kimage_is_destination_range(
91 struct kimage *image, unsigned long start, unsigned long end);
92 static struct page *kimage_alloc_page(struct kimage *image, unsigned int gfp_mask, unsigned long dest);
94 static int do_kimage_alloc(struct kimage **rimage, unsigned long entry,
95 unsigned long nr_segments, struct kexec_segment __user *segments)
102 /* Allocate a controlling structure */
104 image = kmalloc(sizeof(*image), GFP_KERNEL);
108 memset(image, 0, sizeof(*image));
110 image->entry = &image->head;
111 image->last_entry = &image->head;
112 image->control_page = ~0; /* By default this does not apply */
113 image->start = entry;
114 image->type = KEXEC_TYPE_DEFAULT;
116 /* Initialize the list of control pages */
117 INIT_LIST_HEAD(&image->control_pages);
119 /* Initialize the list of destination pages */
120 INIT_LIST_HEAD(&image->dest_pages);
122 /* Initialize the list of unuseable pages */
123 INIT_LIST_HEAD(&image->unuseable_pages);
125 /* Read in the segments */
126 image->nr_segments = nr_segments;
127 segment_bytes = nr_segments * sizeof(*segments);
128 result = copy_from_user(image->segment, segments, segment_bytes);
133 * Verify we have good destination addresses. The caller is
134 * responsible for making certain we don't attempt to load
135 * the new image into invalid or reserved areas of RAM. This
136 * just verifies it is an address we can use.
138 * Since the kernel does everything in page size chunks ensure
139 * the destination addreses are page aligned. Too many
140 * special cases crop of when we don't do this. The most
141 * insidious is getting overlapping destination addresses
142 * simply because addresses are changed to page size
145 result = -EADDRNOTAVAIL;
146 for (i = 0; i < nr_segments; i++) {
147 unsigned long mstart, mend;
148 mstart = image->segment[i].mem;
149 mend = mstart + image->segment[i].memsz;
150 if ((mstart & ~PAGE_MASK) || (mend & ~PAGE_MASK))
152 if (mend >= KEXEC_DESTINATION_MEMORY_LIMIT)
156 /* Verify our destination addresses do not overlap.
157 * If we alloed overlapping destination addresses
158 * through very weird things can happen with no
159 * easy explanation as one segment stops on another.
162 for(i = 0; i < nr_segments; i++) {
163 unsigned long mstart, mend;
165 mstart = image->segment[i].mem;
166 mend = mstart + image->segment[i].memsz;
167 for(j = 0; j < i; j++) {
168 unsigned long pstart, pend;
169 pstart = image->segment[j].mem;
170 pend = pstart + image->segment[j].memsz;
171 /* Do the segments overlap ? */
172 if ((mend > pstart) && (mstart < pend))
177 /* Ensure our buffer sizes are strictly less than
178 * our memory sizes. This should always be the case,
179 * and it is easier to check up front than to be surprised
183 for(i = 0; i < nr_segments; i++) {
184 if (image->segment[i].bufsz > image->segment[i].memsz)
200 static int kimage_normal_alloc(struct kimage **rimage, unsigned long entry,
201 unsigned long nr_segments, struct kexec_segment __user *segments)
204 struct kimage *image;
206 /* Allocate and initialize a controlling structure */
208 result = do_kimage_alloc(&image, entry, nr_segments, segments);
215 * Find a location for the control code buffer, and add it
216 * the vector of segments so that it's pages will also be
217 * counted as destination pages.
220 image->control_code_page = kimage_alloc_control_pages(image,
221 get_order(KEXEC_CONTROL_CODE_SIZE));
222 if (!image->control_code_page) {
223 printk(KERN_ERR "Could not allocate control_code_buffer\n");
237 static int kimage_crash_alloc(struct kimage **rimage, unsigned long entry,
238 unsigned long nr_segments, struct kexec_segment *segments)
241 struct kimage *image;
245 /* Verify we have a valid entry point */
246 if ((entry < crashk_res.start) || (entry > crashk_res.end)) {
247 result = -EADDRNOTAVAIL;
251 /* Allocate and initialize a controlling structure */
252 result = do_kimage_alloc(&image, entry, nr_segments, segments);
257 /* Enable the special crash kernel control page
260 image->control_page = crashk_res.start;
261 image->type = KEXEC_TYPE_CRASH;
264 * Verify we have good destination addresses. Normally
265 * the caller is responsible for making certain we don't
266 * attempt to load the new image into invalid or reserved
267 * areas of RAM. But crash kernels are preloaded into a
268 * reserved area of ram. We must ensure the addresses
269 * are in the reserved area otherwise preloading the
270 * kernel could corrupt things.
272 result = -EADDRNOTAVAIL;
273 for (i = 0; i < nr_segments; i++) {
274 unsigned long mstart, mend;
275 mstart = image->segment[i].mem;
276 mend = mstart + image->segment[i].memsz - 1;
277 /* Ensure we are within the crash kernel limits */
278 if ((mstart < crashk_res.start) || (mend > crashk_res.end))
284 * Find a location for the control code buffer, and add
285 * the vector of segments so that it's pages will also be
286 * counted as destination pages.
289 image->control_code_page = kimage_alloc_control_pages(image,
290 get_order(KEXEC_CONTROL_CODE_SIZE));
291 if (!image->control_code_page) {
292 printk(KERN_ERR "Could not allocate control_code_buffer\n");
306 static int kimage_is_destination_range(
307 struct kimage *image, unsigned long start, unsigned long end)
311 for (i = 0; i < image->nr_segments; i++) {
312 unsigned long mstart, mend;
313 mstart = image->segment[i].mem;
314 mend = mstart + image->segment[i].memsz;
315 if ((end > mstart) && (start < mend)) {
322 static struct page *kimage_alloc_pages(unsigned int gfp_mask, unsigned int order)
325 pages = alloc_pages(gfp_mask, order);
327 unsigned int count, i;
328 pages->mapping = NULL;
329 pages->private = order;
331 for(i = 0; i < count; i++) {
332 SetPageReserved(pages + i);
338 static void kimage_free_pages(struct page *page)
340 unsigned int order, count, i;
341 order = page->private;
343 for(i = 0; i < count; i++) {
344 ClearPageReserved(page + i);
346 __free_pages(page, order);
349 static void kimage_free_page_list(struct list_head *list)
351 struct list_head *pos, *next;
352 list_for_each_safe(pos, next, list) {
355 page = list_entry(pos, struct page, lru);
356 list_del(&page->lru);
358 kimage_free_pages(page);
362 static struct page *kimage_alloc_normal_control_pages(
363 struct kimage *image, unsigned int order)
365 /* Control pages are special, they are the intermediaries
366 * that are needed while we copy the rest of the pages
367 * to their final resting place. As such they must
368 * not conflict with either the destination addresses
369 * or memory the kernel is already using.
371 * The only case where we really need more than one of
372 * these are for architectures where we cannot disable
373 * the MMU and must instead generate an identity mapped
374 * page table for all of the memory.
376 * At worst this runs in O(N) of the image size.
378 struct list_head extra_pages;
383 INIT_LIST_HEAD(&extra_pages);
385 /* Loop while I can allocate a page and the page allocated
386 * is a destination page.
389 unsigned long pfn, epfn, addr, eaddr;
390 pages = kimage_alloc_pages(GFP_KERNEL, order);
393 pfn = page_to_pfn(pages);
395 addr = pfn << PAGE_SHIFT;
396 eaddr = epfn << PAGE_SHIFT;
397 if ((epfn >= (KEXEC_CONTROL_MEMORY_LIMIT >> PAGE_SHIFT)) ||
398 kimage_is_destination_range(image, addr, eaddr))
400 list_add(&pages->lru, &extra_pages);
405 /* Remember the allocated page... */
406 list_add(&pages->lru, &image->control_pages);
408 /* Because the page is already in it's destination
409 * location we will never allocate another page at
410 * that address. Therefore kimage_alloc_pages
411 * will not return it (again) and we don't need
412 * to give it an entry in image->segment[].
415 /* Deal with the destination pages I have inadvertently allocated.
417 * Ideally I would convert multi-page allocations into single
418 * page allocations, and add everyting to image->dest_pages.
420 * For now it is simpler to just free the pages.
422 kimage_free_page_list(&extra_pages);
427 static struct page *kimage_alloc_crash_control_pages(
428 struct kimage *image, unsigned int order)
430 /* Control pages are special, they are the intermediaries
431 * that are needed while we copy the rest of the pages
432 * to their final resting place. As such they must
433 * not conflict with either the destination addresses
434 * or memory the kernel is already using.
436 * Control pages are also the only pags we must allocate
437 * when loading a crash kernel. All of the other pages
438 * are specified by the segments and we just memcpy
439 * into them directly.
441 * The only case where we really need more than one of
442 * these are for architectures where we cannot disable
443 * the MMU and must instead generate an identity mapped
444 * page table for all of the memory.
446 * Given the low demand this implements a very simple
447 * allocator that finds the first hole of the appropriate
448 * size in the reserved memory region, and allocates all
449 * of the memory up to and including the hole.
451 unsigned long hole_start, hole_end, size;
454 size = (1 << order) << PAGE_SHIFT;
455 hole_start = (image->control_page + (size - 1)) & ~(size - 1);
456 hole_end = hole_start + size - 1;
457 while(hole_end <= crashk_res.end) {
459 if (hole_end > KEXEC_CONTROL_MEMORY_LIMIT) {
462 if (hole_end > crashk_res.end) {
465 /* See if I overlap any of the segments */
466 for(i = 0; i < image->nr_segments; i++) {
467 unsigned long mstart, mend;
468 mstart = image->segment[i].mem;
469 mend = mstart + image->segment[i].memsz - 1;
470 if ((hole_end >= mstart) && (hole_start <= mend)) {
471 /* Advance the hole to the end of the segment */
472 hole_start = (mend + (size - 1)) & ~(size - 1);
473 hole_end = hole_start + size - 1;
477 /* If I don't overlap any segments I have found my hole! */
478 if (i == image->nr_segments) {
479 pages = pfn_to_page(hole_start >> PAGE_SHIFT);
484 image->control_page = hole_end;
490 struct page *kimage_alloc_control_pages(
491 struct kimage *image, unsigned int order)
493 struct page *pages = NULL;
494 switch(image->type) {
495 case KEXEC_TYPE_DEFAULT:
496 pages = kimage_alloc_normal_control_pages(image, order);
498 case KEXEC_TYPE_CRASH:
499 pages = kimage_alloc_crash_control_pages(image, order);
505 static int kimage_add_entry(struct kimage *image, kimage_entry_t entry)
507 if (*image->entry != 0) {
510 if (image->entry == image->last_entry) {
511 kimage_entry_t *ind_page;
513 page = kimage_alloc_page(image, GFP_KERNEL, KIMAGE_NO_DEST);
517 ind_page = page_address(page);
518 *image->entry = virt_to_phys(ind_page) | IND_INDIRECTION;
519 image->entry = ind_page;
521 ind_page + ((PAGE_SIZE/sizeof(kimage_entry_t)) - 1);
523 *image->entry = entry;
529 static int kimage_set_destination(
530 struct kimage *image, unsigned long destination)
534 destination &= PAGE_MASK;
535 result = kimage_add_entry(image, destination | IND_DESTINATION);
537 image->destination = destination;
543 static int kimage_add_page(struct kimage *image, unsigned long page)
548 result = kimage_add_entry(image, page | IND_SOURCE);
550 image->destination += PAGE_SIZE;
556 static void kimage_free_extra_pages(struct kimage *image)
558 /* Walk through and free any extra destination pages I may have */
559 kimage_free_page_list(&image->dest_pages);
561 /* Walk through and free any unuseable pages I have cached */
562 kimage_free_page_list(&image->unuseable_pages);
565 static int kimage_terminate(struct kimage *image)
567 if (*image->entry != 0) {
570 *image->entry = IND_DONE;
574 #define for_each_kimage_entry(image, ptr, entry) \
575 for (ptr = &image->head; (entry = *ptr) && !(entry & IND_DONE); \
576 ptr = (entry & IND_INDIRECTION)? \
577 phys_to_virt((entry & PAGE_MASK)): ptr +1)
579 static void kimage_free_entry(kimage_entry_t entry)
583 page = pfn_to_page(entry >> PAGE_SHIFT);
584 kimage_free_pages(page);
587 static void kimage_free(struct kimage *image)
589 kimage_entry_t *ptr, entry;
590 kimage_entry_t ind = 0;
594 kimage_free_extra_pages(image);
595 for_each_kimage_entry(image, ptr, entry) {
596 if (entry & IND_INDIRECTION) {
597 /* Free the previous indirection page */
598 if (ind & IND_INDIRECTION) {
599 kimage_free_entry(ind);
601 /* Save this indirection page until we are
606 else if (entry & IND_SOURCE) {
607 kimage_free_entry(entry);
610 /* Free the final indirection page */
611 if (ind & IND_INDIRECTION) {
612 kimage_free_entry(ind);
615 /* Handle any machine specific cleanup */
616 machine_kexec_cleanup(image);
618 /* Free the kexec control pages... */
619 kimage_free_page_list(&image->control_pages);
623 static kimage_entry_t *kimage_dst_used(struct kimage *image, unsigned long page)
625 kimage_entry_t *ptr, entry;
626 unsigned long destination = 0;
628 for_each_kimage_entry(image, ptr, entry) {
629 if (entry & IND_DESTINATION) {
630 destination = entry & PAGE_MASK;
632 else if (entry & IND_SOURCE) {
633 if (page == destination) {
636 destination += PAGE_SIZE;
642 static struct page *kimage_alloc_page(struct kimage *image, unsigned int gfp_mask, unsigned long destination)
645 * Here we implement safeguards to ensure that a source page
646 * is not copied to its destination page before the data on
647 * the destination page is no longer useful.
649 * To do this we maintain the invariant that a source page is
650 * either its own destination page, or it is not a
651 * destination page at all.
653 * That is slightly stronger than required, but the proof
654 * that no problems will not occur is trivial, and the
655 * implementation is simply to verify.
657 * When allocating all pages normally this algorithm will run
658 * in O(N) time, but in the worst case it will run in O(N^2)
659 * time. If the runtime is a problem the data structures can
666 * Walk through the list of destination pages, and see if I
669 list_for_each_entry(page, &image->dest_pages, lru) {
670 addr = page_to_pfn(page) << PAGE_SHIFT;
671 if (addr == destination) {
672 list_del(&page->lru);
680 /* Allocate a page, if we run out of memory give up */
681 page = kimage_alloc_pages(gfp_mask, 0);
685 /* If the page cannot be used file it away */
686 if (page_to_pfn(page) > (KEXEC_SOURCE_MEMORY_LIMIT >> PAGE_SHIFT)) {
687 list_add(&page->lru, &image->unuseable_pages);
690 addr = page_to_pfn(page) << PAGE_SHIFT;
692 /* If it is the destination page we want use it */
693 if (addr == destination)
696 /* If the page is not a destination page use it */
697 if (!kimage_is_destination_range(image, addr, addr + PAGE_SIZE))
701 * I know that the page is someones destination page.
702 * See if there is already a source page for this
703 * destination page. And if so swap the source pages.
705 old = kimage_dst_used(image, addr);
708 unsigned long old_addr;
709 struct page *old_page;
711 old_addr = *old & PAGE_MASK;
712 old_page = pfn_to_page(old_addr >> PAGE_SHIFT);
713 copy_highpage(page, old_page);
714 *old = addr | (*old & ~PAGE_MASK);
716 /* The old page I have found cannot be a
717 * destination page, so return it.
724 /* Place the page on the destination list I
727 list_add(&page->lru, &image->dest_pages);
733 static int kimage_load_normal_segment(struct kimage *image,
734 struct kexec_segment *segment)
737 unsigned long ubytes, mbytes;
743 ubytes = segment->bufsz;
744 mbytes = segment->memsz;
745 maddr = segment->mem;
747 result = kimage_set_destination(image, maddr);
754 size_t uchunk, mchunk;
755 page = kimage_alloc_page(image, GFP_HIGHUSER, maddr);
760 result = kimage_add_page(image, page_to_pfn(page) << PAGE_SHIFT);
765 /* Start with a clear page */
766 memset(ptr, 0, PAGE_SIZE);
767 ptr += maddr & ~PAGE_MASK;
768 mchunk = PAGE_SIZE - (maddr & ~PAGE_MASK);
769 if (mchunk > mbytes) {
773 if (uchunk > ubytes) {
776 result = copy_from_user(ptr, buf, uchunk);
779 result = (result < 0) ? result : -EIO;
791 static int kimage_load_crash_segment(struct kimage *image,
792 struct kexec_segment *segment)
794 /* For crash dumps kernels we simply copy the data from
795 * user space to it's destination.
796 * We do things a page at a time for the sake of kmap.
799 unsigned long ubytes, mbytes;
805 ubytes = segment->bufsz;
806 mbytes = segment->memsz;
807 maddr = segment->mem;
811 size_t uchunk, mchunk;
812 page = pfn_to_page(maddr >> PAGE_SHIFT);
818 ptr += maddr & ~PAGE_MASK;
819 mchunk = PAGE_SIZE - (maddr & ~PAGE_MASK);
820 if (mchunk > mbytes) {
824 if (uchunk > ubytes) {
826 /* Zero the trailing part of the page */
827 memset(ptr + uchunk, 0, mchunk - uchunk);
829 result = copy_from_user(ptr, buf, uchunk);
832 result = (result < 0) ? result : -EIO;
844 static int kimage_load_segment(struct kimage *image,
845 struct kexec_segment *segment)
847 int result = -ENOMEM;
848 switch(image->type) {
849 case KEXEC_TYPE_DEFAULT:
850 result = kimage_load_normal_segment(image, segment);
852 case KEXEC_TYPE_CRASH:
853 result = kimage_load_crash_segment(image, segment);
860 * Exec Kernel system call: for obvious reasons only root may call it.
862 * This call breaks up into three pieces.
863 * - A generic part which loads the new kernel from the current
864 * address space, and very carefully places the data in the
867 * - A generic part that interacts with the kernel and tells all of
868 * the devices to shut down. Preventing on-going dmas, and placing
869 * the devices in a consistent state so a later kernel can
872 * - A machine specific part that includes the syscall number
873 * and the copies the image to it's final destination. And
874 * jumps into the image at entry.
876 * kexec does not sync, or unmount filesystems so if you need
877 * that to happen you need to do that yourself.
879 struct kimage *kexec_image = NULL;
880 static struct kimage *kexec_crash_image = NULL;
882 * A home grown binary mutex.
883 * Nothing can wait so this mutex is safe to use
884 * in interrupt context :)
886 static int kexec_lock = 0;
888 asmlinkage long sys_kexec_load(unsigned long entry,
889 unsigned long nr_segments, struct kexec_segment __user *segments,
892 struct kimage **dest_image, *image;
896 /* We only trust the superuser with rebooting the system. */
897 if (!capable(CAP_SYS_BOOT))
901 * Verify we have a legal set of flags
902 * This leaves us room for future extensions.
904 if ((flags & KEXEC_FLAGS) != (flags & ~KEXEC_ARCH_MASK))
907 /* Verify we are on the appropriate architecture */
908 if (((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH) &&
909 ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))
914 /* Put an artificial cap on the number
915 * of segments passed to kexec_load.
917 if (nr_segments > KEXEC_SEGMENT_MAX)
923 /* Because we write directly to the reserved memory
924 * region when loading crash kernels we need a mutex here to
925 * prevent multiple crash kernels from attempting to load
926 * simultaneously, and to prevent a crash kernel from loading
927 * over the top of a in use crash kernel.
929 * KISS: always take the mutex.
931 locked = xchg(&kexec_lock, 1);
935 dest_image = &kexec_image;
936 if (flags & KEXEC_ON_CRASH) {
937 dest_image = &kexec_crash_image;
939 if (nr_segments > 0) {
941 /* Loading another kernel to reboot into */
942 if ((flags & KEXEC_ON_CRASH) == 0) {
943 result = kimage_normal_alloc(&image, entry, nr_segments, segments);
945 /* Loading another kernel to switch to if this one crashes */
946 else if (flags & KEXEC_ON_CRASH) {
947 /* Free any current crash dump kernel before
950 kimage_free(xchg(&kexec_crash_image, NULL));
951 result = kimage_crash_alloc(&image, entry, nr_segments, segments);
956 result = machine_kexec_prepare(image);
960 for(i = 0; i < nr_segments; i++) {
961 result = kimage_load_segment(image, &image->segment[i]);
966 result = kimage_terminate(image);
971 /* Install the new kernel, and Uninstall the old */
972 image = xchg(dest_image, image);
975 xchg(&kexec_lock, 0); /* Release the mutex */
981 asmlinkage long compat_sys_kexec_load(unsigned long entry,
982 unsigned long nr_segments, struct compat_kexec_segment __user *segments,
985 struct compat_kexec_segment in;
986 struct kexec_segment out, __user *ksegments;
987 unsigned long i, result;
989 /* Don't allow clients that don't understand the native
990 * architecture to do anything.
992 if ((flags & KEXEC_ARCH_MASK) == KEXEC_ARCH_DEFAULT) {
996 if (nr_segments > KEXEC_SEGMENT_MAX) {
1000 ksegments = compat_alloc_user_space(nr_segments * sizeof(out));
1001 for (i=0; i < nr_segments; i++) {
1002 result = copy_from_user(&in, &segments[i], sizeof(in));
1007 out.buf = compat_ptr(in.buf);
1008 out.bufsz = in.bufsz;
1010 out.memsz = in.memsz;
1012 result = copy_to_user(&ksegments[i], &out, sizeof(out));
1018 return sys_kexec_load(entry, nr_segments, ksegments, flags);
1022 void crash_kexec(struct pt_regs *regs)
1024 struct kimage *image;
1028 /* Take the kexec_lock here to prevent sys_kexec_load
1029 * running on one cpu from replacing the crash kernel
1030 * we are using after a panic on a different cpu.
1032 * If the crash kernel was not located in a fixed area
1033 * of memory the xchg(&kexec_crash_image) would be
1034 * sufficient. But since I reuse the memory...
1036 locked = xchg(&kexec_lock, 1);
1038 image = xchg(&kexec_crash_image, NULL);
1040 machine_crash_shutdown(regs);
1041 machine_kexec(image);
1043 xchg(&kexec_lock, 0);