xref: /openbmc/linux/arch/powerpc/platforms/pseries/rtas-fadump.h (revision 976e3645923bdd2fe7893aae33fd7a21098bfb28)
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 
260226e552SHari Bathini /* Dump request flag */
270226e552SHari Bathini #define RTAS_FADUMP_REQUEST_FLAG	0x00000001
280226e552SHari Bathini 
290226e552SHari Bathini /* Dump status flag */
300226e552SHari Bathini #define RTAS_FADUMP_ERROR_FLAG		0x2000
310226e552SHari Bathini 
320226e552SHari Bathini /* Kernel Dump section info */
330226e552SHari Bathini struct rtas_fadump_section {
340226e552SHari Bathini 	__be32	request_flag;
350226e552SHari Bathini 	__be16	source_data_type;
360226e552SHari Bathini 	__be16	error_flags;
370226e552SHari Bathini 	__be64	source_address;
380226e552SHari Bathini 	__be64	source_len;
390226e552SHari Bathini 	__be64	bytes_dumped;
400226e552SHari Bathini 	__be64	destination_address;
410226e552SHari Bathini };
420226e552SHari Bathini 
430226e552SHari Bathini /* ibm,configure-kernel-dump header. */
440226e552SHari Bathini struct rtas_fadump_section_header {
450226e552SHari Bathini 	__be32	dump_format_version;
460226e552SHari Bathini 	__be16	dump_num_sections;
470226e552SHari Bathini 	__be16	dump_status_flag;
480226e552SHari Bathini 	__be32	offset_first_dump_section;
490226e552SHari Bathini 
500226e552SHari Bathini 	/* Fields for disk dump option. */
510226e552SHari Bathini 	__be32	dd_block_size;
520226e552SHari Bathini 	__be64	dd_block_offset;
530226e552SHari Bathini 	__be64	dd_num_blocks;
540226e552SHari Bathini 	__be32	dd_offset_disk_path;
550226e552SHari Bathini 
560226e552SHari Bathini 	/* Maximum time allowed to prevent an automatic dump-reboot. */
570226e552SHari Bathini 	__be32	max_time_auto;
580226e552SHari Bathini };
590226e552SHari Bathini 
600226e552SHari Bathini /*
610226e552SHari Bathini  * Firmware Assisted dump memory structure. This structure is required for
620226e552SHari Bathini  * registering future kernel dump with power firmware through rtas call.
630226e552SHari Bathini  *
640226e552SHari Bathini  * No disk dump option. Hence disk dump path string section is not included.
650226e552SHari Bathini  */
660226e552SHari Bathini struct rtas_fadump_mem_struct {
670226e552SHari Bathini 	struct rtas_fadump_section_header	header;
680226e552SHari Bathini 
690226e552SHari Bathini 	/* Kernel dump sections */
700226e552SHari Bathini 	struct rtas_fadump_section		cpu_state_data;
710226e552SHari Bathini 	struct rtas_fadump_section		hpte_region;
72*7dee93a9SHari Bathini 
73*7dee93a9SHari Bathini 	/*
74*7dee93a9SHari Bathini 	 * TODO: Extend multiple boot memory regions support in the kernel
75*7dee93a9SHari Bathini 	 *       for this platform.
76*7dee93a9SHari Bathini 	 */
770226e552SHari Bathini 	struct rtas_fadump_section		rmr_region;
780226e552SHari Bathini };
790226e552SHari Bathini 
800226e552SHari Bathini /*
810226e552SHari Bathini  * The firmware-assisted dump format.
820226e552SHari Bathini  *
830226e552SHari Bathini  * The register save area is an area in the partition's memory used to preserve
840226e552SHari Bathini  * the register contents (CPU state data) for the active CPUs during a firmware
850226e552SHari Bathini  * assisted dump. The dump format contains register save area header followed
860226e552SHari Bathini  * by register entries. Each list of registers for a CPU starts with "CPUSTRT"
870226e552SHari Bathini  * and ends with "CPUEND".
880226e552SHari Bathini  */
890226e552SHari Bathini 
900226e552SHari Bathini /* Register save area header. */
910226e552SHari Bathini struct rtas_fadump_reg_save_area_header {
920226e552SHari Bathini 	__be64		magic_number;
930226e552SHari Bathini 	__be32		version;
940226e552SHari Bathini 	__be32		num_cpu_offset;
950226e552SHari Bathini };
960226e552SHari Bathini 
970226e552SHari Bathini /* Register entry. */
980226e552SHari Bathini struct rtas_fadump_reg_entry {
990226e552SHari Bathini 	__be64		reg_id;
1000226e552SHari Bathini 	__be64		reg_value;
1010226e552SHari Bathini };
1020226e552SHari Bathini 
1030226e552SHari Bathini /* Utility macros */
1040226e552SHari Bathini #define RTAS_FADUMP_SKIP_TO_NEXT_CPU(reg_entry)				\
1050226e552SHari Bathini ({									\
1060226e552SHari Bathini 	while (be64_to_cpu(reg_entry->reg_id) !=			\
1070226e552SHari Bathini 	       fadump_str_to_u64("CPUEND"))				\
1080226e552SHari Bathini 		reg_entry++;						\
1090226e552SHari Bathini 	reg_entry++;							\
1100226e552SHari Bathini })
1110226e552SHari Bathini 
1120226e552SHari Bathini #define RTAS_FADUMP_CPU_ID_MASK			((1UL << 32) - 1)
1130226e552SHari Bathini 
1140226e552SHari Bathini #endif /* _PSERIES_RTAS_FADUMP_H */
115