Skip to content

Commit

Permalink
Attempt to handle locked 16-bit cmpxchg
Browse files Browse the repository at this point in the history
  • Loading branch information
tbodt committed Jun 2, 2019
1 parent 873d2fe commit ae69bd5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions emu/decode.h
Expand Up @@ -677,6 +677,18 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) {
switch (insn) {
case 0x65: TRACE("segment gs\n"); SEG_GS(); goto lockrestart;

case 0x66:
// I didn't think this through
#if OP_SIZE == 32
TRACE("locked 16-bit mode\n");
RESTORE_IP;
return glue(DECODER_NAME, 16)(DECODER_PASS_ARGS);
#else
goto lockrestart;
#endif



#define MAKE_OP_ATOMIC(x, OP, op) \
case x+0x0: TRACEI("lock " op " reg8, modrm8"); \
READMODRM_MEM; ATOMIC_##OP(modrm_reg, modrm_val,8); break; \
Expand Down
1 change: 1 addition & 0 deletions emu/interp.c
Expand Up @@ -33,6 +33,7 @@ static bool modrm_compute(struct cpu_state *cpu, struct tlb *tlb, addr_t *addr_o
}
#define READADDR READIMM_(addr_offset, 32); addr += addr_offset

#define RESTORE_IP cpu->eip = saved_ip
#define _READIMM(name,size) \
name = mem_read(cpu->eip, size); \
cpu->eip += size/8
Expand Down
1 change: 1 addition & 0 deletions jit/gen.c
Expand Up @@ -73,6 +73,7 @@ void gen_exit(struct gen_state *state) {
#define FINISH \
return !end_block

#define RESTORE_IP state->ip = saved_ip
#define _READIMM(name, size) \
if (!tlb_read(tlb, state->ip, &name, size/8)) SEGFAULT; \
state->ip += size/8
Expand Down

0 comments on commit ae69bd5

Please sign in to comment.