Lines Matching +full:used +full:- +full:by +full:- +full:rtas
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Firmware-Assisted Dump support on POWERVM platform.
9 #define pr_fmt(fmt) "rtas fadump: " fmt
19 #include <asm/rtas.h>
21 #include <asm/fadump-internal.h>
23 #include "rtas-fadump.h"
31 fadump_conf->boot_mem_dest_addr = in rtas_fadump_update_config()
32 be64_to_cpu(fdm->rmr_region.destination_address); in rtas_fadump_update_config()
34 fadump_conf->fadumphdr_addr = (fadump_conf->boot_mem_dest_addr + in rtas_fadump_update_config()
35 fadump_conf->boot_memory_size); in rtas_fadump_update_config()
45 fadump_conf->boot_mem_addr[0] = in rtas_fadump_get_config()
46 be64_to_cpu(fdm->rmr_region.source_address); in rtas_fadump_get_config()
47 fadump_conf->boot_mem_sz[0] = be64_to_cpu(fdm->rmr_region.source_len); in rtas_fadump_get_config()
48 fadump_conf->boot_memory_size = fadump_conf->boot_mem_sz[0]; in rtas_fadump_get_config()
50 fadump_conf->boot_mem_top = fadump_conf->boot_memory_size; in rtas_fadump_get_config()
51 fadump_conf->boot_mem_regs_cnt = 1; in rtas_fadump_get_config()
55 * re-registering FADump after dump capture. in rtas_fadump_get_config()
57 fadump_conf->reserve_dump_area_start = in rtas_fadump_get_config()
58 be64_to_cpu(fdm->cpu_state_data.destination_address); in rtas_fadump_get_config()
65 u64 addr = fadump_conf->reserve_dump_area_start; in rtas_fadump_init_mem_struct()
86 /* set 0 to disable an automatic dump-reboot. */ in rtas_fadump_init_mem_struct()
97 cpu_to_be64(fadump_conf->cpu_state_data_size); in rtas_fadump_init_mem_struct()
99 addr += fadump_conf->cpu_state_data_size; in rtas_fadump_init_mem_struct()
107 cpu_to_be64(fadump_conf->hpte_region_size); in rtas_fadump_init_mem_struct()
109 addr += fadump_conf->hpte_region_size; in rtas_fadump_init_mem_struct()
116 fdm.rmr_region.source_len = cpu_to_be64(fadump_conf->boot_memory_size); in rtas_fadump_init_mem_struct()
118 addr += fadump_conf->boot_memory_size; in rtas_fadump_init_mem_struct()
133 int rc, err = -EIO; in rtas_fadump_register()
137 rc = rtas_call(fadump_conf->ibm_configure_kernel_dump, 3, 1, in rtas_fadump_register()
150 fadump_conf->dump_registered = 1; in rtas_fadump_register()
153 case -1: in rtas_fadump_register()
156 case -3: in rtas_fadump_register()
163 err = -EINVAL; in rtas_fadump_register()
165 case -9: in rtas_fadump_register()
167 fadump_conf->dump_registered = 1; in rtas_fadump_register()
168 err = -EEXIST; in rtas_fadump_register()
185 rc = rtas_call(fadump_conf->ibm_configure_kernel_dump, 3, 1, in rtas_fadump_unregister()
195 pr_err("Failed to un-register - unexpected error(%d).\n", rc); in rtas_fadump_unregister()
196 return -EIO; in rtas_fadump_unregister()
199 fadump_conf->dump_registered = 0; in rtas_fadump_unregister()
210 rc = rtas_call(fadump_conf->ibm_configure_kernel_dump, 3, 1, in rtas_fadump_invalidate()
220 pr_err("Failed to invalidate - unexpected error (%d).\n", rc); in rtas_fadump_invalidate()
221 return -EIO; in rtas_fadump_invalidate()
224 fadump_conf->dump_active = 0; in rtas_fadump_invalidate()
233 int i = -1; in rtas_fadump_gpr_index()
243 i = -EINVAL; in rtas_fadump_gpr_index()
245 i = -1; in rtas_fadump_gpr_index()
256 regs->gpr[i] = (unsigned long)reg_val; in rtas_fadump_set_regval()
258 regs->nip = (unsigned long)reg_val; in rtas_fadump_set_regval()
260 regs->msr = (unsigned long)reg_val; in rtas_fadump_set_regval()
262 regs->ctr = (unsigned long)reg_val; in rtas_fadump_set_regval()
264 regs->link = (unsigned long)reg_val; in rtas_fadump_set_regval()
266 regs->xer = (unsigned long)reg_val; in rtas_fadump_set_regval()
268 regs->ccr = (unsigned long)reg_val; in rtas_fadump_set_regval()
270 regs->dar = (unsigned long)reg_val; in rtas_fadump_set_regval()
272 regs->dsisr = (unsigned long)reg_val; in rtas_fadump_set_regval()
281 while (be64_to_cpu(reg_entry->reg_id) != fadump_str_to_u64("CPUEND")) { in rtas_fadump_read_regs()
282 rtas_fadump_set_regval(regs, be64_to_cpu(reg_entry->reg_id), in rtas_fadump_read_regs()
283 be64_to_cpu(reg_entry->reg_value)); in rtas_fadump_read_regs()
293 * used to access the data to allow for additional fields to be added without
301 * state from fadump crash info structure populated by first kernel at the
315 addr = be64_to_cpu(fdm_active->cpu_state_data.destination_address); in rtas_fadump_build_cpu_notes()
319 if (be64_to_cpu(reg_header->magic_number) != in rtas_fadump_build_cpu_notes()
322 return -ENOENT; in rtas_fadump_build_cpu_notes()
325 pr_debug("--------CPU State Data------------\n"); in rtas_fadump_build_cpu_notes()
326 pr_debug("Magic Number: %llx\n", be64_to_cpu(reg_header->magic_number)); in rtas_fadump_build_cpu_notes()
327 pr_debug("NumCpuOffset: %x\n", be32_to_cpu(reg_header->num_cpu_offset)); in rtas_fadump_build_cpu_notes()
329 vaddr += be32_to_cpu(reg_header->num_cpu_offset); in rtas_fadump_build_cpu_notes()
339 note_buf = (u32 *)fadump_conf->cpu_notes_buf_vaddr; in rtas_fadump_build_cpu_notes()
341 if (fadump_conf->fadumphdr_addr) in rtas_fadump_build_cpu_notes()
342 fdh = __va(fadump_conf->fadumphdr_addr); in rtas_fadump_build_cpu_notes()
345 if (be64_to_cpu(reg_entry->reg_id) != in rtas_fadump_build_cpu_notes()
348 rc = -ENOENT; in rtas_fadump_build_cpu_notes()
352 cpu = (be64_to_cpu(reg_entry->reg_value) & in rtas_fadump_build_cpu_notes()
354 if (fdh && !cpumask_test_cpu(cpu, &fdh->online_mask)) { in rtas_fadump_build_cpu_notes()
359 if (fdh && fdh->crashing_cpu == cpu) { in rtas_fadump_build_cpu_notes()
360 regs = fdh->regs; in rtas_fadump_build_cpu_notes()
373 fdh->elfcorehdr_addr); in rtas_fadump_build_cpu_notes()
374 fadump_update_elfcore_header(__va(fdh->elfcorehdr_addr)); in rtas_fadump_build_cpu_notes()
385 * Validate and process the dump data stored by firmware before exporting
393 if (!fdm_active || !fadump_conf->fadumphdr_addr) in rtas_fadump_process()
394 return -EINVAL; in rtas_fadump_process()
397 if ((be16_to_cpu(fdm_active->header.dump_status_flag) == in rtas_fadump_process()
399 (fdm_active->cpu_state_data.error_flags != 0) || in rtas_fadump_process()
400 (fdm_active->rmr_region.error_flags != 0)) { in rtas_fadump_process()
401 pr_err("Dump taken by platform is not valid\n"); in rtas_fadump_process()
402 return -EINVAL; in rtas_fadump_process()
404 if ((fdm_active->rmr_region.bytes_dumped != in rtas_fadump_process()
405 fdm_active->rmr_region.source_len) || in rtas_fadump_process()
406 !fdm_active->cpu_state_data.bytes_dumped) { in rtas_fadump_process()
407 pr_err("Dump taken by platform is incomplete\n"); in rtas_fadump_process()
408 return -EINVAL; in rtas_fadump_process()
412 fdh = __va(fadump_conf->fadumphdr_addr); in rtas_fadump_process()
413 if (fdh->magic_number != FADUMP_CRASH_INFO_MAGIC) { in rtas_fadump_process()
415 return -EINVAL; in rtas_fadump_process()
427 elfcorehdr_addr = fdh->elfcorehdr_addr; in rtas_fadump_process()
443 cpu_data_section = &(fdm_ptr->cpu_state_data); in rtas_fadump_region_show()
444 seq_printf(m, "CPU :[%#016llx-%#016llx] %#llx bytes, Dumped: %#llx\n", in rtas_fadump_region_show()
445 be64_to_cpu(cpu_data_section->destination_address), in rtas_fadump_region_show()
446 be64_to_cpu(cpu_data_section->destination_address) + in rtas_fadump_region_show()
447 be64_to_cpu(cpu_data_section->source_len) - 1, in rtas_fadump_region_show()
448 be64_to_cpu(cpu_data_section->source_len), in rtas_fadump_region_show()
449 be64_to_cpu(cpu_data_section->bytes_dumped)); in rtas_fadump_region_show()
451 seq_printf(m, "HPTE:[%#016llx-%#016llx] %#llx bytes, Dumped: %#llx\n", in rtas_fadump_region_show()
452 be64_to_cpu(fdm_ptr->hpte_region.destination_address), in rtas_fadump_region_show()
453 be64_to_cpu(fdm_ptr->hpte_region.destination_address) + in rtas_fadump_region_show()
454 be64_to_cpu(fdm_ptr->hpte_region.source_len) - 1, in rtas_fadump_region_show()
455 be64_to_cpu(fdm_ptr->hpte_region.source_len), in rtas_fadump_region_show()
456 be64_to_cpu(fdm_ptr->hpte_region.bytes_dumped)); in rtas_fadump_region_show()
459 be64_to_cpu(fdm_ptr->rmr_region.source_address), in rtas_fadump_region_show()
460 be64_to_cpu(fdm_ptr->rmr_region.destination_address)); in rtas_fadump_region_show()
462 be64_to_cpu(fdm_ptr->rmr_region.source_len), in rtas_fadump_region_show()
463 be64_to_cpu(fdm_ptr->rmr_region.bytes_dumped)); in rtas_fadump_region_show()
468 fadump_conf->reserve_dump_area_start); in rtas_fadump_region_show()
475 /* Call ibm,os-term rtas call to trigger firmware assisted dump */ in rtas_fadump_trigger()
500 token = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump", NULL); in rtas_fadump_dt_scan()
504 fadump_conf->ibm_configure_kernel_dump = be32_to_cpu(*token); in rtas_fadump_dt_scan()
505 fadump_conf->ops = &rtas_fadump_ops; in rtas_fadump_dt_scan()
506 fadump_conf->fadump_supported = 1; in rtas_fadump_dt_scan()
508 /* Firmware supports 64-bit value for size, align it to pagesize. */ in rtas_fadump_dt_scan()
509 fadump_conf->max_copy_size = ALIGN_DOWN(U64_MAX, PAGE_SIZE); in rtas_fadump_dt_scan()
512 * The 'ibm,kernel-dump' rtas node is present only if there is in rtas_fadump_dt_scan()
515 fdm_active = of_get_flat_dt_prop(node, "ibm,kernel-dump", NULL); in rtas_fadump_dt_scan()
517 pr_info("Firmware-assisted dump is active.\n"); in rtas_fadump_dt_scan()
518 fadump_conf->dump_active = 1; in rtas_fadump_dt_scan()
525 * the ID of a supported section followed by two 32 bit cells which in rtas_fadump_dt_scan()
528 sections = of_get_flat_dt_prop(node, "ibm,configure-kernel-dump-sizes", in rtas_fadump_dt_scan()
541 fadump_conf->cpu_state_data_size = in rtas_fadump_dt_scan()
545 fadump_conf->hpte_region_size = in rtas_fadump_dt_scan()