master
h 123 lines 3.71 KB
Raw
1 /*
2 * Firmware Assisted Dump in PSeries
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef PPC_SPAPR_FADUMP_H
7 #define PPC_SPAPR_FADUMP_H
8
9 #include "target/ppc/cpu.h"
10
11 /* Fadump commands */
12 #define FADUMP_CMD_REGISTER 1
13 #define FADUMP_CMD_UNREGISTER 2
14 #define FADUMP_CMD_INVALIDATE 3
15
16 #define FADUMP_VERSION 1
17
18 /* Firmware provided dump sections */
19 #define FADUMP_CPU_STATE_DATA 0x0001
20 #define FADUMP_HPTE_REGION 0x0002
21 #define FADUMP_REAL_MODE_REGION 0x0011
22
23 /* OS defined sections */
24 #define FADUMP_PARAM_AREA 0x0100
25
26 /* Dump request flag */
27 #define FADUMP_REQUEST_FLAG 0x00000001
28
29 /* Dump status flags */
30 #define FADUMP_STATUS_DUMP_PERFORMED 0x8000
31 #define FADUMP_STATUS_DUMP_TRIGGERED 0x4000
32 #define FADUMP_STATUS_DUMP_ERROR 0x2000
33
34 /* Region dump error flags */
35 #define FADUMP_ERROR_INVALID_DATA_TYPE 0x8000
36 #define FADUMP_ERROR_INVALID_SOURCE_ADDR 0x4000
37 #define FADUMP_ERROR_LENGTH_EXCEEDS_SOURCE 0x2000
38 #define FADUMP_ERROR_INVALID_DEST_ADDR 0x1000
39 #define FAUDMP_ERROR_DEST_TOO_SMALL 0x0800
40
41 /*
42 * The Firmware Assisted Dump Memory structure supports a maximum of 10 sections
43 * in the dump memory structure. Presently, three sections are used for
44 * CPU state data, HPTE & Parameters area, while the remaining seven sections
45 * can be used for boot memory regions.
46 */
47 #define FADUMP_MAX_SECTIONS 10
48
49 /* Number of register entries stored per cpu */
50 #define FADUMP_PER_CPU_REG_ENTRIES (32 /*GPR*/ + 45 /*others*/ + 2 /*STRT & END*/)
51
52 /* Mask of CPU ID in CPUSTRT and CPUEND entries */
53 #define FADUMP_CPU_ID_MASK ((1ULL << 32) - 1)
54
55 typedef struct FadumpSection FadumpSection;
56 typedef struct FadumpSectionHeader FadumpSectionHeader;
57 typedef struct FadumpMemStruct FadumpMemStruct;
58 typedef struct FadumpRegSaveAreaHeader FadumpRegSaveAreaHeader;
59 typedef struct FadumpRegEntry FadumpRegEntry;
60
61 struct SpaprMachineState;
62
63 /* Kernel Dump section info */
64 /* All fields are in big-endian */
65 struct FadumpSection {
66 uint32_t request_flag;
67 uint16_t source_data_type;
68 uint16_t error_flags;
69 uint64_t source_address;
70 uint64_t source_len;
71 uint64_t bytes_dumped;
72 uint64_t destination_address;
73 };
74
75 /* ibm,configure-kernel-dump header. */
76 struct FadumpSectionHeader {
77 uint32_t dump_format_version;
78 uint16_t dump_num_sections;
79 uint16_t dump_status_flag;
80 uint32_t offset_first_dump_section;
81
82 /* Fields for disk dump option. */
83 uint32_t dd_block_size;
84 uint64_t dd_block_offset;
85 uint64_t dd_num_blocks;
86 uint32_t dd_offset_disk_path;
87
88 /* Maximum time allowed to prevent an automatic dump-reboot. */
89 uint32_t max_time_auto;
90 };
91
92 /* Note: All the data in these structures is in big-endian */
93 struct FadumpMemStruct {
94 FadumpSectionHeader header;
95 FadumpSection rgn[FADUMP_MAX_SECTIONS];
96 };
97
98 /*
99 * The firmware-assisted dump format.
100 *
101 * The register save area is an area in the partition's memory used to preserve
102 * the register contents (CPU state data) for the active CPUs during a firmware
103 * assisted dump. The dump format contains register save area header followed
104 * by register entries. Each list of registers for a CPU starts with "CPUSTRT"
105 * and ends with "CPUEND".
106 */
107
108 /* Register save area header. */
109 struct FadumpRegSaveAreaHeader {
110 uint64_t magic_number;
111 uint32_t version;
112 uint32_t num_cpu_offset;
113 };
114
115 /* Register entry. */
116 struct FadumpRegEntry {
117 uint64_t reg_id;
118 uint64_t reg_value;
119 };
120
121 uint32_t do_fadump_register(struct SpaprMachineState *, target_ulong);
122 void trigger_fadump_boot(struct SpaprMachineState *, target_ulong);
123 #endif /* PPC_SPAPR_FADUMP_H */