blob: 0168472b2fdfb66ed122e4ebaabf7a7a2d415efd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * arch/s390/kernel/debug.c
3 * S/390 debug facility
4 *
5 * Copyright (C) 1999, 2000 IBM Deutschland Entwicklung GmbH,
6 * IBM Corporation
7 * Author(s): Michael Holzheu (holzheu@de.ibm.com),
8 * Holger Smolinski (Holger.Smolinski@de.ibm.com)
9 *
10 * Bugreports to: <Linux390@de.ibm.com>
11 */
12
Michael Holzheuc5612c12008-12-25 13:39:43 +010013#define KMSG_COMPONENT "s390dbf"
14#define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <linux/stddef.h>
17#include <linux/kernel.h>
18#include <linux/errno.h>
19#include <linux/slab.h>
20#include <linux/ctype.h>
André Goddard Rosae7d28602009-12-14 18:01:06 -080021#include <linux/string.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/sysctl.h>
23#include <asm/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/module.h>
25#include <linux/init.h>
Michael Holzheu66a464d2005-06-25 14:55:33 -070026#include <linux/fs.h>
27#include <linux/debugfs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29#include <asm/debug.h>
30
31#define DEBUG_PROLOG_ENTRY -1
32
Michael Holzheu66a464d2005-06-25 14:55:33 -070033#define ALL_AREAS 0 /* copy all debug areas */
34#define NO_AREAS 1 /* copy no debug areas */
35
Linus Torvalds1da177e2005-04-16 15:20:36 -070036/* typedefs */
37
38typedef struct file_private_info {
39 loff_t offset; /* offset of last read in file */
40 int act_area; /* number of last formated area */
Michael Holzheu66a464d2005-06-25 14:55:33 -070041 int act_page; /* act page in given area */
Linus Torvalds1da177e2005-04-16 15:20:36 -070042 int act_entry; /* last formated entry (offset */
43 /* relative to beginning of last */
Michael Holzheu66a464d2005-06-25 14:55:33 -070044 /* formated page) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 size_t act_entry_offset; /* up to this offset we copied */
46 /* in last read the last formated */
47 /* entry to userland */
48 char temp_buf[2048]; /* buffer for output */
49 debug_info_t *debug_info_org; /* original debug information */
50 debug_info_t *debug_info_snap; /* snapshot of debug information */
51 struct debug_view *view; /* used view of debug info */
52} file_private_info_t;
53
54typedef struct
55{
56 char *string;
57 /*
58 * This assumes that all args are converted into longs
59 * on L/390 this is the case for all types of parameter
60 * except of floats, and long long (32 bit)
Michael Holzheu66a464d2005-06-25 14:55:33 -070061 *
62 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 long args[0];
64} debug_sprintf_entry_t;
65
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* internal function prototyes */
68
69static int debug_init(void);
70static ssize_t debug_output(struct file *file, char __user *user_buf,
Michael Holzheu66a464d2005-06-25 14:55:33 -070071 size_t user_len, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072static ssize_t debug_input(struct file *file, const char __user *user_buf,
Michael Holzheu66a464d2005-06-25 14:55:33 -070073 size_t user_len, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static int debug_open(struct inode *inode, struct file *file);
75static int debug_close(struct inode *inode, struct file *file);
Cornelia Huck5cbbf162008-05-15 16:52:35 +020076static debug_info_t *debug_info_create(const char *name, int pages_per_area,
Michael Holzheu9637c3f2008-04-17 07:46:18 +020077 int nr_areas, int buf_size, mode_t mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -070078static void debug_info_get(debug_info_t *);
79static void debug_info_put(debug_info_t *);
80static int debug_prolog_level_fn(debug_info_t * id,
Michael Holzheu66a464d2005-06-25 14:55:33 -070081 struct debug_view *view, char *out_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082static int debug_input_level_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070083 struct file *file, const char __user *user_buf,
84 size_t user_buf_size, loff_t * offset);
85static int debug_prolog_pages_fn(debug_info_t * id,
86 struct debug_view *view, char *out_buf);
87static int debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
88 struct file *file, const char __user *user_buf,
89 size_t user_buf_size, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090static int debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070091 struct file *file, const char __user *user_buf,
92 size_t user_buf_size, loff_t * offset);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093static int debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070094 char *out_buf, const char *in_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095static int debug_raw_format_fn(debug_info_t * id,
Michael Holzheu66a464d2005-06-25 14:55:33 -070096 struct debug_view *view, char *out_buf,
97 const char *in_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098static int debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -070099 int area, debug_entry_t * entry, char *out_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101static int debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
Michael Holzheu66a464d2005-06-25 14:55:33 -0700102 char *out_buf, debug_sprintf_entry_t *curr_event);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104/* globals */
105
106struct debug_view debug_raw_view = {
107 "raw",
108 NULL,
109 &debug_raw_header_fn,
110 &debug_raw_format_fn,
111 NULL,
112 NULL
113};
114
115struct debug_view debug_hex_ascii_view = {
116 "hex_ascii",
117 NULL,
118 &debug_dflt_header_fn,
119 &debug_hex_ascii_format_fn,
120 NULL,
121 NULL
122};
123
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100124static struct debug_view debug_level_view = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 "level",
126 &debug_prolog_level_fn,
127 NULL,
128 NULL,
129 &debug_input_level_fn,
130 NULL
131};
132
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100133static struct debug_view debug_pages_view = {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700134 "pages",
135 &debug_prolog_pages_fn,
136 NULL,
137 NULL,
138 &debug_input_pages_fn,
139 NULL
140};
141
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100142static struct debug_view debug_flush_view = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 "flush",
144 NULL,
145 NULL,
146 NULL,
147 &debug_input_flush_fn,
148 NULL
149};
150
151struct debug_view debug_sprintf_view = {
152 "sprintf",
153 NULL,
154 &debug_dflt_header_fn,
155 (debug_format_proc_t*)&debug_sprintf_format_fn,
156 NULL,
157 NULL
158};
159
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100160/* used by dump analysis tools to determine version of debug feature */
Heiko Carstensa8061702008-04-17 07:46:26 +0200161static unsigned int __used debug_feature_version = __DEBUG_FEATURE_VERSION;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
163/* static globals */
164
165static debug_info_t *debug_area_first = NULL;
166static debug_info_t *debug_area_last = NULL;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200167static DEFINE_MUTEX(debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169static int initialized;
170
Arjan van de Ven5dfe4c92007-02-12 00:55:31 -0800171static const struct file_operations debug_file_ops = {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700172 .owner = THIS_MODULE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 .read = debug_output,
Michael Holzheu66a464d2005-06-25 14:55:33 -0700174 .write = debug_input,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 .open = debug_open,
176 .release = debug_close,
177};
178
Michael Holzheu66a464d2005-06-25 14:55:33 -0700179static struct dentry *debug_debugfs_root_entry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181/* functions */
182
183/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700184 * debug_areas_alloc
185 * - Debug areas are implemented as a threedimensonal array:
186 * areas[areanumber][pagenumber][pageoffset]
187 */
188
189static debug_entry_t***
190debug_areas_alloc(int pages_per_area, int nr_areas)
191{
192 debug_entry_t*** areas;
193 int i,j;
194
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800195 areas = kmalloc(nr_areas *
Michael Holzheu66a464d2005-06-25 14:55:33 -0700196 sizeof(debug_entry_t**),
197 GFP_KERNEL);
198 if (!areas)
199 goto fail_malloc_areas;
200 for (i = 0; i < nr_areas; i++) {
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800201 areas[i] = kmalloc(pages_per_area *
Michael Holzheu66a464d2005-06-25 14:55:33 -0700202 sizeof(debug_entry_t*),GFP_KERNEL);
203 if (!areas[i]) {
204 goto fail_malloc_areas2;
205 }
206 for(j = 0; j < pages_per_area; j++) {
Eric Sesterhennfb630512006-03-24 03:15:31 -0800207 areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700208 if(!areas[i][j]) {
209 for(j--; j >=0 ; j--) {
210 kfree(areas[i][j]);
211 }
212 kfree(areas[i]);
213 goto fail_malloc_areas2;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700214 }
215 }
216 }
217 return areas;
218
219fail_malloc_areas2:
220 for(i--; i >= 0; i--){
221 for(j=0; j < pages_per_area;j++){
222 kfree(areas[i][j]);
223 }
224 kfree(areas[i]);
225 }
226 kfree(areas);
227fail_malloc_areas:
228 return NULL;
229
230}
231
232
233/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 * debug_info_alloc
235 * - alloc new debug-info
236 */
237
Michael Holzheu66a464d2005-06-25 14:55:33 -0700238static debug_info_t*
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200239debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
240 int buf_size, int level, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241{
242 debug_info_t* rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243
244 /* alloc everything */
245
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800246 rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 if(!rc)
248 goto fail_malloc_rc;
Eric Sesterhennfb630512006-03-24 03:15:31 -0800249 rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700250 if(!rc->active_entries)
251 goto fail_malloc_active_entries;
Eric Sesterhennfb630512006-03-24 03:15:31 -0800252 rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700253 if(!rc->active_pages)
254 goto fail_malloc_active_pages;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700255 if((mode == ALL_AREAS) && (pages_per_area != 0)){
256 rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
257 if(!rc->areas)
258 goto fail_malloc_areas;
259 } else {
260 rc->areas = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 }
262
263 /* initialize members */
264
265 spin_lock_init(&rc->lock);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700266 rc->pages_per_area = pages_per_area;
267 rc->nr_areas = nr_areas;
268 rc->active_area = 0;
269 rc->level = level;
270 rc->buf_size = buf_size;
271 rc->entry_size = sizeof(debug_entry_t) + buf_size;
Jean Delvare20cb9e72007-03-19 13:18:53 +0100272 strlcpy(rc->name, name, sizeof(rc->name));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273 memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
Michael Holzheu66a464d2005-06-25 14:55:33 -0700274 memset(rc->debugfs_entries, 0 ,DEBUG_MAX_VIEWS *
275 sizeof(struct dentry*));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 atomic_set(&(rc->ref_count), 0);
277
278 return rc;
279
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280fail_malloc_areas:
Michael Holzheu66a464d2005-06-25 14:55:33 -0700281 kfree(rc->active_pages);
282fail_malloc_active_pages:
283 kfree(rc->active_entries);
284fail_malloc_active_entries:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 kfree(rc);
286fail_malloc_rc:
287 return NULL;
288}
289
290/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700291 * debug_areas_free
292 * - free all debug areas
293 */
294
295static void
296debug_areas_free(debug_info_t* db_info)
297{
298 int i,j;
299
300 if(!db_info->areas)
301 return;
302 for (i = 0; i < db_info->nr_areas; i++) {
303 for(j = 0; j < db_info->pages_per_area; j++) {
304 kfree(db_info->areas[i][j]);
305 }
306 kfree(db_info->areas[i]);
307 }
308 kfree(db_info->areas);
309 db_info->areas = NULL;
310}
311
312/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 * debug_info_free
314 * - free memory debug-info
315 */
316
Michael Holzheu66a464d2005-06-25 14:55:33 -0700317static void
318debug_info_free(debug_info_t* db_info){
319 debug_areas_free(db_info);
320 kfree(db_info->active_entries);
321 kfree(db_info->active_pages);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 kfree(db_info);
323}
324
325/*
326 * debug_info_create
327 * - create new debug-info
328 */
329
Michael Holzheu66a464d2005-06-25 14:55:33 -0700330static debug_info_t*
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200331debug_info_create(const char *name, int pages_per_area, int nr_areas,
332 int buf_size, mode_t mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333{
334 debug_info_t* rc;
335
Michael Holzheu66a464d2005-06-25 14:55:33 -0700336 rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size,
337 DEBUG_DEFAULT_LEVEL, ALL_AREAS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 if(!rc)
339 goto out;
340
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200341 rc->mode = mode & ~S_IFMT;
342
Michael Holzheu66a464d2005-06-25 14:55:33 -0700343 /* create root directory */
344 rc->debugfs_root_entry = debugfs_create_dir(rc->name,
345 debug_debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346
347 /* append new element to linked list */
Michael Holzheu66a464d2005-06-25 14:55:33 -0700348 if (!debug_area_first) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 /* first element in list */
350 debug_area_first = rc;
351 rc->prev = NULL;
352 } else {
353 /* append element to end of list */
354 debug_area_last->next = rc;
355 rc->prev = debug_area_last;
356 }
357 debug_area_last = rc;
358 rc->next = NULL;
359
360 debug_info_get(rc);
361out:
362 return rc;
363}
364
365/*
366 * debug_info_copy
367 * - copy debug-info
368 */
369
Michael Holzheu66a464d2005-06-25 14:55:33 -0700370static debug_info_t*
371debug_info_copy(debug_info_t* in, int mode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700373 int i,j;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 debug_info_t* rc;
Michael Holzheu942eaab2005-09-03 15:57:58 -0700375 unsigned long flags;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700376
Michael Holzheu942eaab2005-09-03 15:57:58 -0700377 /* get a consistent copy of the debug areas */
378 do {
379 rc = debug_info_alloc(in->name, in->pages_per_area,
380 in->nr_areas, in->buf_size, in->level, mode);
381 spin_lock_irqsave(&in->lock, flags);
382 if(!rc)
383 goto out;
384 /* has something changed in the meantime ? */
385 if((rc->pages_per_area == in->pages_per_area) &&
386 (rc->nr_areas == in->nr_areas)) {
387 break;
388 }
389 spin_unlock_irqrestore(&in->lock, flags);
390 debug_info_free(rc);
391 } while (1);
392
Julia Lawallacfa9222008-12-25 13:39:30 +0100393 if (mode == NO_AREAS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 goto out;
395
396 for(i = 0; i < in->nr_areas; i++){
Michael Holzheu66a464d2005-06-25 14:55:33 -0700397 for(j = 0; j < in->pages_per_area; j++) {
398 memcpy(rc->areas[i][j], in->areas[i][j],PAGE_SIZE);
399 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 }
401out:
Michael Holzheu942eaab2005-09-03 15:57:58 -0700402 spin_unlock_irqrestore(&in->lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 return rc;
404}
405
406/*
407 * debug_info_get
408 * - increments reference count for debug-info
409 */
410
Michael Holzheu66a464d2005-06-25 14:55:33 -0700411static void
412debug_info_get(debug_info_t * db_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413{
414 if (db_info)
415 atomic_inc(&db_info->ref_count);
416}
417
418/*
419 * debug_info_put:
420 * - decreases reference count for debug-info and frees it if necessary
421 */
422
Michael Holzheu66a464d2005-06-25 14:55:33 -0700423static void
424debug_info_put(debug_info_t *db_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425{
426 int i;
427
428 if (!db_info)
429 return;
430 if (atomic_dec_and_test(&db_info->ref_count)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
Michael Holzheu66a464d2005-06-25 14:55:33 -0700432 if (!db_info->views[i])
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 continue;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700434 debugfs_remove(db_info->debugfs_entries[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700436 debugfs_remove(db_info->debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 if(db_info == debug_area_first)
438 debug_area_first = db_info->next;
439 if(db_info == debug_area_last)
440 debug_area_last = db_info->prev;
441 if(db_info->prev) db_info->prev->next = db_info->next;
442 if(db_info->next) db_info->next->prev = db_info->prev;
443 debug_info_free(db_info);
444 }
445}
446
447/*
448 * debug_format_entry:
449 * - format one debug entry and return size of formated data
450 */
451
Michael Holzheu66a464d2005-06-25 14:55:33 -0700452static int
453debug_format_entry(file_private_info_t *p_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 debug_info_t *id_snap = p_info->debug_info_snap;
456 struct debug_view *view = p_info->view;
457 debug_entry_t *act_entry;
458 size_t len = 0;
459 if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
460 /* print prolog */
461 if (view->prolog_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700462 len += view->prolog_proc(id_snap,view,p_info->temp_buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 goto out;
464 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700465 if (!id_snap->areas) /* this is true, if we have a prolog only view */
466 goto out; /* or if 'pages_per_area' is 0 */
467 act_entry = (debug_entry_t *) ((char*)id_snap->areas[p_info->act_area]
468 [p_info->act_page] + p_info->act_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
470 if (act_entry->id.stck == 0LL)
471 goto out; /* empty entry */
472 if (view->header_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700473 len += view->header_proc(id_snap, view, p_info->act_area,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 act_entry, p_info->temp_buf + len);
475 if (view->format_proc)
Michael Holzheu66a464d2005-06-25 14:55:33 -0700476 len += view->format_proc(id_snap, view, p_info->temp_buf + len,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 DEBUG_DATA(act_entry));
Michael Holzheu66a464d2005-06-25 14:55:33 -0700478out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 return len;
480}
481
482/*
483 * debug_next_entry:
484 * - goto next entry in p_info
485 */
486
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800487static inline int
Michael Holzheu66a464d2005-06-25 14:55:33 -0700488debug_next_entry(file_private_info_t *p_info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700490 debug_info_t *id;
491
492 id = p_info->debug_info_snap;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
494 p_info->act_entry = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700495 p_info->act_page = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 goto out;
497 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700498 if(!id->areas)
499 return 1;
500 p_info->act_entry += id->entry_size;
501 /* switch to next page, if we reached the end of the page */
502 if (p_info->act_entry > (PAGE_SIZE - id->entry_size)){
503 /* next page */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 p_info->act_entry = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700505 p_info->act_page += 1;
506 if((p_info->act_page % id->pages_per_area) == 0) {
507 /* next area */
508 p_info->act_area++;
509 p_info->act_page=0;
510 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 if(p_info->act_area >= id->nr_areas)
512 return 1;
513 }
514out:
515 return 0;
516}
517
518/*
519 * debug_output:
520 * - called for user read()
521 * - copies formated debug entries to the user buffer
522 */
523
Michael Holzheu66a464d2005-06-25 14:55:33 -0700524static ssize_t
525debug_output(struct file *file, /* file descriptor */
526 char __user *user_buf, /* user buffer */
527 size_t len, /* length of buffer */
528 loff_t *offset) /* offset in the file */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529{
530 size_t count = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700531 size_t entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 file_private_info_t *p_info;
533
534 p_info = ((file_private_info_t *) file->private_data);
535 if (*offset != p_info->offset)
536 return -EPIPE;
537 if(p_info->act_area >= p_info->debug_info_snap->nr_areas)
538 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 entry_offset = p_info->act_entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 while(count < len){
Michael Holzheu66a464d2005-06-25 14:55:33 -0700541 int formatted_line_size;
542 int formatted_line_residue;
543 int user_buf_residue;
544 size_t copy_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545
Michael Holzheu66a464d2005-06-25 14:55:33 -0700546 formatted_line_size = debug_format_entry(p_info);
547 formatted_line_residue = formatted_line_size - entry_offset;
548 user_buf_residue = len-count;
549 copy_size = min(user_buf_residue, formatted_line_residue);
550 if(copy_size){
551 if (copy_to_user(user_buf + count, p_info->temp_buf
552 + entry_offset, copy_size))
553 return -EFAULT;
554 count += copy_size;
555 entry_offset += copy_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 }
Michael Holzheu66a464d2005-06-25 14:55:33 -0700557 if(copy_size == formatted_line_residue){
558 entry_offset = 0;
559 if(debug_next_entry(p_info))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 goto out;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700561 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 }
563out:
564 p_info->offset = *offset + count;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700565 p_info->act_entry_offset = entry_offset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 *offset = p_info->offset;
567 return count;
568}
569
570/*
571 * debug_input:
572 * - called for user write()
573 * - calls input function of view
574 */
575
Michael Holzheu66a464d2005-06-25 14:55:33 -0700576static ssize_t
577debug_input(struct file *file, const char __user *user_buf, size_t length,
578 loff_t *offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579{
580 int rc = 0;
581 file_private_info_t *p_info;
582
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200583 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 p_info = ((file_private_info_t *) file->private_data);
585 if (p_info->view->input_proc)
586 rc = p_info->view->input_proc(p_info->debug_info_org,
587 p_info->view, file, user_buf,
588 length, offset);
589 else
590 rc = -EPERM;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200591 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 return rc; /* number of input characters */
593}
594
595/*
596 * debug_open:
597 * - called for user open()
598 * - copies formated output to private_data area of the file
599 * handle
600 */
601
Michael Holzheu66a464d2005-06-25 14:55:33 -0700602static int
603debug_open(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604{
Michael Holzheua0fa8e32009-03-26 15:24:49 +0100605 int i, rc = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 file_private_info_t *p_info;
607 debug_info_t *debug_info, *debug_info_snapshot;
608
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200609 mutex_lock(&debug_mutex);
Josef Sipekd20343e2006-12-08 02:37:35 -0800610 debug_info = file->f_path.dentry->d_inode->i_private;
Michael Holzheu942eaab2005-09-03 15:57:58 -0700611 /* find debug view */
612 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
613 if (!debug_info->views[i])
614 continue;
615 else if (debug_info->debugfs_entries[i] ==
Josef Sipekd20343e2006-12-08 02:37:35 -0800616 file->f_path.dentry) {
Michael Holzheu942eaab2005-09-03 15:57:58 -0700617 goto found; /* found view ! */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 }
620 /* no entry found */
621 rc = -EINVAL;
622 goto out;
623
Michael Holzheu66a464d2005-06-25 14:55:33 -0700624found:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625
Michael Holzheu66a464d2005-06-25 14:55:33 -0700626 /* Make snapshot of current debug areas to get it consistent. */
627 /* To copy all the areas is only needed, if we have a view which */
628 /* formats the debug areas. */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Michael Holzheu66a464d2005-06-25 14:55:33 -0700630 if(!debug_info->views[i]->format_proc &&
631 !debug_info->views[i]->header_proc){
632 debug_info_snapshot = debug_info_copy(debug_info, NO_AREAS);
633 } else {
634 debug_info_snapshot = debug_info_copy(debug_info, ALL_AREAS);
635 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
637 if(!debug_info_snapshot){
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 rc = -ENOMEM;
639 goto out;
640 }
Robert P. J. Day5cbded52006-12-13 00:35:56 -0800641 p_info = kmalloc(sizeof(file_private_info_t),
Michael Holzheu66a464d2005-06-25 14:55:33 -0700642 GFP_KERNEL);
643 if(!p_info){
Michael Holzheu58ace9f2009-03-26 15:24:50 +0100644 debug_info_free(debug_info_snapshot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 rc = -ENOMEM;
646 goto out;
647 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 p_info->offset = 0;
649 p_info->debug_info_snap = debug_info_snapshot;
650 p_info->debug_info_org = debug_info;
651 p_info->view = debug_info->views[i];
652 p_info->act_area = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700653 p_info->act_page = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 p_info->act_entry = DEBUG_PROLOG_ENTRY;
655 p_info->act_entry_offset = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700656 file->private_data = p_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 debug_info_get(debug_info);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700658out:
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200659 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 return rc;
661}
662
663/*
664 * debug_close:
665 * - called for user close()
666 * - deletes private_data area of the file handle
667 */
668
Michael Holzheu66a464d2005-06-25 14:55:33 -0700669static int
670debug_close(struct inode *inode, struct file *file)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671{
672 file_private_info_t *p_info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 p_info = (file_private_info_t *) file->private_data;
Michael Holzheu66a464d2005-06-25 14:55:33 -0700674 if(p_info->debug_info_snap)
675 debug_info_free(p_info->debug_info_snap);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 debug_info_put(p_info->debug_info_org);
677 kfree(file->private_data);
678 return 0; /* success */
679}
680
681/*
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200682 * debug_register_mode:
683 * - Creates and initializes debug area for the caller
684 * The mode parameter allows to specify access rights for the s390dbf files
685 * - Returns handle for debug area
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 */
687
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200688debug_info_t *debug_register_mode(const char *name, int pages_per_area,
689 int nr_areas, int buf_size, mode_t mode,
690 uid_t uid, gid_t gid)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691{
692 debug_info_t *rc = NULL;
693
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200694 /* Since debugfs currently does not support uid/gid other than root, */
695 /* we do not allow gid/uid != 0 until we get support for that. */
696 if ((uid != 0) || (gid != 0))
Michael Holzheuc5612c12008-12-25 13:39:43 +0100697 pr_warning("Root becomes the owner of all s390dbf files "
698 "in sysfs\n");
Stoyan Gaydarov6aa0d3a2009-03-26 15:24:47 +0100699 BUG_ON(!initialized);
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200700 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
702 /* create new debug_info */
703
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200704 rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 if(!rc)
706 goto out;
707 debug_register_view(rc, &debug_level_view);
708 debug_register_view(rc, &debug_flush_view);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700709 debug_register_view(rc, &debug_pages_view);
710out:
711 if (!rc){
Michael Holzheuc5612c12008-12-25 13:39:43 +0100712 pr_err("Registering debug feature %s failed\n", name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 }
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200714 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 return rc;
716}
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200717EXPORT_SYMBOL(debug_register_mode);
718
719/*
720 * debug_register:
721 * - creates and initializes debug area for the caller
722 * - returns handle for debug area
723 */
724
Cornelia Huck5cbbf162008-05-15 16:52:35 +0200725debug_info_t *debug_register(const char *name, int pages_per_area,
726 int nr_areas, int buf_size)
Michael Holzheu9637c3f2008-04-17 07:46:18 +0200727{
728 return debug_register_mode(name, pages_per_area, nr_areas, buf_size,
729 S_IRUSR | S_IWUSR, 0, 0);
730}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731
732/*
733 * debug_unregister:
734 * - give back debug area
735 */
736
Michael Holzheu66a464d2005-06-25 14:55:33 -0700737void
738debug_unregister(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739{
740 if (!id)
741 goto out;
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200742 mutex_lock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 debug_info_put(id);
Christoph Hellwige11f0d02007-05-31 17:38:03 +0200744 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745
Michael Holzheu66a464d2005-06-25 14:55:33 -0700746out:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 return;
748}
749
750/*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700751 * debug_set_size:
752 * - set area size (number of pages) and number of areas
753 */
754static int
755debug_set_size(debug_info_t* id, int nr_areas, int pages_per_area)
756{
757 unsigned long flags;
758 debug_entry_t *** new_areas;
759 int rc=0;
760
761 if(!id || (nr_areas <= 0) || (pages_per_area < 0))
762 return -EINVAL;
763 if(pages_per_area > 0){
764 new_areas = debug_areas_alloc(pages_per_area, nr_areas);
765 if(!new_areas) {
Michael Holzheuc5612c12008-12-25 13:39:43 +0100766 pr_info("Allocating memory for %i pages failed\n",
767 pages_per_area);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700768 rc = -ENOMEM;
769 goto out;
770 }
771 } else {
772 new_areas = NULL;
773 }
774 spin_lock_irqsave(&id->lock,flags);
775 debug_areas_free(id);
776 id->areas = new_areas;
777 id->nr_areas = nr_areas;
778 id->pages_per_area = pages_per_area;
779 id->active_area = 0;
780 memset(id->active_entries,0,sizeof(int)*id->nr_areas);
781 memset(id->active_pages, 0, sizeof(int)*id->nr_areas);
782 spin_unlock_irqrestore(&id->lock,flags);
Michael Holzheuc5612c12008-12-25 13:39:43 +0100783 pr_info("%s: set new size (%i pages)\n" ,id->name, pages_per_area);
Michael Holzheu66a464d2005-06-25 14:55:33 -0700784out:
785 return rc;
786}
787
788/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 * debug_set_level:
790 * - set actual debug level
791 */
792
Michael Holzheu66a464d2005-06-25 14:55:33 -0700793void
794debug_set_level(debug_info_t* id, int new_level)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795{
796 unsigned long flags;
797 if(!id)
798 return;
799 spin_lock_irqsave(&id->lock,flags);
800 if(new_level == DEBUG_OFF_LEVEL){
801 id->level = DEBUG_OFF_LEVEL;
Michael Holzheuc5612c12008-12-25 13:39:43 +0100802 pr_info("%s: switched off\n",id->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
Michael Holzheuc5612c12008-12-25 13:39:43 +0100804 pr_info("%s: level %i is out of range (%i - %i)\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 id->name, new_level, 0, DEBUG_MAX_LEVEL);
806 } else {
807 id->level = new_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 }
809 spin_unlock_irqrestore(&id->lock,flags);
810}
811
812
813/*
814 * proceed_active_entry:
815 * - set active entry to next in the ring buffer
816 */
817
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800818static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700819proceed_active_entry(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700821 if ((id->active_entries[id->active_area] += id->entry_size)
822 > (PAGE_SIZE - id->entry_size)){
823 id->active_entries[id->active_area] = 0;
824 id->active_pages[id->active_area] =
825 (id->active_pages[id->active_area] + 1) %
826 id->pages_per_area;
827 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828}
829
830/*
831 * proceed_active_area:
832 * - set active area to next in the ring buffer
833 */
834
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800835static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700836proceed_active_area(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837{
838 id->active_area++;
839 id->active_area = id->active_area % id->nr_areas;
840}
841
842/*
843 * get_active_entry:
844 */
845
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800846static inline debug_entry_t*
Michael Holzheu66a464d2005-06-25 14:55:33 -0700847get_active_entry(debug_info_t * id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848{
Michael Holzheu66a464d2005-06-25 14:55:33 -0700849 return (debug_entry_t *) (((char *) id->areas[id->active_area]
850 [id->active_pages[id->active_area]]) +
851 id->active_entries[id->active_area]);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852}
853
854/*
855 * debug_finish_entry:
856 * - set timestamp, caller address, cpu number etc.
857 */
858
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800859static inline void
Michael Holzheu66a464d2005-06-25 14:55:33 -0700860debug_finish_entry(debug_info_t * id, debug_entry_t* active, int level,
861 int exception)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862{
Michael Holzheu942eaab2005-09-03 15:57:58 -0700863 active->id.stck = get_clock();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 active->id.fields.cpuid = smp_processor_id();
865 active->caller = __builtin_return_address(0);
866 active->id.fields.exception = exception;
867 active->id.fields.level = level;
868 proceed_active_entry(id);
869 if(exception)
870 proceed_active_area(id);
871}
872
873static int debug_stoppable=1;
874static int debug_active=1;
875
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876#define CTL_S390DBF_STOPPABLE 5678
877#define CTL_S390DBF_ACTIVE 5679
878
879/*
880 * proc handler for the running debug_active sysctl
881 * always allow read, allow write only if debug_stoppable is set or
882 * if debug_active is already off
883 */
Michael Holzheu66a464d2005-06-25 14:55:33 -0700884static int
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700885s390dbf_procactive(ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 void __user *buffer, size_t *lenp, loff_t *ppos)
887{
888 if (!write || debug_stoppable || !debug_active)
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700889 return proc_dointvec(table, write, buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 else
891 return 0;
892}
893
894
895static struct ctl_table s390dbf_table[] = {
896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "debug_stoppable",
898 .data = &debug_stoppable,
899 .maxlen = sizeof(int),
900 .mode = S_IRUGO | S_IWUSR,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 },
903 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 .procname = "debug_active",
905 .data = &debug_active,
906 .maxlen = sizeof(int),
907 .mode = S_IRUGO | S_IWUSR,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = s390dbf_procactive,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 },
Eric W. Biedermanb05fd352009-04-03 04:36:34 -0700910 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911};
912
913static struct ctl_table s390dbf_dir_table[] = {
914 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 .procname = "s390dbf",
916 .maxlen = 0,
917 .mode = S_IRUGO | S_IXUGO,
918 .child = s390dbf_table,
919 },
Eric W. Biedermanb05fd352009-04-03 04:36:34 -0700920 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921};
922
Heiko Carstens2b67fc42007-02-05 21:16:47 +0100923static struct ctl_table_header *s390dbf_sysctl_header;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924
Michael Holzheu66a464d2005-06-25 14:55:33 -0700925void
926debug_stop_all(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927{
928 if (debug_stoppable)
929 debug_active = 0;
930}
931
932
933/*
934 * debug_event_common:
935 * - write debug entry with given size
936 */
937
Michael Holzheu66a464d2005-06-25 14:55:33 -0700938debug_entry_t*
939debug_event_common(debug_info_t * id, int level, const void *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940{
941 unsigned long flags;
942 debug_entry_t *active;
943
Michael Holzheu66a464d2005-06-25 14:55:33 -0700944 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 return NULL;
946 spin_lock_irqsave(&id->lock, flags);
947 active = get_active_entry(id);
948 memset(DEBUG_DATA(active), 0, id->buf_size);
949 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
950 debug_finish_entry(id, active, level, 0);
951 spin_unlock_irqrestore(&id->lock, flags);
952
953 return active;
954}
955
956/*
957 * debug_exception_common:
958 * - write debug entry with given size and switch to next debug area
959 */
960
Michael Holzheu66a464d2005-06-25 14:55:33 -0700961debug_entry_t
962*debug_exception_common(debug_info_t * id, int level, const void *buf, int len)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963{
964 unsigned long flags;
965 debug_entry_t *active;
966
Michael Holzheu66a464d2005-06-25 14:55:33 -0700967 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 return NULL;
969 spin_lock_irqsave(&id->lock, flags);
970 active = get_active_entry(id);
971 memset(DEBUG_DATA(active), 0, id->buf_size);
972 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
973 debug_finish_entry(id, active, level, 1);
974 spin_unlock_irqrestore(&id->lock, flags);
975
976 return active;
977}
978
979/*
980 * counts arguments in format string for sprintf view
981 */
982
Adrian Bunk4448aaf2005-11-08 21:34:42 -0800983static inline int
Michael Holzheu66a464d2005-06-25 14:55:33 -0700984debug_count_numargs(char *string)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985{
986 int numargs=0;
987
988 while(*string) {
989 if(*string++=='%')
990 numargs++;
991 }
992 return(numargs);
993}
994
995/*
996 * debug_sprintf_event:
997 */
998
Michael Holzheu66a464d2005-06-25 14:55:33 -0700999debug_entry_t*
1000debug_sprintf_event(debug_info_t* id, int level,char *string,...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001{
1002 va_list ap;
1003 int numargs,idx;
1004 unsigned long flags;
1005 debug_sprintf_entry_t *curr_event;
1006 debug_entry_t *active;
1007
1008 if((!id) || (level > id->level))
1009 return NULL;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001010 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 return NULL;
1012 numargs=debug_count_numargs(string);
1013
1014 spin_lock_irqsave(&id->lock, flags);
1015 active = get_active_entry(id);
1016 curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active);
1017 va_start(ap,string);
1018 curr_event->string=string;
1019 for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
1020 curr_event->args[idx]=va_arg(ap,long);
1021 va_end(ap);
1022 debug_finish_entry(id, active, level, 0);
1023 spin_unlock_irqrestore(&id->lock, flags);
1024
1025 return active;
1026}
1027
1028/*
1029 * debug_sprintf_exception:
1030 */
1031
Michael Holzheu66a464d2005-06-25 14:55:33 -07001032debug_entry_t*
1033debug_sprintf_exception(debug_info_t* id, int level,char *string,...)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034{
1035 va_list ap;
1036 int numargs,idx;
1037 unsigned long flags;
1038 debug_sprintf_entry_t *curr_event;
1039 debug_entry_t *active;
1040
1041 if((!id) || (level > id->level))
1042 return NULL;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001043 if (!debug_active || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 return NULL;
1045
1046 numargs=debug_count_numargs(string);
1047
1048 spin_lock_irqsave(&id->lock, flags);
1049 active = get_active_entry(id);
1050 curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active);
1051 va_start(ap,string);
1052 curr_event->string=string;
1053 for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
1054 curr_event->args[idx]=va_arg(ap,long);
1055 va_end(ap);
1056 debug_finish_entry(id, active, level, 1);
1057 spin_unlock_irqrestore(&id->lock, flags);
1058
1059 return active;
1060}
1061
1062/*
1063 * debug_init:
1064 * - is called exactly once to initialize the debug feature
1065 */
1066
Michael Holzheu66a464d2005-06-25 14:55:33 -07001067static int
1068__init debug_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069{
1070 int rc = 0;
1071
Eric W. Biederman0b4d4142007-02-14 00:34:09 -08001072 s390dbf_sysctl_header = register_sysctl_table(s390dbf_dir_table);
Christoph Hellwige11f0d02007-05-31 17:38:03 +02001073 mutex_lock(&debug_mutex);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001074 debug_debugfs_root_entry = debugfs_create_dir(DEBUG_DIR_ROOT,NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 initialized = 1;
Christoph Hellwige11f0d02007-05-31 17:38:03 +02001076 mutex_unlock(&debug_mutex);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077
1078 return rc;
1079}
1080
1081/*
1082 * debug_register_view:
1083 */
1084
Michael Holzheu66a464d2005-06-25 14:55:33 -07001085int
1086debug_register_view(debug_info_t * id, struct debug_view *view)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087{
1088 int rc = 0;
1089 int i;
1090 unsigned long flags;
Michael Holzheu9637c3f2008-04-17 07:46:18 +02001091 mode_t mode;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001092 struct dentry *pde;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093
1094 if (!id)
1095 goto out;
Michael Holzheu9637c3f2008-04-17 07:46:18 +02001096 mode = (id->mode | S_IFREG) & ~S_IXUGO;
1097 if (!(view->prolog_proc || view->format_proc || view->header_proc))
1098 mode &= ~(S_IRUSR | S_IRGRP | S_IROTH);
1099 if (!view->input_proc)
1100 mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001101 pde = debugfs_create_file(view->name, mode, id->debugfs_root_entry,
Michael Holzheu942eaab2005-09-03 15:57:58 -07001102 id , &debug_file_ops);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001103 if (!pde){
Michael Holzheuc5612c12008-12-25 13:39:43 +01001104 pr_err("Registering view %s/%s failed due to out of "
1105 "memory\n", id->name,view->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 rc = -1;
1107 goto out;
1108 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 spin_lock_irqsave(&id->lock, flags);
1110 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001111 if (!id->views[i])
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 break;
1113 }
1114 if (i == DEBUG_MAX_VIEWS) {
Michael Holzheuc5612c12008-12-25 13:39:43 +01001115 pr_err("Registering view %s/%s would exceed the maximum "
1116 "number of views %i\n", id->name, view->name, i);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001117 debugfs_remove(pde);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 rc = -1;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001119 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 id->views[i] = view;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001121 id->debugfs_entries[i] = pde;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 }
1123 spin_unlock_irqrestore(&id->lock, flags);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001124out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 return rc;
1126}
1127
1128/*
1129 * debug_unregister_view:
1130 */
1131
Michael Holzheu66a464d2005-06-25 14:55:33 -07001132int
1133debug_unregister_view(debug_info_t * id, struct debug_view *view)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134{
1135 int rc = 0;
1136 int i;
1137 unsigned long flags;
1138
1139 if (!id)
1140 goto out;
1141 spin_lock_irqsave(&id->lock, flags);
1142 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
1143 if (id->views[i] == view)
1144 break;
1145 }
1146 if (i == DEBUG_MAX_VIEWS)
1147 rc = -1;
1148 else {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001149 debugfs_remove(id->debugfs_entries[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 id->views[i] = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 }
1152 spin_unlock_irqrestore(&id->lock, flags);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001153out:
1154 return rc;
1155}
1156
1157static inline char *
1158debug_get_user_string(const char __user *user_buf, size_t user_len)
1159{
1160 char* buffer;
1161
1162 buffer = kmalloc(user_len + 1, GFP_KERNEL);
1163 if (!buffer)
1164 return ERR_PTR(-ENOMEM);
1165 if (copy_from_user(buffer, user_buf, user_len) != 0) {
1166 kfree(buffer);
1167 return ERR_PTR(-EFAULT);
1168 }
1169 /* got the string, now strip linefeed. */
1170 if (buffer[user_len - 1] == '\n')
1171 buffer[user_len - 1] = 0;
1172 else
1173 buffer[user_len] = 0;
1174 return buffer;
1175}
1176
1177static inline int
1178debug_get_uint(char *buf)
1179{
1180 int rc;
1181
André Goddard Rosae7d28602009-12-14 18:01:06 -08001182 buf = skip_spaces(buf);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001183 rc = simple_strtoul(buf, &buf, 10);
1184 if(*buf){
Michael Holzheu66a464d2005-06-25 14:55:33 -07001185 rc = -EINVAL;
1186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 return rc;
1188}
1189
1190/*
1191 * functions for debug-views
1192 ***********************************
1193*/
1194
1195/*
1196 * prints out actual debug level
1197 */
1198
Michael Holzheu66a464d2005-06-25 14:55:33 -07001199static int
1200debug_prolog_pages_fn(debug_info_t * id,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 struct debug_view *view, char *out_buf)
1202{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001203 return sprintf(out_buf, "%i\n", id->pages_per_area);
1204}
1205
1206/*
1207 * reads new size (number of pages per debug area)
1208 */
1209
1210static int
1211debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
1212 struct file *file, const char __user *user_buf,
1213 size_t user_len, loff_t * offset)
1214{
1215 char *str;
1216 int rc,new_pages;
1217
1218 if (user_len > 0x10000)
1219 user_len = 0x10000;
1220 if (*offset != 0){
1221 rc = -EPIPE;
1222 goto out;
1223 }
1224 str = debug_get_user_string(user_buf,user_len);
1225 if(IS_ERR(str)){
1226 rc = PTR_ERR(str);
1227 goto out;
1228 }
1229 new_pages = debug_get_uint(str);
1230 if(new_pages < 0){
1231 rc = -EINVAL;
1232 goto free_str;
1233 }
1234 rc = debug_set_size(id,id->nr_areas, new_pages);
1235 if(rc != 0){
1236 rc = -EINVAL;
1237 goto free_str;
1238 }
1239 rc = user_len;
1240free_str:
1241 kfree(str);
1242out:
1243 *offset += user_len;
1244 return rc; /* number of input characters */
1245}
1246
1247/*
1248 * prints out actual debug level
1249 */
1250
1251static int
1252debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf)
1253{
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 int rc = 0;
1255
Michael Holzheu66a464d2005-06-25 14:55:33 -07001256 if(id->level == DEBUG_OFF_LEVEL) {
1257 rc = sprintf(out_buf,"-\n");
1258 }
1259 else {
1260 rc = sprintf(out_buf, "%i\n", id->level);
1261 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262 return rc;
1263}
1264
1265/*
1266 * reads new debug level
1267 */
1268
Michael Holzheu66a464d2005-06-25 14:55:33 -07001269static int
1270debug_input_level_fn(debug_info_t * id, struct debug_view *view,
1271 struct file *file, const char __user *user_buf,
1272 size_t user_len, loff_t * offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001274 char *str;
1275 int rc,new_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276
Michael Holzheu66a464d2005-06-25 14:55:33 -07001277 if (user_len > 0x10000)
1278 user_len = 0x10000;
1279 if (*offset != 0){
1280 rc = -EPIPE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 goto out;
1282 }
Michael Holzheu66a464d2005-06-25 14:55:33 -07001283 str = debug_get_user_string(user_buf,user_len);
1284 if(IS_ERR(str)){
1285 rc = PTR_ERR(str);
1286 goto out;
1287 }
1288 if(str[0] == '-'){
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 debug_set_level(id, DEBUG_OFF_LEVEL);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001290 rc = user_len;
1291 goto free_str;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 } else {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001293 new_level = debug_get_uint(str);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 }
Michael Holzheu66a464d2005-06-25 14:55:33 -07001295 if(new_level < 0) {
Michael Holzheuc5612c12008-12-25 13:39:43 +01001296 pr_warning("%s is not a valid level for a debug "
1297 "feature\n", str);
Michael Holzheu66a464d2005-06-25 14:55:33 -07001298 rc = -EINVAL;
1299 } else {
1300 debug_set_level(id, new_level);
1301 rc = user_len;
1302 }
1303free_str:
1304 kfree(str);
1305out:
1306 *offset += user_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 return rc; /* number of input characters */
1308}
1309
1310
1311/*
1312 * flushes debug areas
1313 */
1314
Heiko Carstens2b67fc42007-02-05 21:16:47 +01001315static void debug_flush(debug_info_t* id, int area)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316{
1317 unsigned long flags;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001318 int i,j;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319
Michael Holzheu66a464d2005-06-25 14:55:33 -07001320 if(!id || !id->areas)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 return;
1322 spin_lock_irqsave(&id->lock,flags);
1323 if(area == DEBUG_FLUSH_ALL){
1324 id->active_area = 0;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001325 memset(id->active_entries, 0, id->nr_areas * sizeof(int));
1326 for (i = 0; i < id->nr_areas; i++) {
1327 id->active_pages[i] = 0;
1328 for(j = 0; j < id->pages_per_area; j++) {
1329 memset(id->areas[i][j], 0, PAGE_SIZE);
1330 }
1331 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 } else if(area >= 0 && area < id->nr_areas) {
Michael Holzheu66a464d2005-06-25 14:55:33 -07001333 id->active_entries[area] = 0;
1334 id->active_pages[area] = 0;
1335 for(i = 0; i < id->pages_per_area; i++) {
1336 memset(id->areas[area][i],0,PAGE_SIZE);
1337 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 }
1339 spin_unlock_irqrestore(&id->lock,flags);
1340}
1341
1342/*
1343 * view function: flushes debug areas
1344 */
1345
Michael Holzheu66a464d2005-06-25 14:55:33 -07001346static int
1347debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
1348 struct file *file, const char __user *user_buf,
1349 size_t user_len, loff_t * offset)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350{
1351 char input_buf[1];
Michael Holzheu66a464d2005-06-25 14:55:33 -07001352 int rc = user_len;
1353
1354 if (user_len > 0x10000)
1355 user_len = 0x10000;
1356 if (*offset != 0){
1357 rc = -EPIPE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 goto out;
Michael Holzheu66a464d2005-06-25 14:55:33 -07001359 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 if (copy_from_user(input_buf, user_buf, 1)){
1361 rc = -EFAULT;
1362 goto out;
1363 }
1364 if(input_buf[0] == '-') {
1365 debug_flush(id, DEBUG_FLUSH_ALL);
1366 goto out;
1367 }
1368 if (isdigit(input_buf[0])) {
1369 int area = ((int) input_buf[0] - (int) '0');
1370 debug_flush(id, area);
1371 goto out;
1372 }
1373
Michael Holzheuc5612c12008-12-25 13:39:43 +01001374 pr_info("Flushing debug data failed because %c is not a valid "
1375 "area\n", input_buf[0]);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376
Michael Holzheu66a464d2005-06-25 14:55:33 -07001377out:
1378 *offset += user_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 return rc; /* number of input characters */
1380}
1381
1382/*
1383 * prints debug header in raw format
1384 */
1385
Michael Holzheu66a464d2005-06-25 14:55:33 -07001386static int
1387debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
1388 int area, debug_entry_t * entry, char *out_buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389{
1390 int rc;
1391
1392 rc = sizeof(debug_entry_t);
1393 memcpy(out_buf,entry,sizeof(debug_entry_t));
1394 return rc;
1395}
1396
1397/*
1398 * prints debug data in raw format
1399 */
1400
Michael Holzheu66a464d2005-06-25 14:55:33 -07001401static int
1402debug_raw_format_fn(debug_info_t * id, struct debug_view *view,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 char *out_buf, const char *in_buf)
1404{
1405 int rc;
1406
1407 rc = id->buf_size;
1408 memcpy(out_buf, in_buf, id->buf_size);
1409 return rc;
1410}
1411
1412/*
1413 * prints debug data in hex/ascii format
1414 */
1415
Michael Holzheu66a464d2005-06-25 14:55:33 -07001416static int
1417debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
1418 char *out_buf, const char *in_buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419{
1420 int i, rc = 0;
1421
1422 for (i = 0; i < id->buf_size; i++) {
1423 rc += sprintf(out_buf + rc, "%02x ",
1424 ((unsigned char *) in_buf)[i]);
1425 }
1426 rc += sprintf(out_buf + rc, "| ");
1427 for (i = 0; i < id->buf_size; i++) {
1428 unsigned char c = in_buf[i];
1429 if (!isprint(c))
1430 rc += sprintf(out_buf + rc, ".");
1431 else
1432 rc += sprintf(out_buf + rc, "%c", c);
1433 }
1434 rc += sprintf(out_buf + rc, "\n");
1435 return rc;
1436}
1437
1438/*
1439 * prints header for debug entry
1440 */
1441
Michael Holzheu66a464d2005-06-25 14:55:33 -07001442int
1443debug_dflt_header_fn(debug_info_t * id, struct debug_view *view,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444 int area, debug_entry_t * entry, char *out_buf)
1445{
Michael Holzheu942eaab2005-09-03 15:57:58 -07001446 struct timespec time_spec;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 char *except_str;
1448 unsigned long caller;
1449 int rc = 0;
1450 unsigned int level;
1451
1452 level = entry->id.fields.level;
Christof Schmittb592e892009-08-18 15:43:31 +02001453 stck_to_timespec(entry->id.stck, &time_spec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454
1455 if (entry->id.fields.exception)
1456 except_str = "*";
1457 else
1458 except_str = "-";
1459 caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
1460 rc += sprintf(out_buf, "%02i %011lu:%06lu %1u %1s %02i %p ",
Michael Holzheu942eaab2005-09-03 15:57:58 -07001461 area, time_spec.tv_sec, time_spec.tv_nsec / 1000, level,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 except_str, entry->id.fields.cpuid, (void *) caller);
1463 return rc;
1464}
1465
1466/*
1467 * prints debug data sprintf-formated:
1468 * debug_sprinf_event/exception calls must be used together with this view
1469 */
1470
1471#define DEBUG_SPRINTF_MAX_ARGS 10
1472
Michael Holzheu66a464d2005-06-25 14:55:33 -07001473static int
1474debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
1475 char *out_buf, debug_sprintf_entry_t *curr_event)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476{
1477 int num_longs, num_used_args = 0,i, rc = 0;
1478 int index[DEBUG_SPRINTF_MAX_ARGS];
1479
1480 /* count of longs fit into one entry */
1481 num_longs = id->buf_size / sizeof(long);
1482
1483 if(num_longs < 1)
1484 goto out; /* bufsize of entry too small */
1485 if(num_longs == 1) {
1486 /* no args, we use only the string */
1487 strcpy(out_buf, curr_event->string);
1488 rc = strlen(curr_event->string);
1489 goto out;
1490 }
1491
1492 /* number of arguments used for sprintf (without the format string) */
1493 num_used_args = min(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
1494
1495 memset(index,0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
1496
1497 for(i = 0; i < num_used_args; i++)
1498 index[i] = i;
1499
1500 rc = sprintf(out_buf, curr_event->string, curr_event->args[index[0]],
1501 curr_event->args[index[1]], curr_event->args[index[2]],
1502 curr_event->args[index[3]], curr_event->args[index[4]],
1503 curr_event->args[index[5]], curr_event->args[index[6]],
1504 curr_event->args[index[7]], curr_event->args[index[8]],
1505 curr_event->args[index[9]]);
1506
1507out:
1508
1509 return rc;
1510}
1511
1512/*
1513 * clean up module
1514 */
Heiko Carstens2b67fc42007-02-05 21:16:47 +01001515static void __exit debug_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001516{
Michael Holzheu66a464d2005-06-25 14:55:33 -07001517 debugfs_remove(debug_debugfs_root_entry);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 unregister_sysctl_table(s390dbf_sysctl_header);
1519 return;
1520}
1521
1522/*
1523 * module definitions
1524 */
Michael Holzheu66a464d2005-06-25 14:55:33 -07001525postcore_initcall(debug_init);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526module_exit(debug_exit);
1527MODULE_LICENSE("GPL");
1528
1529EXPORT_SYMBOL(debug_register);
1530EXPORT_SYMBOL(debug_unregister);
1531EXPORT_SYMBOL(debug_set_level);
1532EXPORT_SYMBOL(debug_stop_all);
1533EXPORT_SYMBOL(debug_register_view);
1534EXPORT_SYMBOL(debug_unregister_view);
1535EXPORT_SYMBOL(debug_event_common);
1536EXPORT_SYMBOL(debug_exception_common);
1537EXPORT_SYMBOL(debug_hex_ascii_view);
1538EXPORT_SYMBOL(debug_raw_view);
1539EXPORT_SYMBOL(debug_dflt_header_fn);
1540EXPORT_SYMBOL(debug_sprintf_view);
1541EXPORT_SYMBOL(debug_sprintf_exception);
1542EXPORT_SYMBOL(debug_sprintf_event);