powerpc/mm/hash64: Map all the kernel regions in the same 0xc range
[linux-2.6-block.git] / arch / powerpc / include / asm / fadump.h
CommitLineData
eb39c880
MS
1/*
2 * Firmware Assisted dump header file.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright 2011 IBM Corporation
19 * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
20 */
21
22#ifndef __PPC64_FA_DUMP_H__
23#define __PPC64_FA_DUMP_H__
24
25#ifdef CONFIG_FA_DUMP
26
27/*
28 * The RMA region will be saved for later dumping when kernel crashes.
29 * RMA is Real Mode Area, the first block of logical memory address owned
30 * by logical partition, containing the storage that may be accessed with
31 * translate off.
32 */
33#define RMA_START 0x0
34#define RMA_END (ppc64_rma_size)
35
36/*
37 * On some Power systems where RMO is 128MB, it still requires minimum of
38 * 256MB for kernel to boot successfully. When kdump infrastructure is
39 * configured to save vmcore over network, we run into OOM issue while
40 * loading modules related to network setup. Hence we need aditional 64M
41 * of memory to avoid OOM issue.
42 */
43#define MIN_BOOT_MEM (((RMA_END < (0x1UL << 28)) ? (0x1UL << 28) : RMA_END) \
44 + (0x1UL << 26))
45
48a316e3
HB
46/* The upper limit percentage for user specified boot memory size (25%) */
47#define MAX_BOOT_MEM_RATIO 4
48
2df173d9
MS
49#define memblock_num_regions(memblock_type) (memblock.memblock_type.cnt)
50
a4e92ce8
MS
51/* Alignement per CMA requirement. */
52#define FADUMP_CMA_ALIGNMENT (PAGE_SIZE << \
53 max_t(unsigned long, MAX_ORDER - 1, pageblock_order))
54
eb39c880
MS
55/* Firmware provided dump sections */
56#define FADUMP_CPU_STATE_DATA 0x0001
57#define FADUMP_HPTE_REGION 0x0002
58#define FADUMP_REAL_MODE_REGION 0x0011
59
3ccc00a7
MS
60/* Dump request flag */
61#define FADUMP_REQUEST_FLAG 0x00000001
62
63/* FAD commands */
64#define FADUMP_REGISTER 1
65#define FADUMP_UNREGISTER 2
66#define FADUMP_INVALIDATE 3
67
2df173d9
MS
68/* Dump status flag */
69#define FADUMP_ERROR_FLAG 0x2000
70
ebaeb5ae
MS
71#define FADUMP_CPU_ID_MASK ((1UL << 32) - 1)
72
73#define CPU_UNKNOWN (~((u32)0))
74
75/* Utility macros */
408cddd9
HB
76#define SKIP_TO_NEXT_CPU(reg_entry) \
77({ \
78 while (be64_to_cpu(reg_entry->reg_id) != REG_ID("CPUEND")) \
79 reg_entry++; \
80 reg_entry++; \
ebaeb5ae
MS
81})
82
22bd0177
HB
83extern int crashing_cpu;
84
3ccc00a7
MS
85/* Kernel Dump section info */
86struct fadump_section {
408cddd9
HB
87 __be32 request_flag;
88 __be16 source_data_type;
89 __be16 error_flags;
90 __be64 source_address;
91 __be64 source_len;
92 __be64 bytes_dumped;
93 __be64 destination_address;
3ccc00a7
MS
94};
95
96/* ibm,configure-kernel-dump header. */
97struct fadump_section_header {
408cddd9
HB
98 __be32 dump_format_version;
99 __be16 dump_num_sections;
100 __be16 dump_status_flag;
101 __be32 offset_first_dump_section;
3ccc00a7
MS
102
103 /* Fields for disk dump option. */
408cddd9
HB
104 __be32 dd_block_size;
105 __be64 dd_block_offset;
106 __be64 dd_num_blocks;
107 __be32 dd_offset_disk_path;
3ccc00a7
MS
108
109 /* Maximum time allowed to prevent an automatic dump-reboot. */
408cddd9 110 __be32 max_time_auto;
3ccc00a7
MS
111};
112
113/*
114 * Firmware Assisted dump memory structure. This structure is required for
115 * registering future kernel dump with power firmware through rtas call.
116 *
117 * No disk dump option. Hence disk dump path string section is not included.
118 */
119struct fadump_mem_struct {
120 struct fadump_section_header header;
121
122 /* Kernel dump sections */
123 struct fadump_section cpu_state_data;
124 struct fadump_section hpte_region;
125 struct fadump_section rmr_region;
126};
127
128/* Firmware-assisted dump configuration details. */
eb39c880
MS
129struct fw_dump {
130 unsigned long cpu_state_data_size;
131 unsigned long hpte_region_size;
132 unsigned long boot_memory_size;
133 unsigned long reserve_dump_area_start;
134 unsigned long reserve_dump_area_size;
135 /* cmd line option during boot */
136 unsigned long reserve_bootvar;
137
2df173d9 138 unsigned long fadumphdr_addr;
ebaeb5ae
MS
139 unsigned long cpu_notes_buf;
140 unsigned long cpu_notes_buf_size;
141
eb39c880
MS
142 int ibm_configure_kernel_dump;
143
144 unsigned long fadump_enabled:1;
145 unsigned long fadump_supported:1;
146 unsigned long dump_active:1;
3ccc00a7 147 unsigned long dump_registered:1;
a4e92ce8 148 unsigned long nocma:1;
eb39c880
MS
149};
150
2df173d9
MS
151/*
152 * Copy the ascii values for first 8 characters from a string into u64
153 * variable at their respective indexes.
154 * e.g.
155 * The string "FADMPINF" will be converted into 0x4641444d50494e46
156 */
157static inline u64 str_to_u64(const char *str)
158{
159 u64 val = 0;
160 int i;
161
162 for (i = 0; i < sizeof(val); i++)
163 val = (*str) ? (val << 8) | *str++ : val << 8;
164 return val;
165}
166#define STR_TO_HEX(x) str_to_u64(x)
ebaeb5ae 167#define REG_ID(x) str_to_u64(x)
2df173d9
MS
168
169#define FADUMP_CRASH_INFO_MAGIC STR_TO_HEX("FADMPINF")
ebaeb5ae
MS
170#define REGSAVE_AREA_MAGIC STR_TO_HEX("REGSAVE")
171
172/* The firmware-assisted dump format.
173 *
174 * The register save area is an area in the partition's memory used to preserve
175 * the register contents (CPU state data) for the active CPUs during a firmware
176 * assisted dump. The dump format contains register save area header followed
177 * by register entries. Each list of registers for a CPU starts with
178 * "CPUSTRT" and ends with "CPUEND".
179 */
180
181/* Register save area header. */
182struct fadump_reg_save_area_header {
408cddd9
HB
183 __be64 magic_number;
184 __be32 version;
185 __be32 num_cpu_offset;
ebaeb5ae
MS
186};
187
188/* Register entry. */
189struct fadump_reg_entry {
408cddd9
HB
190 __be64 reg_id;
191 __be64 reg_value;
ebaeb5ae 192};
2df173d9
MS
193
194/* fadump crash info structure */
195struct fadump_crash_info_header {
196 u64 magic_number;
197 u64 elfcorehdr_addr;
ebaeb5ae
MS
198 u32 crashing_cpu;
199 struct pt_regs regs;
a0512164 200 struct cpumask online_mask;
2df173d9
MS
201};
202
2df173d9
MS
203struct fad_crash_memory_ranges {
204 unsigned long long base;
205 unsigned long long size;
206};
207
0db6896f 208extern int is_fadump_memory_area(u64 addr, ulong size);
eb39c880
MS
209extern int early_init_dt_scan_fw_dump(unsigned long node,
210 const char *uname, int depth, void *data);
211extern int fadump_reserve_mem(void);
3ccc00a7
MS
212extern int setup_fadump(void);
213extern int is_fadump_active(void);
6fcd6baa 214extern int should_fadump_crash(void);
ebaeb5ae 215extern void crash_fadump(struct pt_regs *, const char *);
b500afff
MS
216extern void fadump_cleanup(void);
217
3ccc00a7
MS
218#else /* CONFIG_FA_DUMP */
219static inline int is_fadump_active(void) { return 0; }
6fcd6baa 220static inline int should_fadump_crash(void) { return 0; }
ebaeb5ae 221static inline void crash_fadump(struct pt_regs *regs, const char *str) { }
eb39c880
MS
222#endif
223#endif