Skip to content
Snippets Groups Projects
Commit 6b8df49b authored by Raymond Toy's avatar Raymond Toy
Browse files

Fix #262: arch_skip_inst invalid code

parent b614f974
Branches
Tags
1 merge request!248Fix #262: arch_skip_inst invalid code
......@@ -30,6 +30,12 @@
*/
static const unsigned char ud1[] = {0x0f, 0xb9};
/*
* Extract the error trap code from the UD1 instruction. BYTE must be
* the 3rd byte of the UD1 instruction that represents the mod r/m
* byte.
*/
#define UD1_CODE(modrm) ((modrm) & 0x3f)
/*
* Set to positive value to enabled debug prints related to the sigill
......@@ -161,7 +167,8 @@ arch_skip_instruction(os_context_t * context)
*/
pc += sizeof(ud1);
code = *pc++;
code = UD1_CODE(*pc++);
SC_PC(context) = (unsigned long) pc;
switch (code) {
......@@ -187,7 +194,7 @@ arch_skip_instruction(os_context_t * context)
break;
default:
fprintf(stderr, "[arch_skip_inst invalid code %d\n]\n", code);
fprintf(stderr, "[arch_skip_inst invalid code 0x%x\n]\n", code);
break;
}
......@@ -387,7 +394,7 @@ sigill_handler(HANDLER_ARGS)
* number is placed in the low 6-bits of the 3rd byte of the
* instruction.
*/
trap = *(((char *)SC_PC(context)) + 2) & 0x3f;
trap = UD1_CODE(*(((char *)SC_PC(context)) + sizeof(ud1)));
DPRINTF(debug_handlers, (stderr, "code = %x\n", trap));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment