s390/dis: use explicit buf len
authorStefan Raspl <raspl@linux.vnet.ibm.com>
Tue, 5 Mar 2013 09:39:55 +0000 (10:39 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 17 Apr 2013 12:07:25 +0000 (14:07 +0200)
Pass buffer length in extra parameter.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Reviewed-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/processor.h
arch/s390/kernel/dis.c
arch/s390/kvm/trace.h

index 94e749c90230d9f824949429d505625f90f7b4e7..6b499870662f2dddbb14dd613943ef10e6303b89 100644 (file)
@@ -161,7 +161,8 @@ extern unsigned long thread_saved_pc(struct task_struct *t);
 
 extern void show_code(struct pt_regs *regs);
 extern void print_fn_code(unsigned char *code, unsigned long len);
-extern int insn_to_mnemonic(unsigned char *instruction, char buf[8]);
+extern int insn_to_mnemonic(unsigned char *instruction, char *buf,
+                           unsigned int len);
 
 unsigned long get_wchan(struct task_struct *p);
 #define task_pt_regs(tsk) ((struct pt_regs *) \
index 3ad5e95401604046371eea84bb02a68a345d5266..7f4a4a8c847c7a3807fd6d913f0ca93fe5b874b8 100644 (file)
@@ -1696,14 +1696,15 @@ static struct insn *find_insn(unsigned char *code)
  * insn_to_mnemonic - decode an s390 instruction
  * @instruction: instruction to decode
  * @buf: buffer to fill with mnemonic
+ * @len: length of buffer
  *
  * Decode the instruction at @instruction and store the corresponding
- * mnemonic into @buf.
+ * mnemonic into @buf of length @len.
  * @buf is left unchanged if the instruction could not be decoded.
  * Returns:
  *  %0 on success, %-ENOENT if the instruction was not found.
  */
-int insn_to_mnemonic(unsigned char *instruction, char buf[8])
+int insn_to_mnemonic(unsigned char *instruction, char *buf, unsigned int len)
 {
        struct insn *insn;
 
@@ -1711,10 +1712,10 @@ int insn_to_mnemonic(unsigned char *instruction, char buf[8])
        if (!insn)
                return -ENOENT;
        if (insn->name[0] == '\0')
-               snprintf(buf, 8, "%s",
+               snprintf(buf, len, "%s",
                         long_insn_name[(int) insn->name[1]]);
        else
-               snprintf(buf, 8, "%.5s", insn->name);
+               snprintf(buf, len, "%.5s", insn->name);
        return 0;
 }
 EXPORT_SYMBOL_GPL(insn_to_mnemonic);
index 2b29e62351d3a09f8e59af8b3d43721700e40fee..53252d2d472007358c4dc9fd788665a8b260e2f3 100644 (file)
@@ -117,7 +117,7 @@ TRACE_EVENT(kvm_s390_intercept_instruction,
                           __entry->instruction,
                           insn_to_mnemonic((unsigned char *)
                                            &__entry->instruction,
-                                        __entry->insn) ?
+                                        __entry->insn, sizeof(__entry->insn)) ?
                           "unknown" : __entry->insn)
        );