From 86060cbe7d07304693f64a77b8d62b47bb1ec250 Mon Sep 17 00:00:00 2001 From: Saagar Jha Date: Thu, 18 Jan 2024 23:40:55 -0800 Subject: [PATCH] Add stub implementation for writes to fs This is "used" by sbcl. --- emu/decode.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/emu/decode.h b/emu/decode.h index 42663b15e2..1f549b9d73 100644 --- a/emu/decode.h +++ b/emu/decode.h @@ -804,14 +804,21 @@ __no_instrument DECODER_RET glue(DECODER_NAME, OP_SIZE)(DECODER_ARGS) { case 0x8d: TRACEI("lea\t\t"); READMODRM_MEM; MOV(addr, modrm_reg,oz); break; - // only gs is supported, and it does nothing - // see comment in sys/tls.c + // we only support fs and gs, and that too not very well. + // gs does nothing: see comment in sys/tls.c + // for fs, we discard writes. if anyone tries to read we trap case 0x8c: TRACEI("mov seg, modrm\t"); READMODRM; - if (modrm.reg != reg_ebp) UNDEFINED; + if (modrm.reg != 5 /* gs */) UNDEFINED; MOV(gs, modrm_val,16); break; + case 0x8e: TRACEI("mov modrm, seg\t"); READMODRM; - if (modrm.reg != reg_ebp) UNDEFINED; - MOV(modrm_val, gs,16); break; + if (modrm.reg == 5 /* gs */) { + MOV(modrm_val, gs,16); break; + } else if (modrm.reg == 4 /* fs */) { + break; + } else { + UNDEFINED; + } case 0x8f: TRACEI("pop modrm"); READMODRM; POP(modrm_val,oz); break;