Merge branch 'master' into for-next
authorJiri Kosina <jkosina@suse.cz>
Tue, 10 Aug 2010 11:22:08 +0000 (13:22 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 10 Aug 2010 11:22:08 +0000 (13:22 +0200)
Conflicts:
arch/arm/mach-omap1/board-nokia770.c

1  2 
drivers/base/core.c
drivers/net/igb/igb_main.c
kernel/trace/trace_kprobe.c

diff --combined drivers/base/core.c
@@@ -251,7 -251,7 +251,7 @@@ static int dev_uevent(struct kset *kset
                                 __func__, retval);
        }
  
 -      /* have the device type specific fuction add its stuff */
 +      /* have the device type specific function add its stuff */
        if (dev->type && dev->type->uevent) {
                retval = dev->type->uevent(dev, env);
                if (retval)
@@@ -1599,7 -1599,7 +1599,7 @@@ EXPORT_SYMBOL_GPL(device_destroy)
   * on the same device to ensure that new_name is valid and
   * won't conflict with other devices.
   */
- int device_rename(struct device *dev, char *new_name)
+ int device_rename(struct device *dev, const char *new_name)
  {
        char *old_class_name = NULL;
        char *new_class_name = NULL;
@@@ -3527,7 -3527,7 +3527,7 @@@ enum latency_range 
   *      Stores a new ITR value based on strictly on packet size.  This
   *      algorithm is less sophisticated than that used in igb_update_itr,
   *      due to the difficulty of synchronizing statistics across multiple
 - *      receive rings.  The divisors and thresholds used by this fuction
 + *      receive rings.  The divisors and thresholds used by this function
   *      were determined based on theoretical maximum wire speed and testing
   *      data, in order to minimize response time while increasing bulk
   *      throughput.
@@@ -5353,6 -5353,7 +5353,7 @@@ static bool igb_clean_tx_irq(struct igb
  
        while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) &&
               (count < tx_ring->count)) {
+               rmb();  /* read buffer_info after eop_desc status */
                for (cleaned = false; !cleaned; count++) {
                        tx_desc = E1000_TX_DESC_ADV(*tx_ring, i);
                        buffer_info = &tx_ring->buffer_info[i];
@@@ -5558,6 -5559,7 +5559,7 @@@ static bool igb_clean_rx_irq_adv(struc
                if (*work_done >= budget)
                        break;
                (*work_done)++;
+               rmb(); /* read descriptor and rx_buffer_info after status DD */
  
                skb = buffer_info->skb;
                prefetch(skb->data - NET_IP_ALIGN);
@@@ -30,6 -30,8 +30,8 @@@
  #include <linux/ptrace.h>
  #include <linux/perf_event.h>
  #include <linux/stringify.h>
+ #include <linux/limits.h>
+ #include <linux/uaccess.h>
  #include <asm/bitsperlong.h>
  
  #include "trace.h"
@@@ -38,6 -40,7 +40,7 @@@
  #define MAX_TRACE_ARGS 128
  #define MAX_ARGSTR_LEN 63
  #define MAX_EVENT_NAME_LEN 64
+ #define MAX_STRING_SIZE PATH_MAX
  #define KPROBE_EVENT_SYSTEM "kprobes"
  
  /* Reserved field names */
@@@ -58,14 -61,16 +61,16 @@@ const char *reserved_field_names[] = 
  };
  
  /* Printing function type */
- typedef int (*print_type_func_t)(struct trace_seq *, const char *, void *);
+ typedef int (*print_type_func_t)(struct trace_seq *, const char *, void *,
+                                void *);
  #define PRINT_TYPE_FUNC_NAME(type)    print_type_##type
  #define PRINT_TYPE_FMT_NAME(type)     print_type_format_##type
  
  /* Printing  in basic type function template */
  #define DEFINE_BASIC_PRINT_TYPE_FUNC(type, fmt, cast)                 \
  static __kprobes int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s,  \
-                                               const char *name, void *data)\
+                                               const char *name,       \
+                                               void *data, void *ent)\
  {                                                                     \
        return trace_seq_printf(s, " %s=" fmt, name, (cast)*(type *)data);\
  }                                                                     \
@@@ -80,6 -85,49 +85,49 @@@ DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d"
  DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long)
  DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long)
  
