xref: /linux/arch/powerpc/platforms/pseries/rtas-fadump.h (revision ff2632d7d08edc11e8bd0629e9fcfebab25c78b4)
10226e552SHari Bathini /* SPDX-License-Identifier: GPL-2.0-or-later */
20226e552SHari Bathini /*
30226e552SHari Bathini  * Firmware-Assisted Dump support on POWERVM platform.
40226e552SHari Bathini  *
50226e552SHari Bathini  * Copyright 2011, Mahesh Salgaonkar, IBM Corporation.
60226e552SHari Bathini  * Copyright 2019, Hari Bathini, IBM Corporation.
70226e552SHari Bathini  */
80226e552SHari Bathini 
90226e552SHari Bathini #ifndef _PSERIES_RTAS_FADUMP_H
100226e552SHari Bathini #define _PSERIES_RTAS_FADUMP_H
110226e552SHari Bathini 
127b1b3b48SHari Bathini /*
137b1b3b48SHari Bathini  * On some Power systems where RMO is 128MB, it still requires minimum of
147b1b3b48SHari Bathini  * 256MB for kernel to boot successfully. When kdump infrastructure is
157b1b3b48SHari Bathini  * configured to save vmcore over network, we run into OOM issue while
167b1b3b48SHari Bathini  * loading modules related to network setup. Hence we need additional 64M
177b1b3b48SHari Bathini  * of memory to avoid OOM issue.
187b1b3b48SHari Bathini  */
197b1b3b48SHari Bathini #define RTAS_FADUMP_MIN_BOOT_MEM	((0x1UL << 28) + (0x1UL << 26))
207b1b3b48SHari Bathini 
210226e552SHari Bathini /* Firmware provided dump sections */
220226e552SHari Bathini #define RTAS_FADUMP_CPU_STATE_DATA	0x0001
230226e552SHari Bathini #define RTAS_FADUMP_HPTE_REGION		0x0002
240226e552SHari Bathini #define RTAS_FADUMP_REAL_MODE_REGION	0x0011
250226e552SHari Bathini 
26*683eab94SHari Bathini /* OS defined sections */
27*683eab94SHari Bathini #define RTAS_FADUMP_PARAM_AREA		0x0100
28*683eab94SHari Bathini 
290226e552SHari Bathini /* Dump request flag */
300226e552SHari Bathini #define RTAS_FADUMP_REQUEST_FLAG	0x00000001
310226e552SHari Bathini 
320226e552SHari Bathini /* Dump status flag */
330226e552SHari Bathini #define RTAS_FADUMP_ERROR_FLAG		0x2000
340226e552SHari Bathini 
3578d5cc15SHari Bathini /*
3678d5cc15SHari Bathini  * The Firmware Assisted Dump Memory structure supports a maximum of 10 sections
37*683eab94SHari Bathini  * in the dump memory structure. Presently, three sections are used for
38*683eab94SHari Bathini  * CPU state data, HPTE & Parameters area, while the remaining seven sections
39*683eab94SHari Bathini  * can be used for boot memory regions.
4078d5cc15SHari Bathini  */
4178d5cc15SHari Bathini #define MAX_SECTIONS				10
42*683eab94SHari Bathini #define RTAS_FADUMP_MAX_BOOT_MEM_REGS		7
4378d5cc15SHari Bathini 
440226e552SHari Bathini /* Kernel Dump section info */
450226e552SHari Bathini struct rtas_fadump_section {
460226e552SHari Bathini 	__be32	request_flag;
470226e552SHari Bathini 	__be16	source_data_type;
480226e552SHari Bathini 	__be16	error_flags;
490226e552SHari Bathini 	__be64	source_address;
500226e552SHari Bathini 	__be64	source_len;
510226e552SHari Bathini 	__be64	bytes_dumped;
520226e552SHari Bathini 	__be64	destination_address;
530226e552SHari Bathini };
540226e552SHari Bathini 
550226e552SHari Bathini /* ibm,configure-kernel-dump header. */
560226e552SHari Bathini struct rtas_fadump_section_header {
570226e552SHari Bathini 	__be32	dump_format_version;
580226e552SHari Bathini 	__be16	dump_num_sections;
590226e552SHari Bathini 	__be16	dump_status_flag;
600226e552SHari Bathini 	__be32	offset_first_dump_section;
610226e552SHari Bathini 
620226e552SHari Bathini 	/* Fields for disk dump option. */
630226e552SHari Bathini 	__be32	dd_block_size;
640226e552SHari Bathini 	__be64	dd_block_offset;
650226e552SHari Bathini 	__be64	dd_num_blocks;
660226e552SHari Bathini 	__be32	dd_offset_disk_path;
670226e552SHari Bathini 
680226e552SHari Bathini 	/* Maximum time allowed to prevent an automatic dump-reboot. */
690226e552SHari Bathini 	__be32	max_time_auto;
700226e552SHari Bathini };
710226e552SHari Bathini 
720226e552SHari Bathini /*
730226e552SHari Bathini  * Firmware Assisted dump memory structure. This structure is required for
740226e552SHari Bathini  * registering future kernel dump with power firmware through rtas call.
750226e552SHari Bathini  *
7678d5cc15SHari Bathini  * In version 1, the platform permits one section header, dump-disk path
7778d5cc15SHari Bathini  * and ten sections.
7878d5cc15SHari Bathini  *
7978d5cc15SHari Bathini  * Note: No disk dump option. Hence disk dump path string section is not
8078d5cc15SHari Bathini  * included.
810226e552SHari Bathini  */
820226e552SHari Bathini struct rtas_fadump_mem_struct {
830226e552SHari Bathini 	struct rtas_fadump_section_header	header;
8478d5cc15SHari Bathini 	struct rtas_fadump_section		rgn[MAX_SECTIONS];
850226e552SHari Bathini };
860226e552SHari Bathini 
870226e552SHari Bathini /*
880226e552SHari Bathini  * The firmware-assisted dump format.
890226e552SHari Bathini  *
900226e552SHari Bathini  * The register save area is an area in the partition's memory used to preserve
910226e552SHari Bathini  * the register contents (CPU state data) for the active CPUs during a firmware
920226e552SHari Bathini  * assisted dump. The dump format contains register save area header followed
930226e552SHari Bathini  * by register entries. Each list of registers for a CPU starts with "CPUSTRT"
940226e552SHari Bathini  * and ends with "CPUEND".
950226e552SHari Bathini  */
960226e552SHari Bathini 
970226e552SHari Bathini /* Register save area header. */
980226e552SHari Bathini struct rtas_fadump_reg_save_area_header {
990226e552SHari Bathini 	__be64		magic_number;
1000226e552SHari Bathini 	__be32		version;
1010226e552SHari Bathini 	__be32		num_cpu_offset;
1020226e552SHari Bathini };
1030226e552SHari Bathini 
1040226e552SHari Bathini /* Register entry. */
1050226e552SHari Bathini struct rtas_fadump_reg_entry {
1060226e552SHari Bathini 	__be64		reg_id;
1070226e552SHari Bathini 	__be64		reg_value;
1080226e552SHari Bathini };
1090226e552SHari Bathini 
1100226e552SHari Bathini /* Utility macros */
1110226e552SHari Bathini #define RTAS_FADUMP_SKIP_TO_NEXT_CPU(reg_entry)				\
1120226e552SHari Bathini ({									\
1130226e552SHari Bathini 	while (be64_to_cpu(reg_entry->reg_id) !=			\
1140226e552SHari Bathini 	       fadump_str_to_u64("CPUEND"))				\
1150226e552SHari Bathini 		reg_entry++;						\
1160226e552SHari Bathini 	reg_entry++;							\
1170226e552SHari Bathini })
1180226e552SHari Bathini 
1190226e552SHari Bathini #define RTAS_FADUMP_CPU_ID_MASK			((1UL << 32) - 1)
1200226e552SHari Bathini 
1210226e552SHari Bathini #endif /* _PSERIES_RTAS_FADUMP_H */
122