x86/paravirt: Standardize 'insn_buff' variable names
We currently have 6 (!) separate naming variants to name temporary instruction buffers that are used for code patching: - insnbuf - insnbuff - insn_buff - insn_buffer - ibuf - ibuffer These are used as local variables, percpu fields and function parameters. Standardize all the names to a single variant: 'insn_buff'. Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@surriel.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
@@ -96,7 +96,7 @@ static void dump_insn(FILE *fp, struct insn *insn)
|
||||
}
|
||||
|
||||
static void dump_stream(FILE *fp, const char *msg, unsigned long nr_iter,
|
||||
unsigned char *insn_buf, struct insn *insn)
|
||||
unsigned char *insn_buff, struct insn *insn)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -109,7 +109,7 @@ static void dump_stream(FILE *fp, const char *msg, unsigned long nr_iter,
|
||||
/* Input a decoded instruction sequence directly */
|
||||
fprintf(fp, " $ echo ");
|
||||
for (i = 0; i < MAX_INSN_SIZE; i++)
|
||||
fprintf(fp, " %02x", insn_buf[i]);
|
||||
fprintf(fp, " %02x", insn_buff[i]);
|
||||
fprintf(fp, " | %s -i -\n", prog);
|
||||
|
||||
if (!input_file) {
|
||||
@@ -137,7 +137,7 @@ fail:
|
||||
}
|
||||
|
||||
/* Read given instruction sequence from the input file */
|
||||
static int read_next_insn(unsigned char *insn_buf)
|
||||
static int read_next_insn(unsigned char *insn_buff)
|
||||
{
|
||||
char buf[256] = "", *tmp;
|
||||
int i;
|
||||
@@ -147,7 +147,7 @@ static int read_next_insn(unsigned char *insn_buf)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < MAX_INSN_SIZE; i++) {
|
||||
insn_buf[i] = (unsigned char)strtoul(tmp, &tmp, 16);
|
||||
insn_buff[i] = (unsigned char)strtoul(tmp, &tmp, 16);
|
||||
if (*tmp != ' ')
|
||||
break;
|
||||
}
|
||||
@@ -155,19 +155,19 @@ static int read_next_insn(unsigned char *insn_buf)
|
||||
return i;
|
||||
}
|
||||
|
||||
static int generate_insn(unsigned char *insn_buf)
|
||||
static int generate_insn(unsigned char *insn_buff)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (input_file)
|
||||
return read_next_insn(insn_buf);
|
||||
return read_next_insn(insn_buff);
|
||||
|
||||
/* Fills buffer with random binary up to MAX_INSN_SIZE */
|
||||
for (i = 0; i < MAX_INSN_SIZE - 1; i += 2)
|
||||
*(unsigned short *)(&insn_buf[i]) = random() & 0xffff;
|
||||
*(unsigned short *)(&insn_buff[i]) = random() & 0xffff;
|
||||
|
||||
while (i < MAX_INSN_SIZE)
|
||||
insn_buf[i++] = random() & 0xff;
|
||||
insn_buff[i++] = random() & 0xff;
|
||||
|
||||
return i;
|
||||
}
|
||||
@@ -239,31 +239,31 @@ int main(int argc, char **argv)
|
||||
int insns = 0;
|
||||
int errors = 0;
|
||||
unsigned long i;
|
||||
unsigned char insn_buf[MAX_INSN_SIZE * 2];
|
||||
unsigned char insn_buff[MAX_INSN_SIZE * 2];
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
/* Prepare stop bytes with NOPs */
|
||||
memset(insn_buf + MAX_INSN_SIZE, INSN_NOP, MAX_INSN_SIZE);
|
||||
memset(insn_buff + MAX_INSN_SIZE, INSN_NOP, MAX_INSN_SIZE);
|
||||
|
||||
for (i = 0; i < iter_end; i++) {
|
||||
if (generate_insn(insn_buf) <= 0)
|
||||
if (generate_insn(insn_buff) <= 0)
|
||||
break;
|
||||
|
||||
if (i < iter_start) /* Skip to given iteration number */
|
||||
continue;
|
||||
|
||||
/* Decode an instruction */
|
||||
insn_init(&insn, insn_buf, sizeof(insn_buf), x86_64);
|
||||
insn_init(&insn, insn_buff, sizeof(insn_buff), x86_64);
|
||||
insn_get_length(&insn);
|
||||
|
||||
if (insn.next_byte <= insn.kaddr ||
|
||||
insn.kaddr + MAX_INSN_SIZE < insn.next_byte) {
|
||||
/* Access out-of-range memory */
|
||||
dump_stream(stderr, "Error: Found an access violation", i, insn_buf, &insn);
|
||||
dump_stream(stderr, "Error: Found an access violation", i, insn_buff, &insn);
|
||||
errors++;
|
||||
} else if (verbose && !insn_complete(&insn))
|
||||
dump_stream(stdout, "Info: Found an undecodable input", i, insn_buf, &insn);
|
||||
dump_stream(stdout, "Info: Found an undecodable input", i, insn_buff, &insn);
|
||||
else if (verbose >= 2)
|
||||
dump_insn(stdout, &insn);
|
||||
insns++;
|
||||
|
Reference in New Issue
Block a user