Skip to content

Commit

Permalink
Changed a bit how SGDT/SIDT are faked ([ARM64_DYNAREC] too)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Feb 6, 2024
1 parent 1642327 commit f8fa53a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
18 changes: 13 additions & 5 deletions src/dynarec/arm64/dynarec_arm64_0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,25 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, NULL, 0, 0, rex, NULL, 0, 0);
MOV32w(x1, 0x7f);
STURH_I9(x1, wback, 0);
MOV32w(x1, 0x000c);
STURH_I9(x1, wback, 2);
MOV32w(x1, 0xd000);
STURH_I9(x1, wback, 4);
if(rex.is32bits) {
MOV32w(x1, 0x3000);
STURw_I9(x1, wback, 2);
} else {
MOV64x(x1, 0xfffffe0000077000LL);
STURx_I9(x1, wback, 2);
}
break;
case 1:
INST_NAME("SIDT Ed");
addr = geted(dyn, addr, ninst, nextop, &wback, x2, &fixedaddress, NULL, 0, 0, rex, NULL, 0, 0);
MOV32w(x1, 0xfff);
STURH_I9(x1, wback, 0);
STURw_I9(xZR, wback, 2);
if(rex.is32bits) {
STURw_I9(xZR, wback, 2);
} else {
MOV64x(x1, 0xfffffe0000000000LL);
STURx_I9(x1, wback, 2);
}
break;
case 4:
INST_NAME("SMSW Ew");
Expand Down
14 changes: 10 additions & 4 deletions src/emu/x64run0f.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,19 @@ uintptr_t Run0F(x64emu_t *emu, rex_t rex, uintptr_t addr, int *step)
switch((nextop>>3)&7) {
case 0: /* SGDT Ed */
ED->word[0] = 0x7f; // dummy return...
ED->word[1] = 0x000c;
ED->word[2] = 0xd000;
if(rex.is32bits) {
*(uint32_t*)(&ED->word[1]) = 0x3000;
} else {
*(uint64_t*)(&ED->word[1]) = 0xfffffe0000077000LL;
}
break;
case 1: /* SIDT Ed */
ED->word[0] = 0xfff; // dummy return, like "disabled"
ED->word[1] = 0;
ED->word[2] = 0;
if(rex.is32bits) {
*(uint32_t*)(&ED->word[1]) = 0x0000;
} else {
*(uint64_t*)(&ED->word[1]) = 0xfffffe0000000000LL;
}
break;
case 4: /* SMSW Ew */
// dummy for now... Do I need to track CR0 state?
Expand Down

0 comments on commit f8fa53a

Please sign in to comment.