Raymond Toy pushed to branch master at cmucl / cmucl
Commits: 6b8df49b by Raymond Toy at 2024-08-22T14:18:22+00:00 Fix #262: arch_skip_inst invalid code
- - - - - 02430975 by Raymond Toy at 2024-08-22T14:18:49+00:00 Merge branch 'issue-262-fix-arch-skip-inst-invalid' into 'master'
Fix #262: arch_skip_inst invalid code
Closes #262
See merge request cmucl/cmucl!248 - - - - -
1 changed file:
- src/lisp/x86-arch.c
Changes:
===================================== src/lisp/x86-arch.c ===================================== @@ -29,7 +29,13 @@ * included here. */ 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));
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/b614f974decf204770b377c...