1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Firmware-Assisted Dump internal code.
5 * Copyright 2011, Mahesh Salgaonkar, IBM Corporation.
6 * Copyright 2019, Hari Bathini, IBM Corporation.
9 #ifndef _ASM_POWERPC_FADUMP_INTERNAL_H
10 #define _ASM_POWERPC_FADUMP_INTERNAL_H
12 /* Maximum number of memory regions kernel supports */
13 #define FADUMP_MAX_MEM_REGS 128
15 #ifndef CONFIG_PRESERVE_FA_DUMP
17 /* The upper limit percentage for user specified boot memory size (25%) */
18 #define MAX_BOOT_MEM_RATIO 4
20 #define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
23 #define FADUMP_REGISTER 1
24 #define FADUMP_UNREGISTER 2
25 #define FADUMP_INVALIDATE 3
28 * Copy the ascii values for first 8 characters from a string into u64
29 * variable at their respective indexes.
31 * The string "FADMPINF" will be converted into 0x4641444d50494e46
33 static inline u64
fadump_str_to_u64(const char *str
)
38 for (i
= 0; i
< sizeof(val
); i
++)
39 val
= (*str
) ? (val
<< 8) | *str
++ : val
<< 8;
43 #define FADUMP_CPU_UNKNOWN (~((u32)0))
46 * The introduction of new fields in the fadump crash info header has
47 * led to a change in the magic key from `FADMPINF` to `FADMPSIG` for
48 * identifying a kernel crash from an old kernel.
50 * To prevent the need for further changes to the magic number in the
51 * event of future modifications to the fadump crash info header, a
52 * version field has been introduced to track the fadump crash info
55 * Consider a few points before adding new members to the fadump crash info
58 * - Append new members; avoid adding them in between.
59 * - Non-primitive members should have a size member as well.
60 * - For every change in the fadump header, increment the
61 * fadump header version. This helps the updated kernel decide how to
62 * handle kernel dumps from older kernels.
64 #define FADUMP_CRASH_INFO_MAGIC_OLD fadump_str_to_u64("FADMPINF")
65 #define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPSIG")
66 #define FADUMP_HEADER_VERSION 1
68 /* fadump crash info structure */
69 struct fadump_crash_info_header
{
78 struct cpumask cpu_mask
;
81 struct fadump_memory_range
{
86 /* fadump memory ranges info */
87 #define RNG_NAME_SZ 16
88 struct fadump_mrange_info
{
89 char name
[RNG_NAME_SZ
];
90 struct fadump_memory_range
*mem_ranges
;
97 /* Platform specific callback functions */
100 /* Firmware-assisted dump configuration details. */
102 unsigned long reserve_dump_area_start
;
103 unsigned long reserve_dump_area_size
;
104 /* cmd line option during boot */
105 unsigned long reserve_bootvar
;
107 unsigned long cpu_state_data_size
;
108 u64 cpu_state_dest_vaddr
;
109 u32 cpu_state_data_version
;
110 u32 cpu_state_entry_size
;
112 unsigned long hpte_region_size
;
114 unsigned long boot_memory_size
;
115 u64 boot_mem_dest_addr
;
116 u64 boot_mem_addr
[FADUMP_MAX_MEM_REGS
];
117 u64 boot_mem_sz
[FADUMP_MAX_MEM_REGS
];
119 u64 boot_mem_regs_cnt
;
121 unsigned long fadumphdr_addr
;
124 unsigned long cpu_notes_buf_vaddr
;
125 unsigned long cpu_notes_buf_size
;
127 unsigned long param_area
;
130 * Maximum size supported by firmware to copy from source to
131 * destination address per entry.
136 int ibm_configure_kernel_dump
;
138 unsigned long fadump_enabled
:1;
139 unsigned long fadump_supported
:1;
140 unsigned long dump_active
:1;
141 unsigned long dump_registered
:1;
142 unsigned long nocma
:1;
143 unsigned long param_area_supported
:1;
145 struct fadump_ops
*ops
;
149 u64 (*fadump_init_mem_struct
)(struct fw_dump
*fadump_conf
);
150 u64 (*fadump_get_metadata_size
)(void);
151 int (*fadump_setup_metadata
)(struct fw_dump
*fadump_conf
);
152 u64 (*fadump_get_bootmem_min
)(void);
153 int (*fadump_register
)(struct fw_dump
*fadump_conf
);
154 int (*fadump_unregister
)(struct fw_dump
*fadump_conf
);
155 int (*fadump_invalidate
)(struct fw_dump
*fadump_conf
);
156 void (*fadump_cleanup
)(struct fw_dump
*fadump_conf
);
157 int (*fadump_process
)(struct fw_dump
*fadump_conf
);
158 void (*fadump_region_show
)(struct fw_dump
*fadump_conf
,
160 void (*fadump_trigger
)(struct fadump_crash_info_header
*fdh
,
162 int (*fadump_max_boot_mem_rgns
)(void);
165 /* Helper functions */
166 s32 __init
fadump_setup_cpu_notes_buf(u32 num_cpus
);
167 void fadump_free_cpu_notes_buf(void);
168 u32
*__init
fadump_regs_to_elf_notes(u32
*buf
, struct pt_regs
*regs
);
169 void __init
fadump_update_elfcore_header(char *bufp
);
170 bool is_fadump_reserved_mem_contiguous(void);
172 #else /* !CONFIG_PRESERVE_FA_DUMP */
174 /* Firmware-assisted dump configuration details. */
180 #endif /* CONFIG_PRESERVE_FA_DUMP */
182 #ifdef CONFIG_PPC_PSERIES
183 extern void rtas_fadump_dt_scan(struct fw_dump
*fadump_conf
, u64 node
);
186 rtas_fadump_dt_scan(struct fw_dump
*fadump_conf
, u64 node
) { }
189 #ifdef CONFIG_PPC_POWERNV
190 extern void opal_fadump_dt_scan(struct fw_dump
*fadump_conf
, u64 node
);
193 opal_fadump_dt_scan(struct fw_dump
*fadump_conf
, u64 node
) { }
196 #endif /* _ASM_POWERPC_FADUMP_INTERNAL_H */