+ /* data_rloc: data relative location, compatible with u32 */
+ #define make_data_rloc(len, roffs)    \
+       (((u32)(len) << 16) | ((u32)(roffs) & 0xffff))
+ #define get_rloc_len(dl)      ((u32)(dl) >> 16)
+ #define get_rloc_offs(dl)     ((u32)(dl) & 0xffff)
+ static inline void *get_rloc_data(u32 *dl)
+ {
+       return (u8 *)dl + get_rloc_offs(*dl);
+ }
+ /* For data_loc conversion */
+ static inline void *get_loc_data(u32 *dl, void *ent)
+ {
+       return (u8 *)ent + get_rloc_offs(*dl);
+ }
+ /*
+  * Convert data_rloc to data_loc:
+  *  data_rloc stores the offset from data_rloc itself, but data_loc
+  *  stores the offset from event entry.
+  */
+ #define convert_rloc_to_loc(dl, offs) ((u32)(dl) + (offs))
+ /* For defining macros, define string/string_size types */
+ typedef u32 string;
+ typedef u32 string_size;
+ /* Print type function for string type */
+ static __kprobes int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s,
+                                                 const char *name,
+                                                 void *data, void *ent)
+ {
+       int len = *(u32 *)data >> 16;
+       if (!len)
+               return trace_seq_printf(s, " %s=(fault)", name);
+       else
+               return trace_seq_printf(s, " %s=\"%s\"", name,
+                                       (const char *)get_loc_data(data, ent));
+ }
+ static const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\"";
  /* Data fetch function type */
  typedef       void (*fetch_func_t)(struct pt_regs *, void *, void *);
  
@@@ -94,32 -142,38 +142,38 @@@ static __kprobes void call_fetch(struc
        return fprm->fn(regs, fprm->data, dest);
  }
  
- #define FETCH_FUNC_NAME(kind, type)   fetch_##kind##_##type
+ #define FETCH_FUNC_NAME(method, type) fetch_##method##_##type
  /*
   * Define macro for basic types - we don't need to define s* types, because
   * we have to care only about bitwidth at recording time.
   */
- #define DEFINE_BASIC_FETCH_FUNCS(kind)  \
- DEFINE_FETCH_##kind(u8)                       \
- DEFINE_FETCH_##kind(u16)              \
- DEFINE_FETCH_##kind(u32)              \
- DEFINE_FETCH_##kind(u64)
- #define CHECK_BASIC_FETCH_FUNCS(kind, fn)     \
-       ((FETCH_FUNC_NAME(kind, u8) == fn) ||   \
-        (FETCH_FUNC_NAME(kind, u16) == fn) ||  \
-        (FETCH_FUNC_NAME(kind, u32) == fn) ||  \
-        (FETCH_FUNC_NAME(kind, u64) == fn))
+ #define DEFINE_BASIC_FETCH_FUNCS(method) \
+ DEFINE_FETCH_##method(u8)             \
+ DEFINE_FETCH_##method(u16)            \
+ DEFINE_FETCH_##method(u32)            \
+ DEFINE_FETCH_##method(u64)
+ #define CHECK_FETCH_FUNCS(method, fn)                 \
+       (((FETCH_FUNC_NAME(method, u8) == fn) ||        \
+         (FETCH_FUNC_NAME(method, u16) == fn) ||       \
+         (FETCH_FUNC_NAME(method, u32) == fn) ||       \
+         (FETCH_FUNC_NAME(method, u64) == fn) ||       \
+         (FETCH_FUNC_NAME(method, string) == fn) ||    \
+         (FETCH_FUNC_NAME(method, string_size) == fn)) \
+        && (fn != NULL))
  
  /* Data fetch function templates */
  #define DEFINE_FETCH_reg(type)                                                \
  static __kprobes void FETCH_FUNC_NAME(reg, type)(struct pt_regs *regs,        \
-                                         void *offset, void *dest)     \
+                                       void *offset, void *dest)       \
  {                                                                     \
        *(type *)dest = (type)regs_get_register(regs,                   \
                                (unsigned int)((unsigned long)offset)); \
  }
  DEFINE_BASIC_FETCH_FUNCS(reg)
