Commit be8dc80
committed
target/i386: Reject ModRM.reg == 7 early when decoding 0xFE/0xFF (group 4 and 5) instructions
According to both table A-6 in Volume 2 of Intel 64 and IA-32 Architectures
Software Developer's Manual and table A-6 in Volume 3 of AMD64 Architecture
Programmer's Manual, the opcode for ModRM.reg == 7 is reserved for both group 4
(0xFE) and 5 (0xFF) instructions.
Although Unicorn already rejects ModRM.reg == 7 early with group 4 (0xFE)
instructions, that is not the case with group 5 (0xFF) instructions.
The latter case is eventually handled in the `default:` block of `switch(op)`,
but by the time that code is reached, some micro-ops are already generated.
These may include a memory load micro-op. As a result, an invalid memory access
error may be produced instead of an expected invalid instruction error.
Fix this bug by rejecting group 4 and 5 instructions with ModRM.reg == 7
before generating any micro-operations.
Signed-off-by: Andrey Polivoda <apolivodaa433@gmail.com>1 parent 3a8311a commit be8dc80
2 files changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5493 | 5493 | | |
5494 | 5494 | | |
5495 | 5495 | | |
5496 | | - | |
| 5496 | + | |
5497 | 5497 | | |
5498 | 5498 | | |
5499 | 5499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2618 | 2618 | | |
2619 | 2619 | | |
2620 | 2620 | | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
2621 | 2638 | | |
2622 | 2639 | | |
2623 | 2640 | | |
| |||
2695 | 2712 | | |
2696 | 2713 | | |
2697 | 2714 | | |
| 2715 | + | |
2698 | 2716 | | |
0 commit comments