[RAMEN9610-14440] UPSTREAM: kasan: add tests for alloca poisoning
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / lib / debug-snapshot-log.h
1
2 #ifndef DEBUG_SNAPSHOT_LOG_H
3 #define DEBUG_SNAPSHOT_LOG_H
4
5 #include <generated/autoconf.h>
6
7 #ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
8 #include <linux/debug-snapshot-binder.h>
9 #endif
10
11 #ifdef DSS_ANALYZER
12
13 #define TASK_COMM_LEN 16
14 #define NR_CPUS 8
15 #undef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #else // DSS_ANALYZER
20
21 #include <linux/clk-provider.h>
22 #include <linux/debug-snapshot.h>
23 #include <linux/debug-snapshot-helper.h>
24
25 #endif // DSS_ANALYZER
26
27 #include <dt-bindings/soc/samsung/debug-snapshot-table.h>
28
29 /* Size domain */
30 #define DSS_KEEP_HEADER_SZ (SZ_256 * 3)
31 #define DSS_HEADER_SZ SZ_4K
32 #define DSS_MMU_REG_SZ SZ_4K
33 #define DSS_CORE_REG_SZ SZ_4K
34 #define DSS_DBGC_LOG_SZ SZ_4K
35 #define DSS_HEADER_TOTAL_SZ (DSS_HEADER_SZ + DSS_MMU_REG_SZ + DSS_CORE_REG_SZ + DSS_DBGC_LOG_SZ)
36 #define DSS_SPARE_SZ (DSS_HEADER_SIZE - DSS_HEADER_TOTAL_SZ)
37
38 /* Length domain */
39 #define DSS_LOG_STRING_LENGTH SZ_128
40 #define DSS_MMU_REG_OFFSET SZ_512
41 #define DSS_CORE_REG_OFFSET SZ_512
42 #define DSS_LOG_MAX_NUM SZ_1K
43 #define DSS_API_MAX_NUM SZ_2K
44 #define DSS_EX_MAX_NUM SZ_8
45 #define DSS_IN_MAX_NUM SZ_8
46 #define DSS_CALLSTACK_MAX_NUM 4
47 #define DSS_ITERATION 5
48 #define DSS_NR_CPUS NR_CPUS
49 #define DSS_ITEM_MAX_NUM 10
50
51 /* Sign domain */
52 #define DSS_SIGN_RESET 0x0
53 #define DSS_SIGN_RESERVED 0x1
54 #define DSS_SIGN_SCRATCH 0xD
55 #define DSS_SIGN_ALIVE 0xFACE
56 #define DSS_SIGN_DEAD 0xDEAD
57 #define DSS_SIGN_PANIC 0xBABA
58 #define DSS_SIGN_SAFE_FAULT 0xFAFA
59 #define DSS_SIGN_NORMAL_REBOOT 0xCAFE
60 #define DSS_SIGN_FORCE_REBOOT 0xDAFE
61 #define DSS_SIGN_LOCKUP 0xDEADBEEF
62
63 /* Specific Address Information */
64 #define DSS_FIXED_VIRT_BASE (VMALLOC_START + 0xEE000000)
65 #define DSS_OFFSET_SCRATCH (0x100)
66 #define DSS_OFFSET_DEBUG_LEVEL (0x180)
67 #define DSS_OFFSET_LAST_LOGBUF (0x200)
68 #define DSS_OFFSET_EMERGENCY_REASON (0x300)
69 #define DSS_OFFSET_CORE_POWER_STAT (0x400)
70 #define DSS_OFFSET_PANIC_STAT (0x500)
71 #define DSS_OFFSET_CORE_LAST_PC (0x600)
72
73 /* S5P_VA_SS_BASE + 0xC00 -- 0xFFF is reserved */
74 #define DSS_OFFSET_PANIC_STRING (0xC00)
75 #define DSS_OFFSET_SPARE_BASE (DSS_HEADER_TOTAL_SZ)
76
77 struct dbg_snapshot_log {
78 struct __task_log {
79 unsigned long long time;
80 unsigned long sp;
81 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
82 struct task_struct *task;
83 #else
84 void *task;
85 #endif
86 char task_comm[TASK_COMM_LEN];
87 int pid;
88 } task[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
89
90 struct __work_log {
91 unsigned long long time;
92 unsigned long sp;
93 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
94 struct worker *worker;
95 work_func_t fn;
96 #else
97 void *worker;
98 void *fn;
99 #endif
100 char task_comm[TASK_COMM_LEN];
101 int en;
102 } work[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
103
104 struct __cpuidle_log {
105 unsigned long long time;
106 unsigned long sp;
107 char *modes;
108 unsigned int state;
109 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
110 u32 num_online_cpus;
111 #else
112 unsigned int num_online_cpus;
113 #endif
114 int delta;
115 int en;
116 } cpuidle[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
117
118 struct __suspend_log {
119 unsigned long long time;
120 unsigned long sp;
121 void *fn;
122 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
123 struct device *dev;
124 #else
125 void *dev;
126 #endif
127 int en;
128 int core;
129 } suspend[DSS_LOG_MAX_NUM * 4];
130
131 struct __irq_log {
132 unsigned long long time;
133 unsigned long sp;
134 int irq;
135 void *fn;
136 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
137 struct irqaction *action;
138 #else
139 void *action;
140 #endif
141 int en;
142 } irq[DSS_NR_CPUS][DSS_LOG_MAX_NUM * 2];
143
144 #ifdef CONFIG_DEBUG_SNAPSHOT_IRQ_EXIT
145 struct __irq_exit_log {
146 unsigned long long time;
147 unsigned long sp;
148 unsigned long long end_time;
149 unsigned long long latency;
150 int irq;
151 } irq_exit[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
152 #endif
153 #ifdef CONFIG_DEBUG_SNAPSHOT_SPINLOCK
154 struct __spinlock_log {
155 unsigned long long time;
156 unsigned long sp;
157 unsigned long long jiffies;
158 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
159 raw_spinlock_t *lock;
160 #ifdef CONFIG_DEBUG_SPINLOCK
161 u16 next;
162 u16 owner;
163 #endif
164 #else
165 void *lock;
166 #ifdef CONFIG_DEBUG_SPINLOCK
167 unsigned short next;
168 unsigned short owner;
169 #endif
170 #endif
171 int en;
172 void *caller[DSS_CALLSTACK_MAX_NUM];
173 } spinlock[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
174 #endif
175 #ifdef CONFIG_DEBUG_SNAPSHOT_IRQ_DISABLED
176 struct __irqs_disabled_log {
177 unsigned long long time;
178 unsigned long index;
179 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
180 struct task_struct *task;
181 #else
182 void *task;
183 #endif
184 char *task_comm;
185 void *caller[DSS_CALLSTACK_MAX_NUM];
186 } irqs_disabled[DSS_NR_CPUS][SZ_32];
187 #endif
188 #ifdef CONFIG_DEBUG_SNAPSHOT_CLK
189 struct __clk_log {
190 unsigned long long time;
191 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
192 struct clk_hw *clk;
193 #else
194 void *clk;
195 #endif
196 const char *f_name;
197 int mode;
198 unsigned long arg;
199 } clk[DSS_LOG_MAX_NUM];
200 #endif
201 #ifdef CONFIG_DEBUG_SNAPSHOT_PMU
202 struct __pmu_log {
203 unsigned long long time;
204 unsigned int id;
205 const char *f_name;
206 int mode;
207 } pmu[DSS_LOG_MAX_NUM];
208 #endif
209 #ifdef CONFIG_DEBUG_SNAPSHOT_FREQ
210 struct __freq_log {
211 unsigned long long time;
212 int cpu;
213 int type;
214 char *freq_name;
215 unsigned long old_freq;
216 unsigned long target_freq;
217 int en;
218 } freq[DSS_LOG_MAX_NUM];
219 #endif
220 #ifdef CONFIG_DEBUG_SNAPSHOT_DM
221 struct __dm_log {
222 unsigned long long time;
223 int cpu;
224 int dm_num;
225 unsigned long min_freq;
226 unsigned long max_freq;
227 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
228 s32 wait_dmt;
229 s32 do_dmt;
230 #else
231 int wait_dmt;
232 int do_dmt;
233 #endif
234 } dm[DSS_LOG_MAX_NUM];
235 #endif
236 #ifdef CONFIG_DEBUG_SNAPSHOT_REG
237 struct __reg_log {
238 unsigned long long time;
239 int read;
240 size_t val;
241 size_t reg;
242 int en;
243 void *caller[DSS_CALLSTACK_MAX_NUM];
244 } reg[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
245 #endif
246 #ifdef CONFIG_DEBUG_SNAPSHOT_HRTIMER
247 struct __hrtimer_log {
248 unsigned long long time;
249 unsigned long long now;
250 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
251 struct hrtimer *timer;
252 #else
253 void *timer;
254 #endif
255 void *fn;
256 int en;
257 } hrtimers[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
258 #endif
259 #ifdef CONFIG_DEBUG_SNAPSHOT_REGULATOR
260 struct __regulator_log {
261 unsigned long long time;
262 unsigned long long acpm_time;
263 int cpu;
264 char name[SZ_16];
265 unsigned int reg;
266 unsigned int voltage;
267 unsigned int raw_volt;
268 int en;
269 } regulator[DSS_LOG_MAX_NUM];
270 #endif
271 #ifdef CONFIG_DEBUG_SNAPSHOT_THERMAL
272 struct __thermal_log {
273 unsigned long long time;
274 int cpu;
275 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
276 struct exynos_tmu_platform_data *data;
277 #else
278 void *data;
279 #endif
280 unsigned int temp;
281 char *cooling_device;
282 unsigned int cooling_state;
283 } thermal[DSS_LOG_MAX_NUM];
284 #endif
285 #ifdef CONFIG_DEBUG_SNAPSHOT_ACPM
286 struct __acpm_log {
287 unsigned long long time;
288 unsigned long long acpm_time;
289 char log[9];
290 unsigned int data;
291 } acpm[DSS_LOG_MAX_NUM];
292 #endif
293 #ifdef CONFIG_DEBUG_SNAPSHOT_I2C
294 struct __i2c_log {
295 unsigned long long time;
296 int cpu;
297 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
298 struct i2c_adapter *adap;
299 struct i2c_msg *msgs;
300 #else
301 void *adp;
302 void *msgs;
303 #endif
304 int num;
305 int en;
306 } i2c[DSS_LOG_MAX_NUM];
307 #endif
308 #ifdef CONFIG_DEBUG_SNAPSHOT_SPI
309 struct __spi_log {
310 unsigned long long time;
311 int cpu;
312 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
313 struct spi_controller *ctlr;
314 struct spi_message *cur_msg;
315 #else
316 void *ctlr;
317 void *cur_msg;
318 #endif
319 int en;
320 } spi[DSS_LOG_MAX_NUM];
321 #endif
322 #ifdef CONFIG_DEBUG_SNAPSHOT_BINDER
323 struct __binder_log {
324 unsigned long long time;
325 int cpu;
326 struct trace_binder_transaction_base base;
327 struct trace_binder_transaction transaction;
328 struct trace_binder_transaction_error error;
329 } binder[DSS_API_MAX_NUM << 2];
330 #endif
331
332 #ifndef CONFIG_DEBUG_SNAPSHOT_MINIMIZED_MODE
333 struct __clockevent_log {
334 unsigned long long time;
335 unsigned long long mct_cycle;
336 #ifdef CONFIG_DEBUG_SNAPSHOT_LINUX_BUILD
337 int64_t delta_ns;
338 ktime_t next_event;
339 #else
340 long long delta_ns;
341 long long next_event;
342 #endif
343 void *caller[DSS_CALLSTACK_MAX_NUM];
344 } clockevent[DSS_NR_CPUS][DSS_LOG_MAX_NUM];
345
346 struct __printkl_log {
347 unsigned long long time;
348 int cpu;
349 size_t msg;
350 size_t val;
351 void *caller[DSS_CALLSTACK_MAX_NUM];
352 } printkl[DSS_API_MAX_NUM];
353
354 struct __printk_log {
355 unsigned long long time;
356 int cpu;
357 char log[DSS_LOG_STRING_LENGTH];
358 void *caller[DSS_CALLSTACK_MAX_NUM];
359 } printk[DSS_API_MAX_NUM];
360 #endif
361 };
362
363 #endif