+ /* No string on the register */
+ #define fetch_reg_string NULL
+ #define fetch_reg_string_size NULL
  
  #define DEFINE_FETCH_stack(type)                                      \
  static __kprobes void FETCH_FUNC_NAME(stack, type)(struct pt_regs *regs,\
                                (unsigned int)((unsigned long)offset)); \
  }
  DEFINE_BASIC_FETCH_FUNCS(stack)
+ /* No string on the stack entry */
+ #define fetch_stack_string NULL
+ #define fetch_stack_string_size NULL
  
  #define DEFINE_FETCH_retval(type)                                     \
  static __kprobes void FETCH_FUNC_NAME(retval, type)(struct pt_regs *regs,\
        *(type *)dest = (type)regs_return_value(regs);                  \
  }
  DEFINE_BASIC_FETCH_FUNCS(retval)
+ /* No string on the retval */
+ #define fetch_retval_string NULL
+ #define fetch_retval_string_size NULL
  
  #define DEFINE_FETCH_memory(type)                                     \
  static __kprobes void FETCH_FUNC_NAME(memory, type)(struct pt_regs *regs,\
                *(type *)dest = retval;                                 \
  }
  DEFINE_BASIC_FETCH_FUNCS(memory)
+ /*
+  * Fetch a null-terminated string. Caller MUST set *(u32 *)dest with max
+  * length and relative data location.
+  */
+ static __kprobes void FETCH_FUNC_NAME(memory, string)(struct pt_regs *regs,
+                                                     void *addr, void *dest)
+ {
+       long ret;
+       int maxlen = get_rloc_len(*(u32 *)dest);
+       u8 *dst = get_rloc_data(dest);
+       u8 *src = addr;
+       mm_segment_t old_fs = get_fs();
+       if (!maxlen)
+               return;
+       /*
+        * Try to get string again, since the string can be changed while
+        * probing.
+        */
+       set_fs(KERNEL_DS);
+       pagefault_disable();
+       do
+               ret = __copy_from_user_inatomic(dst++, src++, 1);
+       while (dst[-1] && ret == 0 && src - (u8 *)addr < maxlen);
+       dst[-1] = '\0';
+       pagefault_enable();
+       set_fs(old_fs);
+       if (ret < 0) {  /* Failed to fetch string */
+               ((u8 *)get_rloc_data(dest))[0] = '\0';
+               *(u32 *)dest = make_data_rloc(0, get_rloc_offs(*(u32 *)dest));
+       } else
+               *(u32 *)dest = make_data_rloc(src - (u8 *)addr,
+                                             get_rloc_offs(*(u32 *)dest));
+ }
+ /* Return the length of string -- including null terminal byte */
+ static __kprobes void FETCH_FUNC_NAME(memory, string_size)(struct pt_regs *regs,
+                                                       void *addr, void *dest)
+ {
+       int ret, len = 0;
+       u8 c;
+       mm_segment_t old_fs = get_fs();
+       set_fs(KERNEL_DS);
+       pagefault_disable();
+       do {
+               ret = __copy_from_user_inatomic(&c, (u8 *)addr + len, 1);
+               len++;
+       } while (c && ret == 0 && len < MAX_STRING_SIZE);
+       pagefault_enable();
+       set_fs(old_fs);
+       if (ret < 0)    /* Failed to check the length */
+               *(u32 *)dest = 0;
+       else
+               *(u32 *)dest = len;
+ }
  
  /* Memory fetching by symbol */
  struct symbol_cache {
@@@ -203,6 -319,8 +319,8 @@@ static __kprobes void FETCH_FUNC_NAME(s
                *(type *)dest = 0;                                      \
  }
  DEFINE_BASIC_FETCH_FUNCS(symbol)
+ DEFINE_FETCH_symbol(string)
+ DEFINE_FETCH_symbol(string_size)
  
  /* Dereference memory access function */
  struct deref_fetch_param {
@@@ -224,12 -342,14 +342,14 @@@ static __kprobes void FETCH_FUNC_NAME(d
                *(type *)dest = 0;                                      \
  }
  DEFINE_BASIC_FETCH_FUNCS(deref)
+ DEFINE_FETCH_deref(string)
+ DEFINE_FETCH_deref(string_size)
  
  static __kprobes void free_deref_fetch_param(struct deref_fetch_param *data)
  {
-       if (CHECK_BASIC_FETCH_FUNCS(deref, data->orig.fn))
+       if (CHECK_FETCH_FUNCS(deref, data->orig.fn))
                free_deref_fetch_param(data->orig.data);
-       else if (CHECK_BASIC_FETCH_FUNCS(symbol, data->orig.fn))
+       else if (CHECK_FETCH_FUNCS(symbol, data->orig.fn))
                free_symbol_cache(data->orig.data);
        kfree(data);
  }
  #define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)
  #define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)
  
- #define ASSIGN_FETCH_FUNC(kind, type) \
-       .kind = FETCH_FUNC_NAME(kind, type)
- #define ASSIGN_FETCH_TYPE(ptype, ftype, sign) \
-       {.name = #ptype,                        \
-        .size = sizeof(ftype),                 \
-        .is_signed = sign,                     \
-        .print = PRINT_TYPE_FUNC_NAME(ptype),  \
-        .fmt = PRINT_TYPE_FMT_NAME(ptype),     \
- ASSIGN_FETCH_FUNC(reg, ftype),                        \
- ASSIGN_FETCH_FUNC(stack, ftype),              \
- ASSIGN_FETCH_FUNC(retval, ftype),             \
- ASSIGN_FETCH_FUNC(memory, ftype),             \
- ASSIGN_FETCH_FUNC(symbol, ftype),             \
- ASSIGN_FETCH_FUNC(deref, ftype),              \
+ /* Fetch types */
+ enum {
+       FETCH_MTD_reg = 0,
+       FETCH_MTD_stack,
+       FETCH_MTD_retval,
+       FETCH_MTD_memory,
+       FETCH_MTD_symbol,
+       FETCH_MTD_deref,
+       FETCH_MTD_END,
+ };
+ #define ASSIGN_FETCH_FUNC(method, type)       \
+       [FETCH_MTD_##method] = FETCH_FUNC_NAME(method, type)
+ #define __ASSIGN_FETCH_TYPE(_name, ptype, ftype, _size, sign, _fmttype)       \
+       {.name = _name,                         \
+        .size = _size,                                 \
+        .is_signed = sign,                             \
+        .print = PRINT_TYPE_FUNC_NAME(ptype),          \
+        .fmt = PRINT_TYPE_FMT_NAME(ptype),             \
+        .fmttype = _fmttype,                           \
+        .fetch = {                                     \
+ ASSIGN_FETCH_FUNC(reg, ftype),                                \
+ ASSIGN_FETCH_FUNC(stack, ftype),                      \
+ ASSIGN_FETCH_FUNC(retval, ftype),                     \
+ ASSIGN_FETCH_FUNC(memory, ftype),                     \
+ ASSIGN_FETCH_FUNC(symbol, ftype),                     \
+ ASSIGN_FETCH_FUNC(deref, ftype),                      \
+         }                                             \
        }
  
+ #define ASSIGN_FETCH_TYPE(ptype, ftype, sign)                 \
+       __ASSIGN_FETCH_TYPE(#ptype, ptype, ftype, sizeof(ftype), sign, #ptype)
+ #define FETCH_TYPE_STRING 0
+ #define FETCH_TYPE_STRSIZE 1
  /* Fetch type information table */
  static const struct fetch_type {
        const char      *name;          /* Name of type */
        int             is_signed;      /* Signed flag */
        print_type_func_t       print;  /* Print functions */
        const char      *fmt;           /* Fromat string */
+       const char      *fmttype;       /* Name in format file */
        /* Fetch functions */
-       fetch_func_t    reg;
-       fetch_func_t    stack;
-       fetch_func_t    retval;
-       fetch_func_t    memory;
-       fetch_func_t    symbol;
-       fetch_func_t    deref;
+       fetch_func_t    fetch[FETCH_MTD_END];
  } fetch_type_table[] = {
+       /* Special types */
+       [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string,
+                                       sizeof(u32), 1, "__data_loc char[]"),
+       [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32,
+                                       string_size, sizeof(u32), 0, "u32"),
+       /* Basic types */
        ASSIGN_FETCH_TYPE(u8,  u8,  0),
        ASSIGN_FETCH_TYPE(u16, u16, 0),
        ASSIGN_FETCH_TYPE(u32, u32, 0),
@@@ -302,12 -444,28 +444,28 @@@ static __kprobes void fetch_stack_addre
        *(unsigned long *)dest = kernel_stack_pointer(regs);
  }
  
+ static fetch_func_t get_fetch_size_function(const struct fetch_type *type,
+                                           fetch_func_t orig_fn)
+ {
+       int i;
+       if (type != &fetch_type_table[FETCH_TYPE_STRING])
+               return NULL;    /* Only string type needs size function */
+       for (i = 0; i < FETCH_MTD_END; i++)
+               if (type->fetch[i] == orig_fn)
+                       return fetch_type_table[FETCH_TYPE_STRSIZE].fetch[i];
+       WARN_ON(1);     /* This should not happen */
+       return NULL;
+ }
  /**
   * Kprobe event core functions
   */
  
  struct probe_arg {
        struct fetch_param      fetch;
+       struct fetch_param      fetch_size;
        unsigned int            offset; /* Offset from argument entry */
        const char              *name;  /* Name of this argument */
        const char              *comm;  /* Command of this argument */
@@@ -429,9 -587,9 +587,9 @@@ error
  
  static void free_probe_arg(struct probe_arg *arg)
  {
-       if (CHECK_BASIC_FETCH_FUNCS(deref, arg->fetch.fn))
+       if (CHECK_FETCH_FUNCS(deref, arg->fetch.fn))
                free_deref_fetch_param(arg->fetch.data);
-       else if (CHECK_BASIC_FETCH_FUNCS(symbol, arg->fetch.fn))
+       else if (CHECK_FETCH_FUNCS(symbol, arg->fetch.fn))
                free_symbol_cache(arg->fetch.data);
        kfree(arg->name);
        kfree(arg->comm);
@@@ -490,7 -648,7 +648,7 @@@ static int register_trace_probe(struct 
        }
        ret = register_probe_event(tp);
        if (ret) {
 -              pr_warning("Faild to register probe event(%d)\n", ret);
 +              pr_warning("Failed to register probe event(%d)\n", ret);
                goto end;
        }
  
@@@ -548,7 -706,7 +706,7 @@@ static int parse_probe_vars(char *arg, 
  
        if (strcmp(arg, "retval") == 0) {
                if (is_return)
-                       f->fn = t->retval;
+                       f->fn = t->fetch[FETCH_MTD_retval];
                else
                        ret = -EINVAL;
        } else if (strncmp(arg, "stack", 5) == 0) {
                        if (ret || param > PARAM_MAX_STACK)
                                ret = -EINVAL;
                        else {
-                               f->fn = t->stack;
+                               f->fn = t->fetch[FETCH_MTD_stack];
                                f->data = (void *)param;
                        }
                } else
@@@ -588,7 -746,7 +746,7 @@@ static int __parse_probe_arg(char *arg
        case '%':       /* named register */
                ret = regs_query_register_offset(arg + 1);
                if (ret >= 0) {
-                       f->fn = t->reg;
+                       f->fn = t->fetch[FETCH_MTD_reg];
                        f->data = (void *)(unsigned long)ret;
                        ret = 0;
                }
                        ret = strict_strtoul(arg + 1, 0, &param);
                        if (ret)
                                break;
-                       f->fn = t->memory;
+                       f->fn = t->fetch[FETCH_MTD_memory];
                        f->data = (void *)param;
                } else {
                        ret = split_symbol_offset(arg + 1, &offset);
                                break;
                        f->data = alloc_symbol_cache(arg + 1, offset);
                        if (f->data)
-                               f->fn = t->symbol;
+                               f->fn = t->fetch[FETCH_MTD_symbol];
                }
                break;
        case '+':       /* deref memory */
                        if (ret)
                                kfree(dprm);
                        else {
-                               f->fn = t->deref;
+                               f->fn = t->fetch[FETCH_MTD_deref];
                                f->data = (void *)dprm;
                        }
                }
                break;
        }
-       if (!ret && !f->fn)
+       if (!ret && !f->fn) {   /* Parsed, but do not find fetch method */
+               pr_info("%s type has no corresponding fetch method.\n",
+                       t->name);
                ret = -EINVAL;
+       }
        return ret;
  }
  
@@@ -652,6 -813,7 +813,7 @@@ static int parse_probe_arg(char *arg, s
                           struct probe_arg *parg, int is_return)
  {
        const char *t;
+       int ret;
  
        if (strlen(arg) > MAX_ARGSTR_LEN) {
                pr_info("Argument is too long.: %s\n",  arg);
        }
        parg->offset = tp->size;
        tp->size += parg->type->size;
-       return __parse_probe_arg(arg, parg->type, &parg->fetch, is_return);
+       ret = __parse_probe_arg(arg, parg->type, &parg->fetch, is_return);
+       if (ret >= 0) {
+               parg->fetch_size.fn = get_fetch_size_function(parg->type,
+                                                             parg->fetch.fn);
+               parg->fetch_size.data = parg->fetch.data;
+       }
+       return ret;
  }
  
  /* Return 1 if name is reserved or already used by another argument */
@@@ -757,14 -925,17 +925,17 @@@ static int create_trace_probe(int argc
                        pr_info("Delete command needs an event name.\n");
                        return -EINVAL;
                }
+               mutex_lock(&probe_lock);
                tp = find_probe_event(event, group);
                if (!tp) {
+                       mutex_unlock(&probe_lock);
                        pr_info("Event %s/%s doesn't exist.\n", group, event);
                        return -ENOENT;
                }
                /* delete an event */
                unregister_trace_probe(tp);
                free_trace_probe(tp);
+               mutex_unlock(&probe_lock);
                return 0;
        }
  
@@@ -1043,6 -1214,54 +1214,54 @@@ static const struct file_operations kpr
        .release        = seq_release,
  };
  
+ /* Sum up total data length for dynamic arraies (strings) */
+ static __kprobes int __get_data_size(struct trace_probe *tp,
+                                    struct pt_regs *regs)
+ {
+       int i, ret = 0;
+       u32 len;
+       for (i = 0; i < tp->nr_args; i++)
+               if (unlikely(tp->args[i].fetch_size.fn)) {
+                       call_fetch(&tp->args[i].fetch_size, regs, &len);
+                       ret += len;
+               }
+       return ret;
+ }
+ /* Store the value of each argument */
+ static __kprobes void store_trace_args(int ent_size, struct trace_probe *tp,
+                                      struct pt_regs *regs,
+                                      u8 *data, int maxlen)
+ {
+       int i;
+       u32 end = tp->size;
+       u32 *dl;        /* Data (relative) location */
+       for (i = 0; i < tp->nr_args; i++) {
+               if (unlikely(tp->args[i].fetch_size.fn)) {
+                       /*
+                        * First, we set the relative location and
+                        * maximum data length to *dl
+                        */
+                       dl = (u32 *)(data + tp->args[i].offset);
+                       *dl = make_data_rloc(maxlen, end - tp->args[i].offset);
+                       /* Then try to fetch string or dynamic array data */
+                       call_fetch(&tp->args[i].fetch, regs, dl);
+                       /* Reduce maximum length */
+                       end += get_rloc_len(*dl);
+                       maxlen -= get_rloc_len(*dl);
+                       /* Trick here, convert data_rloc to data_loc */
+                       *dl = convert_rloc_to_loc(*dl,
+                                ent_size + tp->args[i].offset);
+               } else
+                       /* Just fetching data normally */
+                       call_fetch(&tp->args[i].fetch, regs,
+                                  data + tp->args[i].offset);
+       }
+ }
  /* Kprobe handler */
  static __kprobes void kprobe_trace_func(struct kprobe *kp, struct pt_regs *regs)
  {
        struct kprobe_trace_entry_head *entry;
        struct ring_buffer_event *event;
        struct ring_buffer *buffer;
-       u8 *data;
-       int size, i, pc;
+       int size, dsize, pc;
        unsigned long irq_flags;
        struct ftrace_event_call *call = &tp->call;
  
        local_save_flags(irq_flags);
        pc = preempt_count();
  
-       size = sizeof(*entry) + tp->size;
+       dsize = __get_data_size(tp, regs);
+       size = sizeof(*entry) + tp->size + dsize;
  
        event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
                                                  size, irq_flags, pc);
  
        entry = ring_buffer_event_data(event);
        entry->ip = (unsigned long)kp->addr;
-       data = (u8 *)&entry[1];
-       for (i = 0; i < tp->nr_args; i++)
-               call_fetch(&tp->args[i].fetch, regs, data + tp->args[i].offset);
+       store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
  
        if (!filter_current_check_discard(buffer, call, entry, event))
                trace_nowake_buffer_unlock_commit(buffer, event, irq_flags, pc);
@@@ -1085,15 -1302,15 +1302,15 @@@ static __kprobes void kretprobe_trace_f
        struct kretprobe_trace_entry_head *entry;
        struct ring_buffer_event *event;
        struct ring_buffer *buffer;
-       u8 *data;
-       int size, i, pc;
+       int size, pc, dsize;
        unsigned long irq_flags;
        struct ftrace_event_call *call = &tp->call;
  
        local_save_flags(irq_flags);
        pc = preempt_count();
  
-       size = sizeof(*entry) + tp->size;
+       dsize = __get_data_size(tp, regs);
+       size = sizeof(*entry) + tp->size + dsize;
  
        event = trace_current_buffer_lock_reserve(&buffer, call->event.type,
                                                  size, irq_flags, pc);
        entry = ring_buffer_event_data(event);
        entry->func = (unsigned long)tp->rp.kp.addr;
        entry->ret_ip = (unsigned long)ri->ret_addr;
-       data = (u8 *)&entry[1];
-       for (i = 0; i < tp->nr_args; i++)
-               call_fetch(&tp->args[i].fetch, regs, data + tp->args[i].offset);
+       store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
  
        if (!filter_current_check_discard(buffer, call, entry, event))
                trace_nowake_buffer_unlock_commit(buffer, event, irq_flags, pc);
@@@ -1137,7 -1352,7 +1352,7 @@@ print_kprobe_event(struct trace_iterato
        data = (u8 *)&field[1];
        for (i = 0; i < tp->nr_args; i++)
                if (!tp->args[i].type->print(s, tp->args[i].name,
-                                            data + tp->args[i].offset))
+                                            data + tp->args[i].offset, field))
                        goto partial;
  
        if (!trace_seq_puts(s, "\n"))
@@@ -1179,7 -1394,7 +1394,7 @@@ print_kretprobe_event(struct trace_iter
        data = (u8 *)&field[1];
        for (i = 0; i < tp->nr_args; i++)
                if (!tp->args[i].type->print(s, tp->args[i].name,
-                                            data + tp->args[i].offset))
+                                            data + tp->args[i].offset, field))
                        goto partial;
  
        if (!trace_seq_puts(s, "\n"))
@@@ -1214,11 -1429,6 +1429,6 @@@ static void probe_event_disable(struct 
        }
  }
  
