Merge branch 'x86-paravirt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 paravirt updates from Ingo Molnar: "A handful of paravirt patching code enhancements to make it more robust against patching failures, and related cleanups and not so related cleanups - by Thomas Gleixner and myself" * 'x86-paravirt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/paravirt: Rename paravirt_patch_site::instrtype to paravirt_patch_site::type x86/paravirt: Standardize 'insn_buff' variable names x86/paravirt: Match paravirt patchlet field definition ordering to initialization ordering x86/paravirt: Replace the paravirt patch asm magic x86/paravirt: Unify the 32/64 bit paravirt patching code x86/paravirt: Detect over-sized patching bugs in paravirt_patch_call() x86/paravirt: Detect over-sized patching bugs in paravirt_patch_insns() x86/paravirt: Remove bogus extern declarations
This commit is contained in:
@@ -83,7 +83,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;
|
||||
|
||||
@@ -96,7 +96,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) {
|
||||
@@ -124,7 +124,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;
|
||||
@@ -134,7 +134,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;
|
||||
}
|
||||
@@ -142,19 +142,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;
|
||||
}
|
||||
@@ -226,31 +226,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