X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fs390%2Fkernel%2Fdebug.c;h=f1e538c9dfe0496d8f415b4bd946fc7febba2369;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=d2980b671702b8164cf0dca8e37b8d1991899b23;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index d2980b671..f1e538c9d 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c @@ -54,7 +54,7 @@ typedef struct * */ long args[0]; -} debug_sprintf_entry; +} debug_sprintf_entry_t; extern void tod_to_timeval(uint64_t todval, struct timeval *xtime); @@ -62,9 +62,9 @@ extern void tod_to_timeval(uint64_t todval, struct timeval *xtime); /* internal function prototyes */ static int debug_init(void); -static ssize_t debug_output(struct file *file, char *user_buf, +static ssize_t debug_output(struct file *file, char __user *user_buf, size_t user_len, loff_t * offset); -static ssize_t debug_input(struct file *file, const char *user_buf, +static ssize_t debug_input(struct file *file, const char __user *user_buf, size_t user_len, loff_t * offset); static int debug_open(struct inode *inode, struct file *file); static int debug_close(struct inode *inode, struct file *file); @@ -74,10 +74,10 @@ static void debug_info_put(debug_info_t *); static int debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf); static int debug_input_level_fn(debug_info_t * id, struct debug_view *view, - struct file *file, const char *user_buf, + struct file *file, const char __user *user_buf, size_t user_buf_size, loff_t * offset); static int debug_input_flush_fn(debug_info_t * id, struct debug_view *view, - struct file *file, const char *user_buf, + struct file *file, const char __user *user_buf, size_t user_buf_size, loff_t * offset); static int debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view, char *out_buf, const char *in_buf); @@ -88,7 +88,7 @@ static int debug_raw_header_fn(debug_info_t * id, struct debug_view *view, int area, debug_entry_t * entry, char *out_buf); static int debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view, - char *out_buf, debug_sprintf_entry *curr_event); + char *out_buf, debug_sprintf_entry_t *curr_event); /* globals */ @@ -416,10 +416,10 @@ out: * - copies formated debug entries to the user buffer */ -static ssize_t debug_output(struct file *file, /* file descriptor */ - char *user_buf, /* user buffer */ - size_t len, /* length of buffer */ - loff_t *offset /* offset in the file */ ) +static ssize_t debug_output(struct file *file, /* file descriptor */ + char __user *user_buf, /* user buffer */ + size_t len, /* length of buffer */ + loff_t *offset) /* offset in the file */ { size_t count = 0; size_t entry_offset, size = 0; @@ -462,7 +462,7 @@ out: */ static ssize_t debug_input(struct file *file, - const char *user_buf, size_t length, + const char __user *user_buf, size_t length, loff_t *offset) { int rc = 0; @@ -692,31 +692,21 @@ extern inline debug_entry_t *get_active_entry(debug_info_t * id) } /* - * debug_common: + * debug_finish_entry: * - set timestamp, caller address, cpu number etc. */ -extern inline debug_entry_t *debug_common(debug_info_t * id, int level, - const void *buf, int len, int exception) +extern inline void debug_finish_entry(debug_info_t * id, debug_entry_t* active, + int level, int exception) { - unsigned long flags; - debug_entry_t *active; - - spin_lock_irqsave(&id->lock, flags); - active = get_active_entry(id); STCK(active->id.stck); active->id.fields.cpuid = smp_processor_id(); active->caller = __builtin_return_address(0); active->id.fields.exception = exception; active->id.fields.level = level; - memset(DEBUG_DATA(active), 0, id->buf_size); - memcpy(DEBUG_DATA(active), buf, MIN(len, id->buf_size)); proceed_active_entry(id); if(exception) proceed_active_area(id); - spin_unlock_irqrestore(&id->lock, flags); - - return active; } /* @@ -727,7 +717,17 @@ extern inline debug_entry_t *debug_common(debug_info_t * id, int level, debug_entry_t *debug_event_common(debug_info_t * id, int level, const void *buf, int len) { - return debug_common(id, level, buf, len, 0); + unsigned long flags; + debug_entry_t *active; + + spin_lock_irqsave(&id->lock, flags); + active = get_active_entry(id); + memset(DEBUG_DATA(active), 0, id->buf_size); + memcpy(DEBUG_DATA(active), buf, MIN(len, id->buf_size)); + debug_finish_entry(id, active, level, 0); + spin_unlock_irqrestore(&id->lock, flags); + + return active; } /* @@ -738,7 +738,17 @@ debug_entry_t *debug_event_common(debug_info_t * id, int level, const void *buf, debug_entry_t *debug_exception_common(debug_info_t * id, int level, const void *buf, int len) { - return debug_common(id, level, buf, len, 1); + unsigned long flags; + debug_entry_t *active; + + spin_lock_irqsave(&id->lock, flags); + active = get_active_entry(id); + memset(DEBUG_DATA(active), 0, id->buf_size); + memcpy(DEBUG_DATA(active), buf, MIN(len, id->buf_size)); + debug_finish_entry(id, active, level, 1); + spin_unlock_irqrestore(&id->lock, flags); + + return active; } /* @@ -764,27 +774,28 @@ debug_entry_t *debug_sprintf_event(debug_info_t* id, int level,char *string,...) { va_list ap; - int numargs,alloc_size,idx; - debug_sprintf_entry *curr_event; - debug_entry_t *retval = NULL; + int numargs,idx; + unsigned long flags; + debug_sprintf_entry_t *curr_event; + debug_entry_t *active; if((!id) || (level > id->level)) return NULL; - else { - numargs=debug_count_numargs(string); - alloc_size=offsetof(debug_sprintf_entry,args[numargs]); - curr_event=alloca(alloc_size); - - if(curr_event){ - va_start(ap,string); - curr_event->string=string; - for(idx=0;idxargs[idx]=va_arg(ap,long); - retval=debug_common(id,level, curr_event,alloc_size,0); - va_end(ap); - } - return retval; - } + + numargs=debug_count_numargs(string); + + spin_lock_irqsave(&id->lock, flags); + active = get_active_entry(id); + curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active); + va_start(ap,string); + curr_event->string=string; + for(idx=0;idxbuf_size / sizeof(long))-1));idx++) + curr_event->args[idx]=va_arg(ap,long); + va_end(ap); + debug_finish_entry(id, active, level, 0); + spin_unlock_irqrestore(&id->lock, flags); + + return active; } /* @@ -795,27 +806,28 @@ debug_entry_t *debug_sprintf_exception(debug_info_t* id, int level,char *string,...) { va_list ap; - int numargs,alloc_size,idx; - debug_sprintf_entry *curr_event; - debug_entry_t *retval = NULL; + int numargs,idx; + unsigned long flags; + debug_sprintf_entry_t *curr_event; + debug_entry_t *active; if((!id) || (level > id->level)) return NULL; - else { - numargs=debug_count_numargs(string); - alloc_size=offsetof(debug_sprintf_entry,args[numargs]); - curr_event=alloca(alloc_size); - - if(curr_event){ - va_start(ap,string); - curr_event->string=string; - for(idx=0;idxargs[idx]=va_arg(ap,long); - retval=debug_common(id,level, curr_event,alloc_size,1); - va_end(ap); - } - return retval; - } + + numargs=debug_count_numargs(string); + + spin_lock_irqsave(&id->lock, flags); + active = get_active_entry(id); + curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active); + va_start(ap,string); + curr_event->string=string; + for(idx=0;idxbuf_size / sizeof(long))-1));idx++) + curr_event->args[idx]=va_arg(ap,long); + va_end(ap); + debug_finish_entry(id, active, level, 1); + spin_unlock_irqrestore(&id->lock, flags); + + return active; } /* @@ -942,7 +954,7 @@ static int debug_prolog_level_fn(debug_info_t * id, */ static int debug_input_level_fn(debug_info_t * id, struct debug_view *view, - struct file *file, const char *user_buf, + struct file *file, const char __user *user_buf, size_t in_buf_size, loff_t * offset) { char input_buf[1]; @@ -1004,9 +1016,9 @@ void debug_flush(debug_info_t* id, int area) /* * view function: flushes debug areas */ - + static int debug_input_flush_fn(debug_info_t * id, struct debug_view *view, - struct file *file, const char *user_buf, + struct file *file, const char __user *user_buf, size_t in_buf_size, loff_t * offset) { char input_buf[1]; @@ -1127,7 +1139,7 @@ int debug_dflt_header_fn(debug_info_t * id, struct debug_view *view, #define DEBUG_SPRINTF_MAX_ARGS 10 int debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view, - char *out_buf, debug_sprintf_entry *curr_event) + char *out_buf, debug_sprintf_entry_t *curr_event) { int num_longs, num_used_args = 0,i, rc = 0; int index[DEBUG_SPRINTF_MAX_ARGS];