- static int probe_event_raw_init(struct ftrace_event_call *event_call)
- {
-       return 0;
- }
  #undef DEFINE_FIELD
  #define DEFINE_FIELD(type, item, name, is_signed)                     \
        do {                                                            \
@@@ -1239,7 -1449,7 +1449,7 @@@ static int kprobe_event_define_fields(s
        DEFINE_FIELD(unsigned long, ip, FIELD_STRING_IP, 0);
        /* Set argument names as fields */
        for (i = 0; i < tp->nr_args; i++) {
-               ret = trace_define_field(event_call, tp->args[i].type->name,
+               ret = trace_define_field(event_call, tp->args[i].type->fmttype,
                                         tp->args[i].name,
                                         sizeof(field) + tp->args[i].offset,
                                         tp->args[i].type->size,
@@@ -1261,7 -1471,7 +1471,7 @@@ static int kretprobe_event_define_field
        DEFINE_FIELD(unsigned long, ret_ip, FIELD_STRING_RETIP, 0);
        /* Set argument names as fields */
        for (i = 0; i < tp->nr_args; i++) {
-               ret = trace_define_field(event_call, tp->args[i].type->name,
+               ret = trace_define_field(event_call, tp->args[i].type->fmttype,
                                         tp->args[i].name,
                                         sizeof(field) + tp->args[i].offset,
                                         tp->args[i].type->size,
@@@ -1301,8 -1511,13 +1511,13 @@@ static int __set_print_fmt(struct trace
        pos += snprintf(buf + pos, LEN_OR_ZERO, "\", %s", arg);
  
        for (i = 0; i < tp->nr_args; i++) {
-               pos += snprintf(buf + pos, LEN_OR_ZERO, ", REC->%s",
-                               tp->args[i].name);
+               if (strcmp(tp->args[i].type->name, "string") == 0)
+                       pos += snprintf(buf + pos, LEN_OR_ZERO,
+                                       ", __get_str(%s)",
+                                       tp->args[i].name);
+               else
+                       pos += snprintf(buf + pos, LEN_OR_ZERO, ", REC->%s",
+                                       tp->args[i].name);
        }
  
  #undef LEN_OR_ZERO
@@@ -1339,11 -1554,11 +1554,11 @@@ static __kprobes void kprobe_perf_func(
        struct ftrace_event_call *call = &tp->call;
        struct kprobe_trace_entry_head *entry;
        struct hlist_head *head;
-       u8 *data;
-       int size, __size, i;
+       int size, __size, dsize;
        int rctx;
  
-       __size = sizeof(*entry) + tp->size;
+       dsize = __get_data_size(tp, regs);
+       __size = sizeof(*entry) + tp->size + dsize;
        size = ALIGN(__size + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
        if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
                return;
  
        entry->ip = (unsigned long)kp->addr;
-       data = (u8 *)&entry[1];
-       for (i = 0; i < tp->nr_args; i++)
-               call_fetch(&tp->args[i].fetch, regs, data + tp->args[i].offset);
+       memset(&entry[1], 0, dsize);
+       store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
  
        head = this_cpu_ptr(call->perf_events);
        perf_trace_buf_submit(entry, size, rctx, entry->ip, 1, regs, head);
@@@ -1371,11 -1585,11 +1585,11 @@@ static __kprobes void kretprobe_perf_fu
        struct ftrace_event_call *call = &tp->call;
        struct kretprobe_trace_entry_head *entry;
        struct hlist_head *head;
-       u8 *data;
-       int size, __size, i;
+       int size, __size, dsize;
        int rctx;
  
-       __size = sizeof(*entry) + tp->size;
+       dsize = __get_data_size(tp, regs);
+       __size = sizeof(*entry) + tp->size + dsize;
        size = ALIGN(__size + sizeof(u32), sizeof(u64));
        size -= sizeof(u32);
        if (WARN_ONCE(size > PERF_MAX_TRACE_SIZE,
  
        entry->func = (unsigned long)tp->rp.kp.addr;
        entry->ret_ip = (unsigned long)ri->ret_addr;
-       data = (u8 *)&entry[1];
-       for (i = 0; i < tp->nr_args; i++)
-               call_fetch(&tp->args[i].fetch, regs, data + tp->args[i].offset);
+       store_trace_args(sizeof(*entry), tp, regs, (u8 *)&entry[1], dsize);
  
        head = this_cpu_ptr(call->perf_events);
        perf_trace_buf_submit(entry, size, rctx, entry->ret_ip, 1, regs, head);
@@@ -1486,15 -1698,12 +1698,12 @@@ static int register_probe_event(struct 
        int ret;
  
        /* Initialize ftrace_event_call */
+       INIT_LIST_HEAD(&call->class->fields);
        if (probe_is_return(tp)) {
-               INIT_LIST_HEAD(&call->class->fields);
                call->event.funcs = &kretprobe_funcs;
-               call->class->raw_init = probe_event_raw_init;
                call->class->define_fields = kretprobe_event_define_fields;
        } else {
-               INIT_LIST_HEAD(&call->class->fields);
                call->event.funcs = &kprobe_funcs;
-               call->class->raw_init = probe_event_raw_init;
                call->class->define_fields = kprobe_event_define_fields;
        }
        if (set_print_fmt(tp) < 0)