2 * Firmware Assisted dump: A robust mechanism to get reliable kernel crash
3 * dump with assistance from firmware. This approach does not use kexec,
4 * instead firmware assists in booting the kdump kernel while preserving
5 * memory contents. The most of the code implementation has been adapted
6 * from phyp assisted dump implementation written by Linas Vepstas and
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * Copyright 2011 IBM Corporation
24 * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
28 #define pr_fmt(fmt) "fadump: " fmt
30 #include <linux/string.h>
31 #include <linux/memblock.h>
32 #include <linux/delay.h>
33 #include <linux/debugfs.h>
34 #include <linux/seq_file.h>
35 #include <linux/crash_dump.h>
40 #include <asm/fadump.h>
42 static struct fw_dump fw_dump
;
43 static struct fadump_mem_struct fdm
;
44 static const struct fadump_mem_struct
*fdm_active
;
46 static DEFINE_MUTEX(fadump_mutex
);
47 struct fad_crash_memory_ranges crash_memory_ranges
[INIT_CRASHMEM_RANGES
];
50 /* Scan the Firmware Assisted dump configuration details. */
51 int __init
early_init_dt_scan_fw_dump(unsigned long node
,
52 const char *uname
, int depth
, void *data
)
59 if (depth
!= 1 || strcmp(uname
, "rtas") != 0)
63 * Check if Firmware Assisted dump is supported. if yes, check
64 * if dump has been initiated on last reboot.
66 token
= of_get_flat_dt_prop(node
, "ibm,configure-kernel-dump", NULL
);
70 fw_dump
.fadump_supported
= 1;
71 fw_dump
.ibm_configure_kernel_dump
= *token
;
74 * The 'ibm,kernel-dump' rtas node is present only if there is
75 * dump data waiting for us.
77 fdm_active
= of_get_flat_dt_prop(node
, "ibm,kernel-dump", NULL
);
79 fw_dump
.dump_active
= 1;
81 /* Get the sizes required to store dump data for the firmware provided
83 * For each dump section type supported, a 32bit cell which defines
84 * the ID of a supported section followed by two 32 bit cells which
85 * gives teh size of the section in bytes.
87 sections
= of_get_flat_dt_prop(node
, "ibm,configure-kernel-dump-sizes",
93 num_sections
= size
/ (3 * sizeof(u32
));
95 for (i
= 0; i
< num_sections
; i
++, sections
+= 3) {
96 u32 type
= (u32
)of_read_number(sections
, 1);
99 case FADUMP_CPU_STATE_DATA
:
100 fw_dump
.cpu_state_data_size
=
101 of_read_ulong(§ions
[1], 2);
103 case FADUMP_HPTE_REGION
:
104 fw_dump
.hpte_region_size
=
105 of_read_ulong(§ions
[1], 2);
112 int is_fadump_active(void)
114 return fw_dump
.dump_active
;
117 /* Print firmware assisted dump configurations for debugging purpose. */
118 static void fadump_show_config(void)
120 pr_debug("Support for firmware-assisted dump (fadump): %s\n",
121 (fw_dump
.fadump_supported
? "present" : "no support"));
123 if (!fw_dump
.fadump_supported
)
126 pr_debug("Fadump enabled : %s\n",
127 (fw_dump
.fadump_enabled
? "yes" : "no"));
128 pr_debug("Dump Active : %s\n",
129 (fw_dump
.dump_active
? "yes" : "no"));
130 pr_debug("Dump section sizes:\n");
131 pr_debug(" CPU state data size: %lx\n", fw_dump
.cpu_state_data_size
);
132 pr_debug(" HPTE region size : %lx\n", fw_dump
.hpte_region_size
);
133 pr_debug("Boot memory size : %lx\n", fw_dump
.boot_memory_size
);
136 static unsigned long init_fadump_mem_struct(struct fadump_mem_struct
*fdm
,
142 memset(fdm
, 0, sizeof(struct fadump_mem_struct
));
143 addr
= addr
& PAGE_MASK
;
145 fdm
->header
.dump_format_version
= 0x00000001;
146 fdm
->header
.dump_num_sections
= 3;
147 fdm
->header
.dump_status_flag
= 0;
148 fdm
->header
.offset_first_dump_section
=
149 (u32
)offsetof(struct fadump_mem_struct
, cpu_state_data
);
152 * Fields for disk dump option.
153 * We are not using disk dump option, hence set these fields to 0.
155 fdm
->header
.dd_block_size
= 0;
156 fdm
->header
.dd_block_offset
= 0;
157 fdm
->header
.dd_num_blocks
= 0;
158 fdm
->header
.dd_offset_disk_path
= 0;
160 /* set 0 to disable an automatic dump-reboot. */
161 fdm
->header
.max_time_auto
= 0;
163 /* Kernel dump sections */
164 /* cpu state data section. */
165 fdm
->cpu_state_data
.request_flag
= FADUMP_REQUEST_FLAG
;
166 fdm
->cpu_state_data
.source_data_type
= FADUMP_CPU_STATE_DATA
;
167 fdm
->cpu_state_data
.source_address
= 0;
168 fdm
->cpu_state_data
.source_len
= fw_dump
.cpu_state_data_size
;
169 fdm
->cpu_state_data
.destination_address
= addr
;
170 addr
+= fw_dump
.cpu_state_data_size
;
172 /* hpte region section */
173 fdm
->hpte_region
.request_flag
= FADUMP_REQUEST_FLAG
;
174 fdm
->hpte_region
.source_data_type
= FADUMP_HPTE_REGION
;
175 fdm
->hpte_region
.source_address
= 0;
176 fdm
->hpte_region
.source_len
= fw_dump
.hpte_region_size
;
177 fdm
->hpte_region
.destination_address
= addr
;
178 addr
+= fw_dump
.hpte_region_size
;
180 /* RMA region section */
181 fdm
->rmr_region
.request_flag
= FADUMP_REQUEST_FLAG
;
182 fdm
->rmr_region
.source_data_type
= FADUMP_REAL_MODE_REGION
;
183 fdm
->rmr_region
.source_address
= RMA_START
;
184 fdm
->rmr_region
.source_len
= fw_dump
.boot_memory_size
;
185 fdm
->rmr_region
.destination_address
= addr
;
186 addr
+= fw_dump
.boot_memory_size
;
192 * fadump_calculate_reserve_size(): reserve variable boot area 5% of System RAM
194 * Function to find the largest memory size we need to reserve during early
195 * boot process. This will be the size of the memory that is required for a
196 * kernel to boot successfully.
198 * This function has been taken from phyp-assisted dump feature implementation.
200 * returns larger of 256MB or 5% rounded down to multiples of 256MB.
202 * TODO: Come up with better approach to find out more accurate memory size
203 * that is required for a kernel to boot successfully.
206 static inline unsigned long fadump_calculate_reserve_size(void)
211 * Check if the size is specified through fadump_reserve_mem= cmdline
212 * option. If yes, then use that.
214 if (fw_dump
.reserve_bootvar
)
215 return fw_dump
.reserve_bootvar
;
217 /* divide by 20 to get 5% of value */
218 size
= memblock_end_of_DRAM() / 20;
220 /* round it down in multiples of 256 */
221 size
= size
& ~0x0FFFFFFFUL
;
223 /* Truncate to memory_limit. We don't want to over reserve the memory.*/
224 if (memory_limit
&& size
> memory_limit
)
227 return (size
> MIN_BOOT_MEM
? size
: MIN_BOOT_MEM
);
231 * Calculate the total memory size required to be reserved for
232 * firmware-assisted dump registration.
234 static unsigned long get_fadump_area_size(void)
236 unsigned long size
= 0;
238 size
+= fw_dump
.cpu_state_data_size
;
239 size
+= fw_dump
.hpte_region_size
;
240 size
+= fw_dump
.boot_memory_size
;
241 size
+= sizeof(struct fadump_crash_info_header
);
242 size
+= sizeof(struct elfhdr
); /* ELF core header.*/
243 /* Program headers for crash memory regions. */
244 size
+= sizeof(struct elf_phdr
) * (memblock_num_regions(memory
) + 2);
246 size
= PAGE_ALIGN(size
);
250 int __init
fadump_reserve_mem(void)
252 unsigned long base
, size
, memory_boundary
;
254 if (!fw_dump
.fadump_enabled
)
257 if (!fw_dump
.fadump_supported
) {
258 printk(KERN_INFO
"Firmware-assisted dump is not supported on"
260 fw_dump
.fadump_enabled
= 0;
264 * Initialize boot memory size
265 * If dump is active then we have already calculated the size during
269 fw_dump
.boot_memory_size
= fdm_active
->rmr_region
.source_len
;
271 fw_dump
.boot_memory_size
= fadump_calculate_reserve_size();
274 * Calculate the memory boundary.
275 * If memory_limit is less than actual memory boundary then reserve
276 * the memory for fadump beyond the memory_limit and adjust the
277 * memory_limit accordingly, so that the running kernel can run with
278 * specified memory_limit.
280 if (memory_limit
&& memory_limit
< memblock_end_of_DRAM()) {
281 size
= get_fadump_area_size();
282 if ((memory_limit
+ size
) < memblock_end_of_DRAM())
283 memory_limit
+= size
;
285 memory_limit
= memblock_end_of_DRAM();
286 printk(KERN_INFO
"Adjusted memory_limit for firmware-assisted"
287 " dump, now %#016llx\n",
288 (unsigned long long)memory_limit
);
291 memory_boundary
= memory_limit
;
293 memory_boundary
= memblock_end_of_DRAM();
295 if (fw_dump
.dump_active
) {
296 printk(KERN_INFO
"Firmware-assisted dump is active.\n");
298 * If last boot has crashed then reserve all the memory
299 * above boot_memory_size so that we don't touch it until
300 * dump is written to disk by userspace tool. This memory
301 * will be released for general use once the dump is saved.
303 base
= fw_dump
.boot_memory_size
;
304 size
= memory_boundary
- base
;
305 memblock_reserve(base
, size
);
306 printk(KERN_INFO
"Reserved %ldMB of memory at %ldMB "
307 "for saving crash dump\n",
308 (unsigned long)(size
>> 20),
309 (unsigned long)(base
>> 20));
311 fw_dump
.fadumphdr_addr
=
312 fdm_active
->rmr_region
.destination_address
+
313 fdm_active
->rmr_region
.source_len
;
314 pr_debug("fadumphdr_addr = %p\n",
315 (void *) fw_dump
.fadumphdr_addr
);
317 /* Reserve the memory at the top of memory. */
318 size
= get_fadump_area_size();
319 base
= memory_boundary
- size
;
320 memblock_reserve(base
, size
);
321 printk(KERN_INFO
"Reserved %ldMB of memory at %ldMB "
322 "for firmware-assisted dump\n",
323 (unsigned long)(size
>> 20),
324 (unsigned long)(base
>> 20));
326 fw_dump
.reserve_dump_area_start
= base
;
327 fw_dump
.reserve_dump_area_size
= size
;
331 /* Look for fadump= cmdline option. */
332 static int __init
early_fadump_param(char *p
)
337 if (strncmp(p
, "on", 2) == 0)
338 fw_dump
.fadump_enabled
= 1;
339 else if (strncmp(p
, "off", 3) == 0)
340 fw_dump
.fadump_enabled
= 0;
344 early_param("fadump", early_fadump_param
);
346 /* Look for fadump_reserve_mem= cmdline option */
347 static int __init
early_fadump_reserve_mem(char *p
)
350 fw_dump
.reserve_bootvar
= memparse(p
, &p
);
353 early_param("fadump_reserve_mem", early_fadump_reserve_mem
);
355 static void register_fw_dump(struct fadump_mem_struct
*fdm
)
358 unsigned int wait_time
;
360 pr_debug("Registering for firmware-assisted kernel dump...\n");
362 /* TODO: Add upper time limit for the delay */
364 rc
= rtas_call(fw_dump
.ibm_configure_kernel_dump
, 3, 1, NULL
,
365 FADUMP_REGISTER
, fdm
,
366 sizeof(struct fadump_mem_struct
));
368 wait_time
= rtas_busy_delay_time(rc
);
376 printk(KERN_ERR
"Failed to register firmware-assisted kernel"
377 " dump. Hardware Error(%d).\n", rc
);
380 printk(KERN_ERR
"Failed to register firmware-assisted kernel"
381 " dump. Parameter Error(%d).\n", rc
);
384 printk(KERN_ERR
"firmware-assisted kernel dump is already "
386 fw_dump
.dump_registered
= 1;
389 printk(KERN_INFO
"firmware-assisted kernel dump registration"
391 fw_dump
.dump_registered
= 1;
397 * Validate and process the dump data stored by firmware before exporting
398 * it through '/proc/vmcore'.
400 static int __init
process_fadump(const struct fadump_mem_struct
*fdm_active
)
402 struct fadump_crash_info_header
*fdh
;
404 if (!fdm_active
|| !fw_dump
.fadumphdr_addr
)
407 /* Check if the dump data is valid. */
408 if ((fdm_active
->header
.dump_status_flag
== FADUMP_ERROR_FLAG
) ||
409 (fdm_active
->rmr_region
.error_flags
!= 0)) {
410 printk(KERN_ERR
"Dump taken by platform is not valid\n");
413 if (fdm_active
->rmr_region
.bytes_dumped
!=
414 fdm_active
->rmr_region
.source_len
) {
415 printk(KERN_ERR
"Dump taken by platform is incomplete\n");
419 /* Validate the fadump crash info header */
420 fdh
= __va(fw_dump
.fadumphdr_addr
);
421 if (fdh
->magic_number
!= FADUMP_CRASH_INFO_MAGIC
) {
422 printk(KERN_ERR
"Crash info header is not valid.\n");
427 * We are done validating dump info and elfcore header is now ready
428 * to be exported. set elfcorehdr_addr so that vmcore module will
429 * export the elfcore header through '/proc/vmcore'.
431 elfcorehdr_addr
= fdh
->elfcorehdr_addr
;
436 static inline void fadump_add_crash_memory(unsigned long long base
,
437 unsigned long long end
)
442 pr_debug("crash_memory_range[%d] [%#016llx-%#016llx], %#llx bytes\n",
443 crash_mem_ranges
, base
, end
- 1, (end
- base
));
444 crash_memory_ranges
[crash_mem_ranges
].base
= base
;
445 crash_memory_ranges
[crash_mem_ranges
].size
= end
- base
;
449 static void fadump_exclude_reserved_area(unsigned long long start
,
450 unsigned long long end
)
452 unsigned long long ra_start
, ra_end
;
454 ra_start
= fw_dump
.reserve_dump_area_start
;
455 ra_end
= ra_start
+ fw_dump
.reserve_dump_area_size
;
457 if ((ra_start
< end
) && (ra_end
> start
)) {
458 if ((start
< ra_start
) && (end
> ra_end
)) {
459 fadump_add_crash_memory(start
, ra_start
);
460 fadump_add_crash_memory(ra_end
, end
);
461 } else if (start
< ra_start
) {
462 fadump_add_crash_memory(start
, ra_start
);
463 } else if (ra_end
< end
) {
464 fadump_add_crash_memory(ra_end
, end
);
467 fadump_add_crash_memory(start
, end
);
470 static int fadump_init_elfcore_header(char *bufp
)
474 elf
= (struct elfhdr
*) bufp
;
475 bufp
+= sizeof(struct elfhdr
);
476 memcpy(elf
->e_ident
, ELFMAG
, SELFMAG
);
477 elf
->e_ident
[EI_CLASS
] = ELF_CLASS
;
478 elf
->e_ident
[EI_DATA
] = ELF_DATA
;
479 elf
->e_ident
[EI_VERSION
] = EV_CURRENT
;
480 elf
->e_ident
[EI_OSABI
] = ELF_OSABI
;
481 memset(elf
->e_ident
+EI_PAD
, 0, EI_NIDENT
-EI_PAD
);
482 elf
->e_type
= ET_CORE
;
483 elf
->e_machine
= ELF_ARCH
;
484 elf
->e_version
= EV_CURRENT
;
486 elf
->e_phoff
= sizeof(struct elfhdr
);
488 elf
->e_flags
= ELF_CORE_EFLAGS
;
489 elf
->e_ehsize
= sizeof(struct elfhdr
);
490 elf
->e_phentsize
= sizeof(struct elf_phdr
);
492 elf
->e_shentsize
= 0;
500 * Traverse through memblock structure and setup crash memory ranges. These
501 * ranges will be used create PT_LOAD program headers in elfcore header.
503 static void fadump_setup_crash_memory_ranges(void)
505 struct memblock_region
*reg
;
506 unsigned long long start
, end
;
508 pr_debug("Setup crash memory ranges.\n");
509 crash_mem_ranges
= 0;
511 * add the first memory chunk (RMA_START through boot_memory_size) as
512 * a separate memory chunk. The reason is, at the time crash firmware
513 * will move the content of this memory chunk to different location
514 * specified during fadump registration. We need to create a separate
515 * program header for this chunk with the correct offset.
517 fadump_add_crash_memory(RMA_START
, fw_dump
.boot_memory_size
);
519 for_each_memblock(memory
, reg
) {
520 start
= (unsigned long long)reg
->base
;
521 end
= start
+ (unsigned long long)reg
->size
;
522 if (start
== RMA_START
&& end
>= fw_dump
.boot_memory_size
)
523 start
= fw_dump
.boot_memory_size
;
525 /* add this range excluding the reserved dump area. */
526 fadump_exclude_reserved_area(start
, end
);
530 static int fadump_create_elfcore_headers(char *bufp
)
533 struct elf_phdr
*phdr
;
536 fadump_init_elfcore_header(bufp
);
537 elf
= (struct elfhdr
*)bufp
;
538 bufp
+= sizeof(struct elfhdr
);
540 /* setup PT_LOAD sections. */
542 for (i
= 0; i
< crash_mem_ranges
; i
++) {
543 unsigned long long mbase
, msize
;
544 mbase
= crash_memory_ranges
[i
].base
;
545 msize
= crash_memory_ranges
[i
].size
;
550 phdr
= (struct elf_phdr
*)bufp
;
551 bufp
+= sizeof(struct elf_phdr
);
552 phdr
->p_type
= PT_LOAD
;
553 phdr
->p_flags
= PF_R
|PF_W
|PF_X
;
554 phdr
->p_offset
= mbase
;
556 if (mbase
== RMA_START
) {
558 * The entire RMA region will be moved by firmware
559 * to the specified destination_address. Hence set
560 * the correct offset.
562 phdr
->p_offset
= fdm
.rmr_region
.destination_address
;
565 phdr
->p_paddr
= mbase
;
566 phdr
->p_vaddr
= (unsigned long)__va(mbase
);
567 phdr
->p_filesz
= msize
;
568 phdr
->p_memsz
= msize
;
571 /* Increment number of program headers. */
577 static unsigned long init_fadump_header(unsigned long addr
)
579 struct fadump_crash_info_header
*fdh
;
584 fw_dump
.fadumphdr_addr
= addr
;
586 addr
+= sizeof(struct fadump_crash_info_header
);
588 memset(fdh
, 0, sizeof(struct fadump_crash_info_header
));
589 fdh
->magic_number
= FADUMP_CRASH_INFO_MAGIC
;
590 fdh
->elfcorehdr_addr
= addr
;
595 static void register_fadump(void)
601 * If no memory is reserved then we can not register for firmware-
604 if (!fw_dump
.reserve_dump_area_size
)
607 fadump_setup_crash_memory_ranges();
609 addr
= fdm
.rmr_region
.destination_address
+ fdm
.rmr_region
.source_len
;
610 /* Initialize fadump crash info header. */
611 addr
= init_fadump_header(addr
);
614 pr_debug("Creating ELF core headers at %#016lx\n", addr
);
615 fadump_create_elfcore_headers(vaddr
);
617 /* register the future kernel dump with firmware. */
618 register_fw_dump(&fdm
);
621 static int fadump_unregister_dump(struct fadump_mem_struct
*fdm
)
624 unsigned int wait_time
;
626 pr_debug("Un-register firmware-assisted dump\n");
628 /* TODO: Add upper time limit for the delay */
630 rc
= rtas_call(fw_dump
.ibm_configure_kernel_dump
, 3, 1, NULL
,
631 FADUMP_UNREGISTER
, fdm
,
632 sizeof(struct fadump_mem_struct
));
634 wait_time
= rtas_busy_delay_time(rc
);
640 printk(KERN_ERR
"Failed to un-register firmware-assisted dump."
641 " unexpected error(%d).\n", rc
);
644 fw_dump
.dump_registered
= 0;
648 static ssize_t
fadump_enabled_show(struct kobject
*kobj
,
649 struct kobj_attribute
*attr
,
652 return sprintf(buf
, "%d\n", fw_dump
.fadump_enabled
);
655 static ssize_t
fadump_register_show(struct kobject
*kobj
,
656 struct kobj_attribute
*attr
,
659 return sprintf(buf
, "%d\n", fw_dump
.dump_registered
);
662 static ssize_t
fadump_register_store(struct kobject
*kobj
,
663 struct kobj_attribute
*attr
,
664 const char *buf
, size_t count
)
668 if (!fw_dump
.fadump_enabled
|| fdm_active
)
671 mutex_lock(&fadump_mutex
);
675 if (fw_dump
.dump_registered
== 0) {
679 /* Un-register Firmware-assisted dump */
680 fadump_unregister_dump(&fdm
);
683 if (fw_dump
.dump_registered
== 1) {
687 /* Register Firmware-assisted dump */
696 mutex_unlock(&fadump_mutex
);
697 return ret
< 0 ? ret
: count
;
700 static int fadump_region_show(struct seq_file
*m
, void *private)
702 const struct fadump_mem_struct
*fdm_ptr
;
704 if (!fw_dump
.fadump_enabled
)
708 fdm_ptr
= fdm_active
;
713 "CPU : [%#016llx-%#016llx] %#llx bytes, "
715 fdm_ptr
->cpu_state_data
.destination_address
,
716 fdm_ptr
->cpu_state_data
.destination_address
+
717 fdm_ptr
->cpu_state_data
.source_len
- 1,
718 fdm_ptr
->cpu_state_data
.source_len
,
719 fdm_ptr
->cpu_state_data
.bytes_dumped
);
721 "HPTE: [%#016llx-%#016llx] %#llx bytes, "
723 fdm_ptr
->hpte_region
.destination_address
,
724 fdm_ptr
->hpte_region
.destination_address
+
725 fdm_ptr
->hpte_region
.source_len
- 1,
726 fdm_ptr
->hpte_region
.source_len
,
727 fdm_ptr
->hpte_region
.bytes_dumped
);
729 "DUMP: [%#016llx-%#016llx] %#llx bytes, "
731 fdm_ptr
->rmr_region
.destination_address
,
732 fdm_ptr
->rmr_region
.destination_address
+
733 fdm_ptr
->rmr_region
.source_len
- 1,
734 fdm_ptr
->rmr_region
.source_len
,
735 fdm_ptr
->rmr_region
.bytes_dumped
);
738 (fw_dump
.reserve_dump_area_start
==
739 fdm_ptr
->cpu_state_data
.destination_address
))
742 /* Dump is active. Show reserved memory region. */
744 " : [%#016llx-%#016llx] %#llx bytes, "
746 (unsigned long long)fw_dump
.reserve_dump_area_start
,
747 fdm_ptr
->cpu_state_data
.destination_address
- 1,
748 fdm_ptr
->cpu_state_data
.destination_address
-
749 fw_dump
.reserve_dump_area_start
,
750 fdm_ptr
->cpu_state_data
.destination_address
-
751 fw_dump
.reserve_dump_area_start
);
755 static struct kobj_attribute fadump_attr
= __ATTR(fadump_enabled
,
756 0444, fadump_enabled_show
,
758 static struct kobj_attribute fadump_register_attr
= __ATTR(fadump_registered
,
759 0644, fadump_register_show
,
760 fadump_register_store
);
762 static int fadump_region_open(struct inode
*inode
, struct file
*file
)
764 return single_open(file
, fadump_region_show
, inode
->i_private
);
767 static const struct file_operations fadump_region_fops
= {
768 .open
= fadump_region_open
,
771 .release
= single_release
,
774 static void fadump_init_files(void)
776 struct dentry
*debugfs_file
;
779 rc
= sysfs_create_file(kernel_kobj
, &fadump_attr
.attr
);
781 printk(KERN_ERR
"fadump: unable to create sysfs file"
782 " fadump_enabled (%d)\n", rc
);
784 rc
= sysfs_create_file(kernel_kobj
, &fadump_register_attr
.attr
);
786 printk(KERN_ERR
"fadump: unable to create sysfs file"
787 " fadump_registered (%d)\n", rc
);
789 debugfs_file
= debugfs_create_file("fadump_region", 0444,
790 powerpc_debugfs_root
, NULL
,
791 &fadump_region_fops
);
793 printk(KERN_ERR
"fadump: unable to create debugfs file"
799 * Prepare for firmware-assisted dump.
801 int __init
setup_fadump(void)
803 if (!fw_dump
.fadump_enabled
)
806 if (!fw_dump
.fadump_supported
) {
807 printk(KERN_ERR
"Firmware-assisted dump is not supported on"
812 fadump_show_config();
814 * If dump data is available then see if it is valid and prepare for
815 * saving it to the disk.
817 if (fw_dump
.dump_active
)
818 process_fadump(fdm_active
);
819 /* Initialize the kernel dump memory structure for FAD registration. */
820 else if (fw_dump
.reserve_dump_area_size
)
821 init_fadump_mem_struct(&fdm
, fw_dump
.reserve_dump_area_start
);
826 subsys_initcall(setup_fadump
);