1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Firmware-Assisted Dump support on POWERVM platform. 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright 2011, Mahesh Salgaonkar, IBM Corporation. 6*4882a593Smuzhiyun * Copyright 2019, Hari Bathini, IBM Corporation. 7*4882a593Smuzhiyun */ 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun #ifndef _PSERIES_RTAS_FADUMP_H 10*4882a593Smuzhiyun #define _PSERIES_RTAS_FADUMP_H 11*4882a593Smuzhiyun 12*4882a593Smuzhiyun /* 13*4882a593Smuzhiyun * On some Power systems where RMO is 128MB, it still requires minimum of 14*4882a593Smuzhiyun * 256MB for kernel to boot successfully. When kdump infrastructure is 15*4882a593Smuzhiyun * configured to save vmcore over network, we run into OOM issue while 16*4882a593Smuzhiyun * loading modules related to network setup. Hence we need additional 64M 17*4882a593Smuzhiyun * of memory to avoid OOM issue. 18*4882a593Smuzhiyun */ 19*4882a593Smuzhiyun #define RTAS_FADUMP_MIN_BOOT_MEM ((0x1UL << 28) + (0x1UL << 26)) 20*4882a593Smuzhiyun 21*4882a593Smuzhiyun /* Firmware provided dump sections */ 22*4882a593Smuzhiyun #define RTAS_FADUMP_CPU_STATE_DATA 0x0001 23*4882a593Smuzhiyun #define RTAS_FADUMP_HPTE_REGION 0x0002 24*4882a593Smuzhiyun #define RTAS_FADUMP_REAL_MODE_REGION 0x0011 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun /* Dump request flag */ 27*4882a593Smuzhiyun #define RTAS_FADUMP_REQUEST_FLAG 0x00000001 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun /* Dump status flag */ 30*4882a593Smuzhiyun #define RTAS_FADUMP_ERROR_FLAG 0x2000 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /* Kernel Dump section info */ 33*4882a593Smuzhiyun struct rtas_fadump_section { 34*4882a593Smuzhiyun __be32 request_flag; 35*4882a593Smuzhiyun __be16 source_data_type; 36*4882a593Smuzhiyun __be16 error_flags; 37*4882a593Smuzhiyun __be64 source_address; 38*4882a593Smuzhiyun __be64 source_len; 39*4882a593Smuzhiyun __be64 bytes_dumped; 40*4882a593Smuzhiyun __be64 destination_address; 41*4882a593Smuzhiyun }; 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* ibm,configure-kernel-dump header. */ 44*4882a593Smuzhiyun struct rtas_fadump_section_header { 45*4882a593Smuzhiyun __be32 dump_format_version; 46*4882a593Smuzhiyun __be16 dump_num_sections; 47*4882a593Smuzhiyun __be16 dump_status_flag; 48*4882a593Smuzhiyun __be32 offset_first_dump_section; 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /* Fields for disk dump option. */ 51*4882a593Smuzhiyun __be32 dd_block_size; 52*4882a593Smuzhiyun __be64 dd_block_offset; 53*4882a593Smuzhiyun __be64 dd_num_blocks; 54*4882a593Smuzhiyun __be32 dd_offset_disk_path; 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /* Maximum time allowed to prevent an automatic dump-reboot. */ 57*4882a593Smuzhiyun __be32 max_time_auto; 58*4882a593Smuzhiyun }; 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun /* 61*4882a593Smuzhiyun * Firmware Assisted dump memory structure. This structure is required for 62*4882a593Smuzhiyun * registering future kernel dump with power firmware through rtas call. 63*4882a593Smuzhiyun * 64*4882a593Smuzhiyun * No disk dump option. Hence disk dump path string section is not included. 65*4882a593Smuzhiyun */ 66*4882a593Smuzhiyun struct rtas_fadump_mem_struct { 67*4882a593Smuzhiyun struct rtas_fadump_section_header header; 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun /* Kernel dump sections */ 70*4882a593Smuzhiyun struct rtas_fadump_section cpu_state_data; 71*4882a593Smuzhiyun struct rtas_fadump_section hpte_region; 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* 74*4882a593Smuzhiyun * TODO: Extend multiple boot memory regions support in the kernel 75*4882a593Smuzhiyun * for this platform. 76*4882a593Smuzhiyun */ 77*4882a593Smuzhiyun struct rtas_fadump_section rmr_region; 78*4882a593Smuzhiyun }; 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* 81*4882a593Smuzhiyun * The firmware-assisted dump format. 82*4882a593Smuzhiyun * 83*4882a593Smuzhiyun * The register save area is an area in the partition's memory used to preserve 84*4882a593Smuzhiyun * the register contents (CPU state data) for the active CPUs during a firmware 85*4882a593Smuzhiyun * assisted dump. The dump format contains register save area header followed 86*4882a593Smuzhiyun * by register entries. Each list of registers for a CPU starts with "CPUSTRT" 87*4882a593Smuzhiyun * and ends with "CPUEND". 88*4882a593Smuzhiyun */ 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun /* Register save area header. */ 91*4882a593Smuzhiyun struct rtas_fadump_reg_save_area_header { 92*4882a593Smuzhiyun __be64 magic_number; 93*4882a593Smuzhiyun __be32 version; 94*4882a593Smuzhiyun __be32 num_cpu_offset; 95*4882a593Smuzhiyun }; 96*4882a593Smuzhiyun 97*4882a593Smuzhiyun /* Register entry. */ 98*4882a593Smuzhiyun struct rtas_fadump_reg_entry { 99*4882a593Smuzhiyun __be64 reg_id; 100*4882a593Smuzhiyun __be64 reg_value; 101*4882a593Smuzhiyun }; 102*4882a593Smuzhiyun 103*4882a593Smuzhiyun /* Utility macros */ 104*4882a593Smuzhiyun #define RTAS_FADUMP_SKIP_TO_NEXT_CPU(reg_entry) \ 105*4882a593Smuzhiyun ({ \ 106*4882a593Smuzhiyun while (be64_to_cpu(reg_entry->reg_id) != \ 107*4882a593Smuzhiyun fadump_str_to_u64("CPUEND")) \ 108*4882a593Smuzhiyun reg_entry++; \ 109*4882a593Smuzhiyun reg_entry++; \ 110*4882a593Smuzhiyun }) 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun #define RTAS_FADUMP_CPU_ID_MASK ((1UL << 32) - 1) 113*4882a593Smuzhiyun 114*4882a593Smuzhiyun #endif /* _PSERIES_RTAS_FADUMP_H */